瀏覽代碼

software_endstops: use *_MIN_POS and *_MAX_POS for arcs

If [XYZ]_HOME_POS and [XYZ]_MIN_POS aren't 0, these corrections are
wrong.  Use the same logic as in Marlin.pde:prepare_move: ie, clamp to
[XYZ]_{MIN,MAX}_POS.

While we're here, put this cut-and-paste code in a function
clamp_to_software_endstops.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Ian Jackson 13 年之前
父節點
當前提交
faccb35850
共有 3 個檔案被更改,包括 15 行新增18 行删除
  1. 1
    0
      Marlin/Marlin.h
  2. 13
    7
      Marlin/Marlin.pde
  3. 1
    11
      Marlin/motion_control.cpp

+ 1
- 0
Marlin/Marlin.h 查看文件

@@ -169,6 +169,7 @@ bool IsStopped();
169 169
 
170 170
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
171 171
 void prepare_arc_move(char isclockwise);
172
+void clamp_to_software_endstops(float target[3]);
172 173
 
173 174
 #ifdef FAST_PWM_FAN
174 175
 void setPwmFrequency(uint8_t pin, int val);

+ 13
- 7
Marlin/Marlin.pde 查看文件

@@ -1541,19 +1541,25 @@ void get_arc_coordinates()
1541 1541
    }
1542 1542
 }
1543 1543
 
1544
-void prepare_move()
1544
+void clamp_to_software_endstops(float target[3])
1545 1545
 {
1546 1546
   if (min_software_endstops) {
1547
-    if (destination[X_AXIS] < X_MIN_POS) destination[X_AXIS] = X_MIN_POS;
1548
-    if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS;
1549
-    if (destination[Z_AXIS] < Z_MIN_POS) destination[Z_AXIS] = Z_MIN_POS;
1547
+    if (target[X_AXIS] < X_MIN_POS) target[X_AXIS] = X_MIN_POS;
1548
+    if (target[Y_AXIS] < Y_MIN_POS) target[Y_AXIS] = Y_MIN_POS;
1549
+    if (target[Z_AXIS] < Z_MIN_POS) target[Z_AXIS] = Z_MIN_POS;
1550 1550
   }
1551 1551
 
1552 1552
   if (max_software_endstops) {
1553
-    if (destination[X_AXIS] > X_MAX_POS) destination[X_AXIS] = X_MAX_POS;
1554
-    if (destination[Y_AXIS] > Y_MAX_POS) destination[Y_AXIS] = Y_MAX_POS;
1555
-    if (destination[Z_AXIS] > Z_MAX_POS) destination[Z_AXIS] = Z_MAX_POS;
1553
+    if (target[X_AXIS] > X_MAX_POS) target[X_AXIS] = X_MAX_POS;
1554
+    if (target[Y_AXIS] > Y_MAX_POS) target[Y_AXIS] = Y_MAX_POS;
1555
+    if (target[Z_AXIS] > Z_MAX_POS) target[Z_AXIS] = Z_MAX_POS;
1556 1556
   }
1557
+}
1558
+
1559
+void prepare_move()
1560
+{
1561
+  clamp_to_software_endstops(destination);
1562
+
1557 1563
   previous_millis_cmd = millis();  
1558 1564
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1559 1565
   for(int8_t i=0; i < NUM_AXIS; i++) {

+ 1
- 11
Marlin/motion_control.cpp 查看文件

@@ -125,17 +125,7 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
125 125
     arc_target[axis_linear] += linear_per_segment;
126 126
     arc_target[E_AXIS] += extruder_per_segment;
127 127
 
128
-    if (min_software_endstops) {
129
-      if (arc_target[X_AXIS] < X_HOME_POS) arc_target[X_AXIS] = X_HOME_POS;
130
-      if (arc_target[Y_AXIS] < Y_HOME_POS) arc_target[Y_AXIS] = Y_HOME_POS;
131
-      if (arc_target[Z_AXIS] < Z_HOME_POS) arc_target[Z_AXIS] = Z_HOME_POS;
132
-    }
133
-
134
-    if (max_software_endstops) {
135
-      if (arc_target[X_AXIS] > X_MAX_LENGTH) arc_target[X_AXIS] = X_MAX_LENGTH;
136
-      if (arc_target[Y_AXIS] > Y_MAX_LENGTH) arc_target[Y_AXIS] = Y_MAX_LENGTH;
137
-      if (arc_target[Z_AXIS] > Z_MAX_LENGTH) arc_target[Z_AXIS] = Z_MAX_LENGTH;
138
-    }
128
+    clamp_to_software_endstops(arc_target);
139 129
     plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
140 130
     
141 131
   }

Loading…
取消
儲存