Browse Source

Merge pull request #3110 from thinkyhead/rc_manual_moves

Alternative impl. of LCD-based manual movement
Scott Lahteine 8 years ago
parent
commit
4b3d5aec7a
3 changed files with 41 additions and 9 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 2
    0
      Marlin/planner.h
  3. 38
    8
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin.h View File

@@ -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
 

+ 2
- 0
Marlin/planner.h View File

@@ -189,6 +189,8 @@ class Planner {
189 189
      */
190 190
     static uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
191 191
 
192
+    static bool is_full() { return (block_buffer_tail == BLOCK_MOD(block_buffer_head + 1)); }
193
+
192 194
     #if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(MESH_BED_LEVELING)
193 195
 
194 196
       #if ENABLED(AUTO_BED_LEVELING_FEATURE)

+ 38
- 8
Marlin/ultralcd.cpp View File

@@ -50,6 +50,9 @@
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
+millis_t manual_move_start_time = 0;
55
+
53 56
 bool encoderRateMultiplierEnabled;
54 57
 int32_t lastEncoderMovementMillis;
55 58
 
@@ -938,7 +941,7 @@ void lcd_cooldown() {
938 941
     ENCODER_DIRECTION_NORMAL();
939 942
 
940 943
     // Encoder wheel adjusts the Z position
941
-    if (encoderPosition && planner.movesplanned() <= 3) {
944
+    if (encoderPosition) {
942 945
       refresh_cmd_timeout();
943 946
       current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
944 947
       NOLESS(current_position[Z_AXIS], 0);
@@ -951,8 +954,8 @@ void lcd_cooldown() {
951 954
           LCDVIEW_REDRAW_NOW
952 955
         #endif
953 956
       ;
957
+      encoderPosition = 0;
954 958
     }
955
-    encoderPosition = 0;
956 959
 
957 960
     static bool debounce_click = false;
958 961
     if (LCD_CLICKED) {
@@ -1191,6 +1194,31 @@ static void lcd_prepare_menu() {
1191 1194
 #endif // DELTA_CALIBRATION_MENU
1192 1195
 
1193 1196
 /**
1197
+ * If the most recent manual move hasn't been fed to the planner yet,
1198
+ * and the planner can accept one, send immediately
1199
+ */
1200
+inline void manage_manual_move() {
1201
+  if (manual_move_axis != (int8_t)NO_AXIS && millis() >= manual_move_start_time && !planner.is_full()) {
1202
+    #if ENABLED(DELTA)
1203
+      calculate_delta(current_position);
1204
+      planner.buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[manual_move_axis]/60, active_extruder);
1205
+    #else
1206
+      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);
1207
+    #endif
1208
+    manual_move_axis = (int8_t)NO_AXIS;
1209
+  }
1210
+}
1211
+
1212
+/**
1213
+ * Set a flag that lcd_update() should start a move
1214
+ * to "current_position" after a short delay.
1215
+ */
1216
+inline void manual_move_to_current(AxisEnum axis) {
1217
+  manual_move_start_time = millis() + 500UL; // 1/2 second delay
1218
+  manual_move_axis = (int8_t)axis;
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…
Cancel
Save