From 504099bd6cebcd3c90fae9d50d1b4b41e184232f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 11 Feb 2023 15:32:19 +0000 Subject: [PATCH] optimisation: reduce code size in rendering cursor Change in memory: Flash: -62 bytes SRAM: 0 bytes --- Firmware/mmu2_reporting.cpp | 12 ++++-------- Firmware/ultralcd.cpp | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index b2481098b..8a96424e8 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -171,18 +171,14 @@ static uint8_t ReportErrorHookMonitor(uint8_t ei) { //! ---------------------- //! @endcode // - lcd_set_cursor(0, 3); - lcd_print(current_selection == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(0, 3, current_selection == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); if (two_choices == false) { - lcd_set_cursor(9, 3); - lcd_print(current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); - lcd_set_cursor(18, 3); - lcd_print(current_selection == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(9, 3, current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(18, 3, current_selection == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); } else { // More button for two button screen - lcd_set_cursor(18, 3); - lcd_print(current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(18, 3, current_selection == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); } // Consume rotation event and make feedback sound enc_dif = lcd_encoder_diff; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4d9740dda..ed501e6f9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3089,16 +3089,12 @@ uint8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool all //! @param third_choice text caption of third, optional, choice. void lcd_show_choices_prompt_P(uint8_t selected, const char *first_choice, const char *second_choice, uint8_t second_col, const char *third_choice) { - lcd_set_cursor(0, 3); - lcd_print(selected == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(0, 3, selected == LCD_LEFT_BUTTON_CHOICE ? '>': ' '); lcd_puts_P(first_choice); - lcd_set_cursor(second_col, 3); - lcd_print(selected == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); + lcd_putc_at(second_col, 3, selected == LCD_MIDDLE_BUTTON_CHOICE ? '>': ' '); lcd_puts_P(second_choice); - if (third_choice) - { - lcd_set_cursor(18, 3); - lcd_print(selected == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); + if (third_choice) { + lcd_putc_at(18, 3, selected == LCD_RIGHT_BUTTON_CHOICE ? '>': ' '); lcd_puts_P(third_choice); } }