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

Always report position on config load/reset

Scott Lahteine 7 лет назад
Родитель
Сommit
ccca1ade2d
3 измененных файлов: 16 добавлений и 18 удалений
  1. 1
    1
      Marlin/Marlin.h
  2. 4
    1
      Marlin/Marlin_main.cpp
  3. 11
    16
      Marlin/configuration_store.cpp

+ 1
- 1
Marlin/Marlin.h Просмотреть файл

373
 #endif
373
 #endif
374
 
374
 
375
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
375
 #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
376
-  void set_z_fade_height(const float zfh);
376
+  void set_z_fade_height(const float zfh, const bool do_report=true);
377
 #endif
377
 #endif
378
 
378
 
379
 #if ENABLED(X_DUAL_ENDSTOPS)
379
 #if ENABLED(X_DUAL_ENDSTOPS)

+ 4
- 1
Marlin/Marlin_main.cpp Просмотреть файл

2475
 
2475
 
2476
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2476
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
2477
 
2477
 
2478
-    void set_z_fade_height(const float zfh) {
2478
+    void set_z_fade_height(const float zfh, const bool do_report/*=true*/) {
2479
+
2480
+      if (planner.z_fade_height == zfh) return; // do nothing if no change
2479
 
2481
 
2480
       const bool level_active = planner.leveling_active;
2482
       const bool level_active = planner.leveling_active;
2481
 
2483
 
2497
             #endif
2499
             #endif
2498
           );
2500
           );
2499
         #endif
2501
         #endif
2502
+        if (do_report) report_current_position();
2500
       }
2503
       }
2501
     }
2504
     }
2502
 
2505
 

+ 11
- 16
Marlin/configuration_store.cpp Просмотреть файл

215
   float new_z_fade_height;
215
   float new_z_fade_height;
216
 #endif
216
 #endif
217
 
217
 
218
-#if ENABLED(CNC_COORDINATE_SYSTEMS)
219
-  bool position_changed;
220
-#endif
221
-
222
 /**
218
 /**
223
  * Post-process after Retrieve or Reset
219
  * Post-process after Retrieve or Reset
224
  */
220
  */
225
 void MarlinSettings::postprocess() {
221
 void MarlinSettings::postprocess() {
222
+  const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
223
+
226
   // steps per s2 needs to be updated to agree with units per s2
224
   // steps per s2 needs to be updated to agree with units per s2
227
   planner.reset_acceleration_rates();
225
   planner.reset_acceleration_rates();
228
 
226
 
232
     recalc_delta_settings();
230
     recalc_delta_settings();
233
   #endif
231
   #endif
234
 
232
 
235
-  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
236
-  // and init stepper.count[], planner.position[] with current_position
237
-  planner.refresh_positioning();
238
-
239
   #if ENABLED(PIDTEMP)
233
   #if ENABLED(PIDTEMP)
240
     thermalManager.updatePID();
234
     thermalManager.updatePID();
241
   #endif
235
   #endif
248
   #endif
242
   #endif
249
 
243
 
250
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
244
   #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
251
-    set_z_fade_height(new_z_fade_height);
245
+    set_z_fade_height(new_z_fade_height, false); // false = no report
252
   #endif
246
   #endif
253
 
247
 
254
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
248
   #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
260
     stepper.refresh_motor_power();
254
     stepper.refresh_motor_power();
261
   #endif
255
   #endif
262
 
256
 
263
-  #if ENABLED(CNC_COORDINATE_SYSTEMS)
264
-    if (position_changed) {
265
-      report_current_position();
266
-      position_changed = false;
267
-    }
268
-  #endif
257
+  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
258
+  // and init stepper.count[], planner.position[] with current_position
259
+  planner.refresh_positioning();
260
+
261
+  // Various factors can change the current position
262
+  if (memcmp(oldpos, current_position, sizeof(oldpos)))
263
+    report_current_position();
269
 }
264
 }
270
 
265
 
271
 #if ENABLED(EEPROM_SETTINGS)
266
 #if ENABLED(EEPROM_SETTINGS)
1121
       //
1116
       //
1122
 
1117
 
1123
       #if ENABLED(CNC_COORDINATE_SYSTEMS)
1118
       #if ENABLED(CNC_COORDINATE_SYSTEMS)
1124
-        position_changed = select_coordinate_system(-1); // Go back to machine space
1119
+        (void)select_coordinate_system(-1); // Go back to machine space
1125
         EEPROM_READ(coordinate_system);                  // 27 floats
1120
         EEPROM_READ(coordinate_system);                  // 27 floats
1126
       #else
1121
       #else
1127
         for (uint8_t q = 27; q--;) EEPROM_READ(dummy);
1122
         for (uint8_t q = 27; q--;) EEPROM_READ(dummy);

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