Go Down

Topic: CTE 70 Display with SSD - Read images from SD (Read 854 times) previous topic - next topic


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);
#include <SdFat.h>
SdFat sd;
SdFile myFile;

void setup() {
  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:
//  myGLCD.drawBitmap(0,0,500,251,data); // Here I need to show the image to the LCD.

void loop()
Everything can be done, since you know how to do.


You need a byte array large enough for the bitmap.  You may have issues with there
not being enough RAM, so that the file will need to be read in chunks.

You will need to learn about arrays, they are not difficult.
[ I won't respond to messages, use the forum please ]

Go Up