Pages: [1]   Go Down
Author Topic: Flash & Methods  (Read 275 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Heys guys;

Here is my code:

#include <Flash.h>
#include <UTFT.h>

UTFT tft(ITDB32S, 38, 39, 40, 41);

FLASH_TABLE(int, fTable, 4, {0,0,10,100}, {0, 40, 40, 150});

void setup() {
  DrawMyRect();
}
void loop() {

}

void DrawMyRect() {
  tft.drawRect(fTable[0][0], fTable[0][1], fTable[0][2], fTable[0][3]);  // DOES NOT DISPLAY
  tft.drawRect(0, 0, 10, 100);  // WORKS
}

If I try a Serial.println(fTable[0][0], fTable[0][1], fTable[0][2], fTable[0][3]);
The serial monitor display's the correct information, any ideas would be appreciated


Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
any ideas would be appreciated
Where are you storing your table? Not in SRAM where the drawRect() method is expecting it. You are storing it in Flash (PROGMEM) memory. The Print::print() method is overloaded to deal with data in Flash. The UTFT::drawRect() method is not. You'll need to look at the Flash methods for retrieving data stored in PROGMEM.

For an 8 element array of ints, I can't see the benefits of moving that small an array to PROGMEM.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the nudge in the right direction
Logged

Pages: [1]   Go Up
Jump to: