paulofeju:
My difficulty now is to correctly simplify your showBMP and create a function just to show one Image File, under the following fixed conditions:
- Image files on SD--> 16 or 24bitBMP (or JPG).
- Shield --> Mcufriend TFT 2.8 BLUE (ID 0x4747).
I used the online ImageConverter from UTFT to convert JPEG to RAW file.
Then stored "/MOTO_CORRIDA.raw" in the root directory of SD
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <SdFat.h>
SdFatSoftSpi<12, 11, 13> SD; //Bit-Bang on the Shield pins
#define SD_CS 10
void showRAW(File inFile, int w, int h)
{
uint8_t first = 1;
tft.setAddrWindow(0, 0, w - 1, h - 1);
while (h-- > 0) {
for (int cnt = w; cnt > 0; cnt--) {
uint8_t hi = inFile.read(); //big-endian
uint8_t lo = inFile.read();
uint16_t color = (hi << 8) | lo;
tft.pushColors(&color, 1, first);
first = 0;
}
}
}
void setup()
{
tft.begin(tft.readID()); //correct ID
tft.setRotation(1); //LANDSCAPE
if (SD.begin(SD_CS)) { //readable SD
File f = SD.open("/MOTO_CORRIDA.raw");
if (f != NULL) { //good file
showRAW(f, 320, 240); //320x240
f.close();
}
}
}
void loop()
{
}
It all seems a little crazy to create a 150kB RAW file from an 18kB JPG file (that could have been rendered from Flash memory)
David.