PFW-1397 Drop ON_MENU_ENTER

Using _menu_data_t turns out to save *just* a little bit more flash. So for now just use it.
This commit is contained in:
Guðni Már Gilbert 2022-10-29 10:07:09 +00:00 committed by DRracer
parent 390f69a82f
commit 08460bd403
3 changed files with 18 additions and 8 deletions

View File

@ -29,7 +29,6 @@ uint8_t menu_line = 0;
uint8_t menu_item = 0;
uint8_t menu_row = 0;
uint8_t menu_top = 0;
bool menu_changed; // flag to indicate a new menu was entered
uint8_t menu_clicked = 0;
@ -54,7 +53,6 @@ void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bo
menu_menu = menu;
lcd_encoder = encoder;
menu_top = 0; //reset menu view. Needed if menu_back() is called from deep inside a menu, such as Support
menu_changed = true;
CRITICAL_SECTION_END;
if (reset_menu_state)
menu_data_reset();

View File

@ -58,7 +58,6 @@ extern uint8_t menu_row;
extern uint8_t menu_top;
extern uint8_t menu_clicked;
extern uint8_t menu_leaving;
extern bool menu_changed;
//function pointer to the currently active menu
extern menu_func_t menu_menu;
@ -115,7 +114,6 @@ extern bool menu_item_leave();
/// Entering a new menu
/// @param func lines of code to run once upon enter a menu or submenu
#define ON_MENU_ENTER(func) do { if (menu_changed){ menu_changed = false; func } } while (0)
#define MENU_ITEM_FUNCTION_P(str, func) do { if (menu_item_function_P(str, func)) return; } while (0)
extern uint8_t menu_item_function_P(const char* str, menu_func_t func);

View File

@ -1197,10 +1197,17 @@ static void lcd_menu_fails_stats_mmu_print()
//! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations.
static void lcd_menu_fails_stats_mmu_total()
{
ON_MENU_ENTER(
typedef struct
{
bool initialized; // 1byte
} _menu_data_t;
static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if(_md->initialized) {
MMU2::mmu2.get_statistics();
lcd_timeoutToStatus.stop(); //infinite timeout
);
_md->initialized = false;
}
lcd_home();
lcd_printf_P(PSTR("%S\n" " %-16.16S%-3d\n"/* " %-16.16S%-3d\n" " %-16.16S%-3d"*/),
_T(MSG_TOTAL_FAILURES),
@ -1226,12 +1233,19 @@ static void lcd_menu_fails_stats_mmu_total()
//! @endcode
static void lcd_menu_toolchange_stats_mmu_total()
{
ON_MENU_ENTER(
typedef struct
{
bool initialized; // 1byte
} _menu_data_t;
static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if(_md->initialized) {
lcd_set_cursor(0, 0);
lcd_puts_P(PSTR("Toolchange count:"));
lcd_set_cursor(10, 1);
lcd_print(eeprom_read_dword((uint32_t*)EEPROM_TOTAL_TOOLCHANGE_COUNT));
);
_md->initialized = false;
}
menu_back_if_clicked_fb();
}