-
Notifications
You must be signed in to change notification settings - Fork 10
/
TFT_eTouchGesture.h
86 lines (72 loc) · 1.83 KB
/
TFT_eTouchGesture.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef TFT_E_TOUCH_GESTURE_H
#define TFT_E_TOUCH_GESTURE_H
//
// TFT_eTouchGesture.h
//
// (C) Copyright Achill Hasler 2019.
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file at https://www.boost.org/LICENSE_1_0.txt
//
//
// See TFT_eTouch/docs/html/index.html for documentation.
//
#include <TFT_eTouchBase.h>
/**
* @brief Gesture support for touch
*/
class TFT_eTouchGesture
{
struct FilteredMeasure
{
uint8_t x; ///< raw x measure reduced to 8 bit (ca 213..3881)/16
uint8_t y; ///< raw y measure reduced to 8 bit (ca 222..3929)/16
uint8_t z1; ///< raw z1 measure reduced to 8 bit (ca 29..1748)/16
uint8_t z2; ///< raw z2 measure reduced to 8 bit (ca 963..3989)/16
uint8_t rz; ///< calculated resitor value < 0xff when tuched, 0xff when not tuched.
uint16_t ms;
FilteredMeasure() : rz(0xff) {}
void operator=(const TFT_eTouchBase::Measure& raw);
};
public:
typedef enum
{
none,
stay,
move,
wipe,
zoom_in,
zoom_out
} Action;
/**
* @brief constructor
* @param size stored values
*/
TFT_eTouchGesture(uint16_t size);
~TFT_eTouchGesture();
/**
* You have to feed this instance with new measure in a constant timeframe.
* @brief set measure
* @param raw last readed touch measure
*/
void set(const TFT_eTouchBase::Measure& raw);
/**
* On pen up reset must call.
* @brief reset
*/
void reset();
/**
* Get the action. When Action move or wipe is returned the angle is valid.
* @brief get action
* @param angle in grad
* @return actual action
*/
Action get(int16_t& angle);
private:
FilteredMeasure* data_;
uint16_t size_;
uint16_t next_;
uint16_t used_;
};
//#include <TFT_eTouchGesture.inl>
#endif // TFT_E_TOUCH_GESTURE_H