Преглед изворни кода

Merge pull request #3939 from thinkyhead/rc_resume_get_position

set_current_position_from_planner() after stepper.quick_stop()
Scott Lahteine пре 9 година
родитељ
комит
0d793fb2be
6 измењених фајлова са 54 додато и 15 уклоњено
  1. 5
    0
      Marlin/Marlin.h
  2. 35
    8
      Marlin/Marlin_main.cpp
  3. 3
    0
      Marlin/endstops.cpp
  4. 3
    3
      Marlin/planner.cpp
  5. 3
    3
      Marlin/planner.h
  6. 5
    1
      Marlin/ultralcd.cpp

+ 5
- 0
Marlin/Marlin.h Прегледај датотеку

227
 void prepare_move();
227
 void prepare_move();
228
 void kill(const char*);
228
 void kill(const char*);
229
 
229
 
230
+#if DISABLED(DELTA) && DISABLED(SCARA)
231
+  void set_current_position_from_planner();
232
+#endif
233
+
230
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
234
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
231
   void handle_filament_runout();
235
   void handle_filament_runout();
232
 #endif
236
 #endif
253
 bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); //put a single ASCII command at the end of the current buffer or return false when it is full
257
 bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); //put a single ASCII command at the end of the current buffer or return false when it is full
254
 void enqueue_and_echo_command_now(const char* cmd); // enqueue now, only return when the command has been enqueued
258
 void enqueue_and_echo_command_now(const char* cmd); // enqueue now, only return when the command has been enqueued
255
 void enqueue_and_echo_commands_P(const char* cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
259
 void enqueue_and_echo_commands_P(const char* cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
260
+void clear_command_queue();
256
 
261
 
257
 void clamp_to_software_endstops(float target[3]);
262
 void clamp_to_software_endstops(float target[3]);
258
 
263
 

+ 35
- 8
Marlin/Marlin_main.cpp Прегледај датотеку

552
       if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position_delta", current_position);
552
       if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position_delta", current_position);
553
     #endif
553
     #endif
554
     calculate_delta(current_position);
554
     calculate_delta(current_position);
555
-    planner.set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
555
+    planner.set_position_mm(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
556
   }
556
   }
557
 #endif
557
 #endif
558
 
558
 
613
   drain_queued_commands_P(); // first command executed asap (when possible)
613
   drain_queued_commands_P(); // first command executed asap (when possible)
614
 }
614
 }
615
 
615
 
616
+void clear_command_queue() {
617
+  cmd_queue_index_r = cmd_queue_index_w;
618
+  commands_in_queue = 0;
619
+}
620
+
616
 /**
621
 /**
617
  * Once a new command is in the ring buffer, call this to commit it
622
  * Once a new command is in the ring buffer, call this to commit it
618
  */
623
  */
1448
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1453
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1449
     if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
1454
     if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
1450
   #endif
1455
   #endif
1451
-  planner.set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1456
+  planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1452
 }
1457
 }
1453
-inline void sync_plan_position_e() { planner.set_e_position(current_position[E_AXIS]); }
1458
+inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
1454
 inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
1459
 inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
1455
 inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
1460
 inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
1456
 
1461
 
1607
 
1612
 
1608
       // Tell the planner where we ended up - Get this from the stepper handler
1613
       // Tell the planner where we ended up - Get this from the stepper handler
1609
       zPosition = stepper.get_axis_position_mm(Z_AXIS);
1614
       zPosition = stepper.get_axis_position_mm(Z_AXIS);
1610
-      planner.set_position(
1615
+      planner.set_position_mm(
1611
         current_position[X_AXIS], current_position[Y_AXIS], zPosition,
1616
         current_position[X_AXIS], current_position[Y_AXIS], zPosition,
1612
         current_position[E_AXIS]
1617
         current_position[E_AXIS]
1613
       );
1618
       );
3593
          * Get the current Z position and send it to the planner.
3598
          * Get the current Z position and send it to the planner.
3594
          *
3599
          *
3595
          * >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z
3600
          * >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z
