13 namespace touchscreen {
15 static const uint8_t STATE_RELEASED = 0x00;
16 static const uint8_t STATE_PRESSED = 0x01;
17 static const uint8_t STATE_UPDATED = 0x02;
18 static const uint8_t STATE_RELEASING = 0x04;
19 static const uint8_t STATE_CALIBRATE = 0x07;
33 volatile bool touched{
true};
55 void set_calibration(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max) {
56 this->x_raw_min_ = x_min;
57 this->x_raw_max_ = x_max;
58 this->y_raw_min_ = y_min;
59 this->y_raw_max_ = y_max;
72 for (
auto i : this->touches_) {
73 touches.push_back(i.second);
78 void update()
override;
80 void call_setup()
override;
87 void add_raw_touch_position_(uint8_t
id, int16_t
x_raw, int16_t
y_raw, int16_t
z_raw = 0);
89 virtual void update_touches() = 0;
93 int16_t normalize_(int16_t
val, int16_t min_val, int16_t max_val,
bool inverted =
false);
97 int16_t x_raw_min_{0}, x_raw_max_{0}, y_raw_min_{0}, y_raw_max_{0};
98 int16_t display_width_{0}, display_height_{0};
100 uint16_t touch_timeout_{0};
101 bool invert_x_{
false}, invert_y_{
false}, swap_x_y_{
false};
111 bool first_touch_{
true};
112 bool need_update_{
false};
113 bool is_touched_{
false};
114 bool was_touched_{
false};
115 bool skip_update_{
false};
display::Display * get_display() const
void set_calibration(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max)
std::vector< TouchPoint > TouchPoints_t
Trigger< TouchPoint, const TouchPoints_t & > touch_trigger_
Trigger< const TouchPoints_t & > * get_update_trigger()
Trigger< const TouchPoints_t & > update_trigger_
This class simplifies creating components that periodically check a state.
std::map< uint8_t, TouchPoint > touches_
void set_touch_timeout(uint16_t val)
optional< TouchPoint > get_touch()
virtual void update(const TouchPoints_t &tpoints)
std::vector< TouchListener * > touch_listeners_
TouchscreenInterrupt store_
Trigger * get_release_trigger()
void swap(optional< T > &x, optional< T > &y)
virtual void touch(TouchPoint tp)
void set_mirror_y(bool invert_y)
void set_mirror_x(bool invert_x)
Implementation of SPI Controller mode.
void register_listener(TouchListener *listener)
void set_swap_xy(bool swap)
Trigger< TouchPoint, const TouchPoints_t & > * get_touch_trigger()
TouchPoints_t get_touches()
void set_display(display::Display *display)