Adafruit_ILI9341_Menu
Adafruit_ILI9341_Menu copied to clipboard
Edit Menu problem.
Hi Kris, Thanks for your wonderful library :) Im having a litte headache getting around this problem, I'm creating an Editmenu where I can scroll/select a number of predifined options, those options are in a char array like this:
const char *MidiINChannels[17] = {"ALL","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"};
MidiINMenu.init(MENU_TEXT, MENU_BACKGROUND, MENU_HIGHLIGHTTEXT, MENU_HIGHLIGHT, MENU_SELECTTEXT, MENU_SELECT,DATA_COLUMN, ROW_HEIGHT, ROWS, "Midi IN settings", FONT_ITEM, FONT_TITLE);
MidiINOption5 = MidiINMenu.addNI("Midi Channel", <??? what here ??? >, 0, sizeof(MidiINChannels) / sizeof(MidiINChannels[0]), 1, 0, MidiINChannels);
If I want to pre-populate the option let say with value "ALL" taken from my flash if this value is a String and addNI is expecting a float? Is the data parameter the index of my char array?
I hope it's clear what I'm trying to say/achieve 😄
The "what goes here" is the array element (0-16), You just set the initial value to first element (0) for "All" Like this: MidiINOption5 = MidiINMenu.addNI("Midi Channel", 0, 0, sizeof(MidiINChannels) / sizeof(MidiINChannels[0]), 1, 0, MidiINChannels);
Another option I use all the time is to store the value in eeprom, I read the value at startup so the last menu item selected is presented as the default on next startup, then if the users uses the menu to change the value, I store the new setting in the eeprom.
Thanks, Kris @.***
On Tuesday, January 31, 2023 at 07:48:05 AM CST, cyberdevnet ***@***.***> wrote:
Hi Kris, Thanks for your wonderful library :) Im having a litte headache getting around this problem, I'm creating an Editmenu where I can scroll/select a number of predifined options, those options are in a char array like this: const char *MidiINChannels[17] = {"ALL","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"};
MidiINMenu.init(MENU_TEXT, MENU_BACKGROUND, MENU_HIGHLIGHTTEXT, MENU_HIGHLIGHT, MENU_SELECTTEXT, MENU_SELECT,DATA_COLUMN, ROW_HEIGHT, ROWS, "Midi IN settings", FONT_ITEM, FONT_TITLE);
MidiINOption5 = MidiINMenu.addNI("Midi Channel", <??? what here ??? >, 0, sizeof(MidiINChannels) / sizeof(MidiINChannels[0]), 1, 0, MidiINChannels);
If I want to pre-populate the option let say with value "ALL" taken from my flash if this value is a String and addNI is expecting a float? Is the data parameter the index of my char array?
I hope it's clear what I'm trying to say/achieve 😄
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
I was able to fix in this way:
float tempselectedMidiChannel;
if (selectedMidiChannel == "ALL") // value taken from flash
{
tempselectedMidiChannel = 0;
}
else
{
tempselectedMidiChannel = selectedMidiChannel.toFloat();
}
MidiINOption5 = MidiINMenu.addNI("Midi Channel", tempselectedMidiChannel, 0, sizeof(MidiINChannels) / sizeof(MidiINChannels[0]), 1, 0, MidiINChannels); // midi IN Channell select
in this way I can cast the String taken from flash to the float needed by the addNI method