Remove first parameter of macro menu_format_sheet_P_E, of function menu_format_sheet_P_E and menu_item_submenu_P as it was always called with the same parameter. Saves 66B of FLASH.

This commit is contained in:
Marek Bel 2019-06-26 15:47:06 +02:00
parent 53dbcdd852
commit d879794922
3 changed files with 15 additions and 16 deletions

View File

@ -174,24 +174,23 @@ static void menu_draw_item_puts_P(char type_char, const char* str)
lcd_printf_P(PSTR("%c%-18.18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
}
//! @brief Format sheet name after PROGMEM text
//! @brief Format sheet name
//!
//! @param[in] str_P Pointer to string in PROGMEM
//! @param[in] sheet_E Sheet in EEPROM
//! @param[out] buffer for formatted output
void menu_format_sheet_P_E(const char *str_P, const Sheet &sheet_E, SheetFormatBuffer &buffer)
void menu_format_sheet_P_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
{
uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S "), str_P);
uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S "), _T(MSG_SHEET));
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7);
index += 7;
buffer.c[index] = '\0';
}
static void menu_draw_item_puts_P(char type_char, const char *str_P, const Sheet &sheet)
static void menu_draw_item_puts_P(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_P_E(str_P, sheet, buffer);
menu_format_sheet_P_E(sheet, buffer);
lcd_printf_P(PSTR("%c%-18.18s%c"), (lcd_encoder == menu_item)?'>':' ', buffer.c, type_char);
}
@ -245,11 +244,11 @@ uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu)
return 0;
}
uint8_t menu_item_submenu_P(const char* str_P, const Sheet &sheet, menu_func_t submenu)
uint8_t menu_item_submenu_P(const Sheet &sheet, menu_func_t submenu)
{
if (menu_item == menu_line)
{
if (lcd_draw_update) menu_draw_item_puts_P(LCD_STR_ARROW_RIGHT[0], str_P, sheet);
if (lcd_draw_update) menu_draw_item_puts_P(LCD_STR_ARROW_RIGHT[0], sheet);
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_submenu(submenu);

View File

@ -100,8 +100,8 @@ extern uint8_t menu_item_text_P(const char* str);
#define MENU_ITEM_SUBMENU_P(str, submenu) do { if (menu_item_submenu_P(str, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu);
#define MENU_ITEM_SUBMENU_P_E(str_P, sheet, submenu) do { if (menu_item_submenu_P(str_P, sheet, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_P(const char *str_P, const Sheet &sheet, menu_func_t submenu);
#define MENU_ITEM_SUBMENU_P_E(sheet, submenu) do { if (menu_item_submenu_P(sheet, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_P(const Sheet &sheet, menu_func_t submenu);
#define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0)
@ -135,7 +135,7 @@ struct SheetFormatBuffer
char c[19];
};
extern void menu_format_sheet_P_E(const char *str_P, const Sheet &sheet_E, SheetFormatBuffer &buffer);
extern void menu_format_sheet_P_E(const Sheet &sheet_E, SheetFormatBuffer &buffer);
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P(str, pval, minval, maxval)) return; } while (0)

View File

@ -3122,7 +3122,7 @@ static void lcd_babystep_z()
if (lcd_draw_update)
{
SheetFormatBuffer buffer;
menu_format_sheet_P_E(_T(MSG_SHEET), EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], buffer);
menu_format_sheet_P_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], buffer);
lcd_set_cursor(0, 0);
lcd_print(buffer.c);
lcd_set_cursor(0, 1);
@ -6320,9 +6320,9 @@ static void lcd_select_sheet_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_SHEET));
MENU_ITEM_SUBMENU_P_E(_T(MSG_SHEET), EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu);
MENU_ITEM_SUBMENU_P_E(_T(MSG_SHEET), EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu);
MENU_ITEM_SUBMENU_P_E(_T(MSG_SHEET), EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu);
MENU_ITEM_SUBMENU_P_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu);
MENU_ITEM_SUBMENU_P_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu);
MENU_ITEM_SUBMENU_P_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu);
MENU_END();
}
@ -6415,7 +6415,7 @@ static void lcd_main_menu()
} else
{
MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT
MENU_ITEM_SUBMENU_P_E(_T(MSG_SHEET), EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu);
MENU_ITEM_SUBMENU_P_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu);
}