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
 touch_control_t Touch::controls[];
40
 touch_control_t Touch::controls[];
41
 touch_control_t *Touch::current_control;
41
 touch_control_t *Touch::current_control;
42
 uint16_t Touch::controls_count;
42
 uint16_t Touch::controls_count;
43
-millis_t Touch::now = 0;
43
+millis_t Touch::last_touch_ms = 0;
44
 millis_t Touch::time_to_hold;
44
 millis_t Touch::time_to_hold;
45
 millis_t Touch::repeat_delay;
45
 millis_t Touch::repeat_delay;
46
 millis_t Touch::touch_time;
46
 millis_t Touch::touch_time;
79
 
79
 
80
   if (!enabled) return;
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
   if (get_point(&_x, &_y)) {
87
   if (get_point(&_x, &_y)) {
86
     #if HAS_RESUME_CONTINUE
88
     #if HAS_RESUME_CONTINUE
88
       if (wait_for_user) {
90
       if (wait_for_user) {
89
         touch_control_type = CLICK;
91
         touch_control_type = CLICK;
90
         ui.lcd_clicked = true;
92
         ui.lcd_clicked = true;
93
+        if (ui.external_control) wait_for_user = false;
91
         return;
94
         return;
92
       }
95
       }
93
     #endif
96
     #endif
94
 
97
 
95
     #if LCD_TIMEOUT_TO_STATUS
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
     #endif
100
     #endif
98
 
101
 
99
     if (touch_time) {
102
     if (touch_time) {
100
       #if ENABLED(TOUCH_SCREEN_CALIBRATION)
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
           ui.goto_screen(touch_screen_calibration);
105
           ui.goto_screen(touch_screen_calibration);
103
       #endif
106
       #endif
104
       return;
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
     if (x != 0 && y != 0) {
113
     if (x != 0 && y != 0) {
111
       if (current_control) {
114
       if (current_control) {
131
       }
134
       }
132
 
135
 
133
       if (current_control == NULL)
136
       if (current_control == NULL)
134
-        touch_time = now;
137
+        touch_time = last_touch_ms;
135
     }
138
     }
136
     x = _x;
139
     x = _x;
137
     y = _y;
140
     y = _y;
284
   current_control = control;
287
   current_control = control;
285
   if (delay) {
288
   if (delay) {
286
     repeat_delay = delay > MIN_REPEAT_DELAY ? delay : MIN_REPEAT_DELAY;
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
   ui.refresh();
292
   ui.refresh();
290
 }
293
 }

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

164
     static void reset() { controls_count = 0; touch_time = -1; current_control = NULL; }
164
     static void reset() { controls_count = 0; touch_time = -1; current_control = NULL; }
165
     static void clear() { controls_count = 0; }
165
     static void clear() { controls_count = 0; }
166
     static void idle();
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
     static void disable() { enabled = false; }
174
     static void disable() { enabled = false; }
169
     static void enable() { enabled = true; }
175
     static void enable() { enabled = true; }
170
 
176
 

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

1478
     set_status_P(msg, -1);
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
   void MarlinUI::abort_print() {
1481
   void MarlinUI::abort_print() {
1486
     #if ENABLED(SDSUPPORT)
1482
     #if ENABLED(SDSUPPORT)
1487
       wait_for_heatup = wait_for_user = false;
1483
       wait_for_heatup = wait_for_user = false;

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

38
 #include "../gcode/gcode.h"
38
 #include "../gcode/gcode.h"
39
 #include "../lcd/ultralcd.h"
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
 #if HAS_LEVELING
43
 #if HAS_LEVELING
44
   #include "../feature/bedlevel/bedlevel.h"
44
   #include "../feature/bedlevel/bedlevel.h"

Loading…
Cancel
Save