KodiakBart
Published © GPL3+

Show Those Bitmaps Proudly!

Yes, you CAN load and display BMPs from that card reader on the back of your tiny TFT screen!

BeginnerProtip5,344
Show Those Bitmaps Proudly!

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DSD TECH 1.8 Inch TFT LCD Display Module with SD
×1
Flash Memory Card, SD Card
Flash Memory Card, SD Card
This display requires a micro SD card (2G or less works)
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 2.21k ohm
Resistor 2.21k ohm
×3
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Breadboard (generic)
Breadboard (generic)
I used a mini which snapped into place
×1

Story

Read more

Schematics

Rose BMP Demo

My first try at Fritzing! I hope it is accurate.

Code

Rose BMP Demo

Arduino
/*
Rose BMP Demo
by KodiakBart, Nov 2019
Designed for the DSD Tech 1.8" TFT screen and Adafruit drivers
To allow simultaneous screen and card reader functions,
use hardware SPI, not software SPI
(although pins 8 and 9 can be swapped)
The pin breakout DSD Tech 1.8" TFT screen is as follows:
 VCC........5V
 GND........GND
 GND........
 NC.........
 NC.........
 NC.........
 CLK........13 (or SCK)
 SDA........11 (or MOSI)
 RS.........9  (or DC)
 RST........8  (or RESET)
 CS.........10 (or SS)
Solder a four-pin header to the SD connections on 
the DSD Tech 1.8" TFT screen
 SD_MISO....12
 SD_SCK.....13 (connected to screen CLK above)
 SD_MOSI....11 (connected to screen MOSI above)
 SD_CS......4
The SD card will work if it is 2G or less and formatted as FAT (FAT16)
To fit on the screen, all image files on the card must be pre-sized 
to 160 by 128 pixels or less and must be 24-bit RGB BMPs
The BMP file names must be no longer than 8 characters, 
however, when using many BMP files, the file names will eat up memory,
so use two-letter names
*/
// Libraries used
#include <Adafruit_GFX.h>           // Core graphics library
#include <Adafruit_ST7735.h>        // Hardware-specific library
#include <SdFat.h>                  // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h>      // SPI / QSPI flash library
#include <Adafruit_ImageReader.h>   // Image-reading functions
// Set SPI constants
#define SD_CS    4    // SD card select pin
#define TFT_CS  10    // TFT select pin
#define TFT_DC   9    // TFT display/command pin
#define TFT_RST  8    // Or set to -1 and connect to Arduino RESET pin
// Set SD speed constant in Mhz (maybe try 10 if 4 does not work)
#define MYSDMHZ 4   // For SD.begin() below
// This is required
SdFat SD;
// Create a card reader object
Adafruit_ImageReader myReader(SD);
// Create a screen object
Adafruit_ST7735 myTft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// Create an image object for loading into RAM
Adafruit_Image myImage;
void setup(void) {
 // Init a variable to hold the status from image-reading functions
 ImageReturnCode myStat; 
 // Initialize the TFT screen
 myTft.initR(INITR_BLACKTAB);
 // Rotation can be portrait (0 or 2) or landscape
 // Set TFT rotation to landscape (could be 3, but upside down)
 myTft.setRotation(1);
 // Clear screen to green to indicate that the screen works
 myTft.fillScreen(0x1F42);
 // Pause for dramatic effect
 delay (1000);
 // Initialize the card reader
 // Note: Some breakouts may require 10 MHz
 if(!SD.begin(SD_CS, SD_SCK_MHZ(MYSDMHZ))) {
   for(;;); // Fatal error, do not continue
 }
 // Draw the picture called "ro.bmp" (with "/" root directory indicator
 // found on the root directory of the cared reader)
 // at location 0,0 (top left corner of the screen)
 myStat = myReader.drawBMP("/ro.bmp", myTft, 0, 0); 
 // Pause again
 delay (3000);
 // Clear the screen to black
 myTft.fillScreen(0x0000);
}
void loop() {
}

Credits

KodiakBart

KodiakBart

1 project • 0 followers

Comments