🔧 Optional MPC_AUTOTUNE to save 5.5 - 5.8KB

This commit is contained in:
Scott Lahteine
2023-03-17 20:12:36 -05:00
parent 6f5b7a8b26
commit b5836b243a
12 changed files with 109 additions and 79 deletions

View File

@@ -580,7 +580,6 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
volatile bool Temperature::raw_temps_ready = false;
#if ENABLED(MPCTEMP)
int32_t Temperature::mpc_e_position; // = 0
#endif
@@ -925,7 +924,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif // HAS_PID_HEATING
#if ENABLED(MPCTEMP)
#if ENABLED(MPC_AUTOTUNE)
#if EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND)
#define SINGLEFAN 1
@@ -951,7 +950,6 @@ volatile bool Temperature::raw_temps_ready = false;
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
if (!wait_for_heatup) {
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_INTERRUPTED));
return true;
@@ -981,7 +979,6 @@ volatile bool Temperature::raw_temps_ready = false;
}
} on_exit(e);
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_START, e);
MPCHeaterInfo &hotend = temp_hotend[e];
MPC_t &mpc = hotend.mpc;
@@ -1150,7 +1147,6 @@ volatile bool Temperature::raw_temps_ready = false;
mpc.block_heat_capacity = mpc.ambient_xfer_coeff_fan0 / block_responsiveness;
mpc.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp));
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_DONE));
@@ -1171,7 +1167,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(HAS_FAN, SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF_FAN255 ", ambient_xfer_coeff_fan255, 4));
}
#endif // MPCTEMP
#endif // MPC_AUTOTUNE
int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
switch (heater_id) {
@@ -1509,7 +1505,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
const int32_t e_position = stepper.position(E_AXIS);
const float e_speed = (e_position - mpc_e_position) * planner.mm_per_step[E_AXIS] / MPC_dT;
// The position can appear to make big jumps when, e.g. homing
// The position can appear to make big jumps when, e.g., homing
if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS])
mpc_e_position = e_position;
else if (e_speed > 0.0f) { // Ignore retract/recover moves