Skip to content

Commit 22979cb

Browse files
thinkyheadimp67
authored andcommitted
♻️ Encapsulate PID in class (MarlinFirmware#24389)
1 parent c89800a commit 22979cb

File tree

13 files changed

+216
-298
lines changed

13 files changed

+216
-298
lines changed

Marlin/src/MarlinCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
789789
manage_inactivity(no_stepper_sleep);
790790

791791
// Manage Heaters (and Watchdog)
792-
thermalManager.manage_heater();
792+
thermalManager.task();
793793

794794
// Max7219 heartbeat, animation, etc
795795
TERN_(MAX7219_DEBUG, max7219.idle_tasks());

Marlin/src/core/language.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@
227227
#define STR_PID_DEBUG " PID_DEBUG "
228228
#define STR_PID_DEBUG_INPUT ": Input "
229229
#define STR_PID_DEBUG_OUTPUT " Output "
230-
#define STR_PID_DEBUG_PTERM " pTerm "
231-
#define STR_PID_DEBUG_ITERM " iTerm "
232-
#define STR_PID_DEBUG_DTERM " dTerm "
233-
#define STR_PID_DEBUG_CTERM " cTerm "
234230
#define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !"
235231
#define STR_MPC_AUTOTUNE "MPC Autotune"
236232
#define STR_MPC_AUTOTUNE_START " start for " STR_E

Marlin/src/core/utility.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ void safe_delay(millis_t ms) {
2929
while (ms > 50) {
3030
ms -= 50;
3131
delay(50);
32-
thermalManager.manage_heater();
32+
thermalManager.task();
3333
}
3434
delay(ms);
35-
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
35+
thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made
3636
}
3737

3838
// A delay to provide brittle hosts time to receive bytes

Marlin/src/gcode/motion/G2_G3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void plan_arc(
290290

291291
for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times
292292

293-
thermalManager.manage_heater();
293+
thermalManager.task();
294294
const millis_t ms = millis();
295295
if (ELAPSED(ms, next_idle_ms)) {
296296
next_idle_ms = ms + 200UL;

Marlin/src/gcode/queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind
384384
buff[ind] = '\0'; // Of course, I'm a Terminator.
385385
const bool is_empty = (ind == 0); // An empty line?
386386
if (is_empty)
387-
thermalManager.manage_heater(); // Keep sensors satisfied
387+
thermalManager.task(); // Keep sensors satisfied
388388
else
389389
ind = 0; // Start a new line
390390
return is_empty; // Inform the caller

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
12021202
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
12031203
Popup_Handler(ETemp);
12041204
else {
1205-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1205+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
12061206
Popup_Handler(Heating);
12071207
thermalManager.wait_for_hotend(0);
12081208
}
@@ -1345,7 +1345,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
13451345
Popup_Handler(ETemp);
13461346
}
13471347
else {
1348-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1348+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
13491349
Popup_Handler(Heating);
13501350
thermalManager.wait_for_hotend(0);
13511351
Redraw_Menu();
@@ -1732,7 +1732,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
17321732
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
17331733
Popup_Handler(ETemp);
17341734
else {
1735-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1735+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
17361736
Popup_Handler(Heating);
17371737
thermalManager.wait_for_hotend(0);
17381738
}
@@ -1751,7 +1751,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
17511751
Popup_Handler(ETemp);
17521752
}
17531753
else {
1754-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1754+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
17551755
Popup_Handler(Heating);
17561756
thermalManager.wait_for_hotend(0);
17571757
}
@@ -1769,7 +1769,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
17691769
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
17701770
Popup_Handler(ETemp);
17711771
else {
1772-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1772+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
17731773
Popup_Handler(Heating);
17741774
thermalManager.wait_for_hotend(0);
17751775
}
@@ -4404,7 +4404,7 @@ void CrealityDWINClass::Popup_Control() {
44044404
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
44054405
Popup_Handler(ETemp);
44064406
else {
4407-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
4407+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
44084408
Popup_Handler(Heating);
44094409
thermalManager.wait_for_hotend(0);
44104410
}

Marlin/src/lcd/extui/ui_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace ExtUI {
169169
}
170170

171171
void yield() {
172-
if (!flags.printer_killed) thermalManager.manage_heater();
172+
if (!flags.printer_killed) thermalManager.task();
173173
}
174174

175175
void enableHeater(const extruder_t extruder) {

Marlin/src/libs/buzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
4848
if (!ui.sound_on) return;
4949
while (buffer.isFull()) {
5050
tick();
51-
thermalManager.manage_heater();
51+
thermalManager.task();
5252
}
5353
tone_t tone = { duration, frequency };
5454
buffer.enqueue(tone);

Marlin/src/module/motion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
966966
next_idle_ms = ms + 200UL;
967967
return idle();
968968
}
969-
thermalManager.manage_heater(); // Returns immediately on most calls
969+
thermalManager.task(); // Returns immediately on most calls
970970
}
971971

972972
#if IS_KINEMATIC

Marlin/src/module/planner_bezier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void cubic_b_spline(
123123

124124
for (float t = 0; t < 1;) {
125125

126-
thermalManager.manage_heater();
126+
thermalManager.task();
127127
millis_t now = millis();
128128
if (ELAPSED(now, next_idle_ms)) {
129129
next_idle_ms = now + 200UL;

0 commit comments

Comments
 (0)