From 687c14808a86416b1dfe6786cc700ba6712cad00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 19 Feb 2023 20:14:06 +0000 Subject: [PATCH] optimisation: MMU silent mode toggling & init Change in memory: Flash: -16 bytes SRAM: -2 bytes --- Firmware/Marlin_main.cpp | 6 +----- Firmware/ultralcd.cpp | 10 +++------- Firmware/ultralcd.h | 1 - 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4486c7322..b6e00929a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1465,11 +1465,7 @@ void setup() //mbl_mode_init(); mbl_settings_init(); - SilentModeMenu_MMU = eeprom_read_byte((uint8_t*)EEPROM_MMU_STEALTH); - if (SilentModeMenu_MMU == 255) { - SilentModeMenu_MMU = 1; - eeprom_write_byte((uint8_t*)EEPROM_MMU_STEALTH, SilentModeMenu_MMU); - } + eeprom_init_default_byte((uint8_t*)EEPROM_MMU_STEALTH, 1); #if !defined(DEBUG_DISABLE_FANCHECK) && defined(FANCHECK) && defined(TACH_1) && TACH_1 >-1 setup_fan_interrupt(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0f1b7ac06..cf1938bac 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -61,7 +61,6 @@ int8_t ReInitLCD = 0; uint8_t scrollstuff = 0; int8_t SilentModeMenu = SILENT_MODE_OFF; -uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode int8_t FSensorStateMenu = 1; @@ -3442,10 +3441,8 @@ Sound_CycleState(); } #ifndef MMU_FORCE_STEALTH_MODE -static void lcd_silent_mode_mmu_set() { - if (SilentModeMenu_MMU == 1) SilentModeMenu_MMU = 0; - else SilentModeMenu_MMU = 1; - //saving to eeprom is done in mmu_loop() after mmu actually switches state and confirms with "ok" +static void lcd_mmu_mode_toggle() { + eeprom_toggle((uint8_t*)EEPROM_MMU_STEALTH); } #endif //MMU_FORCE_STEALTH_MODE @@ -4244,8 +4241,7 @@ do\ {\ if (MMU2::mmu2.Enabled())\ {\ - if (SilentModeMenu_MMU == 0) MENU_ITEM_TOGGLE_P(_T(MSG_MMU_MODE), _T(MSG_NORMAL), lcd_silent_mode_mmu_set);\ - else MENU_ITEM_TOGGLE_P(_T(MSG_MMU_MODE), _T(MSG_STEALTH), lcd_silent_mode_mmu_set);\ + MENU_ITEM_TOGGLE_P(_T(MSG_MMU_MODE), eeprom_read_byte((uint8_t*)EEPROM_MMU_STEALTH) ? _T(MSG_STEALTH) : _T(MSG_NORMAL), lcd_mmu_mode_toggle);\ }\ }\ while (0) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index b398f6a91..d520be5d6 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -163,7 +163,6 @@ void printf_IRSensorAnalogBoardChange(); #endif //IR_SENSOR_ANALOG extern int8_t SilentModeMenu; -extern uint8_t SilentModeMenu_MMU; extern bool cancel_heatup; extern bool isPrintPaused;