avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] string array in program memory


From: Jan Spurny
Subject: [avr-gcc-list] string array in program memory
Date: Thu, 1 Jul 2004 19:00:31 +0200

avr-gcc 3.0.3 - I am using this code:

----------------------------------------------------------------------------
const char mzNone[] PROGMEM     = "[none]";
const char mz50[] PROGMEM       = "[ 50 ]";
const char mz100[] PROGMEM      = "[100 ]";

PGM_P choices[3] PROGMEM = {mzZrusC, mz50, mz100};
----------------------------------------------------------------------------

to make "menu" which is displayed on LCD display and changed by pressing one 
button, but when I use this array:

----------------------------------------------------------------------------
void disp_progmem_str(PGM_P str)
{
        char tmpBuf[64];
        strcpy_P(tmpBuf, str);
        display(tmpBuf, 0);
}

void press_button_1()
{
        ...
        choice = choice + 1;
        if (choice == 3)
                choice = 0;
        disp_progmem_str(choices[choice]);
        ...
}
----------------------------------------------------------------------------

all I get is total mess... I was using allmost the same code, but with strings 
stored in ram and it worked well (except, of course, it was eating too much 
memory and it become corrupted often)

any suggestions?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]