Преглед изворни кода

min_pos/max_pos => sw_endstop_min/sw_endstop_max

Scott Lahteine пре 9 година
родитељ
комит
78747b1328
3 измењених фајлова са 34 додато и 24 уклоњено
  1. 2
    2
      Marlin/Marlin.h
  2. 27
    17
      Marlin/Marlin_main.cpp
  3. 5
    5
      Marlin/ultralcd.cpp

+ 2
- 2
Marlin/Marlin.h Прегледај датотеку

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
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
 extern float current_position[NUM_AXIS];
276
 extern float current_position[NUM_AXIS];
277
 extern float home_offset[3]; // axis[n].home_offset
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
 extern bool axis_known_position[3]; // axis[n].is_known
280
 extern bool axis_known_position[3]; // axis[n].is_known
281
 extern bool axis_homed[3]; // axis[n].is_homed
281
 extern bool axis_homed[3]; // axis[n].is_homed
282
 
282
 

+ 27
- 17
Marlin/Marlin_main.cpp Прегледај датотеку

286
 
286
 
287
 float position_shift[3] = { 0 };
287
 float position_shift[3] = { 0 };
288
 float home_offset[3] = { 0 };
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
 #if FAN_COUNT > 0
294
 #if FAN_COUNT > 0
293
   int fanSpeeds[FAN_COUNT] = { 0 };
295
   int fanSpeeds[FAN_COUNT] = { 0 };
1212
     if (axis == X_AXIS) {
1214
     if (axis == X_AXIS) {
1213
       float dual_max_x = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
1215
       float dual_max_x = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
1214
       if (active_extruder != 0) {
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
         return;
1219
         return;
1218
       }
1220
       }
1219
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
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
         return;
1224
         return;
1223
       }
1225
       }
1224
     }
1226
     }
1225
     else
1227
     else
1226
   #endif
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
 static void set_home_offset(AxisEnum axis, float v) {
1243
 static void set_home_offset(AxisEnum axis, float v) {
1234
   current_position[axis] += v - home_offset[axis];
1244
   current_position[axis] += v - home_offset[axis];
1235
   home_offset[axis] = v;
1245
   home_offset[axis] = v;
1294
        * SCARA home positions are based on configuration since the actual
1304
        * SCARA home positions are based on configuration since the actual
1295
        * limits are determined by the inverse kinematic transform.
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
     else
1310
     else
1301
   #endif
1311
   #endif
5842
   bool err = false;
5852
   bool err = false;
5843
   for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
5853
   for (int8_t i = X_AXIS; i <= Z_AXIS; i++) {
5844
     if (axis_homed[i]) {
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
             diff = current_position[i] - base;
5856
             diff = current_position[i] - base;
5847
       if (diff > -20 && diff < 20) {
5857
       if (diff > -20 && diff < 20) {
5848
         set_home_offset((AxisEnum)i, home_offset[i] - diff);
5858
         set_home_offset((AxisEnum)i, home_offset[i] - diff);
7032
 
7042
 
7033
 void clamp_to_software_endstops(float target[3]) {
7043
 void clamp_to_software_endstops(float target[3]) {
7034
   if (min_software_endstops) {
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
     float negative_z_offset = 0;
7048
     float negative_z_offset = 0;
7039
     #if ENABLED(AUTO_BED_LEVELING_FEATURE)
7049
     #if ENABLED(AUTO_BED_LEVELING_FEATURE)
7048
         negative_z_offset += home_offset[Z_AXIS];
7058
         negative_z_offset += home_offset[Z_AXIS];
7049
       }
7059
       }
7050
     #endif
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
   if (max_software_endstops) {
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 Прегледај датотеку

1167
 #if ENABLED(DELTA)
1167
 #if ENABLED(DELTA)
1168
   static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1168
   static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1169
   static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a*a); }
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
 #else
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
 #endif
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
 static void lcd_move_e(
1177
 static void lcd_move_e(
1178
   #if EXTRUDERS > 1
1178
   #if EXTRUDERS > 1
1179
     uint8_t e
1179
     uint8_t e

Loading…
Откажи
Сачувај