I've been playing with a 16x16RGB matrix and using it to show images and simple animations. The animations are stored in flash using PROGMEM. At the moment I am copying identical routines to show different animation array's, so every time I want a new animation I have having to copy the routine in full.
I would like to have a function that would call the array needed but despite looking I can not find one that works for me. Most guides say about using '&' to point(?) to the array but my current setup give an error when compiling:
"invalid conversion from 'const short unsigned int*' to 'short unsigned int' [-fpermissive]"
here is the code (I am using the Adafruit Graphics library to run the matrix):
void setup() {
matrix.begin();
matrix.setBrightness(92);
}
void loop() {
scrollImage(106, 1, 1000 / 30, 1, picToShow);
scrollImage(106, 1, 1000 / 30, 1, showThisPic);
}
void scrollImage(byte width, byte pixelScroll, byte fRate, char scrollDir, unsigned short &picture) {
if (scrollDir == 1) {
for (byte pos = 1; pos < width - 16; pos += pixelScroll) {
buttonCheck();
matrix.drawRGBBitmap(-pos, 0, (const uint16_t *) picture, width, 16);
showBriLevel();
matrix.show();
delay(fRate);
}
}
else {
for (byte pos = width - 16; pos > 0 ; pos -= pixelScroll) {
buttonCheck();
matrix.drawRGBBitmap(-pos, 0, (const uint16_t *) picture, width, 16);
showBriLevel();
matrix.show();
delay(fRate);
}
}
}
const unsigned short picToShow[1696] PROGMEM={
0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69,
...
...
...
};
const unsigned short showThisPic[1696] PROGMEM={
0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69, 0x4A69,
...
...
...
};
I have never tried to pass an array name to a function before and reading the tutorials have left me more confused then when I started! I am left wondering if it is because all the tutorials talk about arrays in RAM and not in FLASH?