Selaa lähdekoodia

General cleanup of config-store, reset_bed_level

Scott Lahteine 7 vuotta sitten
vanhempi
commit
4b49ea1e92

+ 13
- 15
Marlin/src/feature/bedlevel/bedlevel.cpp Näytä tiedosto

@@ -173,27 +173,25 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
173 173
  * Reset calibration results to zero.
174 174
  */
175 175
 void reset_bed_level() {
176
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
177
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
178
+  #endif
176 179
   set_bed_leveling_enabled(false);
177 180
   #if ENABLED(MESH_BED_LEVELING)
178 181
     if (leveling_is_valid()) {
179 182
       mbl.reset();
180 183
       mbl.has_mesh = false;
181 184
     }
182
-  #else
183
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
184
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
185
-    #endif
186
-    #if ABL_PLANAR
187
-      planner.bed_level_matrix.set_to_identity();
188
-    #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
189
-      bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
190
-      bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
191
-      for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
192
-        for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
193
-          z_values[x][y] = NAN;
194
-    #elif ENABLED(AUTO_BED_LEVELING_UBL)
195
-      ubl.reset();
196
-    #endif
185
+  #elif ENABLED(AUTO_BED_LEVELING_UBL)
186
+    ubl.reset();
187
+  #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
188
+    bilinear_start[X_AXIS] = bilinear_start[Y_AXIS] =
189
+    bilinear_grid_spacing[X_AXIS] = bilinear_grid_spacing[Y_AXIS] = 0;
190
+    for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
191
+      for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
192
+        z_values[x][y] = NAN;
193
+  #elif ABL_PLANAR
194
+    planner.bed_level_matrix.set_to_identity();
197 195
   #endif
198 196
 }
199 197
 

+ 4
- 3
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Näytä tiedosto