3596
-         * (most recent planner.set_position/sync_plan_position)
3601
+         * (most recent planner.set_position_mm/sync_plan_position)
3597
          *
3602
          *
3598
          * >> zprobe_zoffset : Z distance from nozzle to Z probe
3603
          * >> zprobe_zoffset : Z distance from nozzle to Z probe
3599
          * (set by default, M851, EEPROM, or Menu)
3604
          * (set by default, M851, EEPROM, or Menu)
5889
 
5894
 
5890
 #endif // FILAMENT_WIDTH_SENSOR
5895
 #endif // FILAMENT_WIDTH_SENSOR
5891
 
5896
 
5897
+#if DISABLED(DELTA) && DISABLED(SCARA)
5898
+  void set_current_position_from_planner() {
5899
+    stepper.synchronize();
5900
+    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
5901
+      vector_3 pos = planner.adjusted_position(); // values directly from steppers...
5902
+      current_position[X_AXIS] = pos.x;
5903
+      current_position[Y_AXIS] = pos.y;
5904
+      current_position[Z_AXIS] = pos.z;
5905
+    #else
5906
+      current_position[X_AXIS] = stepper.get_axis_position_mm(X_AXIS);
5907
+      current_position[Y_AXIS] = stepper.get_axis_position_mm(Y_AXIS);
5908
+      current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
5909
+    #endif
5910
+    sync_plan_position();                       // ...re-apply to planner position
5911
+  }
5912
+#endif
5913
+
5892
 /**
5914
 /**
5893
  * M410: Quickstop - Abort all planned moves
5915
  * M410: Quickstop - Abort all planned moves
5894
  *
5916
  *
5895
  * This will stop the carriages mid-move, so most likely they
5917
  * This will stop the carriages mid-move, so most likely they
5896
  * will be out of sync with the stepper position after this.
5918
  * will be out of sync with the stepper position after this.
5897
  */
5919
  */
5898
-inline void gcode_M410() { stepper.quick_stop(); }
5920
+inline void gcode_M410() {
5921
+  stepper.quick_stop();
5922
+  #if DISABLED(DELTA) && DISABLED(SCARA)
5923
+    set_current_position_from_planner();
5924
+  #endif
5925
+}
5899
 
5926
 
5900
 
5927
 
5901
 #if ENABLED(MESH_BED_LEVELING)
5928
 #if ENABLED(MESH_BED_LEVELING)
7436
     if (active_extruder_parked) {
7463
     if (active_extruder_parked) {
7437
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
7464
       if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) {
7438
         // move duplicate extruder into correct duplication position.
7465
         // move duplicate extruder into correct duplication position.
7439
-        planner.set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
7466
+        planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
7440
         planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
7467
         planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
7441
                          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate[X_AXIS], 1);
7468
                          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate[X_AXIS], 1);
7442
         sync_plan_position();
7469
         sync_plan_position();
7989
                          (EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS], active_extruder);
8016
                          (EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS], active_extruder);
7990
       current_position[E_AXIS] = oldepos;
8017
       current_position[E_AXIS] = oldepos;
7991
       destination[E_AXIS] = oldedes;
8018
       destination[E_AXIS] = oldedes;
7992
-      planner.set_e_position(oldepos);
8019
+      planner.set_e_position_mm(oldepos);
7993
       previous_cmd_ms = ms; // refresh_cmd_timeout()
8020
       previous_cmd_ms = ms; // refresh_cmd_timeout()
7994
       stepper.synchronize();
8021
       stepper.synchronize();
7995
       switch (active_extruder) {
8022
       switch (active_extruder) {

+ 3
- 0
Marlin/endstops.cpp Прегледај датотеку

187
         card.sdprinting = false;
187
         card.sdprinting = false;
188
         card.closefile();
188
         card.closefile();
189
         stepper.quick_stop();
189
         stepper.quick_stop();
190
+        #if DISABLED(DELTA) && DISABLED(SCARA)
191
+          set_current_position_from_planner();
192
+        #endif
190
         thermalManager.disable_all_heaters(); // switch off all heaters.
193
         thermalManager.disable_all_heaters(); // switch off all heaters.
191
       }
194
       }
