// On the SD card use 24 bit color BMP files (be sure they are 24-bit!)
// There are examples images in the sketch folder.
// MS Paint can be used to crop, resize and flip and save images in 24bit BMP format
// Updated 31/3/15 to include new drawRAW() function that draws raw 16 bit images.
// Raw images are created with UTFT library tool (libraries\UTFT\Tools\ImageConverter565.exe)
// Save as .raw file as this can be easily piped to the TFT pushColors() function
// without any tedious byte swapping etc
#include <TFT_HX8357.h> // Hardware-specific library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library
// SD Card library, comment out next line if the SdFat library is used
#include <SD.h>
// SD chip select
#define SDC_CS 53
int button = A0;
// These are used when calling drawBMP() function
#define BU_BMP 1 // Temporarily flip the TFT coords for standard Bottom-Up bit maps
#define TD_BMP 0 // Draw inverted Top-Down bitmaps in standard coord frame
/***************************************************************************************
** Function name: setup
** Descriptions: To set things up
***************************************************************************************/
void setup()
{
Serial.begin(38400); // For debug messages
delay(4000);
tft.init(); // Initialise the display (various parameters configured)
Serial.print(F("Initialising SD card..."));
if (!SD.begin(SDC_CS)) {
Serial.println(F("failed!"));
//return;
}
Serial.println(F("Here we go..."));
// Landscape mode
tft.setRotation(2);
tft.fillScreen(TFT_BLACK);
pinMode(button, INPUT_PULLUP);
// Draw bmp image top left corner at x,y = 0,0
// Image must fit (one day I will add clipping... but it will slow things down)
// drawBMP("2.bmp", 0, 0, BU_BMP);
char *names[12] = {
"1.bmp",
"2.bmp",
"3.bmp",
"4.bmp",
"5.bmp",
"6.bmp",
"7.bmp",
"8.bmp",
"9.bmp",
"10.bmp",
"11.bmp",
"12.bmp",
};
int which_number;
}
/***************************************************************************************
** Function name: loop
** Descriptions: Infinite loop
***************************************************************************************/
void loop()
{
if (digitalRead(button) == LOW) {
//note that arrays start at 0 e.g. 0 .. 11
if (++which_number > 11) which_number = 0;
drawBMP(names[which_number], 0, 0, BU_BMP);
delay(1000);
// Standard BMP files are usually stored with a raster scan of pixel values from bottom up
// File names MUST use the 8.3 file name format (8 chars + . + any 3 extension letters)
// By convention bitmap files end in .bmp
// Bit maps MUST be in 24 bit colout (not 16 or 8 bit greyscale)
}
by the VOID loop the line
drawBMP(names[which_number], 0, 0, BU_BMP);
He gives me an error saying
which_number was not declared in this scope