Dear friends,
Just stuck on reading images from SD ad displaying to LCD.
I'm using SdFat lib and UTFT.
As i'm using Arduino DUE, UTFT tinyFat is not yet ready to work with ARM.
I'm able to read the file from SD without any problem, the UTFT lib has drawBitmap function which is able to draw an array PROGMEM to the LCD.
I was just wondering if is possible to read the file and put it on a variable and then use it with drawBitmap.
I suppose that's not a big deal, but I'm not used to use arrays.
Here is my test code:
const int chipSelect = 53;
#include <UTFT.h>
#include <UTFT_CTE.h>
extern uint8_t SmallFont[];
// Set up UTFT for CTE70 on Arduino Due
UTFT myGLCD(CTE70,25,26,27,28);
UTFT_CTE CTE_LCD(&myGLCD);
#include <SdFat.h>
SdFat sd;
SdFile myFile;
void setup() {
delay(1000);
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(VGA_BLACK);
CTE_LCD.SPI_Flash_init(FLASH_CS_PIN);
Serial.begin(115200);
while (!Serial) {} // wait for Leonardo
Serial.println("Type any character to start");
while (Serial.read() <= 0) {}
delay(400); // catch Due reset problem
// Initialize SdFat or print a detailed error message and halt
// Use half speed like the native library.
// change to SPI_FULL_SPEED for more performance.
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
// re-open the file for reading:
if (!myFile.open("LOGO.c", O_READ)) {
sd.errorHalt("opening test.txt for read failed");
}
// read from the file until there's nothing else in it:
int data; // what kind of variable may I use to deal with ?
while ((data = myFile.read()) >= 0) Serial.write(data);
// close the file:
myFile.close();
// myGLCD.drawBitmap(0,0,500,251,data); // Here I need to show the image to the LCD.
}
void loop()
{
}
[/table]