Browse Source

Move macros above Stepper::babystep

Scott Lahteine 7 years ago
parent
commit
b23d255491
1 changed files with 15 additions and 15 deletions
  1. 15
    15
      Marlin/stepper.cpp

+ 15
- 15
Marlin/stepper.cpp View File

@@ -1108,25 +1108,25 @@ void Stepper::report_positions() {
1108 1108
 
1109 1109
 #if ENABLED(BABYSTEPPING)
1110 1110
 
1111
+  #define _ENABLE(axis) enable_## axis()
1112
+  #define _READ_DIR(AXIS) AXIS ##_DIR_READ
1113
+  #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
1114
+  #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
1115
+
1116
+  #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
1117
+      _ENABLE(axis); \
1118
+      uint8_t old_pin = _READ_DIR(AXIS); \
1119
+      _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \
1120
+      _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \
1121
+      delayMicroseconds(2); \
1122
+      _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \
1123
+      _APPLY_DIR(AXIS, old_pin); \
1124
+    }
1125
+
1111 1126
   // MUST ONLY BE CALLED BY AN ISR,
1112 1127
   // No other ISR should ever interrupt this!
1113 1128
   void Stepper::babystep(const uint8_t axis, const bool direction) {
1114 1129
 
1115
-    #define _ENABLE(axis) enable_## axis()
1116
-    #define _READ_DIR(AXIS) AXIS ##_DIR_READ
1117
-    #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
1118
-    #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
1119
-
1120
-    #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
1121
-        _ENABLE(axis); \
1122
-        uint8_t old_pin = _READ_DIR(AXIS); \
1123
-        _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \
1124
-        _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \
1125
-        delayMicroseconds(2); \
1126
-        _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \
1127
-        _APPLY_DIR(AXIS, old_pin); \
1128
-      }
1129
-
1130 1130
     switch (axis) {
1131 1131
 
1132 1132
       case X_AXIS:

Loading…
Cancel
Save