瀏覽代碼

Encapsulate setting of homing_bump_feedrate

Scott Lahteine 10 年之前
父節點
當前提交
c379f17117
共有 1 個文件被更改,包括 12 次插入14 次删除
  1. 12
    14
      Marlin/Marlin_main.cpp

+ 12
- 14
Marlin/Marlin_main.cpp 查看文件

203
 #endif
203
 #endif
204
 
204
 
205
 float homing_feedrate[] = HOMING_FEEDRATE;
205
 float homing_feedrate[] = HOMING_FEEDRATE;
206
-int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
207
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
206
 bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
208
 int feedmultiply = 100; //100->1 200->2
207
 int feedmultiply = 100; //100->1 200->2
209
 int saved_feedmultiply;
208
 int saved_feedmultiply;
989
 /**
988
 /**
990
  * Some planner shorthand inline functions
989
  * Some planner shorthand inline functions
991
  */
990
  */
991
+inline void set_homing_bump_feedrate(AxisEnum axis) {
992
+  const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
993
+  if (homing_bump_divisor[axis] >= 1)
994
+    feedrate = homing_feedrate[axis] / homing_bump_divisor[axis];
995
+  else {
996
+    feedrate = homing_feedrate[axis] / 10;
997
+    SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less than 1");
998
+  }
999
+}
992
 inline void line_to_current_position() {
1000
 inline void line_to_current_position() {
993
   plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
1001
   plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
994
 }
1002
 }
1119
       endstops_hit_on_purpose(); // clear endstop hit flags
1127
       endstops_hit_on_purpose(); // clear endstop hit flags
1120
 
1128
 
1121
       // move back down slowly to find bed
1129
       // move back down slowly to find bed
1122
-      if (homing_bump_divisor[Z_AXIS] >= 1)
1123
-        feedrate = homing_feedrate[Z_AXIS] / homing_bump_divisor[Z_AXIS];
1124
-      else {
1125
-        feedrate = homing_feedrate[Z_AXIS] / 10;
1126
-        SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less than 1");
1127
-      }
1130
+      set_homing_bump_feedrate(Z_AXIS);
1128
 
1131
 
1129
       zPosition -= home_bump_mm(Z_AXIS) * 2;
1132
       zPosition -= home_bump_mm(Z_AXIS) * 2;
1130
       line_to_z(zPosition);
1133
       line_to_z(zPosition);
1437
 
1440
 
1438
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
1441
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
1439
 
1442
 
1440
-static void homeaxis(int axis) {
1443
+static void homeaxis(AxisEnum axis) {
1441
   #define HOMEAXIS_DO(LETTER) \
1444
   #define HOMEAXIS_DO(LETTER) \
1442
     ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
1445
     ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
1443
 
1446
 
1488
     st_synchronize();
1491
     st_synchronize();
1489
 
1492
 
1490
     // Slow down the feedrate for the next move
1493
     // Slow down the feedrate for the next move
1491
-    if (homing_bump_divisor[axis] >= 1)
1492
-      feedrate = homing_feedrate[axis] / homing_bump_divisor[axis];
1493
-    else {
1494
-      feedrate = homing_feedrate[axis] / 10;
1495
-      SERIAL_ECHOLNPGM("Warning: The Homing Bump Feedrate Divisor cannot be less than 1");
1496
-    }
1494
+    set_homing_bump_feedrate(axis);
1497
 
1495
 
1498
     // Move slowly towards the endstop until triggered
1496
     // Move slowly towards the endstop until triggered
1499
     destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;
1497
     destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir;

Loading…
取消
儲存