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)
// coreyz planning
count_position[X_AXIS] = a;
count_position[B_AXIS] = y + c;
count_position[C_AXIS] = y - c;
count_position[B_AXIS] = b + c;
count_position[C_AXIS] = b - c;
#else
// default non-h-bot planning
count_position[X_AXIS] = a;
@ -1108,24 +1108,24 @@ void Stepper::report_positions() {
#if ENABLED(BABYSTEPPING)
#define _ENABLE(axis) enable_## axis()
#define _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
#define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
#define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
_ENABLE(axis); \
uint8_t old_pin = _READ_DIR(AXIS); \
_APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \
_APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \
delayMicroseconds(2); \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \
_APPLY_DIR(AXIS, old_pin); \
}
// 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 _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
#define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
#define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
_ENABLE(axis); \
uint8_t old_pin = _READ_DIR(AXIS); \
_APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \
_APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \
delayMicroseconds(2); \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \
_APPLY_DIR(AXIS, old_pin); \
}
void Stepper::babystep(const AxisEnum axis, const bool direction) {
switch (axis) {

View file

@ -257,7 +257,7 @@ class Stepper {
#endif
#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
static inline void kill_current_block() {

View file

@ -1916,15 +1916,15 @@ void Temperature::isr() {
} // temp_count >= OVERSAMPLENR
#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
if (curTodo > 0) {
stepper.babystep(axis,/*fwd*/true);
stepper.babystep((AxisEnum)axis,/*fwd*/true);
babystepsTodo[axis]--; //fewer to do next time
}
else if (curTodo < 0) {
stepper.babystep(axis,/*fwd*/false);
stepper.babystep((AxisEnum)axis,/*fwd*/false);
babystepsTodo[axis]++; //fewer to do next time
}
}

View file

@ -384,7 +384,7 @@ class Temperature {
#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(BABYSTEP_XY)
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(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
thermalManager.babystep_axis(axis, babystep_increment);
@ -2982,13 +2982,9 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
lastEncoderBits = enc;
}
bool lcd_detected(void) {
#if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
return lcd.LcdDetected() == 1;
#else
return true;
#endif
}
#if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
bool lcd_detected() { return lcd.LcdDetected() == 1; }
#endif
#endif // ULTIPANEL

View file

@ -41,10 +41,15 @@
void lcd_setstatuspgm(const char* message, const uint8_t level=0);
void lcd_setalertstatuspgm(const char* message);
void lcd_reset_alert_level();
bool lcd_detected(void);
void lcd_kill_screen();
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
void lcd_buzz(long duration, uint16_t freq);
#endif
@ -155,7 +160,7 @@
inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
inline void lcd_buttons_update() {}
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_ALERTMESSAGEPGM(x) NOOP