Browse Source

min_pos/max_pos => sw_endstop_min/sw_endstop_max

Scott Lahteine 8 years ago
parent
commit
78747b1328
3 changed files with 34 additions and 24 deletions
  1. 2
    2
      Marlin/Marlin.h
  2. 27
    17
      Marlin/Marlin_main.cpp
  3. 5
    5
      Marlin/ultralcd.cpp

+ 2
- 2
Marlin/Marlin.h View File

@@ -275,8 +275,8 @@ extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in m
275 275
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
276 276
 extern float current_position[NUM_AXIS];
277 277
 extern float home_offset[3]; // axis[n].home_offset
278
-extern float min_pos[3]; // axis[n].min_pos
279
-extern float max_pos[3]; // axis[n].max_pos
278
+extern float sw_endstop_min[3]; // axis[n].sw_endstop_min
279
+extern float sw_endstop_max[3]; // axis[n].sw_endstop_max
280 280
 extern bool axis_known_position[3]; // axis[n].is_known
281 281
 extern bool axis_homed[3]; // axis[n].is_homed
282 282
 

+ 27
- 17
Marlin/Marlin_main.cpp View File

@@ -286,8 +286,10 @@ float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0);
286 286
 
287 287
 float position_shift[3] = { 0 };
288 288
 float home_offset[3] = { 0 };
289
-float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
290
-float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
289
+
290
+// Software Endstops. Default to configured limits.
291
+float sw_endstop_min[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
292
+float sw_endstop_max[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
291 293
 
292 294
 #if FAN_COUNT > 0
293 295
   int fanSpeeds[FAN_COUNT] = { 0 };
@@ -1212,24 +1214,32 @@ static void update_software_endstops(AxisEnum axis) {
1212 1214
     if (axis == X_AXIS) {
1213 1215
       float dual_max_x = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
1214 1216
       if (active_extruder != 0) {
1215
-        min_pos[X_AXIS] = X2_MIN_POS + offs;
1216
-        max_pos[X_AXIS] = dual_max_x + offs;
1217
+        sw_endstop_min[X_AXIS] = X2_MIN_POS + offs;
1218
+        sw_endstop_max[X_AXIS] = dual_max_x + offs;
1217 1219
         return;
1218 1220
       }
1219 1221
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
1220
-        min_pos[X_AXIS] = base_min_pos(X_AXIS) + offs;
1221
-        max_pos[X_AXIS] = min(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset) + offs;
1222
+        sw_endstop_min[X_AXIS] = base_min_pos(X_AXIS) + offs;
1223
+        sw_endstop_max[X_AXIS] = min(base_max_pos(X_AXIS), dual_max_x - duplicate_extruder_x_offset) + offs;
1222 1224
         return;
1223 1225
       }
1224 1226
     }
1225 1227
     else
1226 1228
   #endif
1227 1229
   {
1228
-    min_pos[axis] = base_min_pos(axis) + offs;
1229
-    max_pos[axis] = base_max_pos(axis) + offs;
1230
+    sw_endstop_min[axis] = base_min_pos(axis) + offs;
1231
+    sw_endstop_max[axis] = base_max_pos(axis) + offs;
1230 1232
   }
1231 1233
 }
1232 1234
 
1235
+/**
1236
+ * Change the home offset for an axis, update the current
1237
+ * position and the software endstops to retain the same
1238
+ * relative distance to the new home.
1239
+ *
1240
+ * Since this changes the current_position, code should
1241
+ * call sync_plan_position soon after this.
1242
+ */
1233 1243
 static void set_home_offset(AxisEnum axis, float v) {
1234 1244
   current_position[axis] += v - home_offset[axis];
1235 1245
   home_offset[axis] = v;
@@ -1294,8 +1304,8 @@ static void set_axis_is_at_home(AxisEnum axis) {
1294 1304
        * SCARA home positions are based on configuration since the actual
1295 1305
        * limits are determined by the inverse kinematic transform.
1296 1306
        */
1297
-      min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
1298
-      max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
1307
+      sw_endstop_min[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis));
1308
+      sw_endstop_max[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis));
1299 1309
     }
