mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-07-23 14:44:12 -06:00
🧑💻 Relocate some factory reset, etc.
This commit is contained in:
parent
b22df8b189
commit
6cda10de0f
7 changed files with 164 additions and 148 deletions
|
@ -140,6 +140,28 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
|||
|
||||
preheat_t MarlinUI::material_preset[PREHEAT_COUNT]; // Initialized by settings.load
|
||||
|
||||
void MarlinUI::reset_material_presets() {
|
||||
#define _PITEM(N,T) PREHEAT_##N##_##T,
|
||||
#if HAS_HOTEND
|
||||
constexpr uint16_t hpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_HOTEND) };
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
constexpr uint16_t bpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_BED) };
|
||||
#endif
|
||||
#if HAS_HEATED_CHAMBER
|
||||
constexpr uint16_t cpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_CHAMBER) };
|
||||
#endif
|
||||
#if HAS_FAN
|
||||
constexpr uint8_t fpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, FAN_SPEED) };
|
||||
#endif
|
||||
for (uint8_t i = 0; i < PREHEAT_COUNT; ++i) {
|
||||
TERN_(HAS_HOTEND, material_preset[i].hotend_temp = hpre[i]);
|
||||
TERN_(HAS_HEATED_BED, material_preset[i].bed_temp = bpre[i]);
|
||||
TERN_(HAS_HEATED_CHAMBER, material_preset[i].chamber_temp = cpre[i]);
|
||||
TERN_(HAS_FAN, material_preset[i].fan_speed = fpre[i]);
|
||||
}
|
||||
}
|
||||
|
||||
FSTR_P MarlinUI::get_preheat_label(const uint8_t m) {
|
||||
#define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
|
||||
#define _PLBL(N) preheat_##N##_label,
|
||||
|
|
|
@ -648,6 +648,7 @@ public:
|
|||
#if HAS_PREHEAT
|
||||
enum PreheatTarget : uint8_t { PT_HOTEND, PT_BED, PT_FAN, PT_CHAMBER, PT_ALL = 0xFF };
|
||||
static preheat_t material_preset[PREHEAT_COUNT];
|
||||
static void reset_material_presets();
|
||||
static FSTR_P get_preheat_label(const uint8_t m);
|
||||
static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder);
|
||||
static void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, _BV(PT_FAN))); }
|
||||
|
|
|
@ -251,6 +251,41 @@ void Endstops::init() {
|
|||
|
||||
} // Endstops::init
|
||||
|
||||
void Endstops::factory_reset() {
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
#ifndef X2_ENDSTOP_ADJUSTMENT
|
||||
#define X2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.x2_endstop_adj = X2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
#ifndef Y2_ENDSTOP_ADJUSTMENT
|
||||
#define Y2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.y2_endstop_adj = Y2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
#ifndef Z2_ENDSTOP_ADJUSTMENT
|
||||
#define Z2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z2_endstop_adj = Z2_ENDSTOP_ADJUSTMENT;
|
||||
#if NUM_Z_STEPPERS >= 3
|
||||
#ifndef Z3_ENDSTOP_ADJUSTMENT
|
||||
#define Z3_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z3_endstop_adj = Z3_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#if NUM_Z_STEPPERS >= 4
|
||||
#ifndef Z4_ENDSTOP_ADJUSTMENT
|
||||
#define Z4_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z4_endstop_adj = Z4_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called at ~1kHz from Temperature ISR: Poll endstop state if required
|
||||
void Endstops::poll() {
|
||||
|
||||
|
|
|
@ -172,6 +172,11 @@ class Endstops {
|
|||
*/
|
||||
static void init();
|
||||
|
||||
/**
|
||||
* Saved settings initialization
|
||||
*/
|
||||
static void factory_reset();
|
||||
|
||||
/**
|
||||
* Are endstops or the Z min probe or the CALIBRATION probe set to abort the move?
|
||||
*/
|
||||
|
|
|
@ -3510,151 +3510,17 @@ void MarlinSettings::reset() {
|
|||
//
|
||||
// Endstop Adjustments
|
||||
//
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
#ifndef X2_ENDSTOP_ADJUSTMENT
|
||||
#define X2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.x2_endstop_adj = X2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
#ifndef Y2_ENDSTOP_ADJUSTMENT
|
||||
#define Y2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.y2_endstop_adj = Y2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
#ifndef Z2_ENDSTOP_ADJUSTMENT
|
||||
#define Z2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z2_endstop_adj = Z2_ENDSTOP_ADJUSTMENT;
|
||||
#if NUM_Z_STEPPERS >= 3
|
||||
#ifndef Z3_ENDSTOP_ADJUSTMENT
|
||||
#define Z3_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z3_endstop_adj = Z3_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#if NUM_Z_STEPPERS >= 4
|
||||
#ifndef Z4_ENDSTOP_ADJUSTMENT
|
||||
#define Z4_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z4_endstop_adj = Z4_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#endif
|
||||
endstops.factory_reset();
|
||||
|
||||
//
|
||||
// Preheat parameters
|
||||
// Material Presets
|
||||
//
|
||||
#if HAS_PREHEAT
|
||||
#define _PITEM(N,T) PREHEAT_##N##_##T,
|
||||
#if HAS_HOTEND
|
||||
constexpr uint16_t hpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_HOTEND) };
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
constexpr uint16_t bpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_BED) };
|
||||
#endif
|
||||
#if HAS_HEATED_CHAMBER
|
||||
constexpr uint16_t cpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_CHAMBER) };
|
||||
#endif
|
||||
#if HAS_FAN
|
||||
constexpr uint8_t fpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, FAN_SPEED) };
|
||||
#endif
|
||||
for (uint8_t i = 0; i < PREHEAT_COUNT; ++i) {
|
||||
TERN_(HAS_HOTEND, ui.material_preset[i].hotend_temp = hpre[i]);
|
||||
TERN_(HAS_HEATED_BED, ui.material_preset[i].bed_temp = bpre[i]);
|
||||
TERN_(HAS_HEATED_CHAMBER, ui.material_preset[i].chamber_temp = cpre[i]);
|
||||
TERN_(HAS_FAN, ui.material_preset[i].fan_speed = fpre[i]);
|
||||
}
|
||||
#endif
|
||||
TERN_(HAS_PREHEAT, ui.reset_material_presets());
|
||||
|
||||
//
|
||||
// Hotend PID
|
||||
// Temperature Manager
|
||||
//
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
constexpr float defKp[] =
|
||||
#ifdef DEFAULT_Kp_LIST
|
||||
DEFAULT_Kp_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kp)
|
||||
#endif
|
||||
, defKi[] =
|
||||
#ifdef DEFAULT_Ki_LIST
|
||||
DEFAULT_Ki_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Ki)
|
||||
#endif
|
||||
, defKd[] =
|
||||
#ifdef DEFAULT_Kd_LIST
|
||||
DEFAULT_Kd_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kd)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKp), 1, HOTENDS), "DEFAULT_Kp_LIST must have between 1 and HOTENDS items.");
|
||||
static_assert(WITHIN(COUNT(defKi), 1, HOTENDS), "DEFAULT_Ki_LIST must have between 1 and HOTENDS items.");
|
||||
static_assert(WITHIN(COUNT(defKd), 1, HOTENDS), "DEFAULT_Kd_LIST must have between 1 and HOTENDS items.");
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
constexpr float defKc[] =
|
||||
#ifdef DEFAULT_Kc_LIST
|
||||
DEFAULT_Kc_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kc)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKc), 1, HOTENDS), "DEFAULT_Kc_LIST must have between 1 and HOTENDS items.");
|
||||
#endif
|
||||
#if ENABLED(PID_FAN_SCALING)
|
||||
constexpr float defKf[] =
|
||||
#ifdef DEFAULT_Kf_LIST
|
||||
DEFAULT_Kf_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kf)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKf), 1, HOTENDS), "DEFAULT_Kf_LIST must have between 1 and HOTENDS items.");
|
||||
#endif
|
||||
#define PID_DEFAULT(N,E) def##N[E]
|
||||
#else
|
||||
#define PID_DEFAULT(N,E) DEFAULT_##N
|
||||
#endif
|
||||
HOTEND_LOOP() {
|
||||
thermalManager.temp_hotend[e].pid.set(
|
||||
PID_DEFAULT(Kp, ALIM(e, defKp)),
|
||||
PID_DEFAULT(Ki, ALIM(e, defKi)),
|
||||
PID_DEFAULT(Kd, ALIM(e, defKd))
|
||||
OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(Kc, ALIM(e, defKc)))
|
||||
OPTARG(PID_FAN_SCALING, PID_DEFAULT(Kf, ALIM(e, defKf)))
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// PID Extrusion Scaling
|
||||
//
|
||||
TERN_(PID_EXTRUSION_SCALING, thermalManager.lpq_len = 20); // Default last-position-queue size
|
||||
|
||||
//
|
||||
// Heated Bed PID
|
||||
//
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
thermalManager.temp_bed.pid.set(DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Heated Chamber PID
|
||||
//
|
||||
#if ENABLED(PIDTEMPCHAMBER)
|
||||
thermalManager.temp_chamber.pid.set(DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd);
|
||||
#endif
|
||||
|
||||
//
|
||||
// User-Defined Thermistors
|
||||
//
|
||||
TERN_(HAS_USER_THERMISTORS, thermalManager.reset_user_thermistors());
|
||||
thermalManager.factory_reset();
|
||||
|
||||
//
|
||||
// Power Monitor
|
||||
|
@ -3750,6 +3616,7 @@ void MarlinSettings::reset() {
|
|||
//
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
|
||||
constexpr float linAdvanceK[] = ADVANCE_K;
|
||||
EXTRUDER_LOOP() {
|
||||
const float a = linAdvanceK[_MAX(uint8_t(e), COUNT(linAdvanceK) - 1)];
|
||||
|
@ -3767,8 +3634,9 @@ void MarlinSettings::reset() {
|
|||
#else
|
||||
stepper.set_advance_tau(ADVANCE_TAU);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif // LIN_ADVANCE
|
||||
|
||||
//
|
||||
// Motor Current PWM
|
||||
|
|
|
@ -711,6 +711,93 @@ volatile bool Temperature::raw_temps_ready = false;
|
|||
|
||||
#endif
|
||||
|
||||
void Temperature::factory_reset() {
|
||||
//
|
||||
// Hotend PID
|
||||
//
|
||||
#if ENABLED(PIDTEMP)
|
||||
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
constexpr float defKp[] =
|
||||
#ifdef DEFAULT_Kp_LIST
|
||||
DEFAULT_Kp_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kp)
|
||||
#endif
|
||||
, defKi[] =
|
||||
#ifdef DEFAULT_Ki_LIST
|
||||
DEFAULT_Ki_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Ki)
|
||||
#endif
|
||||
, defKd[] =
|
||||
#ifdef DEFAULT_Kd_LIST
|
||||
DEFAULT_Kd_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kd)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKp), 1, HOTENDS), "DEFAULT_Kp_LIST must have between 1 and HOTENDS items.");
|
||||
static_assert(WITHIN(COUNT(defKi), 1, HOTENDS), "DEFAULT_Ki_LIST must have between 1 and HOTENDS items.");
|
||||
static_assert(WITHIN(COUNT(defKd), 1, HOTENDS), "DEFAULT_Kd_LIST must have between 1 and HOTENDS items.");
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
constexpr float defKc[] =
|
||||
#ifdef DEFAULT_Kc_LIST
|
||||
DEFAULT_Kc_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kc)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKc), 1, HOTENDS), "DEFAULT_Kc_LIST must have between 1 and HOTENDS items.");
|
||||
#endif
|
||||
#if ENABLED(PID_FAN_SCALING)
|
||||
constexpr float defKf[] =
|
||||
#ifdef DEFAULT_Kf_LIST
|
||||
DEFAULT_Kf_LIST
|
||||
#else
|
||||
ARRAY_BY_HOTENDS1(DEFAULT_Kf)
|
||||
#endif
|
||||
;
|
||||
static_assert(WITHIN(COUNT(defKf), 1, HOTENDS), "DEFAULT_Kf_LIST must have between 1 and HOTENDS items.");
|
||||
#endif
|
||||
#define PID_DEFAULT(N,E) def##N[E]
|
||||
#else
|
||||
#define PID_DEFAULT(N,E) DEFAULT_##N
|
||||
#endif
|
||||
HOTEND_LOOP() {
|
||||
temp_hotend[e].pid.set(
|
||||
PID_DEFAULT(Kp, ALIM(e, defKp)),
|
||||
PID_DEFAULT(Ki, ALIM(e, defKi)),
|
||||
PID_DEFAULT(Kd, ALIM(e, defKd))
|
||||
OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(Kc, ALIM(e, defKc)))
|
||||
OPTARG(PID_FAN_SCALING, PID_DEFAULT(Kf, ALIM(e, defKf)))
|
||||
);
|
||||
}
|
||||
#endif // PIDTEMP
|
||||
|
||||
//
|
||||
// PID Extrusion Scaling
|
||||
//
|
||||
TERN_(PID_EXTRUSION_SCALING, lpq_len = 20); // Default last-position-queue size
|
||||
|
||||
//
|
||||
// Heated Bed PID
|
||||
//
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
temp_bed.pid.set(DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Heated Chamber PID
|
||||
//
|
||||
#if ENABLED(PIDTEMPCHAMBER)
|
||||
temp_chamber.pid.set(DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd);
|
||||
#endif
|
||||
|
||||
// User-Defined Thermistors
|
||||
TERN_(HAS_USER_THERMISTORS, reset_user_thermistors());
|
||||
|
||||
} // factory_reset
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
|
||||
inline void say_default_() { SERIAL_ECHOPGM("#define DEFAULT_"); }
|
||||
|
@ -939,9 +1026,9 @@ volatile bool Temperature::raw_temps_ready = false;
|
|||
auto _set_hotend_pid = [](const uint8_t tool, const raw_pid_t &in_pid) {
|
||||
#if ENABLED(PIDTEMP)
|
||||
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
thermalManager.temp_hotend[tool].pid.set(in_pid);
|
||||
temp_hotend[tool].pid.set(in_pid);
|
||||
#else
|
||||
HOTEND_LOOP() thermalManager.temp_hotend[e].pid.set(in_pid);
|
||||
HOTEND_LOOP() temp_hotend[e].pid.set(in_pid);
|
||||
#endif
|
||||
updatePID();
|
||||
#endif
|
||||
|
|
|
@ -809,16 +809,14 @@ class Temperature {
|
|||
#endif
|
||||
|
||||
public:
|
||||
/**
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Static (class) methods
|
||||
*/
|
||||
|
||||
static void init();
|
||||
|
||||
static void factory_reset();
|
||||
|
||||
#if HAS_USER_THERMISTORS
|
||||
static user_thermistor_t user_thermistor[USER_THERMISTORS];
|
||||
static void M305_report(const uint8_t t_index, const bool forReplay=true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue