From 514afddeb4b3a7ede9ff481504aae69219a95f68 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 1 Apr 2020 18:53:58 -0500 Subject: [PATCH] Minor code cleanup --- Marlin/src/feature/tmc_util.cpp | 2 +- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 4 ++-- Marlin/src/lcd/dogm/ultralcd_DOGM.cpp | 8 +------ Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 1 - Marlin/src/lcd/ultralcd.cpp | 6 ++--- Marlin/src/module/configuration_store.cpp | 6 ++--- Marlin/src/module/temperature.cpp | 22 ++++++------------- 8 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index e5e69eed50..bfc2e1a555 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -1254,7 +1254,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z #endif } - if (axis_connection) ui.set_status_P(GET_TEXT(MSG_ERROR_TMC)); + if (axis_connection) LCD_MESSAGEPGM(MSG_ERROR_TMC); } #endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9ea298f02d..20867b4fea 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2164,7 +2164,7 @@ #define SHARED_SD_CARD #endif #if DISABLED(SHARED_SD_CARD) - #define INIT_SDCARD_ON_BOOT + #define INIT_SDCARD_ON_BOOT 1 #endif #endif diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index ee025f6585..3c89d1803c 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -367,11 +367,11 @@ void MarlinUI::init_lcd() { } bool MarlinUI::detected() { - return true + return (true #if EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008) && defined(DETECT_DEVICE) && lcd.LcdDetected() == 1 #endif - ; + ); } #if HAS_SLOW_BUTTONS diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index fc7656f1cd..4e07999bf6 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -244,13 +244,7 @@ void MarlinUI::init_lcd() { #if DISABLED(MKS_LCD12864B) #if PIN_EXISTS(LCD_BACKLIGHT) - OUT_WRITE(LCD_BACKLIGHT_PIN, ( - #if ENABLED(DELAYED_BACKLIGHT_INIT) - LOW // Illuminate after reset - #else - HIGH // Illuminate right away - #endif - )); + OUT_WRITE(LCD_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT)); // Illuminate after reset or right away #endif #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 6ac84c2bb0..bd73e811d1 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -441,7 +441,6 @@ void DGUSScreenVariableHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variab DGUSLCD_SendStringToDisplay(var); } - void DGUSScreenVariableHandler::SDCardInserted() { top_file = 0; auto cs = ScreenHandler.getCurrentScreen(); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index bbcb678dd8..ff0331eb20 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -351,10 +351,8 @@ void MarlinUI::init() { #endif #endif - #if HAS_ENCODER_ACTION - #if HAS_SLOW_BUTTONS - slow_buttons = 0; - #endif + #if HAS_ENCODER_ACTION && HAS_SLOW_BUTTONS + slow_buttons = 0; #endif update_buttons(); diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index b2c728fbe0..a2beb322f9 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -1391,7 +1391,7 @@ void MarlinSettings::postprocess() { DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) - ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_VERSION)); + LCD_MESSAGEPGM(MSG_ERR_EEPROM_VERSION); #endif eeprom_error = true; } @@ -2199,7 +2199,7 @@ void MarlinSettings::postprocess() { DEBUG_ECHO_START(); DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize()); #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) - ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_INDEX)); + LCD_MESSAGEPGM(MSG_ERR_EEPROM_INDEX); #endif } else if (working_crc != stored_crc) { @@ -2207,7 +2207,7 @@ void MarlinSettings::postprocess() { DEBUG_ERROR_START(); DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); #if HAS_LCD_MENU && DISABLED(EEPROM_AUTO_INIT) - ui.set_status_P(GET_TEXT(MSG_ERR_EEPROM_CRC)); + LCD_MESSAGEPGM(MSG_ERR_EEPROM_CRC); #endif } else if (!validating) { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 4018c7586c..42c79fdd19 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -542,22 +542,14 @@ volatile bool Temperature::raw_temps_ready = false; // Make sure heating is actually working #if WATCH_BED || WATCH_HOTENDS - if ( - #if WATCH_BED && WATCH_HOTENDS - true - #elif WATCH_HOTENDS - !isbed - #else - isbed - #endif - ) { - if (!heated) { // If not yet reached target... - if (current_temp > next_watch_temp) { // Over the watch temp? - next_watch_temp = current_temp + watch_temp_increase; // - set the next temp to watch for - temp_change_ms = ms + watch_temp_period * 1000UL; // - move the expiration timer up - if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached + if (BOTH(WATCH_BED, WATCH_HOTENDS) || isbed == DISABLED(WATCH_HOTENDS)) { + if (!heated) { // If not yet reached target... + if (current_temp > next_watch_temp) { // Over the watch temp? + next_watch_temp = current_temp + watch_temp_increase; // - set the next temp to watch for + temp_change_ms = ms + watch_temp_period * 1000UL; // - move the expiration timer up + if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached } - else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired + else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired _temp_error(heater, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?