forked from reedbn/ubitxv6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_touch.cpp
More file actions
31 lines (25 loc) · 697 Bytes
/
Copy pathui_touch.cpp
File metadata and controls
31 lines (25 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "ui_touch.h"
#include <Arduino.h>//delay
#include "button_timing.h"
#include "touch.h"
ButtonPress_e checkTouch(Point *const touch_point_out){
if (!readTouch(touch_point_out)){
return ButtonPress_e::NotPressed;
}
delay(DEBOUNCE_DELAY_MS);
if (!readTouch(touch_point_out)){//debounce
return ButtonPress_e::NotPressed;
}
uint16_t down_time = 0;
while(readTouch(touch_point_out) && (down_time < LONG_PRESS_TIME_MS)){
delay(LONG_PRESS_POLL_TIME_MS);
down_time += LONG_PRESS_POLL_TIME_MS;
}
scaleTouch(touch_point_out);
if(down_time < LONG_PRESS_TIME_MS){
return ButtonPress_e::ShortPress;
}
else{
return ButtonPress_e::LongPress;
}
}