Fix and improve EEPROM storage (#12054)

* Clean up Temperature PID
* Improve EEPROM read/write/validate
* Group `SINGLENOZZLE` saved settings
* Group planner saved settings
* Group filament change saved settings
* Group skew saved settings
* Group `FWRETRACT` saved settings
This commit is contained in:
Scott Lahteine
2018-10-10 09:45:20 -05:00
committed by GitHub
parent 9b5c1a5e77
commit d556dc1865
35 changed files with 1151 additions and 1246 deletions

View File

@ -232,7 +232,7 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de
if (z != last_z) {
last_z = z;
feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0); // Base the feed rate off of the configured Z_AXIS feed rate
feed_value = planner.settings.max_feedrate_mm_s[Z_AXIS]/(3.0); // Base the feed rate off of the configured Z_AXIS feed rate
destination[X_AXIS] = current_position[X_AXIS];
destination[Y_AXIS] = current_position[Y_AXIS];
@ -245,7 +245,7 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de
// Check if X or Y is involved in the movement.
// Yes: a 'normal' movement. No: a retract() or recover()
feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.settings.max_feedrate_mm_s[E_AXIS] / 1.5;
if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
@ -496,7 +496,7 @@ inline bool prime_nozzle() {
Total_Prime += 0.25;
if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
#endif
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
set_destination_from_current();
planner.synchronize(); // Without this synchronize, the purge is more consistent,
// but because the planner has a buffer, we won't be able
@ -519,7 +519,7 @@ inline bool prime_nozzle() {
#endif
set_destination_from_current();
destination[E_AXIS] += g26_prime_length;
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
set_destination_from_current();
retract_filament(destination);
}

View File

@ -42,8 +42,8 @@ void GcodeSuite::M852() {
++ijk;
const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
if (planner.xy_skew_factor != value) {
planner.xy_skew_factor = value;
if (planner.skew_factor.xy != value) {
planner.skew_factor.xy = value;
++setval;
}
}
@ -57,8 +57,8 @@ void GcodeSuite::M852() {
++ijk;
const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
if (planner.xz_skew_factor != value) {
planner.xz_skew_factor = value;
if (planner.skew_factor.xz != value) {
planner.skew_factor.xz = value;
++setval;
}
}
@ -70,8 +70,8 @@ void GcodeSuite::M852() {
++ijk;
const float value = parser.value_linear_units();
if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
if (planner.yz_skew_factor != value) {
planner.yz_skew_factor = value;
if (planner.skew_factor.yz != value) {
planner.skew_factor.yz = value;
++setval;
}
}
@ -94,11 +94,11 @@ void GcodeSuite::M852() {
if (!ijk) {
SERIAL_ECHO_START();
SERIAL_ECHOPGM(MSG_SKEW_FACTOR " XY: ");
SERIAL_ECHO_F(planner.xy_skew_factor, 6);
SERIAL_ECHO_F(planner.skew_factor.xy, 6);
SERIAL_EOL();
#if ENABLED(SKEW_CORRECTION_FOR_Z)
SERIAL_ECHOPAIR(" XZ: ", planner.xz_skew_factor);
SERIAL_ECHOLNPAIR(" YZ: ", planner.yz_skew_factor);
SERIAL_ECHOPAIR(" XZ: ", planner.skew_factor.xz);
SERIAL_ECHOLNPAIR(" YZ: ", planner.skew_factor.yz);
#else
SERIAL_EOL();
#endif

View File

@ -60,7 +60,7 @@ void GcodeSuite::M201() {
LOOP_XYZE(i) {
if (parser.seen(axis_codes[i])) {
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
planner.settings.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
}
}
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
@ -79,7 +79,7 @@ void GcodeSuite::M203() {
LOOP_XYZE(i)
if (parser.seen(axis_codes[i])) {
const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
planner.settings.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
}
}
@ -93,25 +93,25 @@ void GcodeSuite::M203() {
void GcodeSuite::M204() {
bool report = true;
if (parser.seenval('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
report = false;
}
if (parser.seenval('P')) {
planner.acceleration = parser.value_linear_units();
planner.settings.acceleration = parser.value_linear_units();
report = false;
}
if (parser.seenval('R')) {
planner.retract_acceleration = parser.value_linear_units();
planner.settings.retract_acceleration = parser.value_linear_units();
report = false;
}
if (parser.seenval('T')) {
planner.travel_acceleration = parser.value_linear_units();
planner.settings.travel_acceleration = parser.value_linear_units();
report = false;
}
if (report) {
SERIAL_ECHOPAIR("Acceleration: P", planner.acceleration);
SERIAL_ECHOPAIR(" R", planner.retract_acceleration);
SERIAL_ECHOLNPAIR(" T", planner.travel_acceleration);
SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration);
}
}
@ -128,9 +128,9 @@ void GcodeSuite::M204() {
* J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
*/
void GcodeSuite::M205() {
if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong();
if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
#if ENABLED(JUNCTION_DEVIATION)
if (parser.seen('J')) {
const float junc_dev = parser.value_linear_units();

View File

@ -36,9 +36,9 @@ void M217_report(const bool eeprom=false) {
const int16_t port = command_queue_port[cmd_queue_index_r];
#endif
serialprintPGM_P(port, eeprom ? PSTR(" M217") : PSTR("Singlenozzle:"));
SERIAL_ECHOPAIR_P(port, " S", singlenozzle_swap_length);
SERIAL_ECHOPAIR_P(port, " P", singlenozzle_prime_speed);
SERIAL_ECHOLNPAIR_P(port, " R", singlenozzle_retract_speed);
SERIAL_ECHOPAIR_P(port, " S", sn_settings.swap_length);
SERIAL_ECHOPAIR_P(port, " P", sn_settings.prime_speed);
SERIAL_ECHOLNPAIR_P(port, " R", sn_settings.retract_speed);
}
/**
@ -52,9 +52,9 @@ void GcodeSuite::M217() {
bool report = true;
if (parser.seenval('S')) { report = false; const float v = parser.value_float(); singlenozzle_swap_length = constrain(v, 0, 500); }
if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); singlenozzle_prime_speed = constrain(v, 10, 5400); }
if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); singlenozzle_retract_speed = constrain(v, 10, 5400); }
if (parser.seenval('S')) { report = false; const float v = parser.value_float(); sn_settings.swap_length = constrain(v, 0, 500); }
if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); sn_settings.prime_speed = constrain(v, 10, 5400); }
if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); sn_settings.retract_speed = constrain(v, 10, 5400); }
if (report) M217_report();

View File

@ -72,7 +72,7 @@ void GcodeSuite::M218() {
#if ENABLED(DELTA)
if (target_extruder == active_extruder)
do_blocking_move_to_xy(current_position[X_AXIS], current_position[Y_AXIS], planner.max_feedrate_mm_s[X_AXIS]);
do_blocking_move_to_xy(current_position[X_AXIS], current_position[Y_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS]);
#endif
}

View File

@ -28,14 +28,14 @@
#include "../../module/temperature.h"
void GcodeSuite::M304() {
if (parser.seen('P')) thermalManager.bedKp = parser.value_float();
if (parser.seen('I')) thermalManager.bedKi = scalePID_i(parser.value_float());
if (parser.seen('D')) thermalManager.bedKd = scalePID_d(parser.value_float());
if (parser.seen('P')) thermalManager.bed_pid.Kp = parser.value_float();
if (parser.seen('I')) thermalManager.bed_pid.Ki = scalePID_i(parser.value_float());
if (parser.seen('D')) thermalManager.bed_pid.Kd = scalePID_d(parser.value_float());
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" p:", thermalManager.bedKp);
SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bedKi));
SERIAL_ECHOLNPAIR(" d:", unscalePID_d(thermalManager.bedKd));
SERIAL_ECHOPAIR(" p:", thermalManager.bed_pid.Kp);
SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bed_pid.Ki));
SERIAL_ECHOLNPAIR(" d:", unscalePID_d(thermalManager.bed_pid.Kd));
}
#endif // PIDTEMPBED

View File

@ -38,17 +38,17 @@ void GcodeSuite::M92() {
if (i == E_AXIS) {
const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
if (value < 20) {
float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
float factor = planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
#if HAS_CLASSIC_JERK && (DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE))
planner.max_jerk[E_AXIS] *= factor;
#endif
planner.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
planner.settings.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
planner.max_acceleration_steps_per_s2[E_AXIS + TARGET_EXTRUDER] *= factor;
}
planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
}
else {
planner.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
}
}
}

View File

@ -36,10 +36,10 @@
* Z[units] retract_zlift
*/
void GcodeSuite::M207() {
if (parser.seen('S')) fwretract.retract_length = parser.value_axis_units(E_AXIS);
if (parser.seen('F')) fwretract.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('Z')) fwretract.retract_zlift = parser.value_linear_units();
if (parser.seen('W')) fwretract.swap_retract_length = parser.value_axis_units(E_AXIS);
if (parser.seen('S')) fwretract.settings.retract_length = parser.value_axis_units(E_AXIS);
if (parser.seen('F')) fwretract.settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('Z')) fwretract.settings.retract_zlift = parser.value_linear_units();
if (parser.seen('W')) fwretract.settings.swap_retract_length = parser.value_axis_units(E_AXIS);
}
/**
@ -51,10 +51,10 @@ void GcodeSuite::M207() {
* R[units/min] swap_retract_recover_feedrate_mm_s
*/
void GcodeSuite::M208() {
if (parser.seen('S')) fwretract.retract_recover_length = parser.value_axis_units(E_AXIS);
if (parser.seen('F')) fwretract.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('R')) fwretract.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('W')) fwretract.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
if (parser.seen('S')) fwretract.settings.retract_recover_length = parser.value_axis_units(E_AXIS);
if (parser.seen('F')) fwretract.settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('R')) fwretract.settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
if (parser.seen('W')) fwretract.settings.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
}
#if ENABLED(FWRETRACT_AUTORETRACT)

View File

@ -111,14 +111,14 @@ void GcodeSuite::M600() {
// Unload filament
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
: filament_change_unload_length[active_extruder]);
: fc_settings[active_extruder].unload_length);
// Slow load filament
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
// Fast load filament
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: filament_change_load_length[active_extruder]);
: fc_settings[active_extruder].load_length);
const int beep_count = parser.intval('B',
#ifdef FILAMENT_CHANGE_ALERT_BEEPS

View File

@ -47,17 +47,17 @@ void GcodeSuite::M603() {
// Unload length
if (parser.seen('U')) {
filament_change_unload_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
fc_settings[target_extruder].unload_length = ABS(parser.value_axis_units(E_AXIS));
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
NOMORE(filament_change_unload_length[target_extruder], EXTRUDE_MAXLENGTH);
NOMORE(fc_settings[target_extruder].unload_length, EXTRUDE_MAXLENGTH);
#endif
}
// Load length
if (parser.seen('L')) {
filament_change_load_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
fc_settings[target_extruder].load_length = ABS(parser.value_axis_units(E_AXIS));
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
NOMORE(filament_change_load_length[target_extruder], EXTRUDE_MAXLENGTH);
NOMORE(fc_settings[target_extruder].load_length, EXTRUDE_MAXLENGTH);
#endif
}
}

View File

@ -79,7 +79,7 @@ void GcodeSuite::M701() {
// Load filament
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
: filament_change_load_length[active_extruder]);
: fc_settings[active_extruder].load_length);
load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
#if ENABLED(DUAL_X_CARRIAGE)
@ -147,7 +147,7 @@ void GcodeSuite::M702() {
if (!parser.seenval('T')) {
HOTEND_LOOP() {
if (e != active_extruder) tool_change(e, 0, true);
unload_filament(-filament_change_unload_length[e], true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
unload_filament(-fc_settings[e].unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
}
}
else
@ -155,7 +155,7 @@ void GcodeSuite::M702() {
{
// Unload length
const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
filament_change_unload_length[target_extruder]);
fc_settings[target_extruder].unload_length);
unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
}

View File

@ -161,10 +161,10 @@
*/
#if ENABLED(HYBRID_THRESHOLD)
void GcodeSuite::M913() {
#define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, planner.axis_steps_per_mm[_AXIS(A)])
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[_AXIS(A)])
#define TMC_SAY_PWMTHRS_E(E) tmc_get_pwmthrs(stepperE##E, planner.axis_steps_per_mm[E_AXIS_N(E)])
#define TMC_SET_PWMTHRS_E(E) tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N(E)])
#define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, planner.settings.axis_steps_per_mm[_AXIS(A)])
#define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.settings.axis_steps_per_mm[_AXIS(A)])
#define TMC_SAY_PWMTHRS_E(E) tmc_get_pwmthrs(stepperE##E, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
#define TMC_SET_PWMTHRS_E(E) tmc_set_pwmthrs(stepperE##E, value, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
bool report = true;
const uint8_t index = parser.byteval('I');

View File

@ -113,7 +113,7 @@
* M84 - Disable steppers until next move, or use S<seconds> to specify an idle
* duration after which steppers should turn off. S0 disables the timeout.
* M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
* M92 - Set planner.axis_steps_per_mm for one or more axes.
* M92 - Set planner.settings.axis_steps_per_mm for one or more axes.
* M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER)
* M104 - Set extruder target temp.
* M105 - Report current temperatures.

View File

@ -64,7 +64,7 @@ void GcodeSuite::M290() {
for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
thermalManager.babystep_axis((AxisEnum)a, offs * planner.settings.axis_steps_per_mm[a]);
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_zprobe_zoffset(offs);
#endif
@ -72,7 +72,7 @@ void GcodeSuite::M290() {
#else
if (parser.seenval('Z') || parser.seenval('S')) {
const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
thermalManager.babystep_axis(Z_AXIS, offs * planner.axis_steps_per_mm[Z_AXIS]);
thermalManager.babystep_axis(Z_AXIS, offs * planner.settings.axis_steps_per_mm[Z_AXIS]);
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
if (!parser.seen('P') || parser.value_bool()) mod_zprobe_zoffset(offs);
#endif