1300 1310
     else
1301 1311
   #endif
@@ -5842,7 +5852,7 @@ inline void gcode_M428() {
5842 5852
   bool err = false;
5843 5853
   for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
5844 5854
     if (axis_homed[i]) {
5845
-      float base = (current_position[i] > (min_pos[i] + max_pos[i]) / 2) ? base_home_pos(i) : 0,
5855
+      float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
5846 5856
             diff = current_position[i] - base;
5847 5857
       if (diff > -20 && diff < 20) {
5848 5858
         set_home_offset((AxisEnum)i, home_offset[i] - diff);
@@ -7032,8 +7042,8 @@ void ok_to_send() {
7032 7042
 
7033 7043
 void clamp_to_software_endstops(float target[3]) {
7034 7044
   if (min_software_endstops) {
7035
-    NOLESS(target[X_AXIS], min_pos[X_AXIS]);
7036
-    NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
7045
+    NOLESS(target[X_AXIS], sw_endstop_min[X_AXIS]);
7046
+    NOLESS(target[Y_AXIS], sw_endstop_min[Y_AXIS]);
7037 7047
 
7038 7048
     float negative_z_offset = 0;
7039 7049
     #if ENABLED(AUTO_BED_LEVELING_FEATURE)
@@ -7048,13 +7058,13 @@ void clamp_to_software_endstops(float target[3]) {
7048 7058
         negative_z_offset += home_offset[Z_AXIS];
7049 7059
       }
7050 7060
     #endif
7051
-    NOLESS(target[Z_AXIS], min_pos[Z_AXIS] + negative_z_offset);
7061
+    NOLESS(target[Z_AXIS], sw_endstop_min[Z_AXIS] + negative_z_offset);
7052 7062
   }
7053 7063
 
7054 7064
   if (max_software_endstops) {
7055
-    NOMORE(target[X_AXIS], max_pos[X_AXIS]);
7056
-    NOMORE(target[Y_AXIS], max_pos[Y_AXIS]);
7057
-    NOMORE(target[Z_AXIS], max_pos[Z_AXIS]);
7065
+    NOMORE(target[X_AXIS], sw_endstop_max[X_AXIS]);
7066
+    NOMORE(target[Y_AXIS], sw_endstop_max[Y_AXIS]);
7067
+    NOMORE(target[Z_AXIS], sw_endstop_max[Z_AXIS]);
7058 7068
   }
7059 7069
 }
7060 7070
 

+ 5
- 5
Marlin/ultralcd.cpp View File

@@ -1167,13 +1167,13 @@ static void _lcd_move(const char* name, AxisEnum axis, float min, float max) {
1167 1167
 #if ENABLED(DELTA)
1168 1168
   static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1169 1169
   static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a*a); }
1170
-  static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(min_pos[X_AXIS], -clip), min(max_pos[X_AXIS], clip)); }
1171
-  static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, max(min_pos[Y_AXIS], -clip), min(max_pos[Y_AXIS], clip)); }
1170
+  static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(sw_endstop_min[X_AXIS], -clip), min(sw_endstop_max[X_AXIS], clip)); }
1171
+  static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, max(sw_endstop_min[Y_AXIS], -clip), min(sw_endstop_max[Y_AXIS], clip)); }
1172 1172
 #else
1173
-  static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, min_pos[X_AXIS], max_pos[X_AXIS]); }
1174
-  static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, min_pos[Y_AXIS], max_pos[Y_AXIS]); }
1173
+  static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, sw_endstop_min[X_AXIS], sw_endstop_max[X_AXIS]); }
1174
+  static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, sw_endstop_min[Y_AXIS], sw_endstop_max[Y_AXIS]); }
1175 1175
 #endif
1176
-static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, min_pos[Z_AXIS], max_pos[Z_AXIS]); }
1176
+static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, sw_endstop_min[Z_AXIS], sw_endstop_max[Z_AXIS]); }
1177 1177
 static void lcd_move_e(
1178 1178
   #if EXTRUDERS > 1
1179 1179
     uint8_t e

Loading…
Cancel
Save