Merge pull request #4167 from thinkyhead/rc_eeprom_checksum
EEPROM Checksum
This commit is contained in:
commit
ac4f235912
|
@ -36,88 +36,93 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EEPROM_VERSION "V23"
|
#define EEPROM_VERSION "V24"
|
||||||
|
|
||||||
|
// Change EEPROM version if these are changed:
|
||||||
|
#define EEPROM_OFFSET 100
|
||||||
|
#define MAX_EXTRUDERS 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* V23 EEPROM Layout:
|
* V24 EEPROM Layout:
|
||||||
*
|
*
|
||||||
* 100 Version (char x4)
|
* 100 Version (char x4)
|
||||||
|
* 104 EEPROM Checksum (uint16_t)
|
||||||
*
|
*
|
||||||
* 104 M92 XYZE planner.axis_steps_per_mm (float x4)
|
* 106 M92 XYZE planner.axis_steps_per_mm (float x4)
|
||||||
* 120 M203 XYZE planner.max_feedrate (float x4)
|
* 122 M203 XYZE planner.max_feedrate (float x4)
|
||||||
* 136 M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4)
|
* 138 M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4)
|
||||||
* 152 M204 P planner.acceleration (float)
|
* 154 M204 P planner.acceleration (float)
|
||||||
* 156 M204 R planner.retract_acceleration (float)
|
* 158 M204 R planner.retract_acceleration (float)
|
||||||
* 160 M204 T planner.travel_acceleration (float)
|
* 162 M204 T planner.travel_acceleration (float)
|
||||||
* 164 M205 S planner.min_feedrate (float)
|
* 166 M205 S planner.min_feedrate (float)
|
||||||
* 168 M205 T planner.min_travel_feedrate (float)
|
* 170 M205 T planner.min_travel_feedrate (float)
|
||||||
* 172 M205 B planner.min_segment_time (ulong)
|
* 174 M205 B planner.min_segment_time (ulong)
|
||||||
* 176 M205 X planner.max_xy_jerk (float)
|
* 178 M205 X planner.max_xy_jerk (float)
|
||||||
* 180 M205 Z planner.max_z_jerk (float)
|
* 182 M205 Z planner.max_z_jerk (float)
|
||||||
* 184 M205 E planner.max_e_jerk (float)
|
* 186 M205 E planner.max_e_jerk (float)
|
||||||
* 188 M206 XYZ home_offset (float x3)
|
* 190 M206 XYZ home_offset (float x3)
|
||||||
*
|
*
|
||||||
* Mesh bed leveling:
|
* Mesh bed leveling:
|
||||||
* 200 M420 S status (uint8)
|
* 202 M420 S status (uint8)
|
||||||
* 201 z_offset (float)
|
* 203 z_offset (float)
|
||||||
* 205 mesh_num_x (uint8 as set in firmware)
|
* 207 mesh_num_x (uint8 as set in firmware)
|
||||||
* 206 mesh_num_y (uint8 as set in firmware)
|
* 208 mesh_num_y (uint8 as set in firmware)
|
||||||
* 207 G29 S3 XYZ z_values[][] (float x9, by default)
|
* 209 G29 S3 XYZ z_values[][] (float x9, by default)
|
||||||
*
|
*
|
||||||
* AUTO BED LEVELING
|
* AUTO BED LEVELING
|
||||||
* 243 M851 zprobe_zoffset (float)
|
* 245 M851 zprobe_zoffset (float)
|
||||||
*
|
*
|
||||||
* DELTA:
|
* DELTA:
|
||||||
* 247 M666 XYZ endstop_adj (float x3)
|
* 249 M666 XYZ endstop_adj (float x3)
|
||||||
* 259 M665 R delta_radius (float)
|
* 261 M665 R delta_radius (float)
|
||||||
* 263 M665 L delta_diagonal_rod (float)
|
* 265 M665 L delta_diagonal_rod (float)
|
||||||
* 267 M665 S delta_segments_per_second (float)
|
* 269 M665 S delta_segments_per_second (float)
|
||||||
* 271 M665 A delta_diagonal_rod_trim_tower_1 (float)
|
* 273 M665 A delta_diagonal_rod_trim_tower_1 (float)
|
||||||
* 275 M665 B delta_diagonal_rod_trim_tower_2 (float)
|
* 277 M665 B delta_diagonal_rod_trim_tower_2 (float)
|
||||||
* 279 M665 C delta_diagonal_rod_trim_tower_3 (float)
|
* 281 M665 C delta_diagonal_rod_trim_tower_3 (float)
|
||||||
*
|
*
|
||||||
* Z_DUAL_ENDSTOPS:
|
* Z_DUAL_ENDSTOPS:
|
||||||
* 283 M666 Z z_endstop_adj (float)
|
* 285 M666 Z z_endstop_adj (float)
|
||||||
*
|
*
|
||||||
* ULTIPANEL:
|
* ULTIPANEL:
|
||||||
* 287 M145 S0 H plaPreheatHotendTemp (int)
|
* 289 M145 S0 H plaPreheatHotendTemp (int)
|
||||||
* 289 M145 S0 B plaPreheatHPBTemp (int)
|
* 291 M145 S0 B plaPreheatHPBTemp (int)
|
||||||
* 291 M145 S0 F plaPreheatFanSpeed (int)
|
* 293 M145 S0 F plaPreheatFanSpeed (int)
|
||||||
* 293 M145 S1 H absPreheatHotendTemp (int)
|
* 295 M145 S1 H absPreheatHotendTemp (int)
|
||||||
* 295 M145 S1 B absPreheatHPBTemp (int)
|
* 297 M145 S1 B absPreheatHPBTemp (int)
|
||||||
* 297 M145 S1 F absPreheatFanSpeed (int)
|
* 299 M145 S1 F absPreheatFanSpeed (int)
|
||||||
*
|
*
|
||||||
* PIDTEMP:
|
* PIDTEMP:
|
||||||
* 299 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
|
* 301 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
|
||||||
* 315 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
|
* 317 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
|
||||||
* 331 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
|
* 333 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
|
||||||
* 347 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
|
* 349 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
|
||||||
* 363 M301 L lpq_len (int)
|
* 365 M301 L lpq_len (int)
|
||||||
*
|
*
|
||||||
* PIDTEMPBED:
|
* PIDTEMPBED:
|
||||||
* 365 M304 PID thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
|
* 367 M304 PID thermalManager.bedKp, thermalManager.bedKi, thermalManager.bedKd (float x3)
|
||||||
*
|
*
|
||||||
* DOGLCD:
|
* DOGLCD:
|
||||||
* 377 M250 C lcd_contrast (int)
|
* 379 M250 C lcd_contrast (int)
|
||||||
*
|
*
|
||||||
* SCARA:
|
* SCARA:
|
||||||
* 379 M365 XYZ axis_scaling (float x3)
|
* 381 M365 XYZ axis_scaling (float x3)
|
||||||
*
|
*
|
||||||
* FWRETRACT:
|
* FWRETRACT:
|
||||||
* 391 M209 S autoretract_enabled (bool)
|
* 393 M209 S autoretract_enabled (bool)
|
||||||
* 392 M207 S retract_length (float)
|
* 394 M207 S retract_length (float)
|
||||||
* 396 M207 W retract_length_swap (float)
|
* 398 M207 W retract_length_swap (float)
|
||||||
* 400 M207 F retract_feedrate_mm_s (float)
|
* 402 M207 F retract_feedrate_mm_s (float)
|
||||||
* 404 M207 Z retract_zlift (float)
|
* 406 M207 Z retract_zlift (float)
|
||||||
* 408 M208 S retract_recover_length (float)
|
* 410 M208 S retract_recover_length (float)
|
||||||
* 412 M208 W retract_recover_length_swap (float)
|
* 414 M208 W retract_recover_length_swap (float)
|
||||||
* 416 M208 F retract_recover_feedrate (float)
|
* 418 M208 F retract_recover_feedrate (float)
|
||||||
*
|
*
|
||||||
* Volumetric Extrusion:
|
* Volumetric Extrusion:
|
||||||
* 420 M200 D volumetric_enabled (bool)
|
* 422 M200 D volumetric_enabled (bool)
|
||||||
* 421 M200 T D filament_size (float x4) (T0..3)
|
* 423 M200 T D filament_size (float x4) (T0..3)
|
||||||
*
|
*
|
||||||
* 437 This Slot is Available!
|
* 439 This Slot is Available!
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
|
@ -131,6 +136,9 @@
|
||||||
#include "mesh_bed_leveling.h"
|
#include "mesh_bed_leveling.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint16_t eeprom_checksum;
|
||||||
|
const char version[4] = EEPROM_VERSION;
|
||||||
|
|
||||||
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
|
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
|
@ -140,39 +148,58 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
|
SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
|
||||||
}
|
}
|
||||||
|
eeprom_checksum += c;
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
|
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
|
||||||
do {
|
do {
|
||||||
*value = eeprom_read_byte((unsigned char*)pos);
|
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
||||||
|
*value = c;
|
||||||
|
eeprom_checksum += c;
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
} while (--size);
|
} while (--size);
|
||||||
}
|
}
|
||||||
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
|
|
||||||
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store Configuration Settings - M500
|
* Post-process after Retrieve or Reset
|
||||||
*/
|
*/
|
||||||
|
void Config_Postprocess() {
|
||||||
|
// steps per s2 needs to be updated to agree with units per s2
|
||||||
|
planner.reset_acceleration_rates();
|
||||||
|
|
||||||
#define DUMMY_PID_VALUE 3000.0f
|
#if ENABLED(DELTA)
|
||||||
|
recalc_delta_settings(delta_radius, delta_diagonal_rod);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define EEPROM_OFFSET 100
|
#if ENABLED(PIDTEMP)
|
||||||
|
thermalManager.updatePID();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
calculate_volumetric_multipliers();
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
|
|
||||||
/**
|
#define DUMMY_PID_VALUE 3000.0f
|
||||||
* Store Configuration Settings - M500
|
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
|
||||||
*/
|
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* M500 - Store Configuration
|
||||||
|
*/
|
||||||
void Config_StoreSettings() {
|
void Config_StoreSettings() {
|
||||||
float dummy = 0.0f;
|
float dummy = 0.0f;
|
||||||
char ver[4] = "000";
|
char ver[4] = "000";
|
||||||
int i = EEPROM_OFFSET;
|
int i = EEPROM_OFFSET;
|
||||||
|
|
||||||
EEPROM_WRITE_VAR(i, ver); // invalidate data first
|
EEPROM_WRITE_VAR(i, ver); // invalidate data first
|
||||||
|
i += sizeof(eeprom_checksum); // Skip the checksum slot
|
||||||
|
|
||||||
|
eeprom_checksum = 0; // clear before first "real data"
|
||||||
|
|
||||||
EEPROM_WRITE_VAR(i, planner.axis_steps_per_mm);
|
EEPROM_WRITE_VAR(i, planner.axis_steps_per_mm);
|
||||||
EEPROM_WRITE_VAR(i, planner.max_feedrate);
|
EEPROM_WRITE_VAR(i, planner.max_feedrate);
|
||||||
EEPROM_WRITE_VAR(i, planner.max_acceleration_mm_per_s2);
|
EEPROM_WRITE_VAR(i, planner.max_acceleration_mm_per_s2);
|
||||||
|
@ -199,6 +226,7 @@ void Config_StoreSettings() {
|
||||||
EEPROM_WRITE_VAR(i, mesh_num_y);
|
EEPROM_WRITE_VAR(i, mesh_num_y);
|
||||||
EEPROM_WRITE_VAR(i, mbl.z_values);
|
EEPROM_WRITE_VAR(i, mbl.z_values);
|
||||||
#else
|
#else
|
||||||
|
// For disabled MBL write a default mesh
|
||||||
uint8_t mesh_num_x = 3,
|
uint8_t mesh_num_x = 3,
|
||||||
mesh_num_y = 3,
|
mesh_num_y = 3,
|
||||||
dummy_uint8 = 0;
|
dummy_uint8 = 0;
|
||||||
|
@ -215,6 +243,7 @@ void Config_StoreSettings() {
|
||||||
#endif
|
#endif
|
||||||
EEPROM_WRITE_VAR(i, zprobe_zoffset);
|
EEPROM_WRITE_VAR(i, zprobe_zoffset);
|
||||||
|
|
||||||
|
// 9 floats for DELTA / Z_DUAL_ENDSTOPS
|
||||||
#if ENABLED(DELTA)
|
#if ENABLED(DELTA)
|
||||||
EEPROM_WRITE_VAR(i, endstop_adj); // 3 floats
|
EEPROM_WRITE_VAR(i, endstop_adj); // 3 floats
|
||||||
EEPROM_WRITE_VAR(i, delta_radius); // 1 float
|
EEPROM_WRITE_VAR(i, delta_radius); // 1 float
|
||||||
|
@ -244,7 +273,7 @@ void Config_StoreSettings() {
|
||||||
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
|
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
|
||||||
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
|
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
|
||||||
|
|
||||||
for (uint8_t e = 0; e < 4; e++) {
|
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
|
||||||
|
|
||||||
#if ENABLED(PIDTEMP)
|
#if ENABLED(PIDTEMP)
|
||||||
if (e < HOTENDS) {
|
if (e < HOTENDS) {
|
||||||
|
@ -319,14 +348,16 @@ void Config_StoreSettings() {
|
||||||
EEPROM_WRITE_VAR(i, volumetric_enabled);
|
EEPROM_WRITE_VAR(i, volumetric_enabled);
|
||||||
|
|
||||||
// Save filament sizes
|
// Save filament sizes
|
||||||
for (uint8_t q = 0; q < 4; q++) {
|
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
|
||||||
if (q < EXTRUDERS) dummy = filament_size[q];
|
if (q < EXTRUDERS) dummy = filament_size[q];
|
||||||
EEPROM_WRITE_VAR(i, dummy);
|
EEPROM_WRITE_VAR(i, dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
char ver2[4] = EEPROM_VERSION;
|
uint16_t final_checksum = eeprom_checksum;
|
||||||
|
|
||||||
int j = EEPROM_OFFSET;
|
int j = EEPROM_OFFSET;
|
||||||
EEPROM_WRITE_VAR(j, ver2); // validate data
|
EEPROM_WRITE_VAR(j, version);
|
||||||
|
EEPROM_WRITE_VAR(j, final_checksum);
|
||||||
|
|
||||||
// Report storage size
|
// Report storage size
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
|
@ -335,33 +366,31 @@ void Config_StoreSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Configuration Settings - M501
|
* M501 - Retrieve Configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Config_RetrieveSettings() {
|
void Config_RetrieveSettings() {
|
||||||
|
|
||||||
int i = EEPROM_OFFSET;
|
int i = EEPROM_OFFSET;
|
||||||
char stored_ver[4];
|
char stored_ver[4];
|
||||||
char ver[4] = EEPROM_VERSION;
|
uint16_t stored_checksum;
|
||||||
EEPROM_READ_VAR(i, stored_ver); //read stored version
|
EEPROM_READ_VAR(i, stored_ver);
|
||||||
|
EEPROM_READ_VAR(i, stored_checksum);
|
||||||
// SERIAL_ECHOPAIR("Version: [", ver);
|
// SERIAL_ECHOPAIR("Version: [", ver);
|
||||||
// SERIAL_ECHOPAIR("] Stored version: [", stored_ver);
|
// SERIAL_ECHOPAIR("] Stored version: [", stored_ver);
|
||||||
// SERIAL_ECHOLNPGM("]");
|
// SERIAL_ECHOLNPGM("]");
|
||||||
|
|
||||||
if (strncmp(ver, stored_ver, 3) != 0) {
|
if (strncmp(version, stored_ver, 3) != 0) {
|
||||||
Config_ResetDefault();
|
Config_ResetDefault();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float dummy = 0;
|
float dummy = 0;
|
||||||
|
|
||||||
|
eeprom_checksum = 0; // clear before reading first "real data"
|
||||||
|
|
||||||
// version number match
|
// version number match
|
||||||
EEPROM_READ_VAR(i, planner.axis_steps_per_mm);
|
EEPROM_READ_VAR(i, planner.axis_steps_per_mm);
|
||||||
EEPROM_READ_VAR(i, planner.max_feedrate);
|
EEPROM_READ_VAR(i, planner.max_feedrate);
|
||||||
EEPROM_READ_VAR(i, planner.max_acceleration_mm_per_s2);
|
EEPROM_READ_VAR(i, planner.max_acceleration_mm_per_s2);
|
||||||
|
|
||||||
// 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)
|
|
||||||
planner.reset_acceleration_rates();
|
|
||||||
|
|
||||||
EEPROM_READ_VAR(i, planner.acceleration);
|
EEPROM_READ_VAR(i, planner.acceleration);
|
||||||
EEPROM_READ_VAR(i, planner.retract_acceleration);
|
EEPROM_READ_VAR(i, planner.retract_acceleration);
|
||||||
EEPROM_READ_VAR(i, planner.travel_acceleration);
|
EEPROM_READ_VAR(i, planner.travel_acceleration);
|
||||||
|
@ -382,12 +411,16 @@ void Config_RetrieveSettings() {
|
||||||
mbl.status = dummy_uint8;
|
mbl.status = dummy_uint8;
|
||||||
mbl.z_offset = dummy;
|
mbl.z_offset = dummy;
|
||||||
if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
|
if (mesh_num_x == MESH_NUM_X_POINTS && mesh_num_y == MESH_NUM_Y_POINTS) {
|
||||||
|
// EEPROM data fits the current mesh
|
||||||
EEPROM_READ_VAR(i, mbl.z_values);
|
EEPROM_READ_VAR(i, mbl.z_values);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
// EEPROM data is stale
|
||||||
mbl.reset();
|
mbl.reset();
|
||||||
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
|
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
// MBL is disabled - skip the stored data
|
||||||
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
|
for (uint8_t q = 0; q < mesh_num_x * mesh_num_y; q++) EEPROM_READ_VAR(i, dummy);
|
||||||
#endif // MESH_BED_LEVELING
|
#endif // MESH_BED_LEVELING
|
||||||
|
|
||||||
|
@ -404,7 +437,6 @@ void Config_RetrieveSettings() {
|
||||||
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_1); // 1 float
|
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_1); // 1 float
|
||||||
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_2); // 1 float
|
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_2); // 1 float
|
||||||
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_3); // 1 float
|
EEPROM_READ_VAR(i, delta_diagonal_rod_trim_tower_3); // 1 float
|
||||||
recalc_delta_settings(delta_radius, delta_diagonal_rod);
|
|
||||||
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
||||||
EEPROM_READ_VAR(i, z_endstop_adj);
|
EEPROM_READ_VAR(i, z_endstop_adj);
|
||||||
dummy = 0.0f;
|
dummy = 0.0f;
|
||||||
|
@ -427,7 +459,7 @@ void Config_RetrieveSettings() {
|
||||||
EEPROM_READ_VAR(i, absPreheatFanSpeed);
|
EEPROM_READ_VAR(i, absPreheatFanSpeed);
|
||||||
|
|
||||||
#if ENABLED(PIDTEMP)
|
#if ENABLED(PIDTEMP)
|
||||||
for (uint8_t e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
|
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
|
||||||
EEPROM_READ_VAR(i, dummy); // Kp
|
EEPROM_READ_VAR(i, dummy); // Kp
|
||||||
if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
|
if (e < HOTENDS && dummy != DUMMY_PID_VALUE) {
|
||||||
// do not need to scale PID values as the values in EEPROM are already scaled
|
// do not need to scale PID values as the values in EEPROM are already scaled
|
||||||
|
@ -446,7 +478,7 @@ void Config_RetrieveSettings() {
|
||||||
}
|
}
|
||||||
#else // !PIDTEMP
|
#else // !PIDTEMP
|
||||||
// 4 x 4 = 16 slots for PID parameters
|
// 4 x 4 = 16 slots for PID parameters
|
||||||
for (uint8_t q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc
|
for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ_VAR(i, dummy); // Kp, Ki, Kd, Kc
|
||||||
#endif // !PIDTEMP
|
#endif // !PIDTEMP
|
||||||
|
|
||||||
#if DISABLED(PID_ADD_EXTRUSION_RATE)
|
#if DISABLED(PID_ADD_EXTRUSION_RATE)
|
||||||
|
@ -497,21 +529,24 @@ void Config_RetrieveSettings() {
|
||||||
|
|
||||||
EEPROM_READ_VAR(i, volumetric_enabled);
|
EEPROM_READ_VAR(i, volumetric_enabled);
|
||||||
|
|
||||||
for (uint8_t q = 0; q < 4; q++) {
|
for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
|
||||||
EEPROM_READ_VAR(i, dummy);
|
EEPROM_READ_VAR(i, dummy);
|
||||||
if (q < EXTRUDERS) filament_size[q] = dummy;
|
if (q < EXTRUDERS) filament_size[q] = dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculate_volumetric_multipliers();
|
if (eeprom_checksum == stored_checksum) {
|
||||||
// Call thermalManager.updatePID (similar to when we have processed M301)
|
Config_Postprocess();
|
||||||
thermalManager.updatePID();
|
|
||||||
|
|
||||||
// Report settings retrieved and length
|
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHO(ver);
|
SERIAL_ECHO(version);
|
||||||
SERIAL_ECHOPAIR(" stored settings retrieved (", i);
|
SERIAL_ECHOPAIR(" stored settings retrieved (", i);
|
||||||
SERIAL_ECHOLNPGM(" bytes)");
|
SERIAL_ECHOLNPGM(" bytes)");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
SERIAL_ERROR_START;
|
||||||
|
SERIAL_ERRORLNPGM("EEPROM checksum mismatch");
|
||||||
|
Config_ResetDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(EEPROM_CHITCHAT)
|
#if ENABLED(EEPROM_CHITCHAT)
|
||||||
Config_PrintSettings();
|
Config_PrintSettings();
|
||||||
|
@ -521,9 +556,8 @@ void Config_RetrieveSettings() {
|
||||||
#endif // EEPROM_SETTINGS
|
#endif // EEPROM_SETTINGS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset Configuration Settings - M502
|
* M502 - Reset Configuration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Config_ResetDefault() {
|
void Config_ResetDefault() {
|
||||||
float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
|
float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
|
||||||
float tmp2[] = DEFAULT_MAX_FEEDRATE;
|
float tmp2[] = DEFAULT_MAX_FEEDRATE;
|
||||||
|
@ -538,9 +572,6 @@ void Config_ResetDefault() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// steps per sq second need to be updated to agree with the units per sq second
|
|
||||||
planner.reset_acceleration_rates();
|
|
||||||
|
|
||||||
planner.acceleration = DEFAULT_ACCELERATION;
|
planner.acceleration = DEFAULT_ACCELERATION;
|
||||||
planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
|
planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
|
||||||
planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
|
planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
|
||||||
|
@ -568,7 +599,6 @@ void Config_ResetDefault() {
|
||||||
delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
|
delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
|
||||||
delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
|
delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
|
||||||
delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
|
delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
|
||||||
recalc_delta_settings(delta_radius, delta_diagonal_rod);
|
|
||||||
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
||||||
z_endstop_adj = 0;
|
z_endstop_adj = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -603,8 +633,6 @@ void Config_ResetDefault() {
|
||||||
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
||||||
lpq_len = 20; // default last-position-queue size
|
lpq_len = 20; // default last-position-queue size
|
||||||
#endif
|
#endif
|
||||||
// call thermalManager.updatePID (similar to when we have processed M301)
|
|
||||||
thermalManager.updatePID();
|
|
||||||
#endif // PIDTEMP
|
#endif // PIDTEMP
|
||||||
|
|
||||||
#if ENABLED(PIDTEMPBED)
|
#if ENABLED(PIDTEMPBED)
|
||||||
|
@ -631,7 +659,8 @@ void Config_ResetDefault() {
|
||||||
volumetric_enabled = false;
|
volumetric_enabled = false;
|
||||||
for (uint8_t q = 0; q < COUNT(filament_size); q++)
|
for (uint8_t q = 0; q < COUNT(filament_size); q++)
|
||||||
filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
||||||
calculate_volumetric_multipliers();
|
|
||||||
|
Config_Postprocess();
|
||||||
|
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
|
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
|
||||||
|
@ -639,12 +668,11 @@ void Config_ResetDefault() {
|
||||||
|
|
||||||
#if DISABLED(DISABLE_M503)
|
#if DISABLED(DISABLE_M503)
|
||||||
|
|
||||||
/**
|
|
||||||
* Print Configuration Settings - M503
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
|
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* M503 - Print Configuration
|
||||||
|
*/
|
||||||
void Config_PrintSettings(bool forReplay) {
|
void Config_PrintSettings(bool forReplay) {
|
||||||
// Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
|
// Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue