Hello Folks,
I am quite new in the field of Arduino and hope to get some help from you professionals in the field of programming using PROGMEM. That is my goal: I want to program a sequential light (mini-movie) using a 10x10 LED-matrix. Therefore I use a lot of binary 10x10 arrays like this:
const byte j1[10][10] PROGMEM = {
{0, 0, 0, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 0, 1, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 0, 0, 0, 1, 0, 1},
{1, 0, 0, 1, 1, 1, 1, 0, 0, 1},
{0, 1, 0, 0, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 0, 0, 0},
};
For this mini-movie I need something about 200 frames, means j1 to j200, each 10x10 arrays. That is why I need to use flash-memory instead of RAM. Using the Atmega328P-PU of the Arduino, the following code works:
#include <avr/pgmspace.h>
const byte j1[10][10] PROGMEM = {{0,0,0,1,1,1,1,0,0,0}, {1,1,0,1,1,1,1,0,0,0}, ...
const byte j2... //and so on
void loop() {
led_10x10(j1); //using millis() for the illumination-time for each frame, dosen't matter here...
led_10x10(j2)... //and so on
}
void led_10x10(byte matrix[10][10]) { //subfunction for led actuation
//some for-loops for multiplex , important part is this:
digitalWrite(z, pgm_read_byte( &matrix[i_z][i_s]) ); //z=number of current row; i_z, i_s are continuous variables
}
Now you might thinking: Why do I ask you although the quoted code works? The thing is, that I have to use a DIP40 Atmega324PA, because the DIP28 328PU has not enough pins. Therefore I use the Arduino as ISP using Mighty-Core bootloader for the 324PA. That works fine. However: The compiling of the code above doesn't work anymore. The error:
exit status 1
invalid conversion from 'const byte ()[10] {aka const unsigned char ()[10]}' to 'byte ()[10] {aka unsigned char ()[10]}' [-fpermissive]
The same error occurs with the 328PU using the arduino version 1.6.11 and older. Version 1.6.12 to 1.6.17 works fine. I really think the main problem has something to do with the middle part in void loop. I guess this syntax is not correct... I also tried to use Flash5 but i doesnt work at all. Reading a lot of threads concerning PROGMEM & arrays and their access in the main code didn't help either.
Please, can you help?