Skip to content

Commit 0745d48

Browse files
tpruvotthinkyhead
authored andcommitted
Fix build with and without TOUCH_BUTTONS (MarlinFirmware#14912)
1 parent e7aba49 commit 0745d48

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

Marlin/src/lcd/ultralcd.cpp

+27-28
Original file line numberDiff line numberDiff line change
@@ -764,42 +764,41 @@ void MarlinUI::update() {
764764

765765
// If the action button is pressed...
766766
static bool wait_for_unclick; // = 0
767-
if (touch_buttons) {
768-
if (buttons & EN_C) {
769-
if (!wait_for_unclick) { // If not waiting for a debounce release:
767+
#if ENABLED(TOUCH_BUTTONS)
768+
if (touch_buttons) {
769+
if (!wait_for_unclick && (buttons & EN_C)) { // If not waiting for a debounce release:
770770
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
771771
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
772772
wait_for_user = false; // - Any click clears wait for user
773773
quick_feedback(); // - Always make a click sound
774774
}
775-
}
776-
else if (buttons & (EN_A | EN_B)) { // Ignore the encoder if clicked, to prevent "slippage"
777-
const millis_t ms = millis();
778-
if (ELAPSED(ms, next_button_update_ms)) {
779-
next_button_update_ms = ms + 50;
780-
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP);
781-
if (buttons & EN_A) encoderDiff *= -1;
782-
if (!wait_for_unclick) {
783-
next_button_update_ms += 250;
784-
#if HAS_BUZZER
785-
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
786-
#endif
787-
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
775+
else if (buttons & (EN_A | EN_B)) { // Ignore the encoder if clicked, to prevent "slippage"
776+
const millis_t ms = millis();
777+
if (ELAPSED(ms, next_button_update_ms)) {
778+
next_button_update_ms = ms + 50;
779+
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP);
780+
if (buttons & EN_A) encoderDiff *= -1;
781+
if (!wait_for_unclick) {
782+
next_button_update_ms += 250;
783+
#if HAS_BUZZER
784+
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
785+
#endif
786+
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
787+
}
788788
}
789789
}
790790
}
791-
}
792-
else {
793-
//
794-
// Integrated LCD click handling via button_pressed()
795-
//
796-
if (!external_control && button_pressed()) {
797-
if (!wait_for_unclick) { // If not waiting for a debounce release:
798-
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
799-
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
800-
wait_for_user = false; // - Any click clears wait for user
801-
quick_feedback(); // - Always make a click sound
802-
}
791+
else
792+
#endif //TOUCH_BUTTONS
793+
//
794+
// Integrated LCD click handling via button_pressed()
795+
//
796+
if (!external_control && button_pressed()) {
797+
if (!wait_for_unclick) { // If not waiting for a debounce release:
798+
wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
799+
lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
800+
wait_for_user = false; // - Any click clears wait for user
801+
quick_feedback(); // - Always make a click sound
803802
}
804803
}
805804
else wait_for_unclick = false;

0 commit comments

Comments
 (0)