Skip to content

Commit cb291e8

Browse files
committed
🩹 Fix some temp constraints
1 parent 25caae1 commit cb291e8

File tree

14 files changed

+52
-43
lines changed

14 files changed

+52
-43
lines changed

Marlin/src/gcode/bedlevel/G26.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ void GcodeSuite::G26() {
615615

616616
// If any preset or temperature was specified
617617
if (noztemp) {
618-
if (!WITHIN(noztemp, 165, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT))) {
618+
if (!WITHIN(noztemp, 165, thermalManager.hotend_max_target(active_extruder))) {
619619
SERIAL_ECHOLNPGM("?Specified nozzle temperature not plausible.");
620620
return;
621621
}

Marlin/src/inc/Conditionals_post.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@
24582458
#ifndef BED_OVERSHOOT
24592459
#define BED_OVERSHOOT 10
24602460
#endif
2461-
#define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT))
2461+
#define BED_MAX_TARGET ((BED_MAXTEMP) - (BED_OVERSHOOT))
24622462
#else
24632463
#undef PIDTEMPBED
24642464
#undef PREHEAT_BEFORE_LEVELING
@@ -2469,8 +2469,8 @@
24692469
#ifndef COOLER_OVERSHOOT
24702470
#define COOLER_OVERSHOOT 2
24712471
#endif
2472-
#define COOLER_MIN_TARGET (COOLER_MINTEMP + (COOLER_OVERSHOOT))
2473-
#define COOLER_MAX_TARGET (COOLER_MAXTEMP - (COOLER_OVERSHOOT))
2472+
#define COOLER_MIN_TARGET ((COOLER_MINTEMP) + (COOLER_OVERSHOOT))
2473+
#define COOLER_MAX_TARGET ((COOLER_MAXTEMP) - (COOLER_OVERSHOOT))
24742474
#endif
24752475

24762476
#if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_TEMP_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD || HAS_TEMP_SOC
@@ -2482,7 +2482,7 @@
24822482
#ifndef CHAMBER_OVERSHOOT
24832483
#define CHAMBER_OVERSHOOT 10
24842484
#endif
2485-
#define CHAMBER_MAX_TARGET (CHAMBER_MAXTEMP - (CHAMBER_OVERSHOOT))
2485+
#define CHAMBER_MAX_TARGET ((CHAMBER_MAXTEMP) - (CHAMBER_OVERSHOOT))
24862486
#else
24872487
#undef PIDTEMPCHAMBER
24882488
#endif

Marlin/src/lcd/e3v2/jyersui/dwin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
#define MAX_FLOW_RATE 299
115115
#define MIN_FLOW_RATE 10
116116

117-
#define MAX_E_TEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT)
117+
#define MAX_E_TEMP thermalManager.hotend_max_target(0)
118118
#define MIN_E_TEMP 0
119119
#endif
120120

Marlin/src/lcd/e3v2/proui/dwin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@
154154
#endif
155155

156156
// Editable temperature limits
157-
#define MIN_ETEMP 0
158-
#define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT))
157+
#define MIN_ETEMP 0
158+
#define MAX_ETEMP thermalManager.hotend_max_target(0)
159159
#define MIN_BEDTEMP 0
160160
#define MAX_BEDTEMP BED_MAX_TARGET
161161

Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,7 @@ void AnycubicTFT::getCommandFromTFT() {
697697
case 18: { // A18 set fan speed
698698
float fanPercent;
699699
if (codeSeen('S')) {
700-
fanPercent = codeValue();
701-
fanPercent = constrain(fanPercent, 0, 100);
700+
fanPercent = constrain(codeValue(), 0, 100);
702701
setTargetFan_percent(fanPercent, FAN0);
703702
}
704703
else

Marlin/src/lcd/extui/anycubic_vyper/dgus_tft.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ namespace Anycubic {
10111011
#if HAS_HOTEND
10121012
else if (control_index == TXT_HOTEND_TARGET || control_index == TXT_ADJUST_HOTEND) { // hotend target temp
10131013
control_value = (uint16_t(data_buf[4]) << 8) | uint16_t(data_buf[5]);
1014-
temp = constrain(uint16_t(control_value), 0, HEATER_0_MAXTEMP);
1014+
temp = constrain(uint16_t(control_value), 0, thermalManager.hotend_max_target(0));
10151015
setTargetTemp_celsius(temp, E0);
10161016
//sprintf(str_buf,"%u/%u", (uint16_t)thermalManager.degHotend(0), uint16_t(control_value));
10171017
//sendTxtToTFT(str_buf, TXT_PRINT_HOTEND);
@@ -1021,7 +1021,7 @@ namespace Anycubic {
10211021
#if HAS_HEATED_BED
10221022
else if (control_index == TXT_BED_TARGET || control_index == TXT_ADJUST_BED) {// bed target temp
10231023
control_value = (uint16_t(data_buf[4]) << 8) | uint16_t(data_buf[5]);
1024-
temp = constrain(uint16_t(control_value), 0, BED_MAXTEMP);
1024+
temp = constrain(uint16_t(control_value), 0, BED_MAX_TARGET);
10251025
setTargetTemp_celsius(temp, BED);
10261026
//sprintf(str_buf,"%u/%u", uint16_t(thermalManager.degBed()), uint16_t(control_value));
10271027
//sendTxtToTFT(str_buf, TXT_PRINT_BED);

Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,21 @@ void DGUSScreenHandler::handleTemperatureChanged(DGUS_VP_Variable &var, void *va
379379
default: return;
380380
#if HAS_HOTEND
381381
case VP_T_E0_Set:
382-
NOMORE(newvalue, HEATER_0_MAXTEMP);
382+
NOMORE(newvalue, thermalManager.hotend_max_target(0));
383383
thermalManager.setTargetHotend(newvalue, 0);
384384
acceptedvalue = thermalManager.degTargetHotend(0);
385385
break;
386386
#endif
387387
#if HAS_MULTI_HOTEND
388388
case VP_T_E1_Set:
389-
NOMORE(newvalue, HEATER_1_MAXTEMP);
389+
NOMORE(newvalue, thermalManager.hotend_max_target(1));
390390
thermalManager.setTargetHotend(newvalue, 1);
391391
acceptedvalue = thermalManager.degTargetHotend(1);
392392
break;
393393
#endif
394394
#if HAS_HEATED_BED
395395
case VP_T_Bed_Set:
396-
NOMORE(newvalue, BED_MAXTEMP);
396+
NOMORE(newvalue, BED_MAX_TARGET);
397397
thermalManager.setTargetBed(newvalue);
398398
acceptedvalue = thermalManager.degTargetBed();
399399
break;

Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,15 +809,19 @@ void DGUSRxHandler::pidSetTemp(DGUS_VP &vp, void *data_ptr) {
809809

810810
switch (screen.pid_heater) {
811811
default: return;
812-
case DGUS_Data::Heater::BED:
813-
temp = constrain(temp, BED_MINTEMP, BED_MAX_TARGET);
814-
break;
815-
case DGUS_Data::Heater::H0:
816-
temp = constrain(temp, HEATER_0_MINTEMP, (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT));
817-
break;
812+
#if HAS_HEATED_BED
813+
case DGUS_Data::Heater::BED:
814+
LIMIT(temp, BED_MINTEMP, BED_MAX_TARGET);
815+
break;
816+
#endif
817+
#if HAS_HOTEND
818+
case DGUS_Data::Heater::H0:
819+
LIMIT(temp, celsius_t(HEATER_0_MINTEMP), thermalManager.hotend_max_target(0));
820+
break;
821+
#endif
818822
#if HAS_MULTI_HOTEND
819823
case DGUS_Data::Heater::H1:
820-
temp = constrain(temp, HEATER_1_MINTEMP, (HEATER_1_MAXTEMP - HOTEND_OVERSHOOT));
824+
LIMIT(temp, celsius_t(HEATER_1_MINTEMP), thermalManager.hotend_max_target(0));
821825
break;
822826
#endif
823827
}

Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ uint16_t DGUSScreenHandler::filament_length = DGUS_DEFAULT_FILAMENT_LEN;
5151
char DGUSScreenHandler::gcode[] = "";
5252

5353
DGUS_Data::Heater DGUSScreenHandler::pid_heater = DGUS_Data::Heater::H0;
54-
uint16_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND;
54+
celsius_t DGUSScreenHandler::pid_temp = DGUS_PLA_TEMP_HOTEND;
5555
uint8_t DGUSScreenHandler::pid_cycles = 5;
5656

5757
bool DGUSScreenHandler::settings_ready = false;

Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DGUSScreenHandler {
106106
static char gcode[DGUS_GCODE_LEN + 1];
107107

108108
static DGUS_Data::Heater pid_heater;
109-
static uint16_t pid_temp;
109+
static celsius_t pid_temp;
110110
static uint8_t pid_cycles;
111111

112112
static bool wait_continue;

0 commit comments

Comments
 (0)