Browse Source

Apply sw_endstops_enabled to manual move

Scott Lahteine 8 years ago
parent
commit
e354cf5884
1 changed files with 26 additions and 14 deletions
  1. 26
    14
      Marlin/ultralcd.cpp

+ 26
- 14
Marlin/ultralcd.cpp View File

@@ -1327,30 +1327,42 @@ void kill_screen(const char* lcd_msg) {
1327 1327
    *
1328 1328
    */
1329 1329
 
1330
-  static void _lcd_move_xyz(const char* name, AxisEnum axis, float min, float max) {
1330
+  static void _lcd_move_xyz(const char* name, AxisEnum axis) {
1331 1331
     if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1332 1332
     ENCODER_DIRECTION_NORMAL();
1333 1333
     if (encoderPosition) {
1334 1334
       refresh_cmd_timeout();
1335
+
1336
+      // Limit to software endstops, if enabled
1337
+      float min = (soft_endstops_enabled && min_software_endstops) ? soft_endstop_min[axis] : current_position[axis] - 1000,
1338
+            max = (soft_endstops_enabled && max_software_endstops) ? soft_endstop_max[axis] : current_position[axis] + 1000;
1339
+
1340
+      // Get the new position
1335 1341
       current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;
1336
-      if (min_software_endstops) NOLESS(current_position[axis], min);
1337
-      if (max_software_endstops) NOMORE(current_position[axis], max);
1338
-      encoderPosition = 0;
1342
+
1343
+      // Delta limits XY based on the current offset from center
1344
+      // This assumes the center is 0,0
1345
+      #if ENABLED(DELTA)
1346
+        if (axis != Z_AXIS) {
1347
+          max = sqrt(sq(DELTA_PRINTABLE_RADIUS) - sq(current_position[Y_AXIS - axis]));
1348
+          min = -max;
1349
+        }
1350
+      #endif
1351
+
1352
+      // Limit only when trying to move towards the limit
1353
+      if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min);
1354
+      if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);
1355
+
1339 1356
       manual_move_to_current(axis);
1357
+
1358
+      encoderPosition = 0;
1340 1359
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1341 1360
     }
1342 1361
     if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis]));
1343 1362
   }
1344
-  #if ENABLED(DELTA)
1345
-    static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1346
-    static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - sq(a)); }
1347
-    static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS, max(sw_endstop_min[X_AXIS], -clip), min(sw_endstop_max[X_AXIS], clip)); }
1348
-    static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS, max(sw_endstop_min[Y_AXIS], -clip), min(sw_endstop_max[Y_AXIS], clip)); }
1349
-  #else
1350
-    static void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS, sw_endstop_min[X_AXIS], sw_endstop_max[X_AXIS]); }
1351
-    static void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS, sw_endstop_min[Y_AXIS], sw_endstop_max[Y_AXIS]); }
1352
-  #endif
1353
-  static void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS, sw_endstop_min[Z_AXIS], sw_endstop_max[Z_AXIS]); }
1363
+  static void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
1364
+  static void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); }
1365
+  static void lcd_move_z() { _lcd_move_xyz(PSTR(MSG_MOVE_Z), Z_AXIS); }
1354 1366
   static void _lcd_move_e(
1355 1367
     #if E_MANUAL > 1
1356 1368
       int8_t eindex=-1

Loading…
Cancel
Save