Browse Source

Fix build with and without TOUCH_BUTTONS (#14912)

pull/1/head
Tanguy Pruvot 5 years ago
committed by Scott Lahteine
parent
commit
0745d48993
  1. 55
      Marlin/src/lcd/ultralcd.cpp

55
Marlin/src/lcd/ultralcd.cpp

@ -764,42 +764,41 @@ void MarlinUI::update() {
// If the action button is pressed...
static bool wait_for_unclick; // = 0
if (touch_buttons) {
if (buttons & EN_C) {
if (!wait_for_unclick) { // If not waiting for a debounce release:
#if ENABLED(TOUCH_BUTTONS)
if (touch_buttons) {
if (!wait_for_unclick && (buttons & EN_C)) { // If not waiting for a debounce release:
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
wait_for_user = false; // - Any click clears wait for user
quick_feedback(); // - Always make a click sound
}
}
else if (buttons & (EN_A | EN_B)) { // Ignore the encoder if clicked, to prevent "slippage"
const millis_t ms = millis();
if (ELAPSED(ms, next_button_update_ms)) {
next_button_update_ms = ms + 50;
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP);
if (buttons & EN_A) encoderDiff *= -1;
if (!wait_for_unclick) {
next_button_update_ms += 250;
#if HAS_BUZZER
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#endif
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
else if (buttons & (EN_A | EN_B)) { // Ignore the encoder if clicked, to prevent "slippage"
const millis_t ms = millis();
if (ELAPSED(ms, next_button_update_ms)) {
next_button_update_ms = ms + 50;
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP);
if (buttons & EN_A) encoderDiff *= -1;
if (!wait_for_unclick) {
next_button_update_ms += 250;
#if HAS_BUZZER
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#endif
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
}
}
}
}
}
else {
//
// Integrated LCD click handling via button_pressed()
//
if (!external_control && button_pressed()) {
if (!wait_for_unclick) { // If not waiting for a debounce release:
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
wait_for_user = false; // - Any click clears wait for user
quick_feedback(); // - Always make a click sound
}
else
#endif //TOUCH_BUTTONS
//
// Integrated LCD click handling via button_pressed()
//
if (!external_control && button_pressed()) {
if (!wait_for_unclick) { // If not waiting for a debounce release:
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
wait_for_user = false; // - Any click clears wait for user
quick_feedback(); // - Always make a click sound
}
}
else wait_for_unclick = false;

Loading…
Cancel
Save