|
@@ -23,7 +23,7 @@
|
23
|
23
|
/**
|
24
|
24
|
* configuration_store.cpp
|
25
|
25
|
*
|
26
|
|
- * Configuration and EEPROM storage
|
|
26
|
+ * Settings and EEPROM storage
|
27
|
27
|
*
|
28
|
28
|
* IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
|
29
|
29
|
* in the functions below, also increment the version number. This makes sure that
|
|
@@ -36,13 +36,13 @@
|
36
|
36
|
*
|
37
|
37
|
*/
|
38
|
38
|
|
39
|
|
-#define EEPROM_VERSION "V32"
|
|
39
|
+#define EEPROM_VERSION "V33"
|
40
|
40
|
|
41
|
41
|
// Change EEPROM version if these are changed:
|
42
|
42
|
#define EEPROM_OFFSET 100
|
43
|
43
|
|
44
|
44
|
/**
|
45
|
|
- * V32 EEPROM Layout:
|
|
45
|
+ * V33 EEPROM Layout:
|
46
|
46
|
*
|
47
|
47
|
* 100 Version (char x4)
|
48
|
48
|
* 104 EEPROM Checksum (uint16_t)
|
|
@@ -64,25 +64,28 @@
|
64
|
64
|
* 195 M206 XYZ home_offset (float x3)
|
65
|
65
|
* 207 M218 XYZ hotend_offset (float x3 per additional hotend)
|
66
|
66
|
*
|
|
67
|
+ * Global Leveling:
|
|
68
|
+ * 219 z_fade_height (float)
|
|
69
|
+ *
|
67
|
70
|
* Mesh bed leveling: 43 bytes
|
68
|
|
- * 219 M420 S from mbl.status (bool)
|
69
|
|
- * 220 mbl.z_offset (float)
|
70
|
|
- * 224 GRID_MAX_POINTS_X (uint8_t)
|
71
|
|
- * 225 GRID_MAX_POINTS_Y (uint8_t)
|
72
|
|
- * 226 G29 S3 XYZ z_values[][] (float x9, up to float x 81) +288
|
|
71
|
+ * 223 M420 S from mbl.status (bool)
|
|
72
|
+ * 224 mbl.z_offset (float)
|
|
73
|
+ * 228 GRID_MAX_POINTS_X (uint8_t)
|
|
74
|
+ * 229 GRID_MAX_POINTS_Y (uint8_t)
|
|
75
|
+ * 230 G29 S3 XYZ z_values[][] (float x9, up to float x 81) +288
|
73
|
76
|
*
|
74
|
77
|
* AUTO BED LEVELING 4 bytes
|
75
|
|
- * 262 M851 zprobe_zoffset (float)
|
|
78
|
+ * 266 M851 zprobe_zoffset (float)
|
76
|
79
|
*
|
77
|
80
|
* ABL_PLANAR (or placeholder): 36 bytes
|
78
|
|
- * 266 planner.bed_level_matrix (matrix_3x3 = float x9)
|
|
81
|
+ * 270 planner.bed_level_matrix (matrix_3x3 = float x9)
|
79
|
82
|
*
|
80
|
83
|
* AUTO_BED_LEVELING_BILINEAR (or placeholder): 47 bytes
|
81
|
|
- * 302 GRID_MAX_POINTS_X (uint8_t)
|
82
|
|
- * 303 GRID_MAX_POINTS_Y (uint8_t)
|
83
|
|
- * 304 bilinear_grid_spacing (int x2)
|
84
|
|
- * 308 G29 L F bilinear_start (int x2)
|
85
|
|
- * 312 bed_level_grid[][] (float x9, up to float x256) +988
|
|
84
|
+ * 306 GRID_MAX_POINTS_X (uint8_t)
|
|
85
|
+ * 307 GRID_MAX_POINTS_Y (uint8_t)
|
|
86
|
+ * 308 bilinear_grid_spacing (int x2)
|
|
87
|
+ * 312 G29 L F bilinear_start (int x2)
|
|
88
|
+ * 316 bed_level_grid[][] (float x9, up to float x256) +988
|
86
|
89
|
*
|
87
|
90
|
* DELTA (if deltabot): 48 bytes
|
88
|
91
|
* 348 M666 XYZ endstop_adj (float x3)
|
|
@@ -144,18 +147,21 @@
|
144
|
147
|
* 568 M906 E1 stepperE1 current (uint16_t)
|
145
|
148
|
* 570 M906 E2 stepperE2 current (uint16_t)
|
146
|
149
|
* 572 M906 E3 stepperE3 current (uint16_t)
|
147
|
|
- * 572 M906 E4 stepperE4 current (uint16_t)
|
|
150
|
+ * 576 M906 E4 stepperE4 current (uint16_t)
|
148
|
151
|
*
|
149
|
|
- * 576 Minimum end-point
|
150
|
|
- * 1897 (576 + 36 + 9 + 288 + 988) Maximum end-point
|
|
152
|
+ * 580 Minimum end-point
|
|
153
|
+ * 1901 (580 + 36 + 9 + 288 + 988) Maximum end-point
|
151
|
154
|
*/
|
|
155
|
+#include "configuration_store.h"
|
|
156
|
+
|
|
157
|
+MarlinSettings settings;
|
|
158
|
+
|
152
|
159
|
#include "Marlin.h"
|
153
|
160
|
#include "language.h"
|
154
|
161
|
#include "endstops.h"
|
155
|
162
|
#include "planner.h"
|
156
|
163
|
#include "temperature.h"
|
157
|
164
|
#include "ultralcd.h"
|
158
|
|
-#include "configuration_store.h"
|
159
|
165
|
|
160
|
166
|
#if ENABLED(MESH_BED_LEVELING)
|
161
|
167
|
#include "mesh_bed_leveling.h"
|
|
@@ -176,7 +182,7 @@
|
176
|
182
|
/**
|
177
|
183
|
* Post-process after Retrieve or Reset
|
178
|
184
|
*/
|
179
|
|
-void Config_Postprocess() {
|
|
185
|
+void MarlinSettings::postprocess() {
|
180
|
186
|
// steps per s2 needs to be updated to agree with units per s2
|
181
|
187
|
planner.reset_acceleration_rates();
|
182
|
188
|
|
|
@@ -200,16 +206,28 @@ void Config_Postprocess() {
|
200
|
206
|
// Software endstops depend on home_offset
|
201
|
207
|
LOOP_XYZ(i) update_software_endstops((AxisEnum)i);
|
202
|
208
|
#endif
|
|
209
|
+
|
|
210
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
211
|
+ set_z_fade_height(
|
|
212
|
+ //#if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
213
|
+ // ubl.state.g29_correction_fade_height
|
|
214
|
+ //#else
|
|
215
|
+ planner.z_fade_height
|
|
216
|
+ //#endif
|
|
217
|
+ );
|
|
218
|
+ #endif
|
203
|
219
|
}
|
204
|
220
|
|
205
|
221
|
#if ENABLED(EEPROM_SETTINGS)
|
206
|
222
|
|
207
|
|
- uint16_t eeprom_checksum;
|
208
|
223
|
const char version[4] = EEPROM_VERSION;
|
209
|
224
|
|
210
|
|
- bool eeprom_write_error;
|
|
225
|
+ uint16_t MarlinSettings::eeprom_checksum;
|
211
|
226
|
|
212
|
|
- void _EEPROM_writeData(int &pos, const uint8_t* value, uint16_t size) {
|
|
227
|
+ bool MarlinSettings::eeprom_write_error,
|
|
228
|
+ MarlinSettings::eeprom_read_error;
|
|
229
|
+
|
|
230
|
+ void MarlinSettings::write_data(int &pos, const uint8_t* value, uint16_t size) {
|
213
|
231
|
if (eeprom_write_error) return;
|
214
|
232
|
while (size--) {
|
215
|
233
|
uint8_t * const p = (uint8_t * const)pos;
|
|
@@ -230,8 +248,7 @@ void Config_Postprocess() {
|
230
|
248
|
value++;
|
231
|
249
|
};
|
232
|
250
|
}
|
233
|
|
- bool eeprom_read_error;
|
234
|
|
- void _EEPROM_readData(int &pos, uint8_t* value, uint16_t size) {
|
|
251
|
+ void MarlinSettings::read_data(int &pos, uint8_t* value, uint16_t size) {
|
235
|
252
|
do {
|
236
|
253
|
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
237
|
254
|
if (!eeprom_read_error) *value = c;
|
|
@@ -244,14 +261,14 @@ void Config_Postprocess() {
|
244
|
261
|
#define DUMMY_PID_VALUE 3000.0f
|
245
|
262
|
#define EEPROM_START() int eeprom_index = EEPROM_OFFSET
|
246
|
263
|
#define EEPROM_SKIP(VAR) eeprom_index += sizeof(VAR)
|
247
|
|
- #define EEPROM_WRITE(VAR) _EEPROM_writeData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
|
248
|
|
- #define EEPROM_READ(VAR) _EEPROM_readData(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
|
249
|
|
- #define EEPROM_ASSERT(TST,ERR) if () do{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM(ERR); eeprom_read_error |= true; }while(0)
|
|
264
|
+ #define EEPROM_WRITE(VAR) write_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
|
|
265
|
+ #define EEPROM_READ(VAR) read_data(eeprom_index, (uint8_t*)&VAR, sizeof(VAR))
|
|
266
|
+ #define EEPROM_ASSERT(TST,ERR) if (!(TST)) do{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM(ERR); eeprom_read_error = true; }while(0)
|
250
|
267
|
|
251
|
268
|
/**
|
252
|
269
|
* M500 - Store Configuration
|
253
|
270
|
*/
|
254
|
|
- bool Config_StoreSettings() {
|
|
271
|
+ bool MarlinSettings::save() {
|
255
|
272
|
float dummy = 0.0f;
|
256
|
273
|
char ver[4] = "000";
|
257
|
274
|
|
|
@@ -290,6 +307,17 @@ void Config_Postprocess() {
|
290
|
307
|
#endif
|
291
|
308
|
|
292
|
309
|
//
|
|
310
|
+ // General Leveling
|
|
311
|
+ //
|
|
312
|
+
|
|
313
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
314
|
+ EEPROM_WRITE(planner.z_fade_height);
|
|
315
|
+ #else
|
|
316
|
+ dummy = 10.0;
|
|
317
|
+ EEPROM_WRITE(dummy);
|
|
318
|
+ #endif
|
|
319
|
+
|
|
320
|
+ //
|
293
|
321
|
// Mesh Bed Leveling
|
294
|
322
|
//
|
295
|
323
|
|
|
@@ -552,7 +580,7 @@ void Config_Postprocess() {
|
552
|
580
|
/**
|
553
|
581
|
* M501 - Retrieve Configuration
|
554
|
582
|
*/
|
555
|
|
- bool Config_RetrieveSettings() {
|
|
583
|
+ bool MarlinSettings::load() {
|
556
|
584
|
|
557
|
585
|
EEPROM_START();
|
558
|
586
|
eeprom_read_error = false; // If set EEPROM_READ won't write into RAM
|
|
@@ -573,7 +601,7 @@ void Config_Postprocess() {
|
573
|
601
|
SERIAL_ECHOPGM("EEPROM version mismatch ");
|
574
|
602
|
SERIAL_ECHOPAIR("(EEPROM=", stored_ver);
|
575
|
603
|
SERIAL_ECHOLNPGM(" Marlin=" EEPROM_VERSION ")");
|
576
|
|
- Config_ResetDefault();
|
|
604
|
+ reset();
|
577
|
605
|
}
|
578
|
606
|
else {
|
579
|
607
|
float dummy = 0;
|
|
@@ -619,6 +647,16 @@ void Config_Postprocess() {
|
619
|
647
|
#endif
|
620
|
648
|
|
621
|
649
|
//
|
|
650
|
+ // General Leveling
|
|
651
|
+ //
|
|
652
|
+
|
|
653
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
654
|
+ EEPROM_READ(planner.z_fade_height);
|
|
655
|
+ #else
|
|
656
|
+ EEPROM_READ(dummy);
|
|
657
|
+ #endif
|
|
658
|
+
|
|
659
|
+ //
|
622
|
660
|
// Mesh (Manual) Bed Leveling
|
623
|
661
|
//
|
624
|
662
|
|
|
@@ -713,6 +751,11 @@ void Config_Postprocess() {
|
713
|
751
|
EEPROM_READ(lcd_preheat_bed_temp);
|
714
|
752
|
EEPROM_READ(lcd_preheat_fan_speed);
|
715
|
753
|
|
|
754
|
+ //EEPROM_ASSERT(
|
|
755
|
+ // WITHIN(lcd_preheat_fan_speed, 0, 255),
|
|
756
|
+ // "lcd_preheat_fan_speed out of range"
|
|
757
|
+ //);
|
|
758
|
+
|
716
|
759
|
#if ENABLED(PIDTEMP)
|
717
|
760
|
for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
|
718
|
761
|
EEPROM_READ(dummy); // Kp
|
|
@@ -835,9 +878,9 @@ void Config_Postprocess() {
|
835
|
878
|
|
836
|
879
|
if (eeprom_checksum == stored_checksum) {
|
837
|
880
|
if (eeprom_read_error)
|
838
|
|
- Config_ResetDefault();
|
|
881
|
+ reset();
|
839
|
882
|
else {
|
840
|
|
- Config_Postprocess();
|
|
883
|
+ postprocess();
|
841
|
884
|
SERIAL_ECHO_START;
|
842
|
885
|
SERIAL_ECHO(version);
|
843
|
886
|
SERIAL_ECHOPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET));
|
|
@@ -847,7 +890,7 @@ void Config_Postprocess() {
|
847
|
890
|
else {
|
848
|
891
|
SERIAL_ERROR_START;
|
849
|
892
|
SERIAL_ERRORLNPGM("EEPROM checksum mismatch");
|
850
|
|
- Config_ResetDefault();
|
|
893
|
+ reset();
|
851
|
894
|
}
|
852
|
895
|
|
853
|
896
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
@@ -889,7 +932,7 @@ void Config_Postprocess() {
|
889
|
932
|
#endif
|
890
|
933
|
}
|
891
|
934
|
#if ENABLED(EEPROM_CHITCHAT)
|
892
|
|
- Config_PrintSettings();
|
|
935
|
+ report();
|
893
|
936
|
#endif
|
894
|
937
|
|
895
|
938
|
return !eeprom_read_error;
|
|
@@ -897,7 +940,7 @@ void Config_Postprocess() {
|
897
|
940
|
|
898
|
941
|
#else // !EEPROM_SETTINGS
|
899
|
942
|
|
900
|
|
- bool Config_StoreSettings() {
|
|
943
|
+ bool MarlinSettings::save() {
|
901
|
944
|
SERIAL_ERROR_START;
|
902
|
945
|
SERIAL_ERRORLNPGM("EEPROM disabled");
|
903
|
946
|
return false;
|
|
@@ -908,7 +951,7 @@ void Config_Postprocess() {
|
908
|
951
|
/**
|
909
|
952
|
* M502 - Reset Configuration
|
910
|
953
|
*/
|
911
|
|
-void Config_ResetDefault() {
|
|
954
|
+void MarlinSettings::reset() {
|
912
|
955
|
const float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] = DEFAULT_MAX_FEEDRATE;
|
913
|
956
|
const uint32_t tmp3[] = DEFAULT_MAX_ACCELERATION;
|
914
|
957
|
LOOP_XYZE_N(i) {
|
|
@@ -927,6 +970,11 @@ void Config_ResetDefault() {
|
927
|
970
|
planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
|
928
|
971
|
planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
|
929
|
972
|
planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
|
|
973
|
+
|
|
974
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
975
|
+ planner.z_fade_height = 0.0;
|
|
976
|
+ #endif
|
|
977
|
+
|
930
|
978
|
#if DISABLED(NO_WORKSPACE_OFFSETS)
|
931
|
979
|
ZERO(home_offset);
|
932
|
980
|
#endif
|
|
@@ -968,11 +1016,13 @@ void Config_ResetDefault() {
|
968
|
1016
|
COPY(delta_diagonal_rod_trim, drt);
|
969
|
1017
|
COPY(delta_tower_angle_trim, dta);
|
970
|
1018
|
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
971
|
|
- #if defined(Z_DUAL_ENDSTOPS_ADJUSTMENT)
|
972
|
|
- float z_endstop_adj = Z_DUAL_ENDSTOPS_ADJUSTMENT;
|
973
|
|
- #else
|
974
|
|
- float z_endstop_adj = 0;
|
975
|
|
- #endif
|
|
1019
|
+ float z_endstop_adj =
|
|
1020
|
+ #ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
|
|
1021
|
+ Z_DUAL_ENDSTOPS_ADJUSTMENT
|
|
1022
|
+ #else
|
|
1023
|
+ 0
|
|
1024
|
+ #endif
|
|
1025
|
+ ;
|
976
|
1026
|
#endif
|
977
|
1027
|
|
978
|
1028
|
#if ENABLED(ULTIPANEL)
|
|
@@ -1027,11 +1077,11 @@ void Config_ResetDefault() {
|
1027
|
1077
|
#endif
|
1028
|
1078
|
|
1029
|
1079
|
volumetric_enabled =
|
1030
|
|
- #if ENABLED(VOLUMETRIC_DEFAULT_ON)
|
1031
|
|
- true
|
1032
|
|
- #else
|
1033
|
|
- false
|
1034
|
|
- #endif
|
|
1080
|
+ #if ENABLED(VOLUMETRIC_DEFAULT_ON)
|
|
1081
|
+ true
|
|
1082
|
+ #else
|
|
1083
|
+ false
|
|
1084
|
+ #endif
|
1035
|
1085
|
;
|
1036
|
1086
|
for (uint8_t q = 0; q < COUNT(filament_size); q++)
|
1037
|
1087
|
filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
|
@@ -1077,7 +1127,7 @@ void Config_ResetDefault() {
|
1077
|
1127
|
#endif
|
1078
|
1128
|
#endif
|
1079
|
1129
|
|
1080
|
|
- Config_Postprocess();
|
|
1130
|
+ postprocess();
|
1081
|
1131
|
|
1082
|
1132
|
SERIAL_ECHO_START;
|
1083
|
1133
|
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
|
|
@@ -1088,10 +1138,11 @@ void Config_ResetDefault() {
|
1088
|
1138
|
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START; }while(0)
|
1089
|
1139
|
|
1090
|
1140
|
/**
|
1091
|
|
- * M503 - Print Configuration
|
|
1141
|
+ * M503 - Report current settings in RAM
|
|
1142
|
+ *
|
|
1143
|
+ * Unless specifically disabled, M503 is available even without EEPROM
|
1092
|
1144
|
*/
|
1093
|
|
- void Config_PrintSettings(bool forReplay) {
|
1094
|
|
- // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
|
|
1145
|
+ void MarlinSettings::report(bool forReplay) {
|
1095
|
1146
|
|
1096
|
1147
|
CONFIG_ECHO_START;
|
1097
|
1148
|
|
|
@@ -1211,7 +1262,11 @@ void Config_ResetDefault() {
|
1211
|
1262
|
SERIAL_ECHOLNPGM("Mesh Bed Leveling:");
|
1212
|
1263
|
CONFIG_ECHO_START;
|
1213
|
1264
|
}
|
1214
|
|
- SERIAL_ECHOLNPAIR(" M420 S", mbl.has_mesh() ? 1 : 0);
|
|
1265
|
+ SERIAL_ECHOPAIR(" M420 S", mbl.has_mesh() ? 1 : 0);
|
|
1266
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
1267
|
+ SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height);
|
|
1268
|
+ #endif
|
|
1269
|
+ SERIAL_EOL;
|
1215
|
1270
|
for (uint8_t py = 1; py <= GRID_MAX_POINTS_Y; py++) {
|
1216
|
1271
|
for (uint8_t px = 1; px <= GRID_MAX_POINTS_X; px++) {
|
1217
|
1272
|
CONFIG_ECHO_START;
|
|
@@ -1229,8 +1284,11 @@ void Config_ResetDefault() {
|
1229
|
1284
|
SERIAL_ECHOLNPGM("Unified Bed Leveling:");
|
1230
|
1285
|
CONFIG_ECHO_START;
|
1231
|
1286
|
}
|
1232
|
|
-
|
1233
|
|
- SERIAL_ECHOLNPAIR(" M420 S", ubl.state.active ? 1 : 0);
|
|
1287
|
+ SERIAL_ECHOPAIR(" M420 S", ubl.state.active ? 1 : 0);
|
|
1288
|
+ //#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
1289
|
+ // SERIAL_ECHOLNPAIR(" Z", ubl.state.g29_correction_fade_height);
|
|
1290
|
+ //#endif
|
|
1291
|
+ SERIAL_EOL;
|
1234
|
1292
|
|
1235
|
1293
|
if (!forReplay) {
|
1236
|
1294
|
SERIAL_ECHOPGM("\nUBL is ");
|
|
@@ -1264,7 +1322,11 @@ void Config_ResetDefault() {
|
1264
|
1322
|
SERIAL_ECHOLNPGM("Auto Bed Leveling:");
|
1265
|
1323
|
CONFIG_ECHO_START;
|
1266
|
1324
|
}
|
1267
|
|
- SERIAL_ECHOLNPAIR(" M420 S", planner.abl_enabled ? 1 : 0);
|
|
1325
|
+ SERIAL_ECHOPAIR(" M420 S", planner.abl_enabled ? 1 : 0);
|
|
1326
|
+ #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
|
1327
|
+ SERIAL_ECHOLNPAIR(" Z", planner.z_fade_height);
|
|
1328
|
+ #endif
|
|
1329
|
+ SERIAL_EOL;
|
1268
|
1330
|
|
1269
|
1331
|
#endif
|
1270
|
1332
|
|