TFT eSPI を使ってみた。
コード
#include "FS.h" #include "SD.h" #include "SPI.h" #include "TFT_eSPI.h" TFT_eSPI tft = TFT_eSPI(); // Invoke custom library SPIClass sd_HSPI(HSPI); #define HSPI_SCK 14 #define HSPI_MISO 35 #define HSPI_MOSI 13 #define HSPI_SS 15 static uint8_t data1[120 * 320]; static uint8_t data2[120 * 320]; void testOriginalData() { tft.pushImage(0, 0, 320, 120, data1); tft.pushImage(0, 120, 320, 120, data2); } bool readFile(fs::FS &fs, const char * path){ File file = fs.open(path); if(!file){ Serial.println("Failed to open file for reading"); return false; } file.read(data1, 120 * 320); file.read(data2, 120 * 320); file.close(); return true; } void setup() { // Setup the LCD tft.init(); tft.setRotation(1); sd_HSPI.begin(HSPI_SCK, HSPI_MISO, HSPI_MOSI, HSPI_SS); Serial.begin(115200); delay(100); if(!SD.begin(HSPI_SS, sd_HSPI, 12000000L)){ Serial.println("Card Mount Failed"); return; } } void loop() { //randomSeed(1234); // This ensure test is repeatable with exact same draws each loop char buf[255]; int x, x2; int y, y2; int r; // Clear the screen and draw the frame tft.fillScreen(TFT_BLACK); unsigned long old_time; for(int i = 1; i <= 100; i++) { sprintf(buf, "/output/%04d.dat", i); old_time = millis(); Serial.println(buf); if(readFile(SD, buf)) { // put your main code here, to run repeatedly: testOriginalData(); } Serial.print((float)1/(millis()-old_time)*1000); Serial.println(" fps"); } }
結果
約 5.80 fps になった。
SDの読み込みが遅いのかもしれない。