I am trying to show different images on the e paper. The images should be saved on the sd card. I have the pictures in the correct file format like in the draw images example. I have about 30 Images saved there and they should be shown in the order they are saved. I need to read the image, show it on the display, go into deep sleep and after some time show the next image. When I upload my code the e paper does nothing. The SD card is formatted correctly and gets detected in the demo program. I also updated the microprocessor version, the e paper version. I also managed to show my own images when I include them but not from the sd card. The code is without deepsleep at the moment but will be implemented when the images can be shown.
`#include
include
include
include "epd_driver.h" // Include the correct e-paper driver header
define SD_MISO 16
define SD_MOSI 15
define SD_SCLK 11
define SD_CS 42 // Adjust pin according to your wiring
void loop() {
if (!isFileOpen) {
currentFile = root.openNextFile();
if (!currentFile) {
// If no more files, restart reading from the beginning
root.rewindDirectory();
currentFile = root.openNextFile();
}
if (currentFile && !currentFile.isDirectory()) {
String fileName = currentFile.name();
if (fileName.endsWith(".h")) {
Serial.println("Displaying: " + fileName);
readFile(SD, fileName.c_str());
isFileOpen = true;
} else {
currentFile.close();
}
} else {
if (currentFile) currentFile.close();
}
}
if (isFileOpen) {
displayImageFromFile(currentFile);
delay(6000); // Wait for 6 seconds before displaying the next image
currentFile.close();
isFileOpen = false;
}
I am trying to show different images on the e paper. The images should be saved on the sd card. I have the pictures in the correct file format like in the draw images example. I have about 30 Images saved there and they should be shown in the order they are saved. I need to read the image, show it on the display, go into deep sleep and after some time show the next image. When I upload my code the e paper does nothing. The SD card is formatted correctly and gets detected in the demo program. I also updated the microprocessor version, the e paper version. I also managed to show my own images when I include them but not from the sd card. The code is without deepsleep at the moment but will be implemented when the images can be shown.
`#include
include
include
include "epd_driver.h" // Include the correct e-paper driver header
define SD_MISO 16
define SD_MOSI 15
define SD_SCLK 11
define SD_CS 42 // Adjust pin according to your wiring
uint8_t *framebuffer; File root; File currentFile; bool isFileOpen = false;
void setup() { Serial.begin(115200);
}
void loop() { if (!isFileOpen) { currentFile = root.openNextFile(); if (!currentFile) { // If no more files, restart reading from the beginning root.rewindDirectory(); currentFile = root.openNextFile(); }
}
void readFile(fs::FS &fs, const char *path) { Serial.printf("Reading file: %s\n", path);
File file = fs.open(path); if (!file) { Serial.println("Failed to open file for reading"); return; }
Serial.print("Read from file: "); while (file.available()) { Serial.write(file.read()); } file.close(); }
void displayImageFromFile(File file) { Serial.println("Reading file content..."); // Read file content into a buffer size_t fileSize = file.size(); char fileContent = (char )heap_caps_malloc(fileSize + 1, MALLOC_CAP_SPIRAM); if (!fileContent) { Serial.println("Failed to allocate memory for file content"); return; } file.readBytes(fileContent, fileSize); fileContent[fileSize] = '\0'; // Null-terminate the string
}
uint32_t extractUInt32(const char content, const char key) { String searchString = String(key) + " = "; const char *found = strstr(content, searchString.c_str()); if (found) { return strtoul(found + searchString.length(), NULL, 10); } return 0; }
const uint8_t extractImageData(const char content, const char key) { String searchString = String(key) + " = {"; const char found = strstr(content, searchString.c_str()); if (found) { found += searchString.length(); return (const uint8_t *)found; } return nullptr; } `