Go Down

Topic: [Resolved] PROGMEM in Arduino IDE 1.6.0 (Read 982 times) previous topic - next topic

liudr

Feb 12, 2015, 08:42 am Last Edit: Feb 16, 2015, 06:15 pm by liudr
I've been using PROGMEM prog_char text[]="hello"; for ages without problems.
With the new IDE, it complains about the prog_char. I guess it is because of the DEPRECATED status of the typedef. So I changed to const char PROGMEM text[]="hello" OK, it works on 1.0.x and 1.6.0

But then I also have SRAM arrays that store pointers (FLASH address) to various PROGMEM strings. I used to do:

Code: [Select]
PROGMEM const char *phi_prompt_lcd_ch_item[] = {phi_prompt_lcd_ch0, phi_prompt_lcd_ch1, phi_prompt_lcd_ch2, phi_prompt_lcd_ch3, phi_prompt_lcd_ch4, phi_prompt_lcd_ch5}; ///< Custom LCD character char array addresses.

This way I can save some SRAM. Now this definition is also complained upon in 1.6.0. I don't really know how to fix it. I tried to remove PROGMEM but my program didn't run (probably grabbed wrong stuff in FLASH).

Error:
Code: [Select]

error: variable 'phi_prompt_lcd_ch_item' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 PROGMEM const char * phi_prompt_lcd_ch_item[] = {phi_prompt_lcd_ch0, phi_prompt_lcd_ch1, phi_prompt_lcd_ch2, phi_prompt_lcd_ch3, phi_prompt_lcd_ch4, phi_prompt_lcd_ch5}; ///< Custom LCD character char array addresses.


So PROGMEM alone with the const char * indicates that the pointers reside in FLASH in past versions (possibly avr gcc version instead of Arduino IDE version). Now I tried a few orders and even two PROGMEM but couldn't get this line to compile. Any suggestions? Thanks.

My final version was identical to this AVR GCC 2013 tutorial I found:
Code: [Select]

const char phi_prompt_lcd_ch0[] PROGMEM ={ 4,14,31,64,31,31,31,31,0}; ///< Custom LCD character: Up triangle with block
const char phi_prompt_lcd_ch1[] PROGMEM ={ 4,14,31,64,64,64,64,64,0}; ///< Custom LCD character: Up triangle
const char phi_prompt_lcd_ch2[] PROGMEM ={31,31,31,31,64,64,64,64,0}; ///< Custom LCD character: Top block
const char phi_prompt_lcd_ch3[] PROGMEM ={64,64,64,64,31,31,31,31,0}; ///< Custom LCD character: Bottom block
const char phi_prompt_lcd_ch4[] PROGMEM ={64,64,64,64,64,31,14, 4,0}; ///< Custom LCD character: Down triangle
const char phi_prompt_lcd_ch5[] PROGMEM ={31,31,31,31,64,31,14, 4,0}; ///< Custom LCD character: Down triangle with block
const char * phi_prompt_lcd_ch_item[] PROGMEM = {phi_prompt_lcd_ch0, phi_prompt_lcd_ch1, phi_prompt_lcd_ch2, phi_prompt_lcd_ch3, phi_prompt_lcd_ch4, phi_prompt_lcd_ch5}; ///< Custom LCD character char array addresses.


http://deans-avr-tutorials.googlecode.com/svn/trunk/Progmem/Output/Progmem.pdf

pYro_65

#1
Feb 12, 2015, 02:43 pm Last Edit: Feb 12, 2015, 02:48 pm by pYro_65
The array must be constant, you've created an array of constant elements.

Code: [Select]
const char * const phi_prompt_lcd_ch_item[] PROGMEM = {
  /* Custom LCD character char array addresses. */
  phi_prompt_lcd_ch0,
  phi_prompt_lcd_ch1,
  phi_prompt_lcd_ch2,
  phi_prompt_lcd_ch3,
  phi_prompt_lcd_ch4,
  phi_prompt_lcd_ch5
};


From right to left:

An array which is constant containing char pointers which are constant.

liudr


liudr

I tested and Pyro's solution works for both 1.6.0 and 1.0.6

my_legend_mm

#4
Mar 14, 2015, 04:29 pm Last Edit: Mar 14, 2015, 04:30 pm by my_legend_mm Reason: reomve personal info :)
Hi every one .
I'm working with TFTLCD .
How solve this error .

Code: [Select]
C:\Users\\Documents\Arduino\libraries\TFTLCD\glcdfont.c:9:23: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char  font[] PROGMEM = {
                       ^


thanks  :)

pYro_65

@my_legend_mm,

Quote
static const unsigned char font[] PROGMEM = {

my_legend_mm

Thanks @pYro_65

it's work fine :) .

But i have another problem cam you help me :D
i'm add some library , this Lib not work how remove it and his example .

thanks again .

liudr


my_legend_mm

#8
Mar 17, 2015, 07:56 pm Last Edit: Mar 17, 2015, 07:58 pm by my_legend_mm
 TFT Library ,
i have this LCD in this comment


but i can't make it work , i'm try many library but it's still white .
can you help me ,
thanks for your reply :)

liudr

You need to provide a direct link to the product and the library. Nobody is going to dig that out of a 5-page discussion thread for you. Sorry.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy