update code base to Marlin 2.0.9.2

This commit is contained in:
Stefan Kalscheuer
2021-10-03 18:57:12 +02:00
parent b9d7ba838e
commit 7077da3591
2617 changed files with 332093 additions and 103438 deletions

67
Marlin/src/gcode/config/M301.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -30,6 +30,8 @@
/**
* M301: Set PID parameters P I D (and optionally C, L)
*
* E[extruder] Default: 0
*
* P[float] Kp term
* I[float] Ki term (unscaled)
* D[float] Kd term (unscaled)
@@ -44,45 +46,64 @@
* F[float] Kf term
*/
void GcodeSuite::M301() {
// multi-extruder PID patch: M301 updates or prints a single extruder's PID values
// default behavior (omitting E parameter) is to update for extruder 0 only
const uint8_t e = parser.byteval('E'); // extruder being updated
int8_t e = E_TERN0(parser.byteval('E', -1)); // extruder being updated
if (!parser.seen("PID" TERN_(PID_EXTRUSION_SCALING, "CL") TERN_(PID_FAN_SCALING, "F")))
return M301_report(true E_OPTARG(e));
if (e == -1) e = 0;
if (e < HOTENDS) { // catch bad input value
if (parser.seen('P')) PID_PARAM(Kp, e) = parser.value_float();
if (parser.seen('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float());
if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
if (parser.seenval('P')) PID_PARAM(Kp, e) = parser.value_float();
if (parser.seenval('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float());
if (parser.seenval('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
#if ENABLED(PID_EXTRUSION_SCALING)
if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
if (parser.seenval('C')) PID_PARAM(Kc, e) = parser.value_float();
if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int();
NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN);
NOLESS(thermalManager.lpq_len, 0);
#endif
#if ENABLED(PID_FAN_SCALING)
if (parser.seen('F')) PID_PARAM(Kf, e) = parser.value_float();
if (parser.seenval('F')) PID_PARAM(Kf, e) = parser.value_float();
#endif
thermalManager.updatePID();
SERIAL_ECHO_START();
#if ENABLED(PID_PARAMS_PER_HOTEND)
SERIAL_ECHOPAIR(" e:", e); // specify extruder in serial output
#endif
SERIAL_ECHOPAIR(" p:", PID_PARAM(Kp, e),
" i:", unscalePID_i(PID_PARAM(Ki, e)),
" d:", unscalePID_d(PID_PARAM(Kd, e)));
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPAIR(" c:", PID_PARAM(Kc, e));
#endif
#if ENABLED(PID_FAN_SCALING)
SERIAL_ECHOPAIR(" f:", PID_PARAM(Kf, e));
#endif
SERIAL_EOL();
}
else
SERIAL_ERROR_MSG(STR_INVALID_EXTRUDER);
}
void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t eindex/*=-1*/)) {
report_heading(forReplay, PSTR(STR_HOTEND_PID));
IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr int8_t eindex = -1);
HOTEND_LOOP() {
if (e == eindex || eindex == -1) {
report_echo_start(forReplay);
SERIAL_ECHOPGM_P(
#if ENABLED(PID_PARAMS_PER_HOTEND)
PSTR(" M301 E"), e, SP_P_STR
#else
PSTR(" M301 P")
#endif
, PID_PARAM(Kp, e)
, PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e))
, PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e))
);
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPGM_P(SP_C_STR, PID_PARAM(Kc, e));
if (e == 0) SERIAL_ECHOPGM(" L", thermalManager.lpq_len);
#endif
#if ENABLED(PID_FAN_SCALING)
SERIAL_ECHOPGM(" F", PID_PARAM(Kf, e));
#endif
SERIAL_EOL();
}
}
}
#endif // PIDTEMP