Hi there,
I´m a bloody beginner to Arduino, Coding and all things around these themes.
I tried to get a code working, which was posted long time ago.
My Plan:
I would like to take an Arduino Nano (link will follow), a TFT-Display with SD Card reader, put it all together, just to run a "slide show" of various BMP pictures.
My hardware:
Nano (Nano)
Display (Display)
I tested my display and the nano with other Sketches, everything works fine.
The Sketch, which I think, might be useful and sufficient, is one out of an other topic, which is already closed:
https://forum.arduino.cc/index.php?topic=630955.15
In #20 of above topic, David Prentice released a Sketch, which I used for my "slide show", and it nearly runs perfect like I need it.
This one works fine, but after the nineteenth BMP-file I will see a "load.image error"
It doesn´t matter if I have 4 or 9 or 11 BMP-files (128x160px, 24bit, SD 128MB, formatted in FAT32). Every time the script is running, after the 19th BMP this error occurs.
I´m just an beginner, and I don´t know how to fix this... I would be extremely happy, if someone would help me here.
Thank You so much, and enjoy the weekend....
The Sketch is:
#include <SPI.h>
#include <SD.h>
#include <TFT.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
#define SD_CS 4
#include <TFT.h>
TFT tft(TFT_CS, TFT_DC, TFT_RST);
File root;
int pathlen;
char namebuf[32] = "/"; //BMP files in root directory
#define NAMEMATCH "" // "" matches any name
void setup(void)
{
Serial.begin(9600);
tft.initR(INITR_BLACKTAB);
tft.setRotation(1);
tft.fillScreen(0x001F);
bool good = SD.begin(SD_CS);
if (good) {
root = SD.open(namebuf);
pathlen = strlen(namebuf);
}
if (!good) {
Serial.println(F("cannot start SD"));
tft.fillScreen(0xF800);
while (1) yield();
}
tft.fillScreen(0x07E0);
}
void loop()
{
char *nm = namebuf + pathlen;
File f = root.openNextFile();
uint8_t ret;
uint32_t start;
PImage myPicture;
if (f) {
strcpy(nm, (char *)f.name());
f.close();
strlwr(nm);
if (strstr(nm, ".bmp") != NULL && strstr(nm, NAMEMATCH) != NULL) {
myPicture = tft.loadImage(namebuf);
tft.image(myPicture, 0, 0);
}
}
else root.rewindDirectory();
}