I am trying to setup a multi dimensional array and place it in PROGMEM.
The database in the array is defined as Unsigned char. The required array is a 2 dimensional array. The data in the database represents a very large graphic database. Because of the size of the database, I need to leave it in PROGMEM. The processor I am using is a Mega 2650 so I have plenty of program memory (256k). At this point I am only up to about 26k in Progmem.
I have setup an array system for a lot of text and it works fine in PROGMEM. The code I am using came from the Arduino Reference Manual and looks something like this:
const char TextHdr1[] PROGMEM = "Kloster";
const char TextHdr2[] PROGMEM = "AutoWorks";
const char TextHdr3[] PROGMEM = "Task List:d=Display Image x=Xoffset y=Yoffset";
const char TextHdr4[] PROGMEM = " W=Input Width, H=Input Height X=Input X Y=Input Y ";
const char TextHdr5[] PROGMEM = "Display Image";
const char TextHdr6[] PROGMEM = "Input Width (xxx)";
const char TextHdr7[] PROGMEM = "Input Height (xxx)";
const char* const PROGMEM TextHdrTbl[] = {TextHdr1, TextHdr2, TextHdr3, TextHdr4, TextHdr5, TextHdr6, TextHdr7};
// To call and print the string, I am using this.
u8g2.drawStr(8,28,strcpy_P(ScreenLabel, (char*)pgm_read_word(&(TextHdrTbl[0]))));
The section how to setup an unsigned char in the reference manual, apparently is obsolete. I reviewed the PROGMEM.h file and it delineates the new data types but I am still not getting reliable results.
I setup up the database in SRAM and ran the code to retrieve and display the database works fine.
The 2 dimensional array I setup in PROGMEM is defined as follows (It will compile):
const static unsigned char __attribute__ ((progmem))Image2dArray[160][26] ={0x00,0x00, ect};
I think the problem I am having is how to read the 2 dimensional array. I am using the following code for that:
void DisplayImage(){
byte i;
byte ii;
byte Width;
int iii = 0;
Width = width/8 -1;
u8g2.clearBuffer(); u8g2.sendBuffer();
for(i = Yoffset; i <= height +Yoffset; i++) {
for(ii = Xoffset; ii <= (Width + Xoffset); ii++) {
img[iii] = Image2dArray[i][ii];
iii = iii+1;}
}
u8g2.drawXBM( X, Y, width, height, img);
u8g2.sendBuffer();
}
Is it possible to put (or leave) a 2 dimensional array in PROGMEM??
How do I get the data out basically one byte at a time??