192
     #endif
195
     #endif

+ 3
- 3
Marlin/planner.cpp Прегледај датотеку

1114
  * On CORE machines stepper ABC will be translated from the given XYZ.
1114
  * On CORE machines stepper ABC will be translated from the given XYZ.
1115
  */
1115
  */
1116
 #if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(MESH_BED_LEVELING)
1116
 #if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(MESH_BED_LEVELING)
1117
-  void Planner::set_position(float x, float y, float z, const float& e)
1117
+  void Planner::set_position_mm(float x, float y, float z, const float& e)
1118
 #else
1118
 #else
1119
-  void Planner::set_position(const float& x, const float& y, const float& z, const float& e)
1119
+  void Planner::set_position_mm(const float& x, const float& y, const float& z, const float& e)
1120
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1120
 #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
1121
   {
1121
   {
1122
     #if ENABLED(MESH_BED_LEVELING)
1122
     #if ENABLED(MESH_BED_LEVELING)
1138
 /**
1138
 /**
1139
  * Directly set the planner E position (hence the stepper E position).
1139
  * Directly set the planner E position (hence the stepper E position).
1140
  */
1140
  */
1141
-void Planner::set_e_position(const float& e) {
1141
+void Planner::set_e_position_mm(const float& e) {
1142
   position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
1142
   position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
1143
   stepper.set_e_position(position[E_AXIS]);
1143
   stepper.set_e_position(position[E_AXIS]);
1144
 }
1144
 }

+ 3
- 3
Marlin/planner.h Прегледај датотеку

216
        *
216
        *
217
        * Clears previous speed values.
217
        * Clears previous speed values.
218
        */
218
        */
219
-      static void set_position(float x, float y, float z, const float& e);
219
+      static void set_position_mm(float x, float y, float z, const float& e);
220
 
220
 
221
     #else
221
     #else
222
 
222
 
223
       static void buffer_line(const float& x, const float& y, const float& z, const float& e, float feed_rate, const uint8_t extruder);
223
       static void buffer_line(const float& x, const float& y, const float& z, const float& e, float feed_rate, const uint8_t extruder);
224
-      static void set_position(const float& x, const float& y, const float& z, const float& e);
224
+      static void set_position_mm(const float& x, const float& y, const float& z, const float& e);
225
 
225
 
226
     #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
226
     #endif // AUTO_BED_LEVELING_FEATURE || MESH_BED_LEVELING
227
 
227
 
228
     /**
228
     /**
229
      * Set the E position (mm) of the planner (and the E stepper)
229
      * Set the E position (mm) of the planner (and the E stepper)
230
      */
230
      */
231
-    static void set_e_position(const float& e);
231
+    static void set_e_position_mm(const float& e);
232
 
232
 
233
     /**
233
     /**
234
      * Does the buffer have any blocks queued?
234
      * Does the buffer have any blocks queued?

+ 5
- 1
Marlin/ultralcd.cpp Прегледај датотеку

482
 
482
 
483
   static void lcd_sdcard_stop() {
483
   static void lcd_sdcard_stop() {
484
     stepper.quick_stop();
484
     stepper.quick_stop();
485
+    #if DISABLED(DELTA) && DISABLED(SCARA)
486
+      set_current_position_from_planner();
487
+    #endif
488
+    clear_command_queue();
485
     card.sdprinting = false;
489
     card.sdprinting = false;
486
     card.closefile();
490
     card.closefile();
487
     print_job_timer.stop();
491
     print_job_timer.stop();
1037
     if (LCD_CLICKED) {
1041
     if (LCD_CLICKED) {
1038
       _lcd_level_bed_position = 0;
1042
       _lcd_level_bed_position = 0;
1039
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1043
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1040
-      planner.set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1044
+      planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1041
       lcd_goto_menu(_lcd_level_goto_next_point, true);
1045
       lcd_goto_menu(_lcd_level_goto_next_point, true);
1042
     }
1046
     }
1043
   }
1047
   }

Loading…
Откажи
Сачувај