From a9549f7a08381e786b6232297c4a0c5de4f9c9d8 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 9 Feb 2020 13:22:54 -0500 Subject: [PATCH] Add PID, probe offsets to ExtUI (#16792) --- Marlin/src/lcd/extensible_ui/ui_api.cpp | 50 +++++++++++++++++++++++++ Marlin/src/lcd/extensible_ui/ui_api.h | 18 +++++++++ 2 files changed, 68 insertions(+) diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index d6b4a96706..21c99d94a6 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -826,6 +826,15 @@ namespace ExtUI { #endif // HAS_HOTEND_OFFSET + #if HAS_BED_PROBE + float getProbeOffset_mm(const axis_t axis) { + return probe.offset.pos[axis]; + } + void setProbeOffset_mm(const float val, const axis_t axis) { + probe.offset.pos[axis] = val; + } + #endif + #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } void setAxisBacklash_mm(const float value, const axis_t axis) @@ -885,6 +894,47 @@ namespace ExtUI { float getFeedrate_percent() { return feedrate_percentage; } + #if HAS_PID_HEATING + 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 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); + } + + void setPIDValues(const float p, const float i, const float 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 setBedPIDValues(const float p, const float i, const float 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 startPIDTune(const float temp, extruder_t tool){ + thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true); + } + void startBedPIDTune(const float temp) { + thermalManager.PID_autotune(temp, H_BED, 4, true); + } + #endif + void injectCommands_P(PGM_P const gcode) { queue.inject_P(gcode); } diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index 7a20411ed9..4f88b4606e 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -211,6 +211,11 @@ namespace ExtUI { float getZOffset_mm(); void setZOffset_mm(const float); + #if HAS_BED_PROBE + float getProbeOffset_mm(const axis_t); + void setProbeOffset_mm(const float, const axis_t); + #endif + #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); void setAxisBacklash_mm(const float, const axis_t); @@ -244,6 +249,19 @@ namespace ExtUI { #endif #endif + #if HAS_PID_HEATING + float getPIDValues_Kp(const extruder_t); + float getPIDValues_Ki(const extruder_t); + float getPIDValues_Kd(const extruder_t); + float getBedPIDValues_Kp(); + float getBedPIDValues_Ki(); + float getBedPIDValues_Kd(); + void setPIDValues(const float, const float, const float, extruder_t); + void setBedPIDValues(const float, const float, const float); + void startPIDTune(const float, extruder_t); + void startBedPIDTune(const float); + #endif + /** * Delay and timing routines * Should be used by the EXTENSIBLE_UI to safely pause or measure time