Skip to content

Commit b513004

Browse files
committed
tweak
1 parent 3fc9f34 commit b513004

File tree

3 files changed

+24
-44
lines changed

3 files changed

+24
-44
lines changed

Marlin/src/module/temperature.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1347,15 +1347,21 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
13471347
return constrain(tempinfo.target, 0, MAX_POW);
13481348

13491349
#else // !PID_OPENLOOP
1350+
13501351
float out = tempinfo.pid.get_pid_output(tempinfo.target, tempinfo.celsius);
1352+
13511353
#if ENABLED(PID_FAN_SCALING)
13521354
out += tempinfo.pid.get_fan_scale_output(thermalManager.fan_speed[extr]);
13531355
#endif
1356+
13541357
#if ENABLED(PID_EXTRUSION_SCALING)
13551358
out += tempinfo.pid.get_extrusion_scale_output(
1356-
extr == active_extruder, stepper.position(E_AXIS), planner.mm_per_step[E_AXIS], thermalManager.lpq_len);
1359+
extr == active_extruder, stepper.position(E_AXIS), planner.mm_per_step[E_AXIS], thermalManager.lpq_len
1360+
);
13571361
#endif
1362+
13581363
return constrain(out, tempinfo.pid.low(), tempinfo.pid.high());
1364+
13591365
#endif // !PID_OPENLOOP
13601366
}
13611367

Marlin/src/module/temperature.h

+14-35
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,9 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
199199
void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); }
200200
void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c, raw.f); }
201201

202-
float get_fan_scale_output(const uint8_t fan_speed) {
203-
UNUSED(fan_speed);
204-
return 0;
205-
}
202+
float get_fan_scale_output(const uint8_t) { return 0; }
206203

207-
float get_extrusion_scale_output(const bool is_active, const long e_position, const float e_mm_per_step, const int16_t lpq_len) {
208-
UNUSED(is_active);
209-
UNUSED(e_position);
210-
UNUSED(e_mm_per_step);
211-
UNUSED(lpq_len);
212-
return 0;
213-
}
204+
float get_extrusion_scale_output(const bool, const int32_t, const float, const int16_t) { return 0; }
214205

215206
float get_pid_output(const float target, const float current) {
216207
const float pid_error = target - current;
@@ -274,29 +265,24 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
274265
base::reset();
275266
prev_e_pos = 0;
276267
lpq_ptr = 0;
277-
LOOP_L_N(i, LPQ_ARR_SZ) {
278-
lpq[i] = 0;
279-
}
268+
LOOP_L_N(i, LPQ_ARR_SZ) lpq[i] = 0;
280269
}
281270

282-
float get_extrusion_scale_output(const bool is_active, const long e_position, const float e_mm_per_step, const int16_t lpq_len) {
271+
float get_extrusion_scale_output(const bool is_active, const int32_t e_position, const float e_mm_per_step, const int16_t lpq_len) {
283272
work_c = 0;
284-
if (!is_active) {
285-
return work_c; // 0
286-
}
273+
if (!is_active) return work_c;
287274

288275
if (e_position > prev_e_pos) {
289276
lpq[lpq_ptr] = e_position - prev_e_pos;
290277
prev_e_pos = e_position;
291278
}
292-
else {
279+
else
293280
lpq[lpq_ptr] = 0;
294-
}
295281

296282
++lpq_ptr;
297-
if (lpq_ptr >= LPQ_ARR_SZ || lpq_ptr >= lpq_len) {
283+
284+
if (lpq_ptr >= LPQ_ARR_SZ || lpq_ptr >= lpq_len)
298285
lpq_ptr = 0;
299-
}
300286

301287
work_c = (lpq[lpq_ptr] * e_mm_per_step) * Kc;
302288

@@ -331,9 +317,9 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
331317

332318
float get_fan_scale_output(const uint8_t fan_speed) {
333319
work_f = 0;
334-
if (fan_speed > SCALE_MIN_SPEED) {
320+
if (fan_speed > SCALE_MIN_SPEED)
335321
work_f = Kf + (SCALE_LIN_FACTOR) * fan_speed;
336-
}
322+
337323
return work_f;
338324
}
339325
};
@@ -363,18 +349,13 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
363349
void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); }
364350
void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c, raw.f); }
365351

366-
void reset() {
367-
cPID::reset();
368-
}
352+
void reset() { cPID::reset(); }
369353

370354
float get_fan_scale_output(const uint8_t fan_speed) {
371-
work_f = 0;
372-
if (fan_speed > SCALE_MIN_SPEED) {
373-
work_f = Kf + (SCALE_LIN_FACTOR) * fan_speed;
374-
}
355+
work_f = fan_speed > (SCALE_MIN_SPEED) ? Kf + (SCALE_LIN_FACTOR) * fan_speed : 0;
375356
return work_f;
376357
}
377-
float get_extrusion_scale_output(const bool is_active, const long e_position, const float e_mm_per_step, const int16_t lpq_len) {
358+
float get_extrusion_scale_output(const bool is_active, const int32_t e_position, const float e_mm_per_step, const int16_t lpq_len) {
378359
return cPID::get_extrusion_scale_output(is_active, e_position, e_mm_per_step, lpq_len);
379360
}
380361
};
@@ -1174,9 +1155,7 @@ class Temperature {
11741155

11751156
// Update the temp manager when PID values change
11761157
#if ENABLED(PIDTEMP)
1177-
static void updatePID() {
1178-
HOTEND_LOOP() temp_hotend[e].pid.reset();
1179-
}
1158+
static void updatePID() { HOTEND_LOOP() temp_hotend[e].pid.reset(); }
11801159
static void setPID(const uint8_t hotend, const_float_t p, const_float_t i, const_float_t d) {
11811160
#if ENABLED(PID_PARAMS_PER_HOTEND)
11821161
temp_hotend[hotend].pid.set(p, i, d);

buildroot/tests/LPC1768

+3-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,9 @@ opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING NO
5353
exec_test $1 $2 "Re-ARM with NOZZLE_AS_PROBE and many features." "$3"
5454

5555
restore_configs
56-
opt_set MOTHERBOARD BOARD_BTT_SKR_V1_3 \
57-
EXTRUDERS 2 \
58-
TEMP_SENSOR_0 1 \
59-
TEMP_SENSOR_1 1 \
60-
TEMP_SENSOR_BED 1 \
61-
TEMP_SENSOR_CHAMBER 1 \
62-
TEMP_CHAMBER_PIN P1_30 \
63-
HEATER_CHAMBER_PIN P0_28
56+
opt_set MOTHERBOARD BOARD_BTT_SKR_V1_3 EXTRUDERS 2 \
57+
TEMP_SENSOR_0 1 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 1 TEMP_SENSOR_CHAMBER 1 \
58+
TEMP_CHAMBER_PIN P1_30 HEATER_CHAMBER_PIN P0_28
6459
opt_enable PIDTEMPBED PIDTEMPCHAMBER PID_EXTRUSION_SCALING PID_FAN_SCALING
6560
exec_test $1 $2 "SKR v1.3 with 2*Extr, bed, chamber all PID." "$3"
6661

0 commit comments

Comments
 (0)