ESPHome
2023.5.5
esphome
esphome
components
touchscreen
binary_sensor
touchscreen_binary_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/components/binary_sensor/binary_sensor.h
"
4
#include "
esphome/components/display/display_buffer.h
"
5
#include "
esphome/components/touchscreen/touchscreen.h
"
6
#include "
esphome/core/component.h
"
7
#include "
esphome/core/helpers.h
"
8
9
namespace
esphome
{
10
namespace
touchscreen {
11
12
class
TouchscreenBinarySensor
:
public
binary_sensor::BinarySensor
,
13
public
Component
,
14
public
TouchListener
,
15
public
Parented
<Touchscreen> {
16
public
:
17
void
setup
()
override
{ this->
parent_
->register_listener(
this
); }
18
20
void
set_area
(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max) {
21
this->
x_min_
= x_min;
22
this->
x_max_
= x_max;
23
this->
y_min_
= y_min;
24
this->
y_max_
= y_max;
25
}
26
int16_t
get_x_min
() {
return
this->
x_min_
; }
27
int16_t
get_x_max
() {
return
this->
x_max_
; }
28
int16_t
get_y_min
() {
return
this->
y_min_
; }
29
int16_t
get_y_max
() {
return
this->
y_max_
; }
30
int16_t
get_width
() {
return
this->
x_max_
- this->
x_min_
; }
31
int16_t
get_height
() {
return
this->
y_max_
- this->
y_min_
; }
32
33
void
set_page
(
display::DisplayPage
*page) { this->
page_
= page; }
34
35
void
touch
(
TouchPoint
tp)
override
;
36
void
release
()
override
;
37
38
protected
:
39
int16_t
x_min_
,
x_max_
,
y_min_
,
y_max_
;
40
display::DisplayPage
*
page_
{
nullptr
};
41
};
42
43
}
// namespace touchscreen
44
}
// namespace esphome
esphome::touchscreen::TouchListener
Definition:
touchscreen.h:19
esphome::touchscreen::TouchscreenBinarySensor::y_min_
int16_t y_min_
Definition:
touchscreen_binary_sensor.h:39
esphome::touchscreen::TouchscreenBinarySensor::setup
void setup() override
Definition:
touchscreen_binary_sensor.h:17
display_buffer.h
esphome::touchscreen::TouchscreenBinarySensor::get_y_min
int16_t get_y_min()
Definition:
touchscreen_binary_sensor.h:28
touchscreen.h
esphome::Component
Definition:
component.h:67
esphome::touchscreen::TouchscreenBinarySensor::x_max_
int16_t x_max_
Definition:
touchscreen_binary_sensor.h:39
esphome::touchscreen::TouchscreenBinarySensor::get_width
int16_t get_width()
Definition:
touchscreen_binary_sensor.h:30
binary_sensor.h
esphome::touchscreen::TouchscreenBinarySensor::get_x_min
int16_t get_x_min()
Definition:
touchscreen_binary_sensor.h:26
esphome::Parented< Touchscreen >::parent_
Touchscreen * parent_
Definition:
helpers.h:519
esphome::touchscreen::TouchscreenBinarySensor::y_max_
int16_t y_max_
Definition:
touchscreen_binary_sensor.h:39
esphome::touchscreen::TouchscreenBinarySensor::set_area
void set_area(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max)
Set the touch screen area where the button will detect the touch.
Definition:
touchscreen_binary_sensor.h:20
esphome::display::DisplayPage
Definition:
display_buffer.h:466
esphome::touchscreen::TouchscreenBinarySensor::release
void release() override
Definition:
touchscreen_binary_sensor.cpp:20
esphome::touchscreen::TouchPoint
Definition:
touchscreen.h:12
esphome::touchscreen::TouchscreenBinarySensor::set_page
void set_page(display::DisplayPage *page)
Definition:
touchscreen_binary_sensor.h:33
esphome::touchscreen::TouchscreenBinarySensor::get_height
int16_t get_height()
Definition:
touchscreen_binary_sensor.h:31
esphome::touchscreen::TouchscreenBinarySensor
Definition:
touchscreen_binary_sensor.h:12
esphome::touchscreen::TouchscreenBinarySensor::get_y_max
int16_t get_y_max()
Definition:
touchscreen_binary_sensor.h:29
esphome::touchscreen::TouchscreenBinarySensor::page_
display::DisplayPage * page_
Definition:
touchscreen_binary_sensor.h:40
esphome::touchscreen::TouchscreenBinarySensor::touch
void touch(TouchPoint tp) override
Definition:
touchscreen_binary_sensor.cpp:6
esphome
Definition:
a4988.cpp:4
component.h
esphome::binary_sensor::BinarySensor
Base class for all binary_sensor-type classes.
Definition:
binary_sensor.h:37
helpers.h
esphome::touchscreen::TouchscreenBinarySensor::x_min_
int16_t x_min_
Definition:
touchscreen_binary_sensor.h:39
esphome::touchscreen::TouchscreenBinarySensor::get_x_max
int16_t get_x_max()
Definition:
touchscreen_binary_sensor.h:27
esphome::Parented
Helper class to easily give an object a parent of type T.
Definition:
helpers.h:508
Generated by
1.8.13