Evening gents, when I declare my array with PROGMEM it won't return the correct data but without PROGMEM it's fine
Here's the code:
const PROGMEM int DefaultFuelMapWidth = 8;
const PROGMEM int DefaultFuelMapHeight = 12;
const PROGMEM int DefaultFuelMap[DefaultFuelMapHeight][DefaultFuelMapWidth] =
{
{850, 850, 850, 850, 850, 850, 850, 850},
{780, 780, 780, 780, 780, 780, 780, 780},
{780, 780, 830, 830, 830, 830, 830, 830},
{780, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830},
{830, 830, 830, 830, 830, 830, 830, 830}
};
void setup()
{
Serial.begin(9600);
delay(50);
ShowData(0, 0); // 850
ShowData(6, 0); // 830
ShowData(2, 1); // 780
}
void ShowData(int Col, int Row)
{
int v1;
v1 = DefaultFuelMap[Col][Row];
Serial.println(v1);
delay(50);
}
void loop()
{
}
When I use PROGMEM on the array I get the following results output to the serial monitor:
1542
1542
0
When I remove PROGMEM I get the correct data:
850
830
780
It does the same on a mega 1280 and 2560, I'm a bit stuck as to why it's happening, any ideas?