Drawing Bitmaps

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

Notice its rotated because the screen is 'naturally' portrait but we want the image to be landscape

Copy minibot.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 MISO 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, SDCS 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_ST7735->spitftbitmap example

Edit the setup() intialization to:

  // Use this initializer if you're using a 1.8" TFT
  //tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  // Use this initializer (uncomment) if you're using a 1.44" TFT
  //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

  // Use this initializer (uncomment) if you're using a 0.96" 180x60 TFT
  tft.initR(INITR_MINI160x80);   // initialize a ST7735S chip, mini display

And the drawBmp() routine to:

// change the name here!
  bmpDraw("minibot.bmp", 0, 0);

Upload to the Arduino & you will see ADABOT appear!

To make new bitmaps, make sure they are less than 160 by 80 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 - dont 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 160x80 and placed in any location on the screen.

Last updated on 2017-06-21 at 02.09.56 PM Published on 2017-06-21 at 02.11.16 PM