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_ = std::min(x_min, x_max);
57 this->x_raw_max_ = std::max(x_min, x_max);
58 this->y_raw_min_ = std::min(y_min, y_max);
59 this->y_raw_max_ = std::max(y_min, y_max);
61 this->invert_x_ =
true;
63 this->invert_y_ =
true;
76 for (
auto i : this->touches_) {
77 touches.push_back(i.second);
82 void update()
override;
84 void call_setup()
override;
91 void add_raw_touch_position_(uint8_t
id, int16_t
x_raw, int16_t
y_raw, int16_t
z_raw = 0);
93 virtual void update_touches() = 0;
97 int16_t normalize_(int16_t
val, int16_t min_val, int16_t max_val,
bool inverted =
false);
101 int16_t x_raw_min_{0}, x_raw_max_{0}, y_raw_min_{0}, y_raw_max_{0};
102 int16_t display_width_{0}, display_height_{0};
104 uint16_t touch_timeout_{0};
105 bool invert_x_{
false}, invert_y_{
false}, swap_x_y_{
false};
115 bool first_touch_{
true};
116 bool need_update_{
false};
117 bool is_touched_{
false};
118 bool was_touched_{
false};
119 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)