From 319fec47f0e32208f949bf26b61e2099e020846a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 19 Feb 2023 12:43:21 +0000 Subject: [PATCH 1/3] preheat: improve target temperature threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use 5°C threshold to be consistant with other parts of the firmware. Relying on 95% of the target temperature creates a dependency on the temperature: PLA: Target = 215°C, threshold = 10.75°C PETG: Target = 230°C, threshold = 11.5°C ABS: Target = 255°C, threshold = 12.75°C ASA: Target =260°C, threshold = 13.0°C PC: Target = 275°C, threshold = 13.75°C My proposal is we instead use a constant TEMP_HYSTERESIS = 5, which is consistent with M109, and behavior when restoring print from RAM and some of the MMU code (like unload function) Change in memory: Flash: +2 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d2acf60ccd07..771d6a5e4604 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1888,7 +1888,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) lcd_timeoutToStatus.stop(); - if (current_temperature[0] > (target_temperature[0] * 0.95)) + if (fabs(current_temperature[0] - target_temperature[0]) > TEMP_HYSTERESIS) { switch (eFilamentAction) { From 6ad126ef0b95451126affde73fa76399f461564d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 19 Feb 2023 13:21:30 +0000 Subject: [PATCH 2/3] optimisation: preheat menu always uses integers for target temperature Let's drop the float comparison since it not needed Change in memory: Flash : -16 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 771d6a5e4604..e3df9c00f830 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1888,7 +1888,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) lcd_timeoutToStatus.stop(); - if (fabs(current_temperature[0] - target_temperature[0]) > TEMP_HYSTERESIS) + if (abs((int)current_temperature[0] - nTemp) > TEMP_HYSTERESIS) { switch (eFilamentAction) { From 496b52b819f6909d16246a3a13dbd30f2c95595c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 19 Feb 2023 13:23:31 +0000 Subject: [PATCH 3/3] preheat: sync temperature threshold in M600 and Wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * M600 used 1°C threshold, which may increase the waiting time a bit * Wizard used 3°C Sync both to use TEMP_HYSTERESIS for consistancy No change in memory footprint --- Firmware/Marlin_main.cpp | 2 +- Firmware/ultralcd.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4d56adfbd17f..b1bb1afe40e1 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -11424,7 +11424,7 @@ void M600_wait_for_user(float HotendTempBckp) { } break; case 2: //waiting for nozzle to reach target temperature - if (fabs(degTargetHotend(active_extruder) - degHotend(active_extruder)) < 1) { + if (fabs(degTargetHotend(active_extruder) - degHotend(active_extruder)) < TEMP_HYSTERESIS) { lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD)); waiting_start_time = _millis(); wait_for_user_state = 0; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e3df9c00f830..f4a92daa36e9 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3772,7 +3772,7 @@ static void wait_preheat() plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS] / 60); delay_keep_alive(2000); lcd_display_message_fullscreen_P(_T(MSG_WIZARD_HEATING)); - while (fabs(degHotend(0) - degTargetHotend(0)) > 3) { + while (fabs(degHotend(0) - degTargetHotend(0)) > TEMP_HYSTERESIS) { lcd_display_message_fullscreen_P(_T(MSG_WIZARD_HEATING)); lcd_set_cursor(0, 4);