@@ -310,7 +310,8 @@
310 310
   void unified_bed_leveling::G29() {
311 311
 
312 312
     if (!settings.calc_num_meshes()) {
313
-      SERIAL_PROTOCOLLNPGM("?Enable EEPROM and init with M502, M500.\n");
313
+      SERIAL_PROTOCOLLNPGM("?Enable EEPROM and init with");
314
+      SERIAL_PROTOCOLLNPGM("M502, M500, M501 in that order.\n");
314 315
       return;
315 316
     }
316 317
 
@@ -608,7 +609,7 @@
608 609
     if (parser.seen('L')) {     // Load Current Mesh Data
609 610
       g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
610 611
 
611
-      int16_t a = settings.calc_num_meshes();
612
+      uint16_t a = settings.calc_num_meshes();
612 613
 
613 614
       if (!a) {
614 615
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
@@ -650,7 +651,7 @@
650 651
         return;
651 652
       }
652 653
 
653
-      int16_t a = settings.calc_num_meshes();
654
+      uint16_t a = settings.calc_num_meshes();
654 655
 
655 656
       if (!a) {
656 657
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp Näytä tiedosto

@@ -54,7 +54,7 @@ void GcodeSuite::M420() {
54 54
 
55 55
       #if ENABLED(EEPROM_SETTINGS)
56 56
         const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
57
-        const int16_t a = settings.calc_num_meshes();
57
+        const uint16_t a = settings.calc_num_meshes();
58 58
 
59 59
         if (!a) {
60 60
           SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");

+ 1
- 1
Marlin/src/lcd/ultralcd.cpp Näytä tiedosto

@@ -2285,7 +2285,7 @@ void kill_screen(const char* lcd_msg) {
2285 2285
      *    Save Bed Mesh
2286 2286
      */
2287 2287
     void _lcd_ubl_storage_mesh() {
2288
-      int16_t a = settings.calc_num_meshes();
2288
+      uint16_t a = settings.calc_num_meshes();
2289 2289
       START_MENU();
2290 2290
       MENU_BACK(MSG_UBL_LEVEL_BED);
2291 2291
       if (!WITHIN(ubl_storage_slot, 0, a - 1)) {

+ 34
- 37
Marlin/src/module/configuration_store.cpp Näytä tiedosto

@@ -141,7 +141,7 @@
141 141
  *  539  M200 D    parser.volumetric_enabled        (bool)
142 142
  *  540  M200 T D  planner.filament_size            (float x5) (T0..3)
143 143
  *
144
- * HAVE_TMC2130:                                    22 bytes
144
+ * HAS_TRINAMIC:                                    22 bytes
145 145
  *  560  M906 X    Stepper X current                (uint16_t)
146 146
  *  562  M906 Y    Stepper Y current                (uint16_t)
147 147
  *  564  M906 Z    Stepper Z current                (uint16_t)
@@ -155,28 +155,28 @@
155 155
  *  580  M906 E4   Stepper E4 current               (uint16_t)
156 156
  *
157 157
  * SENSORLESS HOMING                                4 bytes
158
- *  580  M914 X    Stepper X and X2 threshold       (int16_t)
159
- *  582  M914 Y    Stepper Y and Y2 threshold       (int16_t)
158
+ *  582  M914 X    Stepper X and X2 threshold       (int16_t)
159
+ *  584  M914 Y    Stepper Y and Y2 threshold       (int16_t)
160 160
  *
161 161
  * LIN_ADVANCE:                                     8 bytes
162
- *  582  M900 K    extruder_advance_k               (float)
163
- *  586  M900 WHD  advance_ed_ratio                 (float)
162
+ *  586  M900 K    extruder_advance_k               (float)
163
+ *  590  M900 WHD  advance_ed_ratio                 (float)
164 164
  *
165 165
  * HAS_MOTOR_CURRENT_PWM:
166
- *  590  M907 X    Stepper XY current               (uint32_t)
167
- *  594  M907 Z    Stepper Z current                (uint32_t)
168
- *  598  M907 E    Stepper E current                (uint32_t)
166
+ *  594  M907 X    Stepper XY current               (uint32_t)
167
+ *  598  M907 Z    Stepper Z current                (uint32_t)
168
+ *  602  M907 E    Stepper E current                (uint32_t)
169 169
  *
170 170
  * CNC_COORDINATE_SYSTEMS                           108 bytes
171
- *  602  G54-G59.3 coordinate_system                (float x 27)
171
+ *  606  G54-G59.3 coordinate_system                (float x 27)
172 172
  *
173 173
  * SKEW_CORRECTION:                                 12 bytes
174
- *  710  M852 I    planner.xy_skew_factor           (float)
175
- *  714  M852 J    planner.xz_skew_factor           (float)
176
- *  718  M852 K    planner.yz_skew_factor           (float)
174
+ *  714  M852 I    planner.xy_skew_factor           (float)
175
+ *  718  M852 J    planner.xz_skew_factor           (float)
176
+ *  722  M852 K    planner.yz_skew_factor           (float)
177 177
  *
178
- *  722                                   Minimum end-point
179
- * 2251 (722 + 208 + 36 + 9 + 288 + 988)  Maximum end-point
178
+ *  726                                   Minimum end-point
179
+ * 2255 (726 + 208 + 36 + 9 + 288 + 988)  Maximum end-point
180 180
  *
181 181
  * ========================================================================
182 182
  * meshes_begin (between max and min end-point, directly above)
@@ -290,7 +290,7 @@ void MarlinSettings::postprocess() {
290 290
   bool MarlinSettings::eeprom_error;
291 291
 
292 292
   #if ENABLED(AUTO_BED_LEVELING_UBL)
293
-    int MarlinSettings::meshes_begin;
293
+    int16_t MarlinSettings::meshes_begin;
294 294
   #endif
295 295
 
296 296
   /**
@@ -1256,7 +1256,7 @@ void MarlinSettings::postprocess() {
1256 1256
       }
1257 1257
     #endif
1258 1258
 
1259
-    int MarlinSettings::calc_num_meshes() {
1259
+    uint16_t MarlinSettings::calc_num_meshes() {
1260 1260
       //obviously this will get more sophisticated once we've added an actual MAT
1261 1261
 
1262 1262
       if (meshes_begin <= 0) return 0;
@@ -1264,10 +1264,10 @@ void MarlinSettings::postprocess() {
1264 1264
       return (meshes_end - meshes_begin) / sizeof(ubl.z_values);
1265 1265
     }
1266 1266
 
1267
-    void MarlinSettings::store_mesh(int8_t slot) {
1267
+    void MarlinSettings::store_mesh(const int8_t slot) {
1268 1268
 
1269 1269
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1270
-        const int a = calc_num_meshes();
1270
+        const int16_t a = calc_num_meshes();
1271 1271
         if (!WITHIN(slot, 0, a - 1)) {
1272 1272
           #if ENABLED(EEPROM_CHITCHAT)
1273 1273
             ubl_invalid_slot(a);
@@ -1280,11 +1280,10 @@ void MarlinSettings::postprocess() {
1280 1280
         }
1281 1281
 
1282 1282
         uint16_t crc = 0;
1283
-        bool status;
1284 1283
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1285 1284
 
1286 1285
         HAL::PersistentStore::access_start();
1287
-        status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
1286
+        const bool status = HAL::PersistentStore::write_data(pos, (uint8_t *)&ubl.z_values, sizeof(ubl.z_values), &crc);
1288 1287
         HAL::PersistentStore::access_finish();
1289 1288
 
1290 1289
         if (status)
@@ -1304,7 +1303,7 @@ void MarlinSettings::postprocess() {
1304 1303
       #endif
1305 1304
     }
1306 1305
 
1307
-    void MarlinSettings::load_mesh(int8_t slot, void *into /* = 0 */) {
1306
+    void MarlinSettings::load_mesh(const int8_t slot, void * const into/*=NULL*/) {
1308 1307
 
1309 1308
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1310 1309
 
@@ -1320,10 +1319,9 @@ void MarlinSettings::postprocess() {
1320 1319
         uint16_t crc = 0;
1321 1320
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1322 1321
         uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
1323
-        uint16_t status;
1324 1322
 
1325 1323
         HAL::PersistentStore::access_start();
1326
-        status = HAL::PersistentStore::read_data(pos, dest, sizeof(ubl.z_values), &crc);
1324
+        const uint16_t status = HAL::PersistentStore::read_data(pos, dest, sizeof(ubl.z_values), &crc);
1327 1325
         HAL::PersistentStore::access_finish();
1328 1326
 
1329 1327
         if (status)
@@ -1373,17 +1371,13 @@ void MarlinSettings::reset() {
1373 1371
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1374 1372
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1375 1373
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1376
-  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1377 1374
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1375
+  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1378 1376
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1379 1377
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
1380 1378
   planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
1381 1379
   planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
1382 1380
 
1383
-  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1384
-    new_z_fade_height = 0.0;
1385
-  #endif
1386
-
1387 1381
   #if HAS_HOME_OFFSET
1388 1382
     ZERO(home_offset);
1389 1383
   #endif
@@ -1405,7 +1399,14 @@ void MarlinSettings::reset() {
1405 1399
     LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
1406 1400
   #endif
1407 1401
 
1408
-  // Applies to all MBL and ABL
1402
+  //
1403
+  // Global Leveling
1404
+  //
1405
+
1406
+  #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1407
+    new_z_fade_height = 0.0;
1408
+  #endif
1409
+
1409 1410
   #if HAS_LEVELING
1410 1411
     reset_bed_level();
1411 1412
   #endif
@@ -1466,10 +1467,6 @@ void MarlinSettings::reset() {
1466 1467
     lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
1467 1468
   #endif
1468 1469
 
1469
-  #if HAS_LCD_CONTRAST
1470
-    lcd_contrast = DEFAULT_LCD_CONTRAST;
1471
-  #endif
1472
-
1473 1470
   #if ENABLED(PIDTEMP)
1474 1471
     #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
1475 1472
       HOTEND_LOOP()
@@ -1493,6 +1490,10 @@ void MarlinSettings::reset() {
1493 1490
     thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
1494 1491
   #endif
1495 1492
 
1493
+  #if HAS_LCD_CONTRAST
1494
+    lcd_contrast = DEFAULT_LCD_CONTRAST;
1495
+  #endif
1496
+
1496 1497
   #if ENABLED(FWRETRACT)
1497 1498
     fwretract.reset();
1498 1499
   #endif
@@ -1579,10 +1580,6 @@ void MarlinSettings::reset() {
1579 1580
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1580 1581
   #endif
1581 1582
 
1582
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
1583
-    ubl.reset();
1584
-  #endif
1585
-
1586 1583
   #if ENABLED(SKEW_CORRECTION_GCODE)
1587 1584
     planner.xy_skew_factor = XY_SKEW_FACTOR;
1588 1585
     #if ENABLED(SKEW_CORRECTION_FOR_Z)

+ 8
- 8
Marlin/src/module/configuration_store.h Näytä tiedosto

@@ -37,11 +37,11 @@ class MarlinSettings {
37 37
 
38 38
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
39 39
                                          // That can store is enabled
40
-        FORCE_INLINE static int get_start_of_meshes() { return meshes_begin; }
41
-        FORCE_INLINE static int get_end_of_meshes() { return meshes_end; }
42
-        static int calc_num_meshes();
43
-        static void store_mesh(int8_t slot);
44
-        static void load_mesh(int8_t slot, void *into = 0);
40
+        FORCE_INLINE static int16_t get_start_of_meshes() { return meshes_begin; }
41
+        FORCE_INLINE static int16_t get_end_of_meshes() { return meshes_end; }
42
+        static uint16_t calc_num_meshes();
43
+        static void store_mesh(const int8_t slot);
44
+        static void load_mesh(const int8_t slot, void * const into=NULL);
45 45
 
46 46
         //static void delete_mesh();    // necessary if we have a MAT
47 47
         //static void defrag_meshes();  // "
@@ -66,9 +66,9 @@ class MarlinSettings {
66 66
 
67 67
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
68 68
                                          // That can store is enabled
69
-        static int meshes_begin;
70
-        const static int meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
71
-                                                   // live at the very end of the eeprom
69
+        static int16_t meshes_begin;
70
+        const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
71
+                                                       // live at the very end of the eeprom
72 72
 
73 73
       #endif
74 74
 

Loading…
Peruuta
Tallenna