-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserInput.h
33 lines (31 loc) · 1.74 KB
/
UserInput.h
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
32
33
#ifndef _USERINPUT_H_
#define _USERINPUT_H_
/*
* UserInput.h
*
* Usage: A touch event broker that tracks touch point events and uses time, distance, and number of touch points
* to determine if an event is a button press, a swipe or a pinch activity. Data is stored in Touch_Control structure.
*
* Button: 1 touch point < BUTTON_TOUCH max travel. It passes on the last X and Y coordinates.
*
* Gesture: 1 or 2 touch points exceeding BUTTON_TOUCH minimum travel. It passes the distance to the gesture handler
* Direction is positive or negatiove distance fopr X and Y.
*
* Non_Blocking: This is a non-blocking state engine with timer "gesture_timer" set for max press duration.
* The event is reset after timer expiration. When a finger is eventually lifted it can become a valid press
* or gesture again but with new start points. See Dragging description for exception.
*
* Dragging: The starting x,y coordinate are stored and a timer started. While waiting for a press event to complete
* the current x, y coordinates are updated to permit feedback for dragging type events such as operating a slider.
* The starting coordinates are not reset so the total drag distance can still be determined even though the timer has expired.
*
* Number of touch points can be up to 5 but the code is only working with 2 here.
*/
#include <Arduino.h>
// Function declarations
void Button_Handler(int16_t x, uint16_t y, uint8_t _holdtime);
uint8_t Gesture_Handler(uint8_t _gesture, uint8_t _dragEvent, uint8_t _holdtime);
void setPanel(void);
void Touch(void);
void Button_Action(uint16_t button_name);
#endif //end of _USERINPUT_H_