From 87bc5a78b6b787bc6415a49495aee40fa10f7175 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 1 Jun 2020 17:03:48 +0200 Subject: [PATCH 1/8] Remove bogus comment (BED_MINTEMP *is* implemented) --- Firmware/temperature.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 6e9b6985a..a7b9a3cdf 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1165,7 +1165,6 @@ void tp_init() #endif //MAXTEMP 2 #ifdef BED_MINTEMP - /* No bed MINTEMP error implemented?!? */ while(analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) { #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP bed_minttemp_raw += OVERSAMPLENR; @@ -1173,7 +1172,6 @@ void tp_init() bed_minttemp_raw -= OVERSAMPLENR; #endif } - #endif //BED_MINTEMP #ifdef BED_MAXTEMP while(analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) { From 942fca5b660bada0dfdea9d7b2945c8a0ce6ebf0 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 7 Jun 2020 23:15:06 +0200 Subject: [PATCH 2/8] Remove useless assignment target_temperature_bed is already reset by disable_heaters() in Stop() --- Firmware/temperature.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index a7b9a3cdf..9ac97aec0 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2002,7 +2002,6 @@ void check_max_temp() #else if (current_temperature_bed_raw >= bed_maxttemp_raw) { #endif - target_temperature_bed = 0; bed_max_temp_error(); } #endif From 65f25b0d7e4260d06073af2aeea3f39ba6cb6990 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 8 Jun 2020 02:16:00 +0200 Subject: [PATCH 3/8] Remove redundant disable_heater() calls in max/min_temp handling In max/min_temp handlers remove the redundant disable_heater() call. Handlers already need to call Stop(), which will disable all heaters as the first step. Fix comments in order to mention that all heaters get disabled. Use "MAX/MINTEMP BED" correctly in both the LCD and serial. --- Firmware/temperature.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 9ac97aec0..c9e63def3 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1426,19 +1426,16 @@ enum { LCDALERT_NONE = 0, LCDALERT_HEATERMINTEMP, LCDALERT_BEDMINTEMP, LCDALERT_ uint8_t last_alert_sent_to_lcd = LCDALERT_NONE; void max_temp_error(uint8_t e) { - disable_heater(); if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLN((int)e); - SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !"); + SERIAL_ERRORLNPGM(": Heaters switched off. MAXTEMP triggered !"); LCD_ALERTMESSAGEPGM("Err: MAXTEMP"); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); - - - #endif + SET_OUTPUT(FAN_PIN); SET_OUTPUT(BEEPER); WRITE(FAN_PIN, 1); @@ -1457,12 +1454,11 @@ void min_temp_error(uint8_t e) { return; #endif //if (current_temperature_ambient < MINTEMP_MINAMBIENT) return; - disable_heater(); static const char err[] PROGMEM = "Err: MINTEMP"; if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLN((int)e); - SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !"); + SERIAL_ERRORLNPGM(": Heaters switched off. MINTEMP triggered !"); lcd_setalertstatuspgm(err); last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP; } else if( last_alert_sent_to_lcd != LCDALERT_HEATERMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time) @@ -1482,32 +1478,24 @@ void min_temp_error(uint8_t e) { } void bed_max_temp_error(void) { -#if HEATER_BED_PIN > -1 - //WRITE(HEATER_BED_PIN, 0); -#endif if(IsStopped() == false) { SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !"); + SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP BED triggered !"); LCD_ALERTMESSAGEPGM("Err: MAXTEMP BED"); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); #endif - } void bed_min_temp_error(void) { #ifdef DEBUG_DISABLE_MINTEMP return; -#endif -//if (current_temperature_ambient < MINTEMP_MINAMBIENT) return; -#if HEATER_BED_PIN > -1 - //WRITE(HEATER_BED_PIN, 0); #endif static const char err[] PROGMEM = "Err: MINTEMP BED"; if(IsStopped() == false) { SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Temperature heated bed switched off. MINTEMP triggered !"); + SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP BED triggered !"); lcd_setalertstatuspgm(err); last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP; } else if( last_alert_sent_to_lcd != LCDALERT_BEDMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time) From 3336db7954a7204dbf5ae859515dcc11e9dcba18 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 8 Jun 2020 02:56:11 +0200 Subject: [PATCH 4/8] Add some important notes about thermistor ADC handling --- Firmware/temperature.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index c9e63def3..7f293f2ed 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -639,6 +639,7 @@ void manage_heater() return; // more precisely - this condition partially stabilizes time interval for regulation values evaluation (@ ~ 230ms) + // ADC values need to be converted before checking: converted values are later used in MINTEMP updateTemperaturesFromRawValues(); check_max_temp(); From a60ed81a3507814c60354534e4c4f4f9230d2aa6 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 8 Jun 2020 03:14:49 +0200 Subject: [PATCH 5/8] Implement MIN/MAX AMBIENT safety checks Take advantage of the NTC thermistor found on the Einsy as an additional safety measure, following the steps of the other MIN/MAXTEMP errors. Introduce two configurable params AMBIENT_MINTEMP and AMBIENT_MAXTEMP in the variant defines and set them for the MK3/MK3S to -30/+100 respectively. AMBIENT_MINTEMP is primarily intended to catch a defective board thermistor (to ensure MAXTEMP would be properly triggered) and thus the trigger temperature is set just above the sensing limit and well below the operating range. AMBIENT_MAXTEMP is set at 100C, which is instead 20C above the maximum recommended operating temperature of the Einsy. The NTC thermistor is located just above the main power connector on the bottom of the board, and could also help in detecting a faulty connection which can result in rapid overheating of the contacts. As for MAXTEMP, we cut power to the heaters, print fan and motors to reduce power draw. Resume is not possible except by resetting the printer, since the user is highly advised to inspect the board for problems before attempting to continue. --- Firmware/Configuration_adv.h | 4 + Firmware/temperature.cpp | 87 ++++++++++++++++++- Firmware/thermistortables.h | 2 + .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 + .../variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 2 + 5 files changed, 95 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 5386c2815..f206c43c2 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -436,6 +436,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st #undef BED_MINTEMP #undef BED_MAXTEMP #endif +#if TEMP_SENSOR_AMBIENT == 0 + #undef AMBIENT_MINTEMP + #undef AMBIENT_MAXTEMP +#endif #endif //__CONFIGURATION_ADV_H diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 7f293f2ed..75d52817e 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -180,6 +180,12 @@ static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; #ifdef BED_MAXTEMP static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP; #endif +#ifdef AMBIENT_MINTEMP +static int ambient_minttemp_raw = AMBIENT_RAW_LO_TEMP; +#endif +#ifdef AMBIENT_MAXTEMP +static int ambient_maxttemp_raw = AMBIENT_RAW_HI_TEMP; +#endif static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE ); static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN ); @@ -1183,6 +1189,25 @@ void tp_init() #endif } #endif //BED_MAXTEMP + +#ifdef AMBIENT_MINTEMP + while(analog2tempAmbient(ambient_minttemp_raw) < AMBIENT_MINTEMP) { +#if HEATER_AMBIENT_RAW_LO_TEMP < HEATER_AMBIENT_RAW_HI_TEMP + ambient_minttemp_raw += OVERSAMPLENR; +#else + ambient_minttemp_raw -= OVERSAMPLENR; +#endif + } +#endif //AMBIENT_MINTEMP +#ifdef AMBIENT_MAXTEMP + while(analog2tempAmbient(ambient_maxttemp_raw) > AMBIENT_MAXTEMP) { +#if HEATER_AMBIENT_RAW_LO_TEMP < HEATER_AMBIENT_RAW_HI_TEMP + ambient_maxttemp_raw -= OVERSAMPLENR; +#else + ambient_maxttemp_raw += OVERSAMPLENR; +#endif + } +#endif //AMBIENT_MAXTEMP } #if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) @@ -1509,6 +1534,35 @@ void bed_min_temp_error(void) { #endif } + +#ifdef AMBIENT_THERMISTOR +void ambient_max_temp_error(void) { + if(IsStopped() == false) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP AMBIENT triggered !"); + LCD_ALERTMESSAGEPGM("Err: MAXTEMP AMBIENT"); + } +#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE + Stop(); +#endif +} + +void ambient_min_temp_error(void) { +#ifdef DEBUG_DISABLE_MINTEMP + return; +#endif + if(IsStopped() == false) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP AMBIENT triggered !"); + LCD_ALERTMESSAGEPGM("Err: MINTEMP AMBIENT"); + } +#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE + Stop(); +#endif +} +#endif + + #ifdef HEATER_0_USES_MAX6675 #define MAX6675_HEAT_INTERVAL 250 long max6675_previous_millis = MAX6675_HEAT_INTERVAL; @@ -1994,7 +2048,16 @@ void check_max_temp() bed_max_temp_error(); } #endif - +//ambient +#if defined(AMBIENT_MAXTEMP) && (TEMP_SENSOR_AMBIENT != 0) +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP + if (current_temperature_raw_ambient <= ambient_maxttemp_raw) { +#else + if (current_temperature_raw_ambient >= ambient_maxttemp_raw) { +#endif + ambient_max_temp_error(); + } +#endif } //! number of repeating the same state with consecutive step() calls //! used to slow down text switching @@ -2089,12 +2152,32 @@ void check_min_temp_bed() } } +#ifdef AMBIENT_MINTEMP +void check_min_temp_ambient() +{ +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP + if (current_temperature_raw_ambient >= ambient_minttemp_raw) { +#else + if (current_temperature_raw_ambient <= ambient_minttemp_raw) { +#endif + ambient_min_temp_error(); + } +} +#endif + void check_min_temp() { static bool bCheckingOnHeater=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over heaterMintemp) static bool bCheckingOnBed=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over bedMintemp) #ifdef AMBIENT_THERMISTOR -if(current_temperature_raw_ambient>(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) // thermistor is NTC type, so operator is ">" ;-) +#ifdef AMBIENT_MINTEMP +check_min_temp_ambient(); +#endif +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP +if(current_temperature_raw_ambient>(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) // thermistor is NTC type +#else +if(current_temperature_raw_ambient=<(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) +#endif { // ambient temperature is low #endif //AMBIENT_THERMISTOR // *** 'common' part of code for MK2.5 & MK3 diff --git a/Firmware/thermistortables.h b/Firmware/thermistortables.h index dc934ccfd..721c6b359 100644 --- a/Firmware/thermistortables.h +++ b/Firmware/thermistortables.h @@ -1213,6 +1213,8 @@ const short temptable_1047[][2] PROGMEM = { #endif #if (THERMISTORAMBIENT == 2000) //100k thermistor NTCG104LH104JT1 +# define AMBIENT_RAW_HI_TEMP 0 +# define AMBIENT_RAW_LO_TEMP 16383 const short temptable_2000[][2] PROGMEM = { // Source: https://product.tdk.com/info/en/catalog/datasheets/503021/tpd_ntc-thermistor_ntcg_en.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index b135d8d13..04b4c5266 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -296,6 +296,7 @@ #endif #define DETECT_SUPERPINDA #define PINDA_MINTEMP BED_MINTEMP +#define AMBIENT_MINTEMP -30 // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) @@ -306,6 +307,7 @@ #define HEATER_1_MAXTEMP 305 #define HEATER_2_MAXTEMP 305 #define BED_MAXTEMP 125 +#define AMBIENT_MAXTEMP 100 #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) // Define PID constants for extruder with PT100 diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index e618c54ef..c869ec517 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -298,6 +298,7 @@ #endif #define DETECT_SUPERPINDA #define PINDA_MINTEMP BED_MINTEMP +#define AMBIENT_MINTEMP -30 // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) @@ -308,6 +309,7 @@ #define HEATER_1_MAXTEMP 305 #define HEATER_2_MAXTEMP 305 #define BED_MAXTEMP 125 +#define AMBIENT_MAXTEMP 100 #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) // Define PID constants for extruder with PT100 From e1c79c342d75191ea759bfbecba00d9a907df7e0 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 30 Jul 2020 17:14:13 +0200 Subject: [PATCH 6/8] Re-introduce redundant disable_heaters() calls Partially revert 285b505c73a54e9af01816e3a614de73ad181851 so that we ensure heaters are disabled ASAP in case of potential bugs in the max_*_error functions. --- Firmware/temperature.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 75d52817e..f9fa48fff 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1452,6 +1452,7 @@ enum { LCDALERT_NONE = 0, LCDALERT_HEATERMINTEMP, LCDALERT_BEDMINTEMP, LCDALERT_ uint8_t last_alert_sent_to_lcd = LCDALERT_NONE; void max_temp_error(uint8_t e) { + disable_heater(); if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLN((int)e); @@ -1479,6 +1480,7 @@ void min_temp_error(uint8_t e) { #ifdef DEBUG_DISABLE_MINTEMP return; #endif + disable_heater(); //if (current_temperature_ambient < MINTEMP_MINAMBIENT) return; static const char err[] PROGMEM = "Err: MINTEMP"; if(IsStopped() == false) { @@ -1504,6 +1506,7 @@ void min_temp_error(uint8_t e) { } void bed_max_temp_error(void) { + disable_heater(); if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP BED triggered !"); @@ -1518,7 +1521,8 @@ void bed_min_temp_error(void) { #ifdef DEBUG_DISABLE_MINTEMP return; #endif - static const char err[] PROGMEM = "Err: MINTEMP BED"; + disable_heater(); + static const char err[] PROGMEM = "MINTEMP BED"; if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP BED triggered !"); @@ -1537,6 +1541,7 @@ void bed_min_temp_error(void) { #ifdef AMBIENT_THERMISTOR void ambient_max_temp_error(void) { + disable_heater(); if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP AMBIENT triggered !"); @@ -1551,6 +1556,7 @@ void ambient_min_temp_error(void) { #ifdef DEBUG_DISABLE_MINTEMP return; #endif + disable_heater(); if(IsStopped() == false) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP AMBIENT triggered !"); From a8ce9358e55f509f7efde3905261fa702d0cbc5a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 31 Jul 2020 20:19:51 +0200 Subject: [PATCH 7/8] Avoid redundant temperature error strings Factor-out MIN/MAXTEMP [BED/AMB] out of the error message, which is now built at runtime instead. Introduce two missing ultralcd functions lcd_setalertstatus and lcd_updatestatus to handle regular strings. 246272 -> 246084 = 188 bytes saved --- Firmware/temperature.cpp | 64 +++++++++++++++++++++++++--------------- Firmware/ultralcd.cpp | 22 ++++++++++++-- Firmware/ultralcd.h | 2 ++ 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index f9fa48fff..657b23fbc 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1451,13 +1451,42 @@ enum { LCDALERT_NONE = 0, LCDALERT_HEATERMINTEMP, LCDALERT_BEDMINTEMP, LCDALERT_ //! to prevent flicker and improve speed uint8_t last_alert_sent_to_lcd = LCDALERT_NONE; + +//! update the current temperature error message +//! @param type short error abbreviation (PROGMEM) +//! @param func optional lcd update function (lcd_setalertstatus when first setting the error) +void temp_update_messagepgm(const char* PROGMEM type, void (*func)(const char*) = lcd_updatestatus) +{ + char msg[LCD_WIDTH]; + strcpy_P(msg, PSTR("Err: ")); + strcat_P(msg, type); + (*func)(msg); +} + +//! signal a temperature error on both the lcd and serial +//! @param type short error abbreviation (PROGMEM) +//! @param e optional extruder index for hotend errors +void temp_error_messagepgm(const char* PROGMEM type, uint8_t e = EXTRUDERS) +{ + temp_update_messagepgm(type, lcd_setalertstatus); + + SERIAL_ERROR_START; + + if(e != EXTRUDERS) { + SERIAL_ERROR((int)e); + SERIAL_ERRORPGM(": "); + } + + SERIAL_ERRORPGM("Heaters switched off. "); + SERIAL_ERRORRPGM(type); + SERIAL_ERRORLNPGM(" triggered!"); +} + + void max_temp_error(uint8_t e) { disable_heater(); if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLN((int)e); - SERIAL_ERRORLNPGM(": Heaters switched off. MAXTEMP triggered !"); - LCD_ALERTMESSAGEPGM("Err: MAXTEMP"); + temp_error_messagepgm(PSTR("MAXTEMP"), e); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); @@ -1482,16 +1511,13 @@ void min_temp_error(uint8_t e) { #endif disable_heater(); //if (current_temperature_ambient < MINTEMP_MINAMBIENT) return; - static const char err[] PROGMEM = "Err: MINTEMP"; + static const char err[] PROGMEM = "MINTEMP"; if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLN((int)e); - SERIAL_ERRORLNPGM(": Heaters switched off. MINTEMP triggered !"); - lcd_setalertstatuspgm(err); + temp_error_messagepgm(err, e); last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP; } else if( last_alert_sent_to_lcd != LCDALERT_HEATERMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time) // we are already stopped due to some error, only update the status message without flickering - lcd_updatestatuspgm(err); + temp_update_messagepgm(err); last_alert_sent_to_lcd = LCDALERT_HEATERMINTEMP; } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE @@ -1508,9 +1534,7 @@ void min_temp_error(uint8_t e) { void bed_max_temp_error(void) { disable_heater(); if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP BED triggered !"); - LCD_ALERTMESSAGEPGM("Err: MAXTEMP BED"); + temp_error_messagepgm(PSTR("MAXTEMP BED")); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); @@ -1524,13 +1548,11 @@ void bed_min_temp_error(void) { disable_heater(); static const char err[] PROGMEM = "MINTEMP BED"; if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP BED triggered !"); - lcd_setalertstatuspgm(err); + temp_error_messagepgm(err); last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP; } else if( last_alert_sent_to_lcd != LCDALERT_BEDMINTEMP ){ // only update, if the lcd message is to be changed (i.e. not the same as last time) // we are already stopped due to some error, only update the status message without flickering - lcd_updatestatuspgm(err); + temp_update_messagepgm(err); last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP; } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE @@ -1543,9 +1565,7 @@ void bed_min_temp_error(void) { void ambient_max_temp_error(void) { disable_heater(); if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP AMBIENT triggered !"); - LCD_ALERTMESSAGEPGM("Err: MAXTEMP AMBIENT"); + temp_error_messagepgm(PSTR("MAXTEMP AMB")); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); @@ -1558,9 +1578,7 @@ void ambient_min_temp_error(void) { #endif disable_heater(); if(IsStopped() == false) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP AMBIENT triggered !"); - LCD_ALERTMESSAGEPGM("Err: MINTEMP AMBIENT"); + temp_error_messagepgm(PSTR("MINTEMP AMB")); } #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE Stop(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 87266914f..a08f8a365 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8951,13 +8951,14 @@ void lcd_finishstatus() { lcd_draw_update = 2; } + void lcd_setstatus(const char* message) { if (lcd_status_message_level > 0) return; - strncpy(lcd_status_message, message, LCD_WIDTH); - lcd_finishstatus(); + lcd_updatestatus(message); } + void lcd_updatestatuspgm(const char *message){ strncpy_P(lcd_status_message, message, LCD_WIDTH); lcd_status_message[LCD_WIDTH] = 0; @@ -8972,12 +8973,29 @@ void lcd_setstatuspgm(const char* message) return; lcd_updatestatuspgm(message); } + +void lcd_updatestatus(const char *message){ + strncpy(lcd_status_message, message, LCD_WIDTH); + lcd_status_message[LCD_WIDTH] = 0; + lcd_finishstatus(); + // hack lcd_draw_update to 1, i.e. without clear + lcd_draw_update = 1; +} + void lcd_setalertstatuspgm(const char* message) { lcd_setstatuspgm(message); lcd_status_message_level = 1; lcd_return_to_status(); } + +void lcd_setalertstatus(const char* message) +{ + lcd_setstatus(message); + lcd_status_message_level = 1; + lcd_return_to_status(); +} + void lcd_reset_alert_level() { lcd_status_message_level = 0; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 844c7c7d3..a5f07673f 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -23,9 +23,11 @@ void lcd_setstatuspgm(const char* message); //! - always returns the display to the main status screen //! - always makes lcd_reset (which is slow and causes flicker) //! - does not update the message if there is already one (i.e. lcd_status_message_level > 0) +void lcd_setalertstatus(const char* message); void lcd_setalertstatuspgm(const char* message); //! only update the alert message on the main status screen //! has no sideeffects, may be called multiple times +void lcd_updatestatus(const char *message); void lcd_updatestatuspgm(const char *message); void lcd_reset_alert_level(); From a2c7dcbbf8484450614abf0c59c63b5494fa0442 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 4 Aug 2020 13:14:35 +0200 Subject: [PATCH 8/8] Fix indentation --- Firmware/temperature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 657b23fbc..2d09f8e0f 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1546,7 +1546,7 @@ void bed_min_temp_error(void) { return; #endif disable_heater(); - static const char err[] PROGMEM = "MINTEMP BED"; + static const char err[] PROGMEM = "MINTEMP BED"; if(IsStopped() == false) { temp_error_messagepgm(err); last_alert_sent_to_lcd = LCDALERT_BEDMINTEMP;