Prevent re-entrant call of Reprapworld Keypad handler

This commit is contained in:
Scott Lahteine 2016-06-04 01:10:51 -07:00
parent 6abf916575
commit eaa6f568ee
2 changed files with 36 additions and 14 deletions

View file

@ -2584,22 +2584,33 @@ void lcd_update() {
#if ENABLED(REPRAPWORLD_KEYPAD)
#if ENABLED(DELTA) || ENABLED(SCARA)
#define _KEYPAD_MOVE_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
#else
#define _KEYPAD_MOVE_ALLOWED true
#endif
static uint8_t keypad_debounce = 0;
if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
if (_KEYPAD_MOVE_ALLOWED) {
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down();
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left();
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right();
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down();
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up();
if (!REPRAPWORLD_KEYPAD_PRESSED) {
if (keypad_debounce > 0) keypad_debounce--;
}
#endif
else if (!keypad_debounce) {
keypad_debounce = 2;
#if DISABLED(DELTA) && Z_HOME_DIR == -1
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
#endif
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
#if ENABLED(DELTA) || Z_HOME_DIR != -1
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
#endif
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down();
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left();
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right();
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down();
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up();
}
else {
if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
}
}
#endif // REPRAPWORLD_KEYPAD
bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
if (encoderPastThreshold || LCD_CLICKED) {

View file

@ -123,6 +123,17 @@
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
#define REPRAPWORLD_KEYPAD_PRESSED (buttons_reprapworld_keypad & ( \
EN_REPRAPWORLD_KEYPAD_F3 | \
EN_REPRAPWORLD_KEYPAD_F2 | \
EN_REPRAPWORLD_KEYPAD_F1 | \
EN_REPRAPWORLD_KEYPAD_DOWN | \
EN_REPRAPWORLD_KEYPAD_RIGHT | \
EN_REPRAPWORLD_KEYPAD_MIDDLE | \
EN_REPRAPWORLD_KEYPAD_UP | \
EN_REPRAPWORLD_KEYPAD_LEFT) \
)
#endif // REPRAPWORLD_KEYPAD
#if ENABLED(NEWPANEL)