Просмотр исходного кода

Always report position on config load/reset

Scott Lahteine 7 лет назад
Родитель
Сommit
6686d937fb
1 измененных файлов: 17 добавлений и 20 удалений
  1. 17
    20
      Marlin/src/module/configuration_store.cpp

+ 17
- 20
Marlin/src/module/configuration_store.cpp Просмотреть файл

216
   float new_z_fade_height;
216
   float new_z_fade_height;
217
 #endif
217
 #endif
218
 
218
 
219
-#if ENABLED(CNC_COORDINATE_SYSTEMS)
220
-  bool position_changed;
221
-#endif
222
-
223
 /**
219
 /**
224
  * Post-process after Retrieve or Reset
220
  * Post-process after Retrieve or Reset
225
  */
221
  */
226
 void MarlinSettings::postprocess() {
222
 void MarlinSettings::postprocess() {
223
+  const float oldpos[XYZE] = {
224
+    current_position[X_AXIS], current_position[Y_AXIS],
225
+    current_position[Z_AXIS], current_position[E_AXIS]
226
+  };
227
+
227
   // steps per s2 needs to be updated to agree with units per s2
228
   // steps per s2 needs to be updated to agree with units per s2
228
   planner.reset_acceleration_rates();
229
   planner.reset_acceleration_rates();
229
 
230
 
233
     recalc_delta_settings();
234
     recalc_delta_settings();
234
   #endif
235
   #endif
235
 
236
 
236
-  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
237
-  // and init stepper.count[], planner.position[] with current_position
238
-  planner.refresh_positioning();
239
-
240
   #if ENABLED(PIDTEMP)
237
   #if ENABLED(PIDTEMP)
241
     thermalManager.updatePID();
238
     thermalManager.updatePID();
242
   #endif
239
   #endif
249
   #endif
246
   #endif
250
 
247
 
251
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
248
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
252
-    set_z_fade_height(new_z_fade_height);
249
+    set_z_fade_height(new_z_fade_height, false); // false = no report
253
   #endif
250
   #endif
254
 
251
 
255
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
252
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
264
   #if ENABLED(FWRETRACT)
261
   #if ENABLED(FWRETRACT)
265
     fwretract.refresh_autoretract();
262
     fwretract.refresh_autoretract();
266
   #endif
263
   #endif
264
+ 
265
+  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
266
+  // and init stepper.count[], planner.position[] with current_position
267
+  planner.refresh_positioning();
267
 
268
 
268
-  #if ENABLED(CNC_COORDINATE_SYSTEMS)
269
-    if (position_changed) {
270
-      report_current_position();
271
-      position_changed = false;
272
-    }
273
-  #endif
269
+  // Various factors can change the current position
270
+  if (memcmp(oldpos, current_position, sizeof(oldpos)))
271
+    report_current_position();
274
 }
272
 }
275
 
273
 
276
 #if ENABLED(EEPROM_SETTINGS)
274
 #if ENABLED(EEPROM_SETTINGS)
308
     EEPROM_WRITE(ver);     // invalidate data first
306
     EEPROM_WRITE(ver);     // invalidate data first
309
     EEPROM_SKIP(working_crc); // Skip the checksum slot
307
     EEPROM_SKIP(working_crc); // Skip the checksum slot
310
 
308
 
311
-    working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
309
+    working_crc = 0; // clear before first "real data"
312
 
310
 
313
     const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
311
     const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ;
314
     EEPROM_WRITE(esteppers);
312
     EEPROM_WRITE(esteppers);
342
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
340
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
343
       const float zfh = planner.z_fade_height;
341
       const float zfh = planner.z_fade_height;
344
     #else
342
     #else
345
-      const float zfh = 0.0;
343
+      const float zfh = 10.0;
346
     #endif
344
     #endif
347
     EEPROM_WRITE(zfh);
345
     EEPROM_WRITE(zfh);
348
 
346
 
725
       float dummy = 0;
723
       float dummy = 0;
726
       bool dummyb;
724
       bool dummyb;
727
 
725
 
728
-      working_crc = 0; //clear before reading first "real data"
726
+      working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
729
 
727
 
730
       // Number of esteppers may change
728
       // Number of esteppers may change
731
       uint8_t esteppers;
729
       uint8_t esteppers;
913
       #if DISABLED(ULTIPANEL)
911
       #if DISABLED(ULTIPANEL)
914
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
912
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
915
       #endif
913
       #endif
916
-
917
       EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
914
       EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
918
       EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
915
       EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
919
       EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
916
       EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
1094
       //
1091
       //
1095
 
1092
 
1096
       #if ENABLED(CNC_COORDINATE_SYSTEMS)
1093
       #if ENABLED(CNC_COORDINATE_SYSTEMS)
1097
-        position_changed = gcode.select_coordinate_system(-1); // Go back to machine space
1094
+        (void)gcode.select_coordinate_system(-1); // Go back to machine space
1098
         EEPROM_READ(gcode.coordinate_system);                  // 27 floats
1095
         EEPROM_READ(gcode.coordinate_system);                  // 27 floats
1099
       #else
1096
       #else
1100
         for (uint8_t q = 27; q--;) EEPROM_READ(dummy);
1097
         for (uint8_t q = 27; q--;) EEPROM_READ(dummy);

Загрузка…
Отмена
Сохранить