You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is when I try to use the getLabel function, it just returns gibberish. I'm brand new to C++, so any help you could give would be appreciated.
Thank you.
The text was updated successfully, but these errors were encountered:
The macro MenuItem instructs the compiler to put the whole structure with the label string into progmem, see here, so you can not pass a string already in progmem to that structure.
I'd suggest to create the complete menu hierarchy one time for each language, and then in your reset code point to either language version. Should then also be possible to switch at runtime using navigate(<menu Item of some lang version>).
Well actually the label string does not get saved entirely in PROGMEM. Currently only the pointer to the string is stored. If someone wants an extended version of the makro to store the whole label string to save some ram have a look at my changes here: 7FM@16cc793
After calling getLabel() you get the address of the progmem string which is already noticed not directly printable, but almost. When having a subclass from the arduino Print class like Serial you can simply print the progmem string by calling forcing a call to the correct overloaded function by :
I'm writing an Arduino app and I want to be able to change the language of the menus. So I would have something like this:
EN.h
const char PROGMEM WELCOME[] = "Welcome"
DE.h
const char PROGMEM WELCOME[] = "Willkommen"
Main.ino
#include "./EN.h" // or #include "./DE.h"
MenuItem(miWelcome, WELCOME, Menu::NullItem, Menu::NullItem, Menu::NullItem, Menu::NullItem, ShowWelcome);
The problem is when I try to use the getLabel function, it just returns gibberish. I'm brand new to C++, so any help you could give would be appreciated.
Thank you.
The text was updated successfully, but these errors were encountered: