OpenMoCo Menu Manager - completely automated menus for Arduino

Hello! First of all - thanks to developers for nice lib for menu! I found it very handy and simple to use. But I have one major trouble - with newer gcc (I think from 4.6 or 4.7) all PROGMEM identifers must also be const. I try to solve issues with const-ing by static_cast(const_cast(...) all works on OLDER compiler.. but I cannot find right cast for const MENU_LIST const root_list[] = {...}. without second const, that make pointer to arry elements const and PROGMEM-able it all can be compiled on older compiler, and it also WORKS! But as soon as I const root_list[] there is compiling errors about wrong cast from ‘const OMMenuItem* const ()[3]’ to type ‘void’. And without const-ing it cannot compile on ewer gcc :frowning:

HELP! PLEASE! :slight_smile:

I knew about __flash, but I prefere old-gcc compat solution and my knowelage isn't sufficient to port this lib to __flash.

Here is what I came so far
--therm_menu_const.SNIP---
float set_temp = 26.07;
float temp_delta = 0.5;

boolean missed = false;

// values to use

// TYPE MAX MIN TARGET
const MENU_VALUE set_temp_value = { TYPE_FLOAT_100, 125, -50 , MENU_TARGETO(&set_temp) };
const MENU_VALUE temp_delta_value = { TYPE_FLOAT_100, 2, 0.2 , MENU_TARGETO(&temp_delta) };

// LABEL TYPE LENGTH TARGET
const MENU_ITEM item_set_tempme = { {"Set Temperature"}, ITEM_VALUE, 0, MENU_TARGET(const_cast(&set_temp_value)) };
const MENU_ITEM item_temp_deltame = { {"Set Delta"}, ITEM_VALUE, 0, MENU_TARGET(const_cast(&temp_delta_value)) };
const MENU_ITEM item_testme = { {"Exit"}, ITEM_ACTION, 0, MENU_TARGETO(uiQwkScreen) };

// List of items in menu level
const MENU_LIST const root_list[] = { const_cast(&item_set_tempme), const_cast(&item_temp_deltame), const_cast(&item_testme) };

// Root item is always created last, so we can add all other items to it
const MENU_ITEM menu_root = { {"Root"}, ITEM_MENU, MENU_SIZE(root_list), MENU_TARGET(&root_list) };

OMMenuMgr Menu(const_cast(&menu_root));
--therm_menu_const.SNIP---

I add another macro

#define MENU_TARGETO(x) reinterpret_cast(x)
#define MENU_TARGET(x) static_cast(x)