Merge pull request #5155 from thinkyhead/rc_core_babystepping

BABYSTEPPING-oriented cleanup
This commit is contained in:
Scott Lahteine 2016-11-03 23:46:04 -05:00 committed by GitHub
commit 1614c9d207
6 changed files with 34 additions and 33 deletions

View File

@ -982,8 +982,8 @@ void Stepper::set_position(const long &a, const long &b, const long &c, const lo
#elif ENABLED(COREYZ) #elif ENABLED(COREYZ)
// coreyz planning // coreyz planning
count_position[X_AXIS] = a; count_position[X_AXIS] = a;
count_position[B_AXIS] = y + c; count_position[B_AXIS] = b + c;
count_position[C_AXIS] = y - c; count_position[C_AXIS] = b - c;
#else #else
// default non-h-bot planning // default non-h-bot planning
count_position[X_AXIS] = a; count_position[X_AXIS] = a;
@ -1108,10 +1108,6 @@ void Stepper::report_positions() {
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
// MUST ONLY BE CALLED BY AN ISR,
// No other ISR should ever interrupt this!
void Stepper::babystep(const uint8_t axis, const bool direction) {
#define _ENABLE(axis) enable_## axis() #define _ENABLE(axis) enable_## axis()
#define _READ_DIR(AXIS) AXIS ##_DIR_READ #define _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
@ -1127,6 +1123,10 @@ void Stepper::report_positions() {
_APPLY_DIR(AXIS, old_pin); \ _APPLY_DIR(AXIS, old_pin); \
} }
// MUST ONLY BE CALLED BY AN ISR,
// No other ISR should ever interrupt this!
void Stepper::babystep(const AxisEnum axis, const bool direction) {
switch (axis) { switch (axis) {
case X_AXIS: case X_AXIS:

View File

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

View File

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

View File

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

View File

@ -651,7 +651,7 @@ void kill_screen(const char* lcd_msg) {
if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); } if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR; int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
thermalManager.babystep_axis(axis, babystep_increment); thermalManager.babystep_axis(axis, babystep_increment);
@ -2982,13 +2982,9 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
lastEncoderBits = enc; lastEncoderBits = enc;
} }
bool lcd_detected(void) {
#if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE) #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
return lcd.LcdDetected() == 1; bool lcd_detected() { return lcd.LcdDetected() == 1; }
#else
return true;
#endif #endif
}
#endif // ULTIPANEL #endif // ULTIPANEL

View File

@ -41,10 +41,15 @@
void lcd_setstatuspgm(const char* message, const uint8_t level=0); void lcd_setstatuspgm(const char* message, const uint8_t level=0);
void lcd_setalertstatuspgm(const char* message); void lcd_setalertstatuspgm(const char* message);
void lcd_reset_alert_level(); void lcd_reset_alert_level();
bool lcd_detected(void);
void lcd_kill_screen(); void lcd_kill_screen();
void kill_screen(const char* lcd_msg); void kill_screen(const char* lcd_msg);
#if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
bool lcd_detected();
#else
inline bool lcd_detected() { return true; }
#endif
#if HAS_BUZZER #if HAS_BUZZER
void lcd_buzz(long duration, uint16_t freq); void lcd_buzz(long duration, uint16_t freq);
#endif #endif
@ -155,7 +160,7 @@
inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); } inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
inline void lcd_buttons_update() {} inline void lcd_buttons_update() {}
inline void lcd_reset_alert_level() {} inline void lcd_reset_alert_level() {}
inline bool lcd_detected(void) { return true; } inline bool lcd_detected() { return true; }
#define LCD_MESSAGEPGM(x) NOOP #define LCD_MESSAGEPGM(x) NOOP
#define LCD_ALERTMESSAGEPGM(x) NOOP #define LCD_ALERTMESSAGEPGM(x) NOOP