Save ~100B on menu implementation
This commit is contained in:
parent
84ed0725f2
commit
0eb7261e29
@ -252,8 +252,7 @@ static void menu_draw_item_puts_P(char type_char, const char* str, char num)
|
|||||||
lcd_set_cursor(0, menu_row);
|
lcd_set_cursor(0, menu_row);
|
||||||
lcd_printf_P(PSTR("%c%-.16S "), menu_selection_mark(), str);
|
lcd_printf_P(PSTR("%c%-.16S "), menu_selection_mark(), str);
|
||||||
lcd_putc(num);
|
lcd_putc(num);
|
||||||
lcd_set_cursor(19, menu_row);
|
lcd_putc_at(19, menu_row, type_char);
|
||||||
lcd_putc(type_char);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -312,7 +311,7 @@ uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func)
|
uint8_t __attribute__((noinline)) menu_item_function_E(const Sheet &sheet, menu_func_t func)
|
||||||
{
|
{
|
||||||
if (menu_item == menu_line)
|
if (menu_item == menu_line)
|
||||||
{
|
{
|
||||||
@ -346,6 +345,10 @@ uint8_t menu_item_back_P(const char* str)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __attribute__((noinline)) menu_item_leave(){
|
||||||
|
return ((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t menu_item_function_P(const char* str, menu_func_t func)
|
uint8_t menu_item_function_P(const char* str, menu_func_t func)
|
||||||
{
|
{
|
||||||
if (menu_item == menu_line)
|
if (menu_item == menu_line)
|
||||||
|
@ -112,7 +112,8 @@ extern uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func);
|
|||||||
extern uint8_t menu_item_back_P(const char* str);
|
extern uint8_t menu_item_back_P(const char* str);
|
||||||
|
|
||||||
// leaving menu - this condition must be immediately before MENU_ITEM_BACK_P
|
// leaving menu - this condition must be immediately before MENU_ITEM_BACK_P
|
||||||
#define ON_MENU_LEAVE(func) do { if (((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving){ func } } while (0)
|
#define ON_MENU_LEAVE(func) do { if (menu_item_leave()){ func } } while (0)
|
||||||
|
extern bool menu_item_leave();
|
||||||
|
|
||||||
#define MENU_ITEM_FUNCTION_P(str, func) do { if (menu_item_function_P(str, func)) return; } 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);
|
extern uint8_t menu_item_function_P(const char* str, menu_func_t func);
|
||||||
|
Loading…
Reference in New Issue
Block a user