Browse Source

Fix Color UI external_control, wait_for_release (#19771)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Victor Oliveira 4 years ago
parent
commit
0b80841c38
No account linked to committer's email address

+ 12
- 9
Marlin/src/lcd/tft/touch.cpp View File

@@ -40,7 +40,7 @@ int16_t Touch::x, Touch::y;
40 40
 touch_control_t Touch::controls[];
41 41
 touch_control_t *Touch::current_control;
42 42
 uint16_t Touch::controls_count;
43
-millis_t Touch::now = 0;
43
+millis_t Touch::last_touch_ms = 0;
44 44
 millis_t Touch::time_to_hold;
45 45
 millis_t Touch::repeat_delay;
46 46
 millis_t Touch::touch_time;
@@ -79,8 +79,10 @@ void Touch::idle() {
79 79
 
80 80
   if (!enabled) return;
81 81
 
82
-  if (now == millis()) return;
83
-  now = millis();
82
+  // Return if Touch::idle is called within the same millisecond
83
+  const millis_t now = millis();
84
+  if (last_touch_ms == now) return;
85
+  last_touch_ms = now;
84 86
 
85 87
   if (get_point(&_x, &_y)) {
86 88
     #if HAS_RESUME_CONTINUE
@@ -88,24 +90,25 @@ void Touch::idle() {
88 90
       if (wait_for_user) {
89 91
         touch_control_type = CLICK;
90 92
         ui.lcd_clicked = true;
93
+        if (ui.external_control) wait_for_user = false;
91 94
         return;
92 95
       }
93 96
     #endif
94 97
 
95 98
     #if LCD_TIMEOUT_TO_STATUS
96
-      ui.return_to_status_ms = now + LCD_TIMEOUT_TO_STATUS;
99
+      ui.return_to_status_ms = last_touch_ms + LCD_TIMEOUT_TO_STATUS;
97 100
     #endif
98 101
 
99 102
     if (touch_time) {
100 103
       #if ENABLED(TOUCH_SCREEN_CALIBRATION)
101
-        if (touch_control_type == NONE && ELAPSED(now, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen())
104
+        if (touch_control_type == NONE && ELAPSED(last_touch_ms, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen())
102 105
           ui.goto_screen(touch_screen_calibration);
103 106
       #endif
104 107
       return;
105 108
     }
106 109
 
107
-    if (time_to_hold == 0) time_to_hold = now + MINIMUM_HOLD_TIME;
108
-    if (PENDING(now, time_to_hold)) return;
110
+    if (time_to_hold == 0) time_to_hold = last_touch_ms + MINIMUM_HOLD_TIME;
111
+    if (PENDING(last_touch_ms, time_to_hold)) return;
109 112
 
110 113
     if (x != 0 && y != 0) {
111 114
       if (current_control) {
@@ -131,7 +134,7 @@ void Touch::idle() {
131 134
       }
132 135
 
133 136
       if (current_control == NULL)
134
-        touch_time = now;
137
+        touch_time = last_touch_ms;
135 138
     }
136 139
     x = _x;
137 140
     y = _y;
@@ -284,7 +287,7 @@ void Touch::hold(touch_control_t *control, millis_t delay) {
284 287
   current_control = control;
285 288
   if (delay) {
286 289
     repeat_delay = delay > MIN_REPEAT_DELAY ? delay : MIN_REPEAT_DELAY;
287
-    time_to_hold = now + repeat_delay;
290
+    time_to_hold = last_touch_ms + repeat_delay;
288 291
   }
289 292
   ui.refresh();
290 293
 }

+ 7
- 1
Marlin/src/lcd/tft/touch.h View File

@@ -164,7 +164,13 @@ class Touch {
164 164
     static void reset() { controls_count = 0; touch_time = -1; current_control = NULL; }
165 165
     static void clear() { controls_count = 0; }
166 166
     static void idle();
167
-    static bool is_clicked() { return touch_control_type == CLICK; }
167
+    static bool is_clicked() {
168
+      if (touch_control_type == CLICK) {
169
+        touch_control_type = NONE;
170
+        return true;
171
+      }
172
+      return false;
173
+    }
168 174
     static void disable() { enabled = false; }
169 175
     static void enable() { enabled = true; }
170 176
 

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp View File

@@ -1478,10 +1478,6 @@ void MarlinUI::update() {
1478 1478
     set_status_P(msg, -1);
1479 1479
   }
1480 1480
 
1481
-  #if ENABLED(SDSUPPORT)
1482
-    extern bool wait_for_user, wait_for_heatup;
1483
-  #endif
1484
-
1485 1481
   void MarlinUI::abort_print() {
1486 1482
     #if ENABLED(SDSUPPORT)
1487 1483
       wait_for_heatup = wait_for_user = false;

+ 1
- 1
Marlin/src/module/probe.cpp View File

@@ -38,7 +38,7 @@
38 38
 #include "../gcode/gcode.h"
39 39
 #include "../lcd/ultralcd.h"
40 40
 
41
-#include "../MarlinCore.h" // for stop(), disable_e_steppers, wait_for_user
41
+#include "../MarlinCore.h" // for stop(), disable_e_steppers
42 42
 
43 43
 #if HAS_LEVELING
44 44
   #include "../feature/bedlevel/bedlevel.h"

Loading…
Cancel
Save