|
@@ -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
|
}
|