ESPHome
2025.5.0
Loading...
Searching...
No Matches
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
#include <vector>
10
11
namespace
esphome
{
12
namespace
touchscreen {
13
14
class
TouchscreenBinarySensor
:
public
binary_sensor::BinarySensor
,
15
public
Component
,
16
public
TouchListener
,
17
public
Parented
<Touchscreen> {
18
public
:
19
void
setup
()
override
;
20
22
void
set_area
(int16_t x_min, int16_t x_max, int16_t y_min, int16_t y_max) {
23
this->
x_min_
= x_min;
24
this->
x_max_
= x_max;
25
this->
y_min_
= y_min;
26
this->
y_max_
= y_max;
27
}
28
void
set_use_raw
(
bool
use_raw) { this->
use_raw_
= use_raw; }
29
int16_t
get_x_min
() {
return
this->
x_min_
; }
30
int16_t
get_x_max
() {
return
this->
x_max_
; }
31
int16_t
get_y_min
() {
return
this->
y_min_
; }
32
int16_t
get_y_max
() {
return
this->
y_max_
; }
33
int16_t
get_width
() {
return
this->
x_max_
- this->
x_min_
; }
34
int16_t
get_height
() {
return
this->
y_max_
- this->
y_min_
; }
35
36
void
add_page
(
display::DisplayPage
*page) { this->
pages_
.push_back(page); }
37
38
void
touch
(
TouchPoint
tp)
override
;
39
void
release
()
override
;
40
41
protected
:
42
int16_t
x_min_
{},
x_max_
{},
y_min_
{},
y_max_
{};
43
bool
use_raw_
{};
44
std::vector<display::DisplayPage *>
pages_
{};
45
};
46
47
}
// namespace touchscreen
48
}
// namespace esphome
binary_sensor.h
esphome::Component
Definition
component.h:70
esphome::Parented
Helper class to easily give an object a parent of type T.
Definition
helpers.h:538
esphome::binary_sensor::BinarySensor
Base class for all binary_sensor-type classes.
Definition
binary_sensor.h:37
esphome::display::DisplayPage
Definition
display.h:690
esphome::touchscreen::TouchListener
Definition
touchscreen.h:38
esphome::touchscreen::TouchscreenBinarySensor
Definition
touchscreen_binary_sensor.h:17
esphome::touchscreen::TouchscreenBinarySensor::x_max_
int16_t x_max_
Definition
touchscreen_binary_sensor.h:42
esphome::touchscreen::TouchscreenBinarySensor::y_max_
int16_t y_max_
Definition
touchscreen_binary_sensor.h:42
esphome::touchscreen::TouchscreenBinarySensor::x_min_
int16_t x_min_
Definition
touchscreen_binary_sensor.h:42
esphome::touchscreen::TouchscreenBinarySensor::touch
void touch(TouchPoint tp) override
Definition
touchscreen_binary_sensor.cpp:11
esphome::touchscreen::TouchscreenBinarySensor::add_page
void add_page(display::DisplayPage *page)
Definition
touchscreen_binary_sensor.h:36
esphome::touchscreen::TouchscreenBinarySensor::get_y_min
int16_t get_y_min()
Definition
touchscreen_binary_sensor.h:31
esphome::touchscreen::TouchscreenBinarySensor::setup
void setup() override
Definition
touchscreen_binary_sensor.cpp:6
esphome::touchscreen::TouchscreenBinarySensor::get_width
int16_t get_width()
Definition
touchscreen_binary_sensor.h:33
esphome::touchscreen::TouchscreenBinarySensor::get_x_min
int16_t get_x_min()
Definition
touchscreen_binary_sensor.h:29
esphome::touchscreen::TouchscreenBinarySensor::pages_
std::vector< display::DisplayPage * > pages_
Definition
touchscreen_binary_sensor.h:44
esphome::touchscreen::TouchscreenBinarySensor::get_y_max
int16_t get_y_max()
Definition
touchscreen_binary_sensor.h:32
esphome::touchscreen::TouchscreenBinarySensor::use_raw_
bool use_raw_
Definition
touchscreen_binary_sensor.h:43
esphome::touchscreen::TouchscreenBinarySensor::release
void release() override
Definition
touchscreen_binary_sensor.cpp:31
esphome::touchscreen::TouchscreenBinarySensor::get_x_max
int16_t get_x_max()
Definition
touchscreen_binary_sensor.h:30
esphome::touchscreen::TouchscreenBinarySensor::get_height
int16_t get_height()
Definition
touchscreen_binary_sensor.h:34
esphome::touchscreen::TouchscreenBinarySensor::y_min_
int16_t y_min_
Definition
touchscreen_binary_sensor.h:42
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:22
esphome::touchscreen::TouchscreenBinarySensor::set_use_raw
void set_use_raw(bool use_raw)
Definition
touchscreen_binary_sensor.h:28
component.h
display_buffer.h
helpers.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
esphome::touchscreen::TouchPoint
Definition
touchscreen.h:21
touchscreen.h
Generated by
1.12.0