I've defined a struct as follows:
typedef struct{
uint16_t height;
uint16_t width;
uint16_t bytes;
uint8_t dig[820];
} digit;
I'd like to create an array of these and store the array in flash. First I create several instances:
const digit Zero PROGMEM = {46, 122, 16,
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xc0,
[rest of array omitted for brevity] ... }};
const digit One PROGMEM = {46, 122, 16,
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xc0,
[rest of array omitted for brevity] ... }};
etc.
Then I declare the array:
const digit digits[] PROGMEM = {Zero, One, Two};
But the compiler throws an error on that line:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Seeeduino V4(Atmega328P)"
Sketch uses 8786 bytes (27%) of program storage space. Maximum is 32256 bytes.
Global variables use 2677 bytes (130%) of dynamic memory, leaving -629 bytes for local variables. Maximum is 2048 bytes.
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
If I comment out the array declaration, the code compiles fine:
Sketch uses 2956 bytes (9%) of program storage space. Maximum is 32256 bytes.
Global variables use 199 bytes (9%) of dynamic memory, leaving 1849 bytes for local variables. Maximum is 2048 bytes.
So, it kinda looks like the compiler is trying to stick the array in RAM, though the declaration also significantly expands flash consumption, too. What am I doing wrong? Thanks.