This just a note that might help someone.
While updating a project written using the old, deprecated syntax of "prog_char" etc. I noticed a 'gotcha'.

I had a number of text strings:

prog_char txt1[] = "Some txt";
prog_char txt2[] = "Some more txt";
... etc

and an array of pointers to them:
prog_char* ptrs_to_text[] = {txt1, txt2 ...};         // Case 1

The new version is:
char txt1[] PROGMEM = "Some txt";
char txt2[] PROGMEM = "Some more txt";
... etc

and an array of pointers to them:
char* ptrs_to_text[] PROGMEM = {txt1, txt2 ...};      // Case 2

Seeing that nothing worked any more, I investigated.
In case 1, the strings are in flash, but the array is in ram.
Case 2 has both the strings and the array in flash, as needs a pgm_read_word to access each pointer.

It's sort of obvious after the event but I though I'd point it out.
Perhaps a small mention on the website where the "prog_char" stuff is mentioned as deprecated?

Regards,

Bob
--
The Sun is out, the sky is blue, it's time to drive the MR2.

_______________________________________________
AVR-chat mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-chat

Reply via email to