Skip to content

Commit 9359871

Browse files
thinkyheadLCh-77
authored andcommitted
♻️ Encapsulate PID in class (MarlinFirmware#24389)
1 parent fda314c commit 9359871

File tree

13 files changed

+216
-298
lines changed

13 files changed

+216
-298
lines changed

Marlin/src/MarlinCore.cpp

+1-1
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

-4
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

+2-2
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

+1-1
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

+1-1
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
13961396
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
13971397
Popup_Handler(ETemp);
13981398
else {
1399-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1399+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
14001400
Popup_Handler(Heating);
14011401
thermalManager.wait_for_hotend(0);
14021402
}
@@ -1539,7 +1539,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
15391539
Popup_Handler(ETemp);
15401540
}
15411541
else {
1542-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1542+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
15431543
Popup_Handler(Heating);
15441544
thermalManager.wait_for_hotend(0);
15451545
Redraw_Menu();
@@ -1946,7 +1946,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
19461946
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
19471947
Popup_Handler(ETemp);
19481948
else {
1949-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1949+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
19501950
Popup_Handler(Heating);
19511951
thermalManager.wait_for_hotend(0);
19521952
}
@@ -1965,7 +1965,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
19651965
Popup_Handler(ETemp);
19661966
}
19671967
else {
1968-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1968+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
19691969
Popup_Handler(Heating);
19701970
thermalManager.wait_for_hotend(0);
19711971
}
@@ -1983,7 +1983,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
19831983
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
19841984
Popup_Handler(ETemp);
19851985
else {
1986-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
1986+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
19871987
Popup_Handler(Heating);
19881988
thermalManager.wait_for_hotend(0);
19891989
}
@@ -5444,7 +5444,7 @@ void CrealityDWINClass::Popup_Control() {
54445444
if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp)
54455445
Popup_Handler(ETemp);
54465446
else {
5447-
if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) {
5447+
if (thermalManager.temp_hotend[0].is_below_target(-2)) {
54485448
Popup_Handler(Heating);
54495449
thermalManager.wait_for_hotend(0);
54505450
}

Marlin/src/lcd/extui/ui_api.cpp

+1-1
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

+1-1
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

+1-1
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

+1-1
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)