|
@@ -200,6 +200,7 @@ millis_t MarlinUI::next_button_update_ms; // = 0
|
200
|
200
|
#endif
|
201
|
201
|
|
202
|
202
|
#if ENABLED(TOUCH_BUTTONS)
|
|
203
|
+ uint8_t MarlinUI::touch_buttons;
|
203
|
204
|
uint8_t MarlinUI::repeat_delay;
|
204
|
205
|
#endif
|
205
|
206
|
|
|
@@ -778,58 +779,46 @@ void MarlinUI::update() {
|
778
|
779
|
|
779
|
780
|
#if ENABLED(TOUCH_BUTTONS)
|
780
|
781
|
|
781
|
|
- #define TOUCH_MENU_MASK 0x80
|
782
|
|
-
|
783
|
|
- static bool arrow_pressed; // = false
|
784
|
|
-
|
785
|
|
- // Handle touch events which are slow to read
|
786
|
|
- if (ELAPSED(ms, next_button_update_ms)) {
|
787
|
|
- uint8_t touch_buttons = touch.read_buttons();
|
788
|
|
- if (touch_buttons) {
|
789
|
|
- RESET_STATUS_TIMEOUT();
|
790
|
|
- if (touch_buttons & TOUCH_MENU_MASK) { // Processing Menu Area touch?
|
791
|
|
- if (!wait_for_unclick) { // If not waiting for a debounce release:
|
792
|
|
- wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
|
793
|
|
- wait_for_user = false; // - Any click clears wait for user
|
794
|
|
- // TODO for next PR.
|
795
|
|
- //uint8_t tpos = touch_buttons & ~(TOUCH_MENU_MASK); // Safe 7bit touched screen coordinate
|
796
|
|
- next_button_update_ms = ms + 500; // Defer next check for 1/2 second
|
797
|
|
- #if HAS_LCD_MENU
|
798
|
|
- refresh();
|
799
|
|
- #endif
|
800
|
|
- }
|
801
|
|
- touch_buttons = 0; // Swallow the touch
|
802
|
|
- }
|
803
|
|
- buttons |= (touch_buttons & (EN_C | EN_D)); // Pass on Click and Back buttons
|
804
|
|
- if (touch_buttons & (EN_A | EN_B)) { // A and/or B button?
|
|
782
|
+ if (touch_buttons) {
|
|
783
|
+ RESET_STATUS_TIMEOUT();
|
|
784
|
+ if (buttons & (EN_A | EN_B)) { // Menu arrows, in priority
|
|
785
|
+ if (ELAPSED(ms, next_button_update_ms)) {
|
805
|
786
|
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP) * encoderDirection;
|
806
|
|
- if (touch_buttons & EN_A) encoderDiff *= -1;
|
807
|
|
- next_button_update_ms = ms + repeat_delay; // Assume the repeat delay
|
808
|
|
- if (!wait_for_unclick && !arrow_pressed) { // On click prepare for repeat
|
809
|
|
- next_button_update_ms += 250; // Longer delay on first press
|
810
|
|
- arrow_pressed = true; // Mark arrow as pressed
|
|
787
|
+ if (buttons & EN_A) encoderDiff *= -1;
|
|
788
|
+ next_button_update_ms = ms + repeat_delay; // Assume the repeat delay
|
|
789
|
+ if (!wait_for_unclick) {
|
|
790
|
+ next_button_update_ms += 250; // Longer delay on first press
|
|
791
|
+ wait_for_unclick = true; // Avoid Back/Select click while repeating
|
811
|
792
|
#if HAS_BUZZER
|
812
|
793
|
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
|
813
|
794
|
#endif
|
814
|
795
|
}
|
815
|
796
|
}
|
816
|
797
|
}
|
817
|
|
- if (!(touch_buttons & (EN_A | EN_B))) arrow_pressed = false;
|
|
798
|
+ else if (!wait_for_unclick && (buttons & EN_C)) { // OK button, if not waiting for a debounce release:
|
|
799
|
+ wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
|
|
800
|
+ lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
|
|
801
|
+ wait_for_user = false; // - Any click clears wait for user
|
|
802
|
+ quick_feedback(); // - Always make a click sound
|
|
803
|
+ }
|
818
|
804
|
}
|
|
805
|
+ else // keep wait_for_unclick value
|
819
|
806
|
|
820
|
807
|
#endif // TOUCH_BUTTONS
|
821
|
808
|
|
822
|
|
- // Integrated LCD click handling via button_pressed
|
823
|
|
- if (!external_control && button_pressed()) {
|
824
|
|
- if (!wait_for_unclick) { // If not waiting for a debounce release:
|
825
|
|
- wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
|
826
|
|
- lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
|
827
|
|
- wait_for_user = false; // - Any click clears wait for user
|
828
|
|
- quick_feedback(); // - Always make a click sound
|
|
809
|
+ {
|
|
810
|
+ // Integrated LCD click handling via button_pressed
|
|
811
|
+ if (!external_control && button_pressed()) {
|
|
812
|
+ if (!wait_for_unclick) { // If not waiting for a debounce release:
|
|
813
|
+ wait_for_unclick = true; // - Set debounce flag to ignore continous clicks
|
|
814
|
+ lcd_clicked = !wait_for_user && !no_reentry; // - Keep the click if not waiting for a user-click
|
|
815
|
+ wait_for_user = false; // - Any click clears wait for user
|
|
816
|
+ quick_feedback(); // - Always make a click sound
|
|
817
|
+ }
|
|
818
|
+ }
|
|
819
|
+ else
|
|
820
|
+ wait_for_unclick = false;
|
829
|
821
|
}
|
830
|
|
- }
|
831
|
|
- else
|
832
|
|
- wait_for_unclick = false;
|
833
|
822
|
|
834
|
823
|
if (LCD_BACK_CLICKED()) {
|
835
|
824
|
quick_feedback();
|
|
@@ -894,8 +883,13 @@ void MarlinUI::update() {
|
894
|
883
|
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
|
895
|
884
|
|
896
|
885
|
#if ENABLED(TOUCH_BUTTONS)
|
897
|
|
- if (on_status_screen())
|
898
|
|
- next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2;
|
|
886
|
+
|
|
887
|
+ if (on_status_screen()) next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2;
|
|
888
|
+
|
|
889
|
+ #if HAS_ENCODER_ACTION
|
|
890
|
+ touch_buttons = touch.read_buttons();
|
|
891
|
+ #endif
|
|
892
|
+
|
899
|
893
|
#endif
|
900
|
894
|
|
901
|
895
|
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
|
|
@@ -1249,6 +1243,9 @@ void MarlinUI::update() {
|
1249
|
1243
|
#if HAS_SLOW_BUTTONS
|
1250
|
1244
|
| slow_buttons
|
1251
|
1245
|
#endif
|
|
1246
|
+ #if ENABLED(TOUCH_BUTTONS) && HAS_ENCODER_ACTION
|
|
1247
|
+ | touch_buttons
|
|
1248
|
+ #endif
|
1252
|
1249
|
);
|
1253
|
1250
|
|
1254
|
1251
|
#elif HAS_ADC_BUTTONS
|