Browse Source

Merge pull request #5155 from thinkyhead/rc_core_babystepping

BABYSTEPPING-oriented cleanup
Scott Lahteine 8 years ago
parent
commit
1614c9d207
6 changed files with 34 additions and 33 deletions
  1. 18
    18
      Marlin/stepper.cpp
  2. 1
    1
      Marlin/stepper.h
  3. 3
    3
      Marlin/temperature.cpp
  4. 1
    1
      Marlin/temperature.h
  5. 4
    8
      Marlin/ultralcd.cpp
  6. 7
    2
      Marlin/ultralcd.h

+ 18
- 18
Marlin/stepper.cpp View File

@@ -982,8 +982,8 @@ void Stepper::set_position(const long &a, const long &b, const long &c, const lo
982 982
   #elif ENABLED(COREYZ)
983 983
     // coreyz planning
984 984
     count_position[X_AXIS] = a;
985
-    count_position[B_AXIS] = y + c;
986
-    count_position[C_AXIS] = y - c;
985
+    count_position[B_AXIS] = b + c;
986
+    count_position[C_AXIS] = b - c;
987 987
   #else
988 988
     // default non-h-bot planning
989 989
     count_position[X_AXIS] = a;
@@ -1108,24 +1108,24 @@ 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
-  void Stepper::babystep(const uint8_t axis, const bool direction) {
1114
-
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
-      }
1128
+  void Stepper::babystep(const AxisEnum axis, const bool direction) {
1129 1129
 
1130 1130
     switch (axis) {
1131 1131
 

+ 1
- 1
Marlin/stepper.h View File

@@ -257,7 +257,7 @@ class Stepper {
257 257
     #endif
258 258
 
259 259
     #if ENABLED(BABYSTEPPING)
260
-      static void babystep(const uint8_t axis, const bool direction); // perform a short step with a single stepper motor, outside of any convention
260
+      static void babystep(const AxisEnum axis, const bool direction); // perform a short step with a single stepper motor, outside of any convention
261 261
     #endif
262 262
 
263 263
     static inline void kill_current_block() {

+ 3
- 3
Marlin/temperature.cpp View File

@@ -1916,15 +1916,15 @@ void Temperature::isr() {
1916 1916
   } // temp_count >= OVERSAMPLENR
1917 1917
 
1918 1918
   #if ENABLED(BABYSTEPPING)
1919
-    for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
1919
+    LOOP_XYZ(axis) {
1920 1920
       int curTodo = babystepsTodo[axis]; //get rid of volatile for performance
1921 1921
 
1922 1922
       if (curTodo > 0) {
1923
-        stepper.babystep(axis,/*fwd*/true);
1923
+        stepper.babystep((AxisEnum)axis,/*fwd*/true);
1924 1924
         babystepsTodo[axis]--; //fewer to do next time
1925 1925
       }
1926 1926
       else if (curTodo < 0) {
1927
-        stepper.babystep(axis,/*fwd*/false);
1927
+        stepper.babystep((AxisEnum)axis,/*fwd*/false);
1928 1928
         babystepsTodo[axis]++; //fewer to do next time
1929 1929
       }
1930 1930
     }

+ 1
- 1
Marlin/temperature.h View File

@@ -384,7 +384,7 @@ class Temperature {
384 384
 
385 385
     #if ENABLED(BABYSTEPPING)
386 386
 
387
-      static void babystep_axis(AxisEnum axis, int distance) {
387
+      static void babystep_axis(const AxisEnum axis, const int distance) {
388 388
         #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
389 389
           #if ENABLED(BABYSTEP_XY)
390 390
             switch (axis) {

+ 4
- 8
Marlin/ultralcd.cpp View File

@@ -651,7 +651,7 @@ void kill_screen(const char* lcd_msg) {
651 651
       if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); }
652 652
       ENCODER_DIRECTION_NORMAL();
653 653
       if (encoderPosition) {
654
-        int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
654
+        int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
655 655
         encoderPosition = 0;
656 656
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
657 657
         thermalManager.babystep_axis(axis, babystep_increment);
@@ -2982,13 +2982,9 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2982 2982
     lastEncoderBits = enc;
2983 2983
   }
2984 2984
 
2985
-  bool lcd_detected(void) {
2986
-    #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
2987
-      return lcd.LcdDetected() == 1;
2988
-    #else
2989
-      return true;
2990
-    #endif
2991
-  }
2985
+  #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
2986
+    bool lcd_detected() { return lcd.LcdDetected() == 1; }
2987
+  #endif
2992 2988
 
2993 2989
 #endif // ULTIPANEL
2994 2990
 

+ 7
- 2
Marlin/ultralcd.h View File

@@ -41,10 +41,15 @@
41 41
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
42 42
   void lcd_setalertstatuspgm(const char* message);
43 43
   void lcd_reset_alert_level();
44
-  bool lcd_detected(void);
45 44
   void lcd_kill_screen();
46 45
   void kill_screen(const char* lcd_msg);
47 46
 
47
+  #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
48
+    bool lcd_detected();
49
+  #else
50
+    inline bool lcd_detected() { return true; }
51
+  #endif
52
+
48 53
   #if HAS_BUZZER
49 54
     void lcd_buzz(long duration, uint16_t freq);
50 55
   #endif
@@ -155,7 +160,7 @@
155 160
   inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
156 161
   inline void lcd_buttons_update() {}
157 162
   inline void lcd_reset_alert_level() {}
158
-  inline bool lcd_detected(void) { return true; }
163
+  inline bool lcd_detected() { return true; }
159 164
 
160 165
   #define LCD_MESSAGEPGM(x) NOOP
161 166
   #define LCD_ALERTMESSAGEPGM(x) NOOP

Loading…
Cancel
Save