So the modifications are to place the code below into openchronous.h and edit all that applies. use a temp to store menu_item->is and the code becomes smaller, and has complete static allocation of the structure, in flash code, a smaller RAM overhead, and smaller code size. The need to copy a larger argument list into a dynamic structure is avoided. I'll take the new lcd display code on board soon.... :D
/* Menu definitions and declarations */
struct menu {
/* Pointer to up button handler */
void (*up_btn_fn)(void);
/* Pointer to down button handler */
void (*down_btn_fn)(void);
/* Pointer to function button (NUM) */
void (*num_btn_fn)(void);
/* Pointer to settings button (long STAR) */
void (*lstar_btn_fn)(void);
/* Pointer to function button (long NUM) */
void (*lnum_btn_fn)(void);
/* Pointer to simultaneous up&down press */
void (*updown_btn_fn)(void);
/* Pointer to activate function */
void (*activate_fn)(void);
/* Pointer to deactivate function */
void (*deactivate_fn)(void);
};
struct allocation {
struct menu *is;
/* pointer to next menu item */
struct allocation *next;
};
/* The currently active menu item */
struct allocation *menu_item;
/* NB: More public definitions */
#define MODULE(name) struct menu name##_menu; struct allocation name##_allocation = { &name##_menu, NULL }
#define REGISTER(name) menu_add_entry(&name##_allocation)
#define END(name) struct menu name##_menu = { name##_up_press, name##_down_press, name##_num_press, name##_lstar_press, name##_lnum_press, name##_ud_press, name##_activated, name##_deactivated }