🐛 Fix / refactor shared PID (#24673)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro
2022-09-04 02:51:53 +02:00
committed by Scott Lahteine
parent e04e18a590
commit aa28358267
15 changed files with 323 additions and 266 deletions

View File

@ -421,16 +421,16 @@ void DGUSTxHandler::PIDKp(DGUS_VP &vp) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Kp();
value = ExtUI::getBedPID_Kp();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Kp(ExtUI::E0);
value = ExtUI::getPID_Kp(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Kp(ExtUI::E1);
value = ExtUI::getPID_Kp(ExtUI::E1);
break;
#endif
#endif
@ -447,16 +447,16 @@ void DGUSTxHandler::PIDKi(DGUS_VP &vp) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Ki();
value = ExtUI::getBedPID_Ki();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Ki(ExtUI::E0);
value = ExtUI::getPID_Ki(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Ki(ExtUI::E1);
value = ExtUI::getPID_Ki(ExtUI::E1);
break;
#endif
#endif
@ -473,16 +473,16 @@ void DGUSTxHandler::PIDKd(DGUS_VP &vp) {
default: return;
#if ENABLED(PIDTEMPBED)
case DGUS_Data::Heater::BED:
value = ExtUI::getBedPIDValues_Kd();
value = ExtUI::getBedPID_Kd();
break;
#endif
#if ENABLED(PIDTEMP)
case DGUS_Data::Heater::H0:
value = ExtUI::getPIDValues_Kd(ExtUI::E0);
value = ExtUI::getPID_Kd(ExtUI::E0);
break;
#if HAS_MULTI_HOTEND
case DGUS_Data::Heater::H1:
value = ExtUI::getPIDValues_Kd(ExtUI::E1);
value = ExtUI::getPID_Kd(ExtUI::E1);
break;
#endif
#endif

View File

@ -459,17 +459,17 @@ void NextionTFT::PanelInfo(uint8_t req) {
case 37: // PID
#if ENABLED(PIDTEMP)
#define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E0))
#define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPID_K##B(E0))
#else
#define SEND_PID_INFO_0(A, B) SEND_NA(A)
#endif
#if BOTH(PIDTEMP, HAS_MULTI_EXTRUDER)
#define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E1))
#define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPID_K##B(E1))
#else
#define SEND_PID_INFO_1(A, B) SEND_NA(A)
#endif
#if ENABLED(PIDTEMPBED)
#define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPIDValues_K##B())
#define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPID_K##B())
#else
#define SEND_PID_INFO_BED(A, B) SEND_NA(A)
#endif

View File

@ -976,32 +976,26 @@ namespace ExtUI {
float getFeedrate_percent() { return feedrate_percentage; }
#if ENABLED(PIDTEMP)
float getPIDValues_Kp(const extruder_t tool) { return PID_PARAM(Kp, tool); }
float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); }
float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); }
float getPID_Kp(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.p(); }
float getPID_Ki(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.i(); }
float getPID_Kd(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.d(); }
void setPIDValues(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) {
thermalManager.temp_hotend[tool].pid.Kp = p;
thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i);
thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d);
thermalManager.updatePID();
void setPID(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) {
thermalManager.setPID(uint8_t(tool), p, i, d);
}
void startPIDTune(const celsius_t temp, extruder_t tool) {
thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true);
thermalManager.PID_autotune(temp, heater_id_t(tool), 8, true);
}
#endif
#if ENABLED(PIDTEMPBED)
float getBedPIDValues_Kp() { return thermalManager.temp_bed.pid.Kp; }
float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); }
float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); }
float getBedPID_Kp() { return thermalManager.temp_bed.pid.p(); }
float getBedPID_Ki() { return thermalManager.temp_bed.pid.i(); }
float getBedPID_Kd() { return thermalManager.temp_bed.pid.d(); }
void setBedPIDValues(const_float_t p, const_float_t i, const_float_t d) {
thermalManager.temp_bed.pid.Kp = p;
thermalManager.temp_bed.pid.Ki = scalePID_i(i);
thermalManager.temp_bed.pid.Kd = scalePID_d(d);
thermalManager.updatePID();
void setBedPID(const_float_t p, const_float_t i, const_float_t d) {
thermalManager.temp_bed.pid.set(p, i, d);
}
void startBedPIDTune(const celsius_t temp) {

View File

@ -324,18 +324,18 @@ namespace ExtUI {
#endif
#if ENABLED(PIDTEMP)
float getPIDValues_Kp(const extruder_t);
float getPIDValues_Ki(const extruder_t);
float getPIDValues_Kd(const extruder_t);
void setPIDValues(const_float_t, const_float_t , const_float_t , extruder_t);
float getPID_Kp(const extruder_t);
float getPID_Ki(const extruder_t);
float getPID_Kd(const extruder_t);
void setPID(const_float_t, const_float_t , const_float_t , extruder_t);
void startPIDTune(const celsius_t, extruder_t);
#endif
#if ENABLED(PIDTEMPBED)
float getBedPIDValues_Kp();
float getBedPIDValues_Ki();
float getBedPIDValues_Kd();
void setBedPIDValues(const_float_t, const_float_t , const_float_t);
float getBedPID_Kp();
float getBedPID_Ki();
float getBedPID_Kd();
void setBedPID(const_float_t, const_float_t , const_float_t);
void startBedPIDTune(const celsius_t);
#endif