瀏覽代碼

Merge pull request #5155 from thinkyhead/rc_core_babystepping

BABYSTEPPING-oriented cleanup
Scott Lahteine 8 年之前
父節點
當前提交
1614c9d207
共有 6 個文件被更改,包括 34 次插入33 次删除
  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 查看文件

982
   #elif ENABLED(COREYZ)
982
   #elif ENABLED(COREYZ)
983
     // coreyz planning
983
     // coreyz planning
984
     count_position[X_AXIS] = a;
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
   #else
987
   #else
988
     // default non-h-bot planning
988
     // default non-h-bot planning
989
     count_position[X_AXIS] = a;
989
     count_position[X_AXIS] = a;
1108
 
1108
 
1109
 #if ENABLED(BABYSTEPPING)
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
   // MUST ONLY BE CALLED BY AN ISR,
1126
   // MUST ONLY BE CALLED BY AN ISR,
1112
   // No other ISR should ever interrupt this!
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
     switch (axis) {
1130
     switch (axis) {
1131
 
1131
 

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

257
     #endif
257
     #endif
258
 
258
 
259
     #if ENABLED(BABYSTEPPING)
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
     #endif
261
     #endif
262
 
262
 
263
     static inline void kill_current_block() {
263
     static inline void kill_current_block() {

+ 3
- 3
Marlin/temperature.cpp 查看文件

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

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

384
 
384
 
385
     #if ENABLED(BABYSTEPPING)
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
         #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
388
         #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
389
           #if ENABLED(BABYSTEP_XY)
389
           #if ENABLED(BABYSTEP_XY)
390
             switch (axis) {
390
             switch (axis) {

+ 4
- 8
Marlin/ultralcd.cpp 查看文件

651
       if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); }
651
       if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); }
652
       ENCODER_DIRECTION_NORMAL();
652
       ENCODER_DIRECTION_NORMAL();
653
       if (encoderPosition) {
653
       if (encoderPosition) {
654
-        int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
654
+        int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
655
         encoderPosition = 0;
655
         encoderPosition = 0;
656
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
656
         lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
657
         thermalManager.babystep_axis(axis, babystep_increment);
657
         thermalManager.babystep_axis(axis, babystep_increment);
2982
     lastEncoderBits = enc;
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
 #endif // ULTIPANEL
2989
 #endif // ULTIPANEL
2994
 
2990
 

+ 7
- 2
Marlin/ultralcd.h 查看文件

41
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
41
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
42
   void lcd_setalertstatuspgm(const char* message);
42
   void lcd_setalertstatuspgm(const char* message);
43
   void lcd_reset_alert_level();
43
   void lcd_reset_alert_level();
44
-  bool lcd_detected(void);
45
   void lcd_kill_screen();
44
   void lcd_kill_screen();
46
   void kill_screen(const char* lcd_msg);
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
   #if HAS_BUZZER
53
   #if HAS_BUZZER
49
     void lcd_buzz(long duration, uint16_t freq);
54
     void lcd_buzz(long duration, uint16_t freq);
50
   #endif
55
   #endif
155
   inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
160
   inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
156
   inline void lcd_buttons_update() {}
161
   inline void lcd_buttons_update() {}
157
   inline void lcd_reset_alert_level() {}
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
   #define LCD_MESSAGEPGM(x) NOOP
165
   #define LCD_MESSAGEPGM(x) NOOP
161
   #define LCD_ALERTMESSAGEPGM(x) NOOP
166
   #define LCD_ALERTMESSAGEPGM(x) NOOP

Loading…
取消
儲存