Selaa lähdekoodia

Merge pull request #2469 from wavexx/fix_current_pos_init

Initialize current_position correctly during startup
DRracer 5 vuotta sitten
vanhempi
commit
73349033d5
1 muutettua tiedostoa jossa 8 lisäystä ja 1 poistoa
  1. 8 1
      Firmware/Marlin_main.cpp

+ 8 - 1
Firmware/Marlin_main.cpp

@@ -1313,10 +1313,17 @@ void setup()
 	setup_photpin();
 
 	servo_init();
+
 	// Reset the machine correction matrix.
 	// It does not make sense to load the correction matrix until the machine is homed.
 	world2machine_reset();
-    
+
+    // Initialize current_position accounting for software endstops to
+    // avoid unexpected initial shifts on the first move
+    clamp_to_software_endstops(current_position);
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS],
+                      current_position[Z_AXIS], current_position[E_AXIS]);
+
 #ifdef FILAMENT_SENSOR
 	fsensor_init();
 #endif //FILAMENT_SENSOR