Fix keypad-related compile error (#12306)

This commit is contained in:
Ludy 2018-11-03 04:29:32 +01:00 committed by Scott Lahteine
parent 2fb2e286ee
commit 5ba6607181
5 changed files with 66 additions and 100 deletions

View file

@ -39,7 +39,7 @@ void GcodeSuite::M906() {
bool report = true;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3)
const uint8_t index = parser.byteval('I');
const uint8_t index = parser.byteval('I');
#endif
LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) {

View file

@ -44,9 +44,9 @@
#elif ENABLED(ZONESTAR_LCD)
#define ADC_KEYPAD
#define REPRAPWORLD_KEYPAD
#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0
#define ADC_KEYPAD
#define ADC_KEY_NUM 8
#define ULTIPANEL

View file

@ -224,26 +224,6 @@ bool lcd_blink() {
volatile uint8_t buttons_reprapworld_keypad;
#endif
#if ENABLED(REPRAPWORLD_KEYPAD) || ENABLED(ADC_KEYPAD)
#define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
#endif // REPRAPWORLD_KEYPAD || ADC_KEYPAD
#if ENABLED(ADC_KEYPAD)
inline bool handle_adc_keypad() {
@ -251,22 +231,15 @@ bool lcd_blink() {
if (buttons_reprapworld_keypad) {
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
if (encoderDirection == -1) { // side effect which signals we are inside a menu
if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT) { menu_action_back(); lcd_quick_feedback(true); }
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) { lcd_return_to_status(); lcd_quick_feedback(true); }
if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { menu_action_back(); lcd_quick_feedback(true); }
else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) { lcd_return_to_status(); lcd_quick_feedback(true); }
}
else {
if (buttons_reprapworld_keypad & (EN_REPRAPWORLD_KEYPAD_DOWN|EN_REPRAPWORLD_KEYPAD_UP|EN_REPRAPWORLD_KEYPAD_RIGHT)) {
if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0;
}
}
#if ENABLED(ADC_KEYPAD_DEBUG)
SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
#endif
else if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition += ENCODER_PULSES_PER_STEP;
else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition -= ENCODER_PULSES_PER_STEP;
else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) encoderPosition = 0;
next_button_update_ms = millis() + ADC_MIN_KEY_DELAY;
return true;
}
@ -276,34 +249,6 @@ bool lcd_blink() {
#elif ENABLED(REPRAPWORLD_KEYPAD)
#define KEYPAD_HOME EN_REPRAPWORLD_KEYPAD_F1
#define KEYPAD_EN_C EN_REPRAPWORLD_KEYPAD_MIDDLE
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
#define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F2)
#define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F3)
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
#define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
#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_MOVE_HOME (buttons_reprapworld_keypad & KEYPAD_HOME)
#define REPRAPWORLD_KEYPAD_MOVE_MENU (buttons_reprapworld_keypad & KEYPAD_EN_C)
#define REPRAPWORLD_KEYPAD_PRESSED (buttons_reprapworld_keypad & ( \
EN_REPRAPWORLD_KEYPAD_F1 | \
EN_REPRAPWORLD_KEYPAD_F2 | \
EN_REPRAPWORLD_KEYPAD_F3 | \
EN_REPRAPWORLD_KEYPAD_DOWN | \
EN_REPRAPWORLD_KEYPAD_RIGHT | \
EN_REPRAPWORLD_KEYPAD_MIDDLE | \
EN_REPRAPWORLD_KEYPAD_UP | \
EN_REPRAPWORLD_KEYPAD_LEFT) \
)
void lcd_move_x();
void lcd_move_y();
void lcd_move_z();
@ -318,42 +263,38 @@ bool lcd_blink() {
default: break;
}
}
inline void reprapworld_keypad_move_z_up() { _reprapworld_keypad_move(Z_AXIS, 1); }
inline void reprapworld_keypad_move_z_down() { _reprapworld_keypad_move(Z_AXIS, -1); }
inline void reprapworld_keypad_move_x_left() { _reprapworld_keypad_move(X_AXIS, -1); }
inline void reprapworld_keypad_move_x_right() { _reprapworld_keypad_move(X_AXIS, 1); }
inline void reprapworld_keypad_move_y_up() { _reprapworld_keypad_move(Y_AXIS, -1); }
inline void reprapworld_keypad_move_y_down() { _reprapworld_keypad_move(Y_AXIS, 1); }
inline void reprapworld_keypad_move_home() { enqueue_and_echo_commands_P(PSTR("G28")); } // move all axes home and wait
inline void reprapworld_keypad_move_menu() { lcd_goto_screen(menu_move); }
inline void handle_reprapworld_keypad() {
static uint8_t keypad_debounce = 0;
if (!REPRAPWORLD_KEYPAD_PRESSED) {
if (!RRK( EN_REPRAPWORLD_KEYPAD_F1 | EN_REPRAPWORLD_KEYPAD_F2
| EN_REPRAPWORLD_KEYPAD_F3 | EN_REPRAPWORLD_KEYPAD_DOWN
| EN_REPRAPWORLD_KEYPAD_RIGHT | EN_REPRAPWORLD_KEYPAD_MIDDLE
| EN_REPRAPWORLD_KEYPAD_UP | EN_REPRAPWORLD_KEYPAD_LEFT )
) {
if (keypad_debounce > 0) keypad_debounce--;
}
else if (!keypad_debounce) {
keypad_debounce = 2;
if (REPRAPWORLD_KEYPAD_MOVE_MENU) reprapworld_keypad_move_menu();
if (RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)) lcd_goto_screen(menu_move);
#if DISABLED(DELTA) && Z_HOME_DIR == -1
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
#endif
if (all_axes_homed()) {
#if ENABLED(DELTA) || Z_HOME_DIR != -1
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
if (RRK(EN_REPRAPWORLD_KEYPAD_F2)) _reprapworld_keypad_move(Z_AXIS, 1);
#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();
if (RRK(EN_REPRAPWORLD_KEYPAD_F3)) _reprapworld_keypad_move(Z_AXIS, -1);
if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) _reprapworld_keypad_move(X_AXIS, -1);
if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) _reprapworld_keypad_move(X_AXIS, 1);
if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) _reprapworld_keypad_move(Y_AXIS, 1);
if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1);
}
else if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
else if (RRK(EN_REPRAPWORLD_KEYPAD_F1)) enqueue_and_echo_commands_P(PSTR("G28"));
}
}
@ -1038,22 +979,19 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = {
// VALUE_MIN, VALUE_MAX, KEY
{ 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F1 + 1 }, // F1
{ 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F2 + 1 }, // F2
{ 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F3 + 1 }, // F3
{ 300, 500, BLEN_REPRAPWORLD_KEYPAD_LEFT + 1 }, // LEFT
{ 1900, 2200, BLEN_REPRAPWORLD_KEYPAD_RIGHT + 1 }, // RIGHT
{ 570, 870, BLEN_REPRAPWORLD_KEYPAD_UP + 1 }, // UP
{ 2670, 2870, BLEN_REPRAPWORLD_KEYPAD_DOWN + 1 }, // DOWN
{ 1150, 1450, BLEN_REPRAPWORLD_KEYPAD_MIDDLE + 1 }, // ENTER
{ 4000, 4096, 1 + BLEN_REPRAPWORLD_KEYPAD_F1 }, // F1
{ 4000, 4096, 1 + BLEN_REPRAPWORLD_KEYPAD_F2 }, // F2
{ 4000, 4096, 1 + BLEN_REPRAPWORLD_KEYPAD_F3 }, // F3
{ 300, 500, 1 + BLEN_REPRAPWORLD_KEYPAD_LEFT }, // LEFT
{ 1900, 2200, 1 + BLEN_REPRAPWORLD_KEYPAD_RIGHT }, // RIGHT
{ 570, 870, 1 + BLEN_REPRAPWORLD_KEYPAD_UP }, // UP
{ 2670, 2870, 1 + BLEN_REPRAPWORLD_KEYPAD_DOWN }, // DOWN
{ 1150, 1450, 1 + BLEN_REPRAPWORLD_KEYPAD_MIDDLE }, // ENTER
};
uint8_t get_ADC_keyValue(void) {
if (thermalManager.ADCKey_count >= 16) {
const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw >> 2;
#if ENABLED(ADC_KEYPAD_DEBUG)
SERIAL_PROTOCOLLN(currentkpADCValue);
#endif
thermalManager.current_ADCKey_raw = 0;
thermalManager.ADCKey_count = 0;
if (currentkpADCValue < 4000)

View file

@ -408,15 +408,42 @@
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#define REPRAPWORLD_BTN_OFFSET 0 // Bit offset into buttons for shift register values
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
#define RRK(B) (buttons_reprapworld_keypad & (B))
#ifdef EN_C
#define LCD_CLICKED() ((buttons & EN_C) || REPRAPWORLD_KEYPAD_MOVE_MENU)
#define LCD_CLICKED() ((buttons & EN_C) || RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE))
#else
#define LCD_CLICKED() REPRAPWORLD_KEYPAD_MOVE_MENU
#define LCD_CLICKED() RRK(EN_REPRAPWORLD_KEYPAD_MIDDLE)
#endif
#endif // REPRAPWORLD_KEYPAD
#ifndef LCD_CLICKED
#ifdef EN_C
#define LCD_CLICKED() (buttons & EN_C)
#else
#define LCD_CLICKED() false
#endif
#elif defined(EN_C)
#define LCD_CLICKED() (buttons & EN_C)
#else
#define LCD_CLICKED() false
#endif
extern uint8_t lcd_status_update_delay;

View file

@ -1831,6 +1831,7 @@ void Temperature::isr() {
static uint8_t pwm_count = _BV(SOFT_PWM_SCALE);
// avoid multiple loads of pwm_count
uint8_t pwm_count_tmp = pwm_count;
#if ENABLED(ADC_KEYPAD)
static unsigned int raw_ADCKey_value = 0;
#endif