diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d840a..19f7517957 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6232,7 +6232,9 @@ SERIAL_PROTOCOLPGM("\n\n"); } if (code_seen('S')) { - setTargetHotendSafe(code_value(), extruder); + if (!setTargetHotendSafe(code_value(), extruder)){ // Set the hotend temperature, unless we are stopped, in which case send an error (setTargetHotendSafe() returns true if it let the printer start heating, false otherwise) + SERIAL_PROTOCOLLNPGM("Hotend temperature not set because Stop() has been called. Use M999 to reset and try again."); + } } break; } @@ -6255,7 +6257,12 @@ SERIAL_PROTOCOLPGM("\n\n"); - `S` - Target temperature */ case 140: - if (code_seen('S')) setTargetBed(code_value()); + + if (code_seen('S')) { + if (!setTargetBed(code_value())) { + SERIAL_PROTOCOLLNPGM("Bed temperature not set because Stop() has been called. Use M999 to reset and try again."); + } + } break; /*! @@ -6392,19 +6399,19 @@ SERIAL_PROTOCOLPGM("\n\n"); if(setTargetedHotend(109, extruder)){ break; } + bool set_heater_success = true; // Set to true by default to allow the program to continue if S or R are not sent + if (code_seen('S')) { + set_heater_success = setTargetHotendSafe(code_value(), extruder); + } else if (code_seen('R')) { + set_heater_success = setTargetHotendSafe(code_value(), extruder); + } + if (set_heater_success){ LCD_MESSAGERPGM(_T(MSG_HEATING)); heating_status = 1; if (farm_mode) { prusa_statistics(1); }; #ifdef AUTOTEMP autotemp_enabled=false; - #endif - if (code_seen('S')) { - setTargetHotendSafe(code_value(), extruder); - } else if (code_seen('R')) { - setTargetHotendSafe(code_value(), extruder); - } - #ifdef AUTOTEMP if (code_seen('S')) autotemp_min=code_value(); if (code_seen('B')) autotemp_max=code_value(); if (code_seen('F')) @@ -6432,7 +6439,10 @@ SERIAL_PROTOCOLPGM("\n\n"); //starttime=_millis(); previous_millis_cmd = _millis(); + } else { // Stopped is therefore true, send a message over serial. + SERIAL_PROTOCOLLNPGM("Hotend temperature not set because Stop() has been called. Use M999 to reset and try again."); } + } break; /*! @@ -6452,18 +6462,22 @@ SERIAL_PROTOCOLPGM("\n\n"); #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 { bool CooldownNoWait = false; - LCD_MESSAGERPGM(_T(MSG_BED_HEATING)); - heating_status = 3; - if (farm_mode) { prusa_statistics(1); }; + bool set_heater_success = true; // Set to true by default to allow the program to continue if S or R are not sent if (code_seen('S')) { - setTargetBed(code_value()); + set_heater_success = setTargetBed(code_value()); CooldownNoWait = true; } else if (code_seen('R')) { - setTargetBed(code_value()); + set_heater_success = setTargetBed(code_value()); } + if (set_heater_success){ + + LCD_MESSAGERPGM(_T(MSG_BED_HEATING)); + heating_status = 3; + if (farm_mode) { prusa_statistics(1); }; + codenum = _millis(); cancel_heatup = false; @@ -6496,6 +6510,9 @@ SERIAL_PROTOCOLPGM("\n\n"); heating_status = 4; previous_millis_cmd = _millis(); + } else { + SERIAL_PROTOCOLLNPGM("Bed temperature not set because Stop() has been called. Use M999 to reset and try again."); + } } #endif break; diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 32ff6961ac..018fdaac4e 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -159,17 +159,22 @@ FORCE_INLINE float degTargetBed() { // Doesn't save FLASH when FORCE_INLINE removed. FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { - target_temperature[extruder] = celsius; - resetPID(extruder); + if (!IsStopped()){ + target_temperature[extruder] = celsius; + resetPID(extruder); + } }; // Doesn't save FLASH when not inlined. -static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder) +static inline bool setTargetHotendSafe(const float &celsius, uint8_t extruder) { - if (extruder