ARTS37 / SerialMenuCmd

This Arduino library constitutes a basic Command Line Interface
MIT License
8 stars 2 forks source link

inline command menus #2

Open ElectroLund opened 1 month ago

ElectroLund commented 1 month ago

I mistakenly assumed I could just put the tMenuCmdTxt txt1[] strings into the stMenuCmd list[]. Like this:

stMenuCmd list[] = 
{
    {"red light test",  'R', cliCmnd1 }, 
    {"green light test",    'G', cliCmnd2 }, 
    {"blue light test", 'B', cliCmnd3 }, 
    {"random light test",   'A', cliCmnd4 }, 
    {"turn off lights", 'N', cliCmnd5 }, 
    {"door up motor test",  'U', cliCmnd6 }, 
    {"door down motor test",    'D', cliCmnd7 }, 
    {"stop door",   'S', cliCmnd8 }, 
    {"quit admin",  'Q', cliCmnd9 }, 
    {"display menu",    '?', cliCmnd10 }, 
};

It compiles and uploads. And veeeeery strange bugs happen. I see that the tMenuCmdTxt is just defined as:

typedef const char PROGMEM tMenuCmdTxt;

Apparently that can't be put inline.

ARTS37 commented 1 month ago

Hi Rob, The implementation you attempted is sensible and intuitive. Unfortunately this is not possible. Character strings must be declared "tMenuCmdTxt". Therefore, the character strings are stored in program memory and not in RAM.Otherwise, in your case you would use 156 bytes of RAM out of the 2KB available. I opted for a restrictive implementation (and not necessarily intuitive) but it has the advantage of preserving RAM.

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Sans virus.www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Le lun. 30 sept. 2024 à 01:17, Rob @.***> a écrit :

I mistakenly assumed I could just put the tMenuCmdTxt txt1[] strings into the stMenuCmd list[]. Like this:

stMenuCmd list[] = { {"red light test", 'R', cliCmnd1 }, {"green light test", 'G', cliCmnd2 }, {"blue light test", 'B', cliCmnd3 }, {"random light test", 'A', cliCmnd4 }, {"turn off lights", 'N', cliCmnd5 }, {"door up motor test", 'U', cliCmnd6 }, {"door down motor test", 'D', cliCmnd7 }, {"stop door", 'S', cliCmnd8 }, {"quit admin", 'Q', cliCmnd9 }, {"display menu", '?', cliCmnd10 }, };

It compiles and uploads. And veeeeery strange bugs happen. I see that the tMenuCmdTxt is just defined as:

typedef const char PROGMEM tMenuCmdTxt;

Apparently that can't be put inline.

— Reply to this email directly, view it on GitHub https://github.com/ARTS37/SerialMenuCmd/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUBWICRMP4LO3I3I437636DZZCDCLAVCNFSM6AAAAABPCEIMHWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TKMRRGEYDIMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>