Browse Source

General cleanup of config-store, reset_bed_level

Scott Lahteine 7 years ago
parent
commit
4b49ea1e92

+ 13
- 15
Marlin/src/feature/bedlevel/bedlevel.cpp View File

173
  * Reset calibration results to zero.
173
  * Reset calibration results to zero.
174
  */
174
  */
175
 void reset_bed_level() {
175
 void reset_bed_level() {
176
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
177
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
178
+  #endif
176
   set_bed_leveling_enabled(false);
179
   set_bed_leveling_enabled(false);
177
   #if ENABLED(MESH_BED_LEVELING)
180
   #if ENABLED(MESH_BED_LEVELING)
178
     if (leveling_is_valid()) {
181
     if (leveling_is_valid()) {
179
       mbl.reset();
182
       mbl.reset();
180
       mbl.has_mesh = false;
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
   #endif
195
   #endif
198
 }
196
 }
199
 
197
 

+ 4
- 3
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

310
   void unified_bed_leveling::G29() {
310
   void unified_bed_leveling::G29() {
311
 
311
 
312
     if (!settings.calc_num_meshes()) {
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
       return;
315
       return;
315
     }
316
     }
316
 
317
 
608
     if (parser.seen('L')) {     // Load Current Mesh Data
609
     if (parser.seen('L')) {     // Load Current Mesh Data
609
       g29_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
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
       if (!a) {
614
       if (!a) {
614
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
615
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
650
         return;
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
       if (!a) {
656
       if (!a) {
656
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
657
         SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");

+ 1
- 1
Marlin/src/gcode/bedlevel/M420.cpp View File

54
 
54
 
55
       #if ENABLED(EEPROM_SETTINGS)
55
       #if ENABLED(EEPROM_SETTINGS)
56
         const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot;
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
         if (!a) {
59
         if (!a) {
60
           SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
60
           SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");

+ 1
- 1
Marlin/src/lcd/ultralcd.cpp View File

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

+ 34
- 37
Marlin/src/module/configuration_store.cpp View File

141
  *  539  M200 D    parser.volumetric_enabled        (bool)
141
  *  539  M200 D    parser.volumetric_enabled        (bool)
142
  *  540  M200 T D  planner.filament_size            (float x5) (T0..3)
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
  *  560  M906 X    Stepper X current                (uint16_t)
145
  *  560  M906 X    Stepper X current                (uint16_t)
146
  *  562  M906 Y    Stepper Y current                (uint16_t)
146
  *  562  M906 Y    Stepper Y current                (uint16_t)
147
  *  564  M906 Z    Stepper Z current                (uint16_t)
147
  *  564  M906 Z    Stepper Z current                (uint16_t)
155
  *  580  M906 E4   Stepper E4 current               (uint16_t)
155
  *  580  M906 E4   Stepper E4 current               (uint16_t)
156
  *
156
  *
157
  * SENSORLESS HOMING                                4 bytes
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
  * LIN_ADVANCE:                                     8 bytes
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
  * HAS_MOTOR_CURRENT_PWM:
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
  * CNC_COORDINATE_SYSTEMS                           108 bytes
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
  * SKEW_CORRECTION:                                 12 bytes
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
  * meshes_begin (between max and min end-point, directly above)
182
  * meshes_begin (between max and min end-point, directly above)
290
   bool MarlinSettings::eeprom_error;
290
   bool MarlinSettings::eeprom_error;
291
 
291
 
292
   #if ENABLED(AUTO_BED_LEVELING_UBL)
292
   #if ENABLED(AUTO_BED_LEVELING_UBL)
293
-    int MarlinSettings::meshes_begin;
293
+    int16_t MarlinSettings::meshes_begin;
294
   #endif
294
   #endif
295
 
295
 
296
   /**
296
   /**
1256
       }
1256
       }
1257
     #endif
1257
     #endif
1258
 
1258
 
1259
-    int MarlinSettings::calc_num_meshes() {
1259
+    uint16_t MarlinSettings::calc_num_meshes() {
1260
       //obviously this will get more sophisticated once we've added an actual MAT
1260
       //obviously this will get more sophisticated once we've added an actual MAT
1261
 
1261
 
1262
       if (meshes_begin <= 0) return 0;
1262
       if (meshes_begin <= 0) return 0;
1264
       return (meshes_end - meshes_begin) / sizeof(ubl.z_values);
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
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1269
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1270
-        const int a = calc_num_meshes();
1270
+        const int16_t a = calc_num_meshes();
1271
         if (!WITHIN(slot, 0, a - 1)) {
1271
         if (!WITHIN(slot, 0, a - 1)) {
1272
           #if ENABLED(EEPROM_CHITCHAT)
1272
           #if ENABLED(EEPROM_CHITCHAT)
1273
             ubl_invalid_slot(a);
1273
             ubl_invalid_slot(a);
1280
         }
1280
         }
1281
 
1281
 
1282
         uint16_t crc = 0;
1282
         uint16_t crc = 0;
1283
-        bool status;
1284
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1283
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1285
 
1284
 
1286
         HAL::PersistentStore::access_start();
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
         HAL::PersistentStore::access_finish();
1287
         HAL::PersistentStore::access_finish();
1289
 
1288
 
1290
         if (status)
1289
         if (status)
1304
       #endif
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
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1308
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1310
 
1309
 
1320
         uint16_t crc = 0;
1319
         uint16_t crc = 0;
1321
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1320
         int pos = meshes_end - (slot + 1) * sizeof(ubl.z_values);
1322
         uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
1321
         uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values;
1323
-        uint16_t status;
1324
 
1322
 
1325
         HAL::PersistentStore::access_start();
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
         HAL::PersistentStore::access_finish();
1325
         HAL::PersistentStore::access_finish();
1328
 
1326
 
1329
         if (status)
1327
         if (status)
1373
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1371
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1374
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1372
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1375
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1373
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1376
-  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1377
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1374
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1375
+  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1378
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1376
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1379
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
1377
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
1380
   planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
1378
   planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK;
1381
   planner.max_jerk[E_AXIS] = DEFAULT_EJERK;
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
   #if HAS_HOME_OFFSET
1381
   #if HAS_HOME_OFFSET
1388
     ZERO(home_offset);
1382
     ZERO(home_offset);
1389
   #endif
1383
   #endif
1405
     LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
1399
     LOOP_XYZ(i) HOTEND_LOOP() hotend_offset[i][e] = tmp4[i][e];
1406
   #endif
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
   #if HAS_LEVELING
1410
   #if HAS_LEVELING
1410
     reset_bed_level();
1411
     reset_bed_level();
1411
   #endif
1412
   #endif
1466
     lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
1467
     lcd_preheat_fan_speed[1] = PREHEAT_2_FAN_SPEED;
1467
   #endif
1468
   #endif
1468
 
1469
 
1469
-  #if HAS_LCD_CONTRAST
1470
-    lcd_contrast = DEFAULT_LCD_CONTRAST;
1471
-  #endif
1472
-
1473
   #if ENABLED(PIDTEMP)
1470
   #if ENABLED(PIDTEMP)
1474
     #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
1471
     #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
1475
       HOTEND_LOOP()
1472
       HOTEND_LOOP()
1493
     thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
1490
     thermalManager.bedKd = scalePID_d(DEFAULT_bedKd);
1494
   #endif
1491
   #endif
1495
 
1492
 
1493
+  #if HAS_LCD_CONTRAST
1494
+    lcd_contrast = DEFAULT_LCD_CONTRAST;
1495
+  #endif
1496
+
1496
   #if ENABLED(FWRETRACT)
1497
   #if ENABLED(FWRETRACT)
1497
     fwretract.reset();
1498
     fwretract.reset();
1498
   #endif
1499
   #endif
1579
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1580
       stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
1580
   #endif
1581
   #endif
1581
 
1582
 
1582
-  #if ENABLED(AUTO_BED_LEVELING_UBL)
1583
-    ubl.reset();
1584
-  #endif
1585
-
1586
   #if ENABLED(SKEW_CORRECTION_GCODE)
1583
   #if ENABLED(SKEW_CORRECTION_GCODE)
1587
     planner.xy_skew_factor = XY_SKEW_FACTOR;
1584
     planner.xy_skew_factor = XY_SKEW_FACTOR;
1588
     #if ENABLED(SKEW_CORRECTION_FOR_Z)
1585
     #if ENABLED(SKEW_CORRECTION_FOR_Z)

+ 8
- 8
Marlin/src/module/configuration_store.h View File

37
 
37
 
38
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
38
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
39
                                          // That can store is enabled
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
         //static void delete_mesh();    // necessary if we have a MAT
46
         //static void delete_mesh();    // necessary if we have a MAT
47
         //static void defrag_meshes();  // "
47
         //static void defrag_meshes();  // "
66
 
66
 
67
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
67
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
68
                                          // That can store is enabled
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
       #endif
73
       #endif
74
 
74
 

Loading…
Cancel
Save