Browse Source

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

Scott Lahteine 8 years ago
parent
commit
a3e25a0fca
2 changed files with 39 additions and 9 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 38
    8
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin.h View File

213
  * A_AXIS and B_AXIS are used by COREXY printers
213
  * A_AXIS and B_AXIS are used by COREXY printers
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.
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
 #define _AXIS(AXIS) AXIS ##_AXIS
218
 #define _AXIS(AXIS) AXIS ##_AXIS
219
 
219
 

+ 38
- 8
Marlin/ultralcd.cpp View File

50
 
50
 
51
 int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
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
 bool encoderRateMultiplierEnabled;
55
 bool encoderRateMultiplierEnabled;
54
 int32_t lastEncoderMovementMillis;
56
 int32_t lastEncoderMovementMillis;
55
 
57
 
938
     ENCODER_DIRECTION_NORMAL();
940
     ENCODER_DIRECTION_NORMAL();
939
 
941
 
940
     // Encoder wheel adjusts the Z position
942
     // Encoder wheel adjusts the Z position
941
-    if (encoderPosition && planner.movesplanned() <= 3) {
943
+    if (encoderPosition) {
942
       refresh_cmd_timeout();
944
       refresh_cmd_timeout();
943
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
945
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
944
       NOLESS(current_position[Z_AXIS], 0);
946
       NOLESS(current_position[Z_AXIS], 0);
951
           LCDVIEW_REDRAW_NOW
953
           LCDVIEW_REDRAW_NOW
952
         #endif
954
         #endif
953
       ;
955
       ;
956
+      encoderPosition = 0;
954
     }
957
     }
955
-    encoderPosition = 0;
956
 
958
 
957
     static bool debounce_click = false;
959
     static bool debounce_click = false;
958
     if (LCD_CLICKED) {
960
     if (LCD_CLICKED) {
1191
 #endif // DELTA_CALIBRATION_MENU
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
  * "Prepare" > "Move Axis" submenu
1223
  * "Prepare" > "Move Axis" submenu
1196
  *
1224
  *
1200
 
1228
 
1201
 static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1229
 static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1202
   ENCODER_DIRECTION_NORMAL();
1230
   ENCODER_DIRECTION_NORMAL();
1203
-  if (encoderPosition && planner.movesplanned() <= 3) {
1231
+  if (encoderPosition) {
1204
     refresh_cmd_timeout();
1232
     refresh_cmd_timeout();
1205
     current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1233
     current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1206
     if (min_software_endstops) NOLESS(current_position[axis], min);
1234
     if (min_software_endstops) NOLESS(current_position[axis], min);
1207
     if (max_software_endstops) NOMORE(current_position[axis], max);
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
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1238
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1210
   }
1239
   }
1211
-  encoderPosition = 0;
1212
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1240
   if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
1213
   if (LCD_CLICKED) lcd_goto_previous_menu(true);
1241
   if (LCD_CLICKED) lcd_goto_previous_menu(true);
1214
 }
1242
 }
1232
     unsigned short original_active_extruder = active_extruder;
1260
     unsigned short original_active_extruder = active_extruder;
1233
     active_extruder = e;
1261
     active_extruder = e;
1234
   #endif
1262
   #endif
1235
-  if (encoderPosition && planner.movesplanned() <= 3) {
1263
+  if (encoderPosition) {
1236
     current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
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
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1267
     lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1239
   }
1268
   }
1240
-  encoderPosition = 0;
1241
   if (lcdDrawUpdate) {
1269
   if (lcdDrawUpdate) {
1242
     PGM_P pos_label;
1270
     PGM_P pos_label;
1243
     #if EXTRUDERS == 1
1271
     #if EXTRUDERS == 1
2149
     static millis_t return_to_status_ms = 0;
2177
     static millis_t return_to_status_ms = 0;
2150
   #endif
2178
   #endif
2151
 
2179
 
2180
+  manage_manual_move();
2181
+
2152
   lcd_buttons_update();
2182
   lcd_buttons_update();
2153
 
2183
 
2154
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
2184
   #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)

Loading…
Cancel
Save