I have a question. I adopted the use of const int over #define. Thinking I was doing good.
Today I learned that my const int consumes RAM, atleast the arrays do. In fact 75% of my RAM consists out of const ints. I already wondered why my program would use so much RAM.
Now my RAM memory is full. I googled the above and I used PROGMEM in the declarations. Thinking it would solve my memory problem. And it does... I got my 75% back.
What I don't know, is why all my arrays are now broken or how I can fix this.
For instance I have
const byte accessoryAddresses[] = // conversion array for accessory panel items to Xnet addresses
{
1, 9,
2, 10,
3, 11,
4, 12,
5, 13,
6, 14,
7, 15,
8, 16,
} ;
And when I try to do:
Serial.println((int)accessoryAddresses[Address]);
(with address being 0-15)
I get complete random values. My best guess would be that PROGMEM stores the constants on places which are also used by heap or stack during runtime or something...???
What is happening?
Can I fix this?
And if so: how?
Also, why does const int uses memory in the first place? I thought it was just a compile time thingy to replace the functionality of #define to eliminate certain macro pitfals ???
Regards,
Bas