many more lcd_putc_at optimisations

Changes in
lcd_implementation_drawmenu_sdfile
and
lcd_implementation_drawmenu_sddirectory
seem to save the most.

Change in memory:
Flash: -72 bytes
SRAM: 0 bytes
This commit is contained in:
Guðni Már Gilbert 2023-04-15 13:40:41 +00:00
parent dea7f2b26c
commit 9b6e1babcb
3 changed files with 11 additions and 23 deletions

View File

@ -622,8 +622,7 @@ void crashdet_detected(uint8_t mask)
lcd_print(msg);
// ask whether to resume printing
lcd_set_cursor(0, 1);
lcd_puts_P(_T(MSG_RESUME_PRINT));
lcd_puts_at_P(0, 1, _T(MSG_RESUME_PRINT));
lcd_putc('?');
uint8_t yesno = lcd_show_yes_no_and_wait(false);
if (yesno == LCD_LEFT_BUTTON_CHOICE)

View File

@ -159,8 +159,7 @@ static char menu_selection_mark(){
static void menu_draw_item_puts_P(char type_char, const char* str)
{
lcd_set_cursor(0, menu_row);
lcd_putc(menu_selection_mark());
lcd_putc_at(0, menu_row, menu_selection_mark());
lcd_print_pad_P(str, LCD_WIDTH - 2);
lcd_putc(type_char);
}
@ -218,10 +217,9 @@ void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_select_E(sheet, buffer);
lcd_putc(menu_selection_mark());
lcd_putc_at(0, menu_row, menu_selection_mark());
lcd_print_pad(buffer.c, LCD_WIDTH - 2);
lcd_putc(type_char);
}
@ -229,10 +227,9 @@ static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet)
static void menu_draw_item_puts_E(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_E(sheet, buffer);
lcd_putc(menu_selection_mark());
lcd_putc_at(0, menu_row, menu_selection_mark());
lcd_print_pad(buffer.c, LCD_WIDTH - 2);
lcd_putc(type_char);
}

View File

@ -267,22 +267,18 @@ const char STR_SEPARATOR[] PROGMEM = "------------";
static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* longFilename)
{
uint8_t len = LCD_WIDTH - 1;
lcd_set_cursor(0, row);
lcd_print((lcd_encoder == menu_item)?'>':' ');
lcd_putc_at(0, row, (lcd_encoder == menu_item)?'>':' ');
lcd_print_pad(longFilename, len);
}
static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* longFilename)
{
uint8_t len = LCD_WIDTH - 2;
lcd_set_cursor(0, row);
lcd_print((lcd_encoder == menu_item)?'>':' ');
lcd_print(LCD_STR_FOLDER[0]);
lcd_putc_at(0, row, (lcd_encoder == menu_item)?'>':' ');
lcd_putc(LCD_STR_FOLDER[0]);
lcd_print_pad(longFilename, len);
}
#define MENU_ITEM_SDDIR(str_fn, str_fnl) do { menu_item_sddir(str_fn, str_fnl); } while (0)
#define MENU_ITEM_SDFILE(str_fn, str_fnl) do { menu_item_sdfile(str_fn, str_fnl); } while (0)
@ -2935,9 +2931,8 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg)
if (multi_screen) {
// Display the "next screen" indicator character.
lcd_set_custom_characters_nextpage();
lcd_set_cursor(19, 3);
// Display the double down arrow.
lcd_print(LCD_STR_ARROW_2_DOWN[0]);
lcd_putc_at(19, 3, LCD_STR_ARROW_2_DOWN[0]);
}
return multi_screen ? msgend : NULL;
@ -2969,9 +2964,8 @@ void lcd_show_fullscreen_message_and_wait_P(const char *msg)
// Until confirmed by a button click.
for (;;) {
if (msg_next == NULL) {
lcd_set_cursor(19, 3);
// Display the confirm char.
lcd_print(LCD_STR_CONFIRM[0]);
lcd_putc_at(19, 3, LCD_STR_CONFIRM[0]);
}
// Wait for 5 seconds before displaying the next text.
for (uint8_t i = 0; i < 100; ++ i) {
@ -4785,8 +4779,7 @@ char reset_menu() {
};
lcd_clear();
lcd_set_cursor(0, 0);
lcd_putc('>');
lcd_putc_at(0, 0, '>');
lcd_consume_click();
while (1) {
@ -5139,8 +5132,7 @@ static void lcd_rename_sheet_menu()
{
lcd_putc(menuData->name[i]);
}
lcd_set_cursor(menuData->selected, 1);
lcd_putc('^');
lcd_putc_at(menuData->selected, 1, '^');
if (lcd_clicked())
{
if ((menuData->selected + 1u) < sizeof(Sheet::name))