hi! im running arduino on an esp32 wired to an sd card and a tft display. my hardware is working fine, ive managed to read/write to the sd and the display. the issue is: my sd card contains an rgb565 array, but when i use the sd library to read it, it returns it as a string. the display library TFT_ESPI can only draw images from an uint16_t array, not a string. any ideas how i can display the rgb565 string onto the tft? my code:
#include <TFT_eSPI.h> // Include the graphics library (this includes the sprite functions)
//#include "vid.h"
TFT_eSPI tft = TFT_eSPI(); // Declare object "tft"
#include <SD.h>
#include <sd_defines.h>
#include <sd_diskio.h>
#include <dummy.h>
File myFile;
SPIClass SPISD(HSPI);
String inString; //need to use Strings because of the ESP32 webserver
void setup(){
Serial.begin(115200);
Serial.println();
tft.begin(); // i
// Initialise the TFT registers
tft.init();
// Optionally set colour depth to 8 or 16 bits, default is 16 if not spedified
// spr.setColorDepth(8)
tft.setSwapBytes(true); // Swap the byte order for pushImage() - corrects endianness
pinMode(25,OUTPUT);
digitalWrite(25,HIGH);
SPISD.begin(14,5,13);
if (!SD.begin(15,SPISD)) { //SD_CS_PIN this pin is just the dummy pin since the SD need the input
Serial.println(F("failed!"));
return;
}
else Serial.println(F("SD read!"));
myFile = SD.open("/test.txt", "r"); //read from file
if (myFile)
{
Serial.println("test.txt:");
while (myFile.available())
{
inString = myFile.readString();
}
myFile.close();
Serial.println(inString);//inside the string is the rgb array, it looks like: 0x0000, 0x0000, 0x0000,.......
}
else
{
Serial.println("error opening test.txt to read");
}
}
void loop(void)
{
tft.pushImage(0,0,240,176,inString);
}