There is a built in microSD card slot into the breakout, and we can use that to load bitmap images! You will need a microSD card formatted FAT16 or FAT32 (they almost always are by default).
Its really easy to draw bitmaps! Lets start by downloading this image of ADABOT
Copy adabot240.bmp into the base directory of a microSD card and insert it into the microSD socket in the breakout.
Two more wires are required to interface with the onboard SD card:
- You'll need to connect up the SO pin to the SPI MISO line on your microcontroller. On Arduino Uno/Duemilanove/328-based, thats Digital 12. On Mega's, its Digital 50 and on Leonardo/Due its ICSP-1 (See SPI Connections for more details)
- Also, the CCS or CC pin to Digital 4 on your Arduino as well. You can change this pin later, but stick with this for now.
You may want to try the SD library examples before continuing, especially one that lists all the files on the SD card
Open the File→examples→Adafruit ImageReader Library→BreakoutST7789 - 320x240 example:
You will need to change a couple of lines for this to work with the 240x240 display. First, we need to set this to the correct display size, so look for the following code:
tft.init(240, 320); // Init ST7789 320x240
and change it to this:
tft.init(240, 240); // Init ST7789 240x240
Second, we need to change the filename that we are loading, so look for the following lines of code.
Serial.print(F("Loading purple.bmp to screen...")); stat = reader.drawBMP("/purple.bmp", tft, 0, 0);
and change them to this:
Serial.print(F("Loading adabot240.bmp to screen...")); stat = reader.drawBMP("/adabot240.bmp", tft, 0, 0);
Now upload the example sketch to the Arduino. You should see ADABOT appear! If you have any problems, check the serial console for any messages such as not being able to initialize the microSD card or not finding the image.
To make new bitmaps, make sure they are less than 240 by 240 pixels and save them in 24-bit BMP format! They must be in 24-bit format, even if they are not 24-bit color as that is the easiest format for the Arduino. You can rotate images using the setRotation() procedure
You can draw as many images as you want - don't forget the names must be less than 8 characters long. Just copy the BMP drawing routines below loop() and call
bmpDraw(bmpfilename, x, y);
For each bitmap. They can be smaller than 240x240 and placed in any location on the screen.
Text editor powered by tinymce.