Pages: [1]   Go Down
Author Topic: CTE 70 Display with SSD - Read images from SD  (Read 647 times)
0 Members and 1 Guest are viewing this topic.
Brasil
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]
Logged

Everything can be done, since you know how to do.

0
Offline Offline
Shannon Member
****
Karma: 199
Posts: 11671
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: