Selaa lähdekoodia

Instead of trying to move now, set a flag to move asap

Scott Lahteine 8 vuotta sitten
vanhempi
commit
a3e25a0fca
2 muutettua tiedostoa jossa 39 lisäystä ja 9 poistoa
  1. 1
    1
      Marlin/Marlin.h
  2. 38
    8
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin.h Näytä tiedosto

@@ -213,7 +213,7 @@ void manage_inactivity(bool ignore_stepper_queue = false);
213 213
  * A_AXIS and B_AXIS are used by COREXY printers
214 214
  * X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
215 215
  */
216
-enum AxisEnum {X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, B_AXIS = 1, Z_AXIS = 2, C_AXIS = 2, E_AXIS = 3, X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 5};
216
+enum AxisEnum {NO_AXIS = -1, X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, B_AXIS = 1, Z_AXIS = 2, C_AXIS = 2, E_AXIS = 3, X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 5};
217 217
 
218 218
 #define _AXIS(AXIS) AXIS ##_AXIS
219 219
 

+ 38
- 8
Marlin/ultralcd.cpp Näytä tiedosto

@@ -50,6 +50,8 @@
50 50
 
51 51
 int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
52 52
 
53
+int8_t manual_move_axis = (int8_t)NO_AXIS;
54
+
53 55
 bool encoderRateMultiplierEnabled;
54 56
 int32_t lastEncoderMovementMillis;
55 57
 
@@ -938,7 +940,7 @@ void lcd_cooldown() {
938 940
     ENCODER_DIRECTION_NORMAL();
939 941
 
940 942
     // Encoder wheel adjusts the Z position
941
-    if (encoderPosition && planner.movesplanned() <= 3) {
943
+    if (encoderPosition) {
942 944
       refresh_cmd_timeout();
943 945
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
944 946
       NOLESS(current_position[Z_AXIS], 0);
@@ -951,8 +953,8 @@ void lcd_cooldown() {
951 953
           LCDVIEW_REDRAW_NOW
952 954
         #endif
953 955
       ;
956
+      encoderPosition = 0;
954 957
     }
955
-    encoderPosition = 0;
956 958
 
957 959
     static bool debounce_click = false;
958 960
     if (LCD_CLICKED) {
@@ -1191,6 +1193,32 @@ static void lcd_prepare_menu() {
1191 1193
 #endif // DELTA_CALIBRATION_MENU
1192 1194
 
1193 1195
 /**
1196
+ * If the manual move hasn't been fed to the planner yet,
1197
+ * and the planner can accept one, send immediately
1198
+ */
1199
+inline void manage_manual_move() {
1200
+  if (manual_move_axis != (int8_t)NO_AXIS && !planner.planner_is_full()) {
1201
+    #if ENABLED(DELTA)
1202
+      calculate_delta(current_position);
1203
+      planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, active_extruder);
1204
+    #else
1205
+      planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, active_extruder);
1206
+    #endif
1207
+    manual_move_axis = (int8_t)NO_AXIS;
1208
+  }
1209
+}
1210
+
1211
+/**
1212
+ * Set a flag that lcd_update() should send a move
1213
+ * to "current_position" at the next opportunity,
1214
+ * and try to send one now.
1215
+ */
1216
+inline void manual_move_to_current(AxisEnum axis) {
1217
+  manual_move_axis = (int8_t)axis;
1218
+  manage_manual_move();
1219
+}
1220
+
1221
+/**
1194 1222
  *
1195 1223
  * "Prepare" > "Move Axis" submenu
1196 1224
  *
@@ -1200,15 +1228,15 @@ float move_menu_scale;
1200 1228
 
1201 1229
 static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1202 1230
   ENCODER_DIRECTION_NORMAL();
1203
-  if (encoderPosition && planner.movesplanned() <= 3) {
1231
+  if (encoderPosition) {
1204 1232
     refresh_cmd_timeout();
1205 1233
     current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1206 1234
     if (min_software_endstops) NOLESS(current_position[axis], min);
1207 1235
     if (max_software_endstops) NOMORE(current_position[axis], max);
1208
-    line_to_current(axis);
1236
+    encoderPosition = 0;
1237
+    manual_move_to_current(axis);
1209 1238
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1210 1239
   }
1211
-  encoderPosition = 0;
1212 1240
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1213 1241
   if (LCD_CLICKED) lcd_goto_previous_menu(true);
1214 1242
 }
@@ -1232,12 +1260,12 @@ static void lcd_move_e(
1232 1260
     unsigned short original_active_extruder = active_extruder;
1233 1261
     active_extruder = e;
1234 1262
   #endif
1235
-  if (encoderPosition && planner.movesplanned() <= 3) {
1263
+  if (encoderPosition) {
1236 1264
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1237
-    line_to_current(E_AXIS);
1265
+    encoderPosition = 0;
1266
+    manual_move_to_current(E_AXIS);
1238 1267
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1239 1268
   }
1240
-  encoderPosition = 0;
1241 1269
   if (lcdDrawUpdate) {
1242 1270
     PGM_P pos_label;
1243 1271
     #if EXTRUDERS == 1
@@ -2149,6 +2177,8 @@ void lcd_update() {
2149 2177
     static millis_t return_to_status_ms = 0;
2150 2178
   #endif
2151 2179
 
2180
+  manage_manual_move();
2181
+
2152 2182
   lcd_buttons_update();
2153 2183
 
2154 2184
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)

Loading…
Peruuta
Tallenna