esphome 2025.2.2__py3-none-any.whl → 2025.3.0b2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/__main__.py +9 -1
- esphome/components/api/api_connection.cpp +426 -70
- esphome/components/api/api_connection.h +117 -25
- esphome/components/api/api_pb2.cpp +33 -0
- esphome/components/api/api_pb2.h +4 -0
- esphome/components/api/api_server.cpp +2 -2
- esphome/components/api/list_entities.cpp +76 -22
- esphome/components/api/list_entities.h +1 -0
- esphome/components/api/subscribe_state.h +2 -0
- esphome/components/audio/__init__.py +1 -1
- esphome/components/audio/audio_decoder.cpp +43 -11
- esphome/components/audio/audio_reader.cpp +2 -2
- esphome/components/audio/audio_resampler.cpp +4 -2
- esphome/components/audio/audio_transfer_buffer.cpp +19 -9
- esphome/components/audio/audio_transfer_buffer.h +7 -2
- esphome/components/bluetooth_proxy/bluetooth_proxy.h +8 -0
- esphome/components/bmp085/bmp085.cpp +1 -1
- esphome/components/chsc6x/__init__.py +2 -0
- esphome/components/chsc6x/chsc6x_touchscreen.cpp +47 -0
- esphome/components/chsc6x/chsc6x_touchscreen.h +34 -0
- esphome/components/chsc6x/touchscreen.py +33 -0
- esphome/components/climate/__init__.py +0 -1
- esphome/components/cst816/binary_sensor/__init__.py +2 -25
- esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +3 -14
- esphome/components/cst816/touchscreen/cst816_touchscreen.h +0 -4
- esphome/components/esp32_ble_beacon/__init__.py +3 -1
- esphome/components/esp8266/gpio.py +1 -2
- esphome/components/font/__init__.py +185 -185
- esphome/components/font/font.cpp +4 -4
- esphome/components/font/font.h +1 -0
- esphome/components/haier/climate.py +11 -10
- esphome/components/hbridge/switch/hbridge_switch.cpp +2 -2
- esphome/components/heatpumpir/climate.py +2 -1
- esphome/components/heatpumpir/heatpumpir.cpp +1 -0
- esphome/components/heatpumpir/heatpumpir.h +1 -0
- esphome/components/i2c/__init__.py +6 -6
- esphome/components/i2c/i2c_bus_esp_idf.cpp +6 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
- esphome/components/ili9xxx/display.py +1 -0
- esphome/components/ili9xxx/ili9xxx_display.h +5 -0
- esphome/components/ili9xxx/ili9xxx_init.h +59 -0
- esphome/components/ld2450/__init__.py +51 -0
- esphome/components/ld2450/binary_sensor.py +47 -0
- esphome/components/ld2450/button/__init__.py +45 -0
- esphome/components/ld2450/button/reset_button.cpp +9 -0
- esphome/components/ld2450/button/reset_button.h +18 -0
- esphome/components/ld2450/button/restart_button.cpp +9 -0
- esphome/components/ld2450/button/restart_button.h +18 -0
- esphome/components/ld2450/ld2450.cpp +876 -0
- esphome/components/ld2450/ld2450.h +234 -0
- esphome/components/ld2450/number/__init__.py +121 -0
- esphome/components/ld2450/number/presence_timeout_number.cpp +12 -0
- esphome/components/ld2450/number/presence_timeout_number.h +18 -0
- esphome/components/ld2450/number/zone_coordinate_number.cpp +14 -0
- esphome/components/ld2450/number/zone_coordinate_number.h +19 -0
- esphome/components/ld2450/select/__init__.py +56 -0
- esphome/components/ld2450/select/baud_rate_select.cpp +12 -0
- esphome/components/ld2450/select/baud_rate_select.h +18 -0
- esphome/components/ld2450/select/zone_type_select.cpp +12 -0
- esphome/components/ld2450/select/zone_type_select.h +18 -0
- esphome/components/ld2450/sensor.py +156 -0
- esphome/components/ld2450/switch/__init__.py +45 -0
- esphome/components/ld2450/switch/bluetooth_switch.cpp +12 -0
- esphome/components/ld2450/switch/bluetooth_switch.h +18 -0
- esphome/components/ld2450/switch/multi_target_switch.cpp +12 -0
- esphome/components/ld2450/switch/multi_target_switch.h +18 -0
- esphome/components/ld2450/text_sensor.py +62 -0
- esphome/components/lvgl/defines.py +0 -2
- esphome/components/lvgl/font.cpp +1 -1
- esphome/components/lvgl/lvgl_esphome.cpp +27 -19
- esphome/components/lvgl/widgets/img.py +1 -3
- esphome/components/mcp2515/mcp2515.cpp +1 -0
- esphome/components/mdns/__init__.py +1 -1
- esphome/components/mixer/speaker/mixer_speaker.cpp +6 -1
- esphome/components/mixer/speaker/mixer_speaker.h +2 -0
- esphome/components/mlx90393/sensor.py +53 -33
- esphome/components/mlx90393/sensor_mlx90393.cpp +4 -0
- esphome/components/mlx90393/sensor_mlx90393.h +8 -3
- esphome/components/mqtt/__init__.py +2 -2
- esphome/components/msa3xx/__init__.py +189 -0
- esphome/components/msa3xx/binary_sensor.py +40 -0
- esphome/components/msa3xx/msa3xx.cpp +417 -0
- esphome/components/msa3xx/msa3xx.h +311 -0
- esphome/components/msa3xx/sensor.py +42 -0
- esphome/components/msa3xx/text_sensor.py +38 -0
- esphome/components/nfc/binary_sensor/__init__.py +4 -4
- esphome/components/opentherm/binary_sensor/__init__.py +4 -4
- esphome/components/opentherm/generate.py +6 -6
- esphome/components/opentherm/sensor/__init__.py +5 -6
- esphome/components/packages/__init__.py +35 -11
- esphome/components/pn532/binary_sensor.py +4 -4
- esphome/components/rc522/binary_sensor.py +4 -4
- esphome/components/resampler/speaker/resampler_speaker.h +2 -0
- esphome/components/socket/bsd_sockets_impl.cpp +1 -0
- esphome/components/socket/lwip_sockets_impl.cpp +1 -0
- esphome/components/socket/socket.h +3 -1
- esphome/components/speaker/speaker.h +2 -2
- esphome/components/ssd1306_base/__init__.py +7 -7
- esphome/components/thermostat/climate.py +1 -1
- esphome/components/tmp1075/tmp1075.cpp +7 -11
- esphome/components/tmp1075/tmp1075.h +1 -2
- esphome/components/tormatic/__init__.py +1 -0
- esphome/components/tormatic/cover.py +47 -0
- esphome/components/tormatic/tormatic_cover.cpp +355 -0
- esphome/components/tormatic/tormatic_cover.h +60 -0
- esphome/components/tormatic/tormatic_protocol.h +211 -0
- esphome/components/touchscreen/binary_sensor/__init__.py +3 -0
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +7 -1
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +3 -1
- esphome/components/touchscreen/touchscreen.cpp +3 -4
- esphome/components/udp/udp_component.h +4 -1
- esphome/components/web_server/list_entities.cpp +70 -66
- esphome/components/web_server/list_entities.h +43 -22
- esphome/components/web_server/web_server.cpp +345 -68
- esphome/components/web_server/web_server.h +138 -6
- esphome/components/web_server_base/__init__.py +1 -1
- esphome/components/web_server_idf/__init__.py +2 -0
- esphome/components/web_server_idf/web_server_idf.cpp +177 -30
- esphome/components/web_server_idf/web_server_idf.h +53 -4
- esphome/config_validation.py +23 -125
- esphome/const.py +5 -1
- esphome/core/config.py +12 -4
- esphome/core/defines.h +1 -1
- esphome/core/helpers.h +24 -3
- esphome/core/time.cpp +1 -0
- esphome/cpp_generator.py +3 -3
- esphome/dashboard/core.py +30 -21
- esphome/dashboard/dns.py +7 -1
- esphome/dashboard/entries.py +83 -16
- esphome/dashboard/settings.py +0 -4
- esphome/dashboard/status/mdns.py +43 -14
- esphome/dashboard/status/mqtt.py +22 -9
- esphome/dashboard/status/ping.py +54 -10
- esphome/dashboard/web_server.py +56 -24
- esphome/storage_json.py +4 -0
- esphome/wizard.py +13 -17
- esphome/writer.py +1 -3
- esphome/yaml_util.py +36 -33
- esphome/zeroconf.py +9 -21
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/METADATA +7 -7
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/RECORD +145 -105
- esphome/components/cst816/binary_sensor/cst816_button.h +0 -27
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/LICENSE +0 -0
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/WHEEL +0 -0
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/entry_points.txt +0 -0
- {esphome-2025.2.2.dist-info → esphome-2025.3.0b2.dist-info}/top_level.txt +0 -0
@@ -259,14 +259,14 @@ AudioReaderState AudioReader::file_read_() {
|
|
259
259
|
}
|
260
260
|
|
261
261
|
AudioReaderState AudioReader::http_read_() {
|
262
|
-
this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS));
|
262
|
+
this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), false);
|
263
263
|
|
264
264
|
if (esp_http_client_is_complete_data_received(this->client_)) {
|
265
265
|
if (this->output_transfer_buffer_->available() == 0) {
|
266
266
|
this->cleanup_connection_();
|
267
267
|
return AudioReaderState::FINISHED;
|
268
268
|
}
|
269
|
-
} else {
|
269
|
+
} else if (this->output_transfer_buffer_->free() > 0) {
|
270
270
|
size_t bytes_to_read = this->output_transfer_buffer_->free();
|
271
271
|
int received_len =
|
272
272
|
esp_http_client_read(this->client_, (char *) this->output_transfer_buffer_->get_buffer_end(), bytes_to_read);
|
@@ -93,8 +93,9 @@ AudioResamplerState AudioResampler::resample(bool stop_gracefully, int32_t *ms_d
|
|
93
93
|
}
|
94
94
|
|
95
95
|
if (!this->pause_output_) {
|
96
|
-
// Move audio data to the sink
|
97
|
-
|
96
|
+
// Move audio data to the sink without shifting the data in the output transfer buffer to avoid unnecessary, slow
|
97
|
+
// data moves
|
98
|
+
this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), false);
|
98
99
|
} else {
|
99
100
|
// If paused, block to avoid wasting CPU resources
|
100
101
|
delay(READ_WRITE_TIMEOUT_MS);
|
@@ -115,6 +116,7 @@ AudioResamplerState AudioResampler::resample(bool stop_gracefully, int32_t *ms_d
|
|
115
116
|
|
116
117
|
if ((this->input_stream_info_.get_sample_rate() != this->output_stream_info_.get_sample_rate()) ||
|
117
118
|
(this->input_stream_info_.get_bits_per_sample() != this->output_stream_info_.get_bits_per_sample())) {
|
119
|
+
// Adjust gain by -3 dB to avoid clipping due to the resampling process
|
118
120
|
esp_audio_libs::resampler::ResamplerResults results =
|
119
121
|
this->resampler_->resample(this->input_transfer_buffer_->get_buffer_start(),
|
120
122
|
this->output_transfer_buffer_->get_buffer_end(), frames_available, frames_free, -3);
|
@@ -33,12 +33,17 @@ size_t AudioTransferBuffer::free() const {
|
|
33
33
|
if (this->buffer_size_ == 0) {
|
34
34
|
return 0;
|
35
35
|
}
|
36
|
-
return this->buffer_size_ - (this->buffer_length_
|
36
|
+
return this->buffer_size_ - (this->buffer_length_ + (this->data_start_ - this->buffer_));
|
37
37
|
}
|
38
38
|
|
39
39
|
void AudioTransferBuffer::decrease_buffer_length(size_t bytes) {
|
40
40
|
this->buffer_length_ -= bytes;
|
41
|
-
this->
|
41
|
+
if (this->buffer_length_ > 0) {
|
42
|
+
this->data_start_ += bytes;
|
43
|
+
} else {
|
44
|
+
// All the data in the buffer has been consumed, reset the start pointer
|
45
|
+
this->data_start_ = this->buffer_;
|
46
|
+
}
|
42
47
|
}
|
43
48
|
|
44
49
|
void AudioTransferBuffer::increase_buffer_length(size_t bytes) { this->buffer_length_ += bytes; }
|
@@ -71,7 +76,7 @@ bool AudioTransferBuffer::has_buffered_data() const {
|
|
71
76
|
|
72
77
|
bool AudioTransferBuffer::reallocate(size_t new_buffer_size) {
|
73
78
|
if (this->buffer_length_ > 0) {
|
74
|
-
//
|
79
|
+
// Buffer currently has data, so reallocation is impossible
|
75
80
|
return false;
|
76
81
|
}
|
77
82
|
this->deallocate_buffer_();
|
@@ -106,12 +111,14 @@ void AudioTransferBuffer::deallocate_buffer_() {
|
|
106
111
|
this->buffer_length_ = 0;
|
107
112
|
}
|
108
113
|
|
109
|
-
size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_wait) {
|
110
|
-
|
111
|
-
|
112
|
-
|
114
|
+
size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_wait, bool pre_shift) {
|
115
|
+
if (pre_shift) {
|
116
|
+
// Shift data in buffer to start
|
117
|
+
if (this->buffer_length_ > 0) {
|
118
|
+
memmove(this->buffer_, this->data_start_, this->buffer_length_);
|
119
|
+
}
|
120
|
+
this->data_start_ = this->buffer_;
|
113
121
|
}
|
114
|
-
this->data_start_ = this->buffer_;
|
115
122
|
|
116
123
|
size_t bytes_to_read = this->free();
|
117
124
|
size_t bytes_read = 0;
|
@@ -125,7 +132,7 @@ size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_
|
|
125
132
|
return bytes_read;
|
126
133
|
}
|
127
134
|
|
128
|
-
size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait) {
|
135
|
+
size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait, bool post_shift) {
|
129
136
|
size_t bytes_written = 0;
|
130
137
|
if (this->available()) {
|
131
138
|
#ifdef USE_SPEAKER
|
@@ -139,11 +146,14 @@ size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait)
|
|
139
146
|
}
|
140
147
|
|
141
148
|
this->decrease_buffer_length(bytes_written);
|
149
|
+
}
|
142
150
|
|
151
|
+
if (post_shift) {
|
143
152
|
// Shift unwritten data to the start of the buffer
|
144
153
|
memmove(this->buffer_, this->data_start_, this->buffer_length_);
|
145
154
|
this->data_start_ = this->buffer_;
|
146
155
|
}
|
156
|
+
|
147
157
|
return bytes_written;
|
148
158
|
}
|
149
159
|
|
@@ -60,6 +60,7 @@ class AudioTransferBuffer {
|
|
60
60
|
|
61
61
|
protected:
|
62
62
|
/// @brief Allocates the transfer buffer in external memory, if available.
|
63
|
+
/// @param buffer_size The number of bytes to allocate
|
63
64
|
/// @return True is successful, false otherwise.
|
64
65
|
bool allocate_buffer_(size_t buffer_size);
|
65
66
|
|
@@ -89,8 +90,10 @@ class AudioSinkTransferBuffer : public AudioTransferBuffer {
|
|
89
90
|
|
90
91
|
/// @brief Writes any available data in the transfer buffer to the sink.
|
91
92
|
/// @param ticks_to_wait FreeRTOS ticks to block while waiting for the sink to have enough space
|
93
|
+
/// @param post_shift If true, all remaining data is moved to the start of the buffer after transferring to the sink.
|
94
|
+
/// Defaults to true.
|
92
95
|
/// @return Number of bytes written
|
93
|
-
size_t transfer_data_to_sink(TickType_t ticks_to_wait);
|
96
|
+
size_t transfer_data_to_sink(TickType_t ticks_to_wait, bool post_shift = true);
|
94
97
|
|
95
98
|
/// @brief Adds a ring buffer as the transfer buffer's sink.
|
96
99
|
/// @param ring_buffer weak_ptr to the allocated ring buffer
|
@@ -125,8 +128,10 @@ class AudioSourceTransferBuffer : public AudioTransferBuffer {
|
|
125
128
|
|
126
129
|
/// @brief Reads any available data from the sink into the transfer buffer.
|
127
130
|
/// @param ticks_to_wait FreeRTOS ticks to block while waiting for the source to have enough data
|
131
|
+
/// @param pre_shift If true, any unwritten data is moved to the start of the buffer before transferring from the
|
132
|
+
/// source. Defaults to true.
|
128
133
|
/// @return Number of bytes read
|
129
|
-
size_t transfer_data_from_source(TickType_t ticks_to_wait);
|
134
|
+
size_t transfer_data_from_source(TickType_t ticks_to_wait, bool pre_shift = true);
|
130
135
|
|
131
136
|
/// @brief Adds a ring buffer as the transfer buffer's source.
|
132
137
|
/// @param ring_buffer weak_ptr to the allocated ring buffer
|
@@ -15,6 +15,9 @@
|
|
15
15
|
|
16
16
|
#include "bluetooth_connection.h"
|
17
17
|
|
18
|
+
#include <esp_bt.h>
|
19
|
+
#include <esp_bt_device.h>
|
20
|
+
|
18
21
|
namespace esphome {
|
19
22
|
namespace bluetooth_proxy {
|
20
23
|
|
@@ -114,6 +117,11 @@ class BluetoothProxy : public esp32_ble_tracker::ESPBTDeviceListener, public Com
|
|
114
117
|
return flags;
|
115
118
|
}
|
116
119
|
|
120
|
+
std::string get_bluetooth_mac_address_pretty() {
|
121
|
+
const uint8_t *mac = esp_bt_dev_get_address();
|
122
|
+
return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
123
|
+
}
|
124
|
+
|
117
125
|
protected:
|
118
126
|
void send_api_packet_(const esp32_ble_tracker::ESPBTDevice &device);
|
119
127
|
|
@@ -95,7 +95,7 @@ void BMP085Component::read_pressure_() {
|
|
95
95
|
return;
|
96
96
|
}
|
97
97
|
|
98
|
-
uint32_t value = (uint32_t(buffer[0]) << 16) | (uint32_t(buffer[1]) << 8) | uint32_t(buffer[
|
98
|
+
uint32_t value = (uint32_t(buffer[0]) << 16) | (uint32_t(buffer[1]) << 8) | uint32_t(buffer[2]);
|
99
99
|
if ((value >> 5) == 0) {
|
100
100
|
ESP_LOGW(TAG, "Invalid pressure!");
|
101
101
|
this->status_set_warning();
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#include "chsc6x_touchscreen.h"
|
2
|
+
|
3
|
+
namespace esphome {
|
4
|
+
namespace chsc6x {
|
5
|
+
|
6
|
+
void CHSC6XTouchscreen::setup() {
|
7
|
+
ESP_LOGCONFIG(TAG, "Setting up CHSC6X Touchscreen...");
|
8
|
+
if (this->interrupt_pin_ != nullptr) {
|
9
|
+
this->interrupt_pin_->setup();
|
10
|
+
this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE);
|
11
|
+
}
|
12
|
+
if (this->x_raw_max_ == this->x_raw_min_) {
|
13
|
+
this->x_raw_max_ = this->display_->get_native_width();
|
14
|
+
}
|
15
|
+
if (this->y_raw_max_ == this->y_raw_min_) {
|
16
|
+
this->y_raw_max_ = this->display_->get_native_height();
|
17
|
+
}
|
18
|
+
|
19
|
+
ESP_LOGCONFIG(TAG, "CHSC6X Touchscreen setup complete");
|
20
|
+
}
|
21
|
+
|
22
|
+
void CHSC6XTouchscreen::update_touches() {
|
23
|
+
uint8_t data[CHSC6X_REG_STATUS_LEN];
|
24
|
+
if (!this->read_bytes(CHSC6X_REG_STATUS, data, sizeof(data))) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
uint8_t num_of_touches = data[CHSC6X_REG_STATUS_TOUCH];
|
29
|
+
|
30
|
+
if (num_of_touches == 1) {
|
31
|
+
uint16_t x = data[CHSC6X_REG_STATUS_X_COR];
|
32
|
+
uint16_t y = data[CHSC6X_REG_STATUS_Y_COR];
|
33
|
+
this->add_raw_touch_position_(0, x, y);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
void CHSC6XTouchscreen::dump_config() {
|
38
|
+
ESP_LOGCONFIG(TAG, "CHSC6X Touchscreen:");
|
39
|
+
LOG_I2C_DEVICE(this);
|
40
|
+
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
|
41
|
+
ESP_LOGCONFIG(TAG, " Touch timeout: %d", this->touch_timeout_);
|
42
|
+
ESP_LOGCONFIG(TAG, " x_raw_max_: %d", this->x_raw_max_);
|
43
|
+
ESP_LOGCONFIG(TAG, " y_raw_max_: %d", this->y_raw_max_);
|
44
|
+
}
|
45
|
+
|
46
|
+
} // namespace chsc6x
|
47
|
+
} // namespace esphome
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/components/i2c/i2c.h"
|
4
|
+
#include "esphome/components/touchscreen/touchscreen.h"
|
5
|
+
#include "esphome/core/component.h"
|
6
|
+
#include "esphome/core/hal.h"
|
7
|
+
#include "esphome/core/log.h"
|
8
|
+
|
9
|
+
namespace esphome {
|
10
|
+
namespace chsc6x {
|
11
|
+
|
12
|
+
static const char *const TAG = "chsc6x.touchscreen";
|
13
|
+
|
14
|
+
static const uint8_t CHSC6X_REG_STATUS = 0x00;
|
15
|
+
static const uint8_t CHSC6X_REG_STATUS_TOUCH = 0x00;
|
16
|
+
static const uint8_t CHSC6X_REG_STATUS_X_COR = 0x02;
|
17
|
+
static const uint8_t CHSC6X_REG_STATUS_Y_COR = 0x04;
|
18
|
+
static const uint8_t CHSC6X_REG_STATUS_LEN = 0x05;
|
19
|
+
static const uint8_t CHSC6X_CHIP_ID = 0x2e;
|
20
|
+
|
21
|
+
class CHSC6XTouchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice {
|
22
|
+
public:
|
23
|
+
void setup() override;
|
24
|
+
void update_touches() override;
|
25
|
+
void dump_config() override;
|
26
|
+
|
27
|
+
void set_interrupt_pin(InternalGPIOPin *pin) { this->interrupt_pin_ = pin; }
|
28
|
+
|
29
|
+
protected:
|
30
|
+
InternalGPIOPin *interrupt_pin_{};
|
31
|
+
};
|
32
|
+
|
33
|
+
} // namespace chsc6x
|
34
|
+
} // namespace esphome
|
@@ -0,0 +1,33 @@
|
|
1
|
+
from esphome import pins
|
2
|
+
import esphome.codegen as cg
|
3
|
+
from esphome.components import i2c, touchscreen
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.const import CONF_ID, CONF_INTERRUPT_PIN
|
6
|
+
|
7
|
+
chsc6x_ns = cg.esphome_ns.namespace("chsc6x")
|
8
|
+
|
9
|
+
CHSC6XTouchscreen = chsc6x_ns.class_(
|
10
|
+
"CHSC6XTouchscreen",
|
11
|
+
touchscreen.Touchscreen,
|
12
|
+
i2c.I2CDevice,
|
13
|
+
)
|
14
|
+
|
15
|
+
CONFIG_SCHEMA = (
|
16
|
+
touchscreen.touchscreen_schema("100ms")
|
17
|
+
.extend(
|
18
|
+
{
|
19
|
+
cv.GenerateID(): cv.declare_id(CHSC6XTouchscreen),
|
20
|
+
cv.Optional(CONF_INTERRUPT_PIN): pins.internal_gpio_input_pin_schema,
|
21
|
+
}
|
22
|
+
)
|
23
|
+
.extend(i2c.i2c_device_schema(0x2E))
|
24
|
+
)
|
25
|
+
|
26
|
+
|
27
|
+
async def to_code(config):
|
28
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
29
|
+
await touchscreen.register_touchscreen(var, config)
|
30
|
+
await i2c.register_i2c_device(var, config)
|
31
|
+
|
32
|
+
if interrupt_pin := config.get(CONF_INTERRUPT_PIN):
|
33
|
+
cg.add(var.set_interrupt_pin(await cg.gpio_pin_expression(interrupt_pin)))
|
@@ -1,28 +1,5 @@
|
|
1
|
-
import esphome.codegen as cg
|
2
1
|
import esphome.config_validation as cv
|
3
|
-
from esphome.components import binary_sensor
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
CONF_CST816_ID = "cst816_id"
|
9
|
-
|
10
|
-
CST816Button = cst816_ns.class_(
|
11
|
-
"CST816Button",
|
12
|
-
binary_sensor.BinarySensor,
|
13
|
-
cg.Component,
|
14
|
-
CST816ButtonListener,
|
15
|
-
cg.Parented.template(CST816Touchscreen),
|
16
|
-
)
|
17
|
-
|
18
|
-
CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(CST816Button).extend(
|
19
|
-
{
|
20
|
-
cv.GenerateID(CONF_CST816_ID): cv.use_id(CST816Touchscreen),
|
21
|
-
}
|
3
|
+
CONFIG_SCHEMA = cv.invalid(
|
4
|
+
"The CST816 binary sensor has been removed. Instead use the touchscreen binary sensor with the 'use_raw' flag set."
|
22
5
|
)
|
23
|
-
|
24
|
-
|
25
|
-
async def to_code(config):
|
26
|
-
var = await binary_sensor.new_binary_sensor(config)
|
27
|
-
await cg.register_component(var, config)
|
28
|
-
await cg.register_parented(var, config[CONF_CST816_ID])
|
@@ -37,14 +37,6 @@ void CST816Touchscreen::continue_setup_() {
|
|
37
37
|
ESP_LOGCONFIG(TAG, "CST816 Touchscreen setup complete");
|
38
38
|
}
|
39
39
|
|
40
|
-
void CST816Touchscreen::update_button_state_(bool state) {
|
41
|
-
if (this->button_touched_ == state)
|
42
|
-
return;
|
43
|
-
this->button_touched_ = state;
|
44
|
-
for (auto *listener : this->button_listeners_)
|
45
|
-
listener->update_button(state);
|
46
|
-
}
|
47
|
-
|
48
40
|
void CST816Touchscreen::setup() {
|
49
41
|
ESP_LOGCONFIG(TAG, "Setting up CST816 Touchscreen...");
|
50
42
|
if (this->reset_pin_ != nullptr) {
|
@@ -68,18 +60,13 @@ void CST816Touchscreen::update_touches() {
|
|
68
60
|
}
|
69
61
|
uint8_t num_of_touches = data[REG_TOUCH_NUM] & 3;
|
70
62
|
if (num_of_touches == 0) {
|
71
|
-
this->update_button_state_(false);
|
72
63
|
return;
|
73
64
|
}
|
74
65
|
|
75
66
|
uint16_t x = encode_uint16(data[REG_XPOS_HIGH] & 0xF, data[REG_XPOS_LOW]);
|
76
67
|
uint16_t y = encode_uint16(data[REG_YPOS_HIGH] & 0xF, data[REG_YPOS_LOW]);
|
77
68
|
ESP_LOGV(TAG, "Read touch %d/%d", x, y);
|
78
|
-
|
79
|
-
this->update_button_state_(true);
|
80
|
-
} else {
|
81
|
-
this->add_raw_touch_position_(0, x, y);
|
82
|
-
}
|
69
|
+
this->add_raw_touch_position_(0, x, y);
|
83
70
|
}
|
84
71
|
|
85
72
|
void CST816Touchscreen::dump_config() {
|
@@ -87,6 +74,8 @@ void CST816Touchscreen::dump_config() {
|
|
87
74
|
LOG_I2C_DEVICE(this);
|
88
75
|
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
|
89
76
|
LOG_PIN(" Reset Pin: ", this->reset_pin_);
|
77
|
+
ESP_LOGCONFIG(TAG, " X Raw Min: %d, X Raw Max: %d", this->x_raw_min_, this->x_raw_max_);
|
78
|
+
ESP_LOGCONFIG(TAG, " Y Raw Min: %d, Y Raw Max: %d", this->y_raw_min_, this->y_raw_max_);
|
90
79
|
const char *name;
|
91
80
|
switch (this->chip_id_) {
|
92
81
|
case CST820_CHIP_ID:
|
@@ -40,7 +40,6 @@ class CST816Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
|
|
40
40
|
public:
|
41
41
|
void setup() override;
|
42
42
|
void update_touches() override;
|
43
|
-
void register_button_listener(CST816ButtonListener *listener) { this->button_listeners_.push_back(listener); }
|
44
43
|
void dump_config() override;
|
45
44
|
|
46
45
|
void set_interrupt_pin(InternalGPIOPin *pin) { this->interrupt_pin_ = pin; }
|
@@ -49,14 +48,11 @@ class CST816Touchscreen : public touchscreen::Touchscreen, public i2c::I2CDevice
|
|
49
48
|
|
50
49
|
protected:
|
51
50
|
void continue_setup_();
|
52
|
-
void update_button_state_(bool state);
|
53
51
|
|
54
52
|
InternalGPIOPin *interrupt_pin_{};
|
55
53
|
GPIOPin *reset_pin_{};
|
56
54
|
uint8_t chip_id_{};
|
57
55
|
bool skip_probe_{}; // if set, do not expect to be able to probe the controller on the i2c bus.
|
58
|
-
std::vector<CST816ButtonListener *> button_listeners_;
|
59
|
-
bool button_touched_{};
|
60
56
|
};
|
61
57
|
|
62
58
|
} // namespace cst816
|
@@ -66,7 +66,9 @@ FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant
|
|
66
66
|
|
67
67
|
async def to_code(config):
|
68
68
|
uuid = config[CONF_UUID].hex
|
69
|
-
uuid_arr = [
|
69
|
+
uuid_arr = [
|
70
|
+
cg.RawExpression(f"0x{uuid[i : i + 2]}") for i in range(0, len(uuid), 2)
|
71
|
+
]
|
70
72
|
var = cg.new_Pvariable(config[CONF_ID], uuid_arr)
|
71
73
|
|
72
74
|
parent = await cg.get_variable(config[esp32_ble.CONF_BLE_ID])
|
@@ -112,8 +112,7 @@ def validate_supports(value):
|
|
112
112
|
)
|
113
113
|
if is_pullup and num == 16:
|
114
114
|
raise cv.Invalid(
|
115
|
-
"GPIO Pin 16 does not support pullup pin mode. "
|
116
|
-
"Please choose another pin.",
|
115
|
+
"GPIO Pin 16 does not support pullup pin mode. Please choose another pin.",
|
117
116
|
[CONF_MODE, CONF_PULLUP],
|
118
117
|
)
|
119
118
|
if is_pulldown and num != 16:
|