Compare commits
65 Commits
2022.10.0b
...
2022.10.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd8b9fb028 | ||
|
|
bdf1813b3a | ||
|
|
45b6c93f5f | ||
|
|
6124531479 | ||
|
|
b8549d323c | ||
|
|
01adece673 | ||
|
|
0220934e4c | ||
|
|
ca09693efa | ||
|
|
e96d7483b3 | ||
|
|
ccbfa20bb9 | ||
|
|
58cd754e07 | ||
|
|
d1263e583b | ||
|
|
67c911c37f | ||
|
|
288e3c3e3e | ||
|
|
a84378c6c2 | ||
|
|
b6073408f4 | ||
|
|
b2d91ac5de | ||
|
|
8bf34e09f4 | ||
|
|
be914f2c15 | ||
|
|
e8de6a3a67 | ||
|
|
3c320c4c83 | ||
|
|
3b83f967e4 | ||
|
|
5e96b8ef7c | ||
|
|
5df0e82c37 | ||
|
|
2d58239b74 | ||
|
|
6b52f62531 | ||
|
|
1001d9c04e | ||
|
|
119c3f6f46 | ||
|
|
d2c1c7507c | ||
|
|
efdb3d1f40 | ||
|
|
9dbc32b85f | ||
|
|
66226abb48 | ||
|
|
34bef2f2ca | ||
|
|
fdd4ca6837 | ||
|
|
9655362f23 | ||
|
|
130c9fad22 | ||
|
|
041eb8f6cc | ||
|
|
733a84df75 | ||
|
|
acd0b50b40 | ||
|
|
60e46d485e | ||
|
|
5bf0c92318 | ||
|
|
39d493c278 | ||
|
|
d2ce62aa13 | ||
|
|
c8eb30ef27 | ||
|
|
31ad75d01b | ||
|
|
aa2eb29274 | ||
|
|
22eb4f9cb9 | ||
|
|
3acc8e7479 | ||
|
|
adc8c1aa38 | ||
|
|
3a82f500d4 | ||
|
|
7d1d4831a8 | ||
|
|
ab86ddcf02 | ||
|
|
bf8eddb13b | ||
|
|
e5eaf7a3fe | ||
|
|
50f32a3aa5 | ||
|
|
eb878710c1 | ||
|
|
311980e0e4 | ||
|
|
df73170e5a | ||
|
|
ccc13cc9e1 | ||
|
|
020b2c05c8 | ||
|
|
4c37c17df1 | ||
|
|
8f67acadd8 | ||
|
|
ca13c4c1a6 | ||
|
|
d0c646c721 | ||
|
|
8a055675af |
@@ -58,7 +58,7 @@ class BLEPresenceDevice : public binary_sensor::BinarySensorInitiallyOff,
|
||||
case MATCH_BY_SERVICE_UUID:
|
||||
for (auto uuid : device.get_service_uuids()) {
|
||||
if (this->uuid_ == uuid) {
|
||||
this->publish_state(device.get_rssi());
|
||||
this->publish_state(true);
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class BLEPresenceDevice : public binary_sensor::BinarySensorInitiallyOff,
|
||||
return false;
|
||||
}
|
||||
|
||||
this->publish_state(device.get_rssi());
|
||||
this->publish_state(true);
|
||||
this->found_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,16 +26,9 @@ bool BluetoothProxy::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
|
||||
device.get_rssi());
|
||||
this->send_api_packet_(device);
|
||||
|
||||
this->address_type_map_[device.address_uint64()] = device.get_address_type();
|
||||
|
||||
if (this->address_ == 0)
|
||||
return true;
|
||||
|
||||
if (this->state_ == espbt::ClientState::DISCOVERED) {
|
||||
ESP_LOGV(TAG, "Connecting to address %s", this->address_str().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
BLEClientBase::parse_device(device);
|
||||
return true;
|
||||
}
|
||||
@@ -216,20 +209,9 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest
|
||||
switch (msg.request_type) {
|
||||
case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_CONNECT: {
|
||||
this->address_ = msg.address;
|
||||
if (this->address_type_map_.find(this->address_) != this->address_type_map_.end()) {
|
||||
// Utilise the address type cache
|
||||
this->remote_addr_type_ = this->address_type_map_[this->address_];
|
||||
} else {
|
||||
this->remote_addr_type_ = BLE_ADDR_TYPE_PUBLIC;
|
||||
}
|
||||
this->remote_bda_[0] = (this->address_ >> 40) & 0xFF;
|
||||
this->remote_bda_[1] = (this->address_ >> 32) & 0xFF;
|
||||
this->remote_bda_[2] = (this->address_ >> 24) & 0xFF;
|
||||
this->remote_bda_[3] = (this->address_ >> 16) & 0xFF;
|
||||
this->remote_bda_[4] = (this->address_ >> 8) & 0xFF;
|
||||
this->remote_bda_[5] = (this->address_ >> 0) & 0xFF;
|
||||
this->set_state(espbt::ClientState::DISCOVERED);
|
||||
esp_ble_gap_stop_scanning();
|
||||
this->set_state(espbt::ClientState::SEARCHING);
|
||||
api::global_api_server->send_bluetooth_connections_free(this->get_bluetooth_connections_free(),
|
||||
this->get_bluetooth_connections_limit());
|
||||
break;
|
||||
}
|
||||
case api::enums::BLUETOOTH_DEVICE_REQUEST_TYPE_DISCONNECT: {
|
||||
|
||||
@@ -45,7 +45,6 @@ class BluetoothProxy : public BLEClientBase {
|
||||
protected:
|
||||
void send_api_packet_(const esp32_ble_tracker::ESPBTDevice &device);
|
||||
|
||||
std::map<uint64_t, esp_ble_addr_type_t> address_type_map_;
|
||||
int16_t send_service_{-1};
|
||||
bool active_;
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_B
|
||||
bool BLEClientBase::parse_device(const espbt::ESPBTDevice &device) {
|
||||
if (device.address_uint64() != this->address_)
|
||||
return false;
|
||||
if (this->state_ != espbt::ClientState::IDLE)
|
||||
if (this->state_ != espbt::ClientState::IDLE && this->state_ != espbt::ClientState::SEARCHING)
|
||||
return false;
|
||||
|
||||
ESP_LOGD(TAG, "Found device at MAC address [%s]", device.address_str().c_str());
|
||||
|
||||
@@ -145,6 +145,8 @@ class ESPBTDeviceListener {
|
||||
enum class ClientState {
|
||||
// Connection is idle, no device detected.
|
||||
IDLE,
|
||||
// Searching for device.
|
||||
SEARCHING,
|
||||
// Device advertisement found.
|
||||
DISCOVERED,
|
||||
// Connection in progress.
|
||||
|
||||
@@ -571,24 +571,16 @@ int64_t payload_to_number(const std::vector<uint8_t> &data, SensorValueType sens
|
||||
static_cast<int32_t>(((value & 0x7FFF) << 16 | (value & 0xFFFF0000) >> 16) | sign_bit), bitmask);
|
||||
} break;
|
||||
case SensorValueType::U_QWORD:
|
||||
// Ignore bitmask for U_QWORD
|
||||
value = get_data<uint64_t>(data, offset);
|
||||
break;
|
||||
case SensorValueType::S_QWORD:
|
||||
// Ignore bitmask for S_QWORD
|
||||
value = get_data<int64_t>(data, offset);
|
||||
// Ignore bitmask for QWORD
|
||||
value = get_data<uint64_t>(data, offset);
|
||||
break;
|
||||
case SensorValueType::U_QWORD_R:
|
||||
// Ignore bitmask for U_QWORD
|
||||
value = get_data<uint64_t>(data, offset);
|
||||
value = static_cast<uint64_t>(value & 0xFFFF) << 48 | (value & 0xFFFF000000000000) >> 48 |
|
||||
static_cast<uint64_t>(value & 0xFFFF0000) << 32 | (value & 0x0000FFFF00000000) >> 32 |
|
||||
static_cast<uint64_t>(value & 0xFFFF00000000) << 16 | (value & 0x00000000FFFF0000) >> 16;
|
||||
break;
|
||||
case SensorValueType::S_QWORD_R:
|
||||
// Ignore bitmask for S_QWORD
|
||||
value = get_data<int64_t>(data, offset);
|
||||
break;
|
||||
case SensorValueType::S_QWORD_R: {
|
||||
// Ignore bitmask for QWORD
|
||||
uint64_t tmp = get_data<uint64_t>(data, offset);
|
||||
value = (tmp << 48) | (tmp >> 48) | ((tmp & 0xFFFF0000) << 16) | ((tmp >> 16) & 0xFFFF0000);
|
||||
} break;
|
||||
case SensorValueType::RAW:
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -55,6 +55,7 @@ from esphome.const import (
|
||||
DEVICE_CLASS_PM25,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_POWER_FACTOR,
|
||||
DEVICE_CLASS_PRECIPITATION_INTENSITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_REACTIVE_POWER,
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
@@ -65,6 +66,8 @@ from esphome.const import (
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
@@ -100,6 +103,7 @@ DEVICE_CLASSES = [
|
||||
DEVICE_CLASS_PM25,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_POWER_FACTOR,
|
||||
DEVICE_CLASS_PRECIPITATION_INTENSITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_REACTIVE_POWER,
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||
@@ -110,6 +114,8 @@ DEVICE_CLASSES = [
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
]
|
||||
|
||||
|
||||
@@ -974,9 +974,19 @@ void ThermostatClimate::change_preset_(climate::ClimatePreset preset) {
|
||||
auto config = this->preset_config_.find(preset);
|
||||
|
||||
if (config != this->preset_config_.end()) {
|
||||
ESP_LOGI(TAG, "Switching to preset %s", LOG_STR_ARG(climate::climate_preset_to_string(preset)));
|
||||
this->change_preset_internal_(config->second);
|
||||
ESP_LOGI(TAG, "Preset %s requested", LOG_STR_ARG(climate::climate_preset_to_string(preset)));
|
||||
if (this->change_preset_internal_(config->second) || (!this->preset.has_value()) ||
|
||||
this->preset.value() != preset) {
|
||||
// Fire any preset changed trigger if defined
|
||||
Trigger<> *trig = this->preset_change_trigger_;
|
||||
assert(trig != nullptr);
|
||||
trig->trigger();
|
||||
|
||||
this->refresh();
|
||||
ESP_LOGI(TAG, "Preset %s applied", LOG_STR_ARG(climate::climate_preset_to_string(preset)));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "No changes required to apply preset %s", LOG_STR_ARG(climate::climate_preset_to_string(preset)));
|
||||
}
|
||||
this->custom_preset.reset();
|
||||
this->preset = preset;
|
||||
} else {
|
||||
@@ -988,9 +998,19 @@ void ThermostatClimate::change_custom_preset_(const std::string &custom_preset)
|
||||
auto config = this->custom_preset_config_.find(custom_preset);
|
||||
|
||||
if (config != this->custom_preset_config_.end()) {
|
||||
ESP_LOGI(TAG, "Switching to custom preset %s", custom_preset.c_str());
|
||||
this->change_preset_internal_(config->second);
|
||||
ESP_LOGI(TAG, "Custom preset %s requested", custom_preset.c_str());
|
||||
if (this->change_preset_internal_(config->second) || (!this->custom_preset.has_value()) ||
|
||||
this->custom_preset.value() != custom_preset) {
|
||||
// Fire any preset changed trigger if defined
|
||||
Trigger<> *trig = this->preset_change_trigger_;
|
||||
assert(trig != nullptr);
|
||||
trig->trigger();
|
||||
|
||||
this->refresh();
|
||||
ESP_LOGI(TAG, "Custom preset %s applied", custom_preset.c_str());
|
||||
} else {
|
||||
ESP_LOGI(TAG, "No changes required to apply custom preset %s", custom_preset.c_str());
|
||||
}
|
||||
this->preset.reset();
|
||||
this->custom_preset = custom_preset;
|
||||
} else {
|
||||
@@ -998,39 +1018,46 @@ void ThermostatClimate::change_custom_preset_(const std::string &custom_preset)
|
||||
}
|
||||
}
|
||||
|
||||
void ThermostatClimate::change_preset_internal_(const ThermostatClimateTargetTempConfig &config) {
|
||||
bool ThermostatClimate::change_preset_internal_(const ThermostatClimateTargetTempConfig &config) {
|
||||
bool something_changed = false;
|
||||
|
||||
if (this->supports_two_points_) {
|
||||
this->target_temperature_low = config.default_temperature_low;
|
||||
this->target_temperature_high = config.default_temperature_high;
|
||||
if (this->target_temperature_low != config.default_temperature_low) {
|
||||
this->target_temperature_low = config.default_temperature_low;
|
||||
something_changed = true;
|
||||
}
|
||||
if (this->target_temperature_high != config.default_temperature_high) {
|
||||
this->target_temperature_high = config.default_temperature_high;
|
||||
something_changed = true;
|
||||
}
|
||||
} else {
|
||||
this->target_temperature = config.default_temperature;
|
||||
if (this->target_temperature != config.default_temperature) {
|
||||
this->target_temperature = config.default_temperature;
|
||||
something_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: The mode, fan_mode, and swing_mode can all be defined on the preset but if the climate.control call
|
||||
// also specifies them then the control's version will override these for that call
|
||||
if (config.mode_.has_value()) {
|
||||
this->mode = *config.mode_;
|
||||
// Note: The mode, fan_mode and swing_mode can all be defined in the preset but if the climate.control call
|
||||
// also specifies them then the climate.control call's values will override the preset's values for that call
|
||||
if (config.mode_.has_value() && (this->mode != config.mode_.value())) {
|
||||
ESP_LOGV(TAG, "Setting mode to %s", LOG_STR_ARG(climate::climate_mode_to_string(*config.mode_)));
|
||||
this->mode = *config.mode_;
|
||||
something_changed = true;
|
||||
}
|
||||
|
||||
if (config.fan_mode_.has_value()) {
|
||||
this->fan_mode = *config.fan_mode_;
|
||||
if (config.fan_mode_.has_value() && (this->fan_mode != config.fan_mode_.value())) {
|
||||
ESP_LOGV(TAG, "Setting fan mode to %s", LOG_STR_ARG(climate::climate_fan_mode_to_string(*config.fan_mode_)));
|
||||
this->fan_mode = *config.fan_mode_;
|
||||
something_changed = true;
|
||||
}
|
||||
|
||||
if (config.swing_mode_.has_value()) {
|
||||
if (config.swing_mode_.has_value() && (this->swing_mode != config.swing_mode_.value())) {
|
||||
ESP_LOGV(TAG, "Setting swing mode to %s", LOG_STR_ARG(climate::climate_swing_mode_to_string(*config.swing_mode_)));
|
||||
this->swing_mode = *config.swing_mode_;
|
||||
something_changed = true;
|
||||
}
|
||||
|
||||
// Fire any preset changed trigger if defined
|
||||
if (this->preset != preset) {
|
||||
Trigger<> *trig = this->preset_change_trigger_;
|
||||
assert(trig != nullptr);
|
||||
trig->trigger();
|
||||
}
|
||||
|
||||
this->refresh();
|
||||
return something_changed;
|
||||
}
|
||||
|
||||
void ThermostatClimate::set_preset_config(climate::ClimatePreset preset,
|
||||
|
||||
@@ -168,7 +168,8 @@ class ThermostatClimate : public climate::Climate, public Component {
|
||||
|
||||
/// Applies the temperature, mode, fan, and swing modes of the provided config.
|
||||
/// This is agnostic of custom vs built in preset
|
||||
void change_preset_internal_(const ThermostatClimateTargetTempConfig &config);
|
||||
/// Returns true if something was changed
|
||||
bool change_preset_internal_(const ThermostatClimateTargetTempConfig &config);
|
||||
|
||||
/// Return the traits of this controller.
|
||||
climate::ClimateTraits traits() override;
|
||||
|
||||
@@ -20,8 +20,6 @@ void XPT2046Component::setup() {
|
||||
this->irq_pin_->setup(); // INPUT
|
||||
this->irq_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
|
||||
this->irq_pin_->setup();
|
||||
|
||||
this->store_.pin = this->irq_pin_->to_isr();
|
||||
this->irq_pin_->attach_interrupt(XPT2046TouchscreenStore::gpio_intr, &this->store_, gpio::INTERRUPT_FALLING_EDGE);
|
||||
}
|
||||
spi_setup();
|
||||
@@ -29,10 +27,10 @@ void XPT2046Component::setup() {
|
||||
}
|
||||
|
||||
void XPT2046Component::loop() {
|
||||
if ((this->irq_pin_ == nullptr) || (!this->store_.touch))
|
||||
return;
|
||||
this->store_.touch = false;
|
||||
check_touch_();
|
||||
if ((this->irq_pin_ != nullptr) && (this->store_.touch || this->touched)) {
|
||||
this->store_.touch = false;
|
||||
check_touch_();
|
||||
}
|
||||
}
|
||||
|
||||
void XPT2046Component::update() {
|
||||
@@ -45,94 +43,88 @@ void XPT2046Component::check_touch_() {
|
||||
bool touch = false;
|
||||
uint32_t now = millis();
|
||||
|
||||
this->z_raw = 0;
|
||||
enable();
|
||||
|
||||
// In case the penirq pin is present only do the SPI transaction if it reports a touch (is low).
|
||||
// The touch has to be also confirmed with checking the pressure over threshold
|
||||
if ((this->irq_pin_ == nullptr) || !this->irq_pin_->digital_read()) {
|
||||
enable();
|
||||
int16_t touch_pressure_1 = read_adc_(0xB1 /* touch_pressure_1 */);
|
||||
int16_t touch_pressure_2 = read_adc_(0xC1 /* touch_pressure_2 */);
|
||||
|
||||
int16_t touch_pressure_1 = read_adc_(0xB1 /* touch_pressure_1 */);
|
||||
int16_t touch_pressure_2 = read_adc_(0xC1 /* touch_pressure_2 */);
|
||||
this->z_raw = touch_pressure_1 + 0Xfff - touch_pressure_2;
|
||||
|
||||
this->z_raw = touch_pressure_1 + 4095 - touch_pressure_2;
|
||||
touch = (this->z_raw >= this->threshold_);
|
||||
if (touch) {
|
||||
read_adc_(0xD1 /* X */); // dummy Y measure, 1st is always noisy
|
||||
data[0] = read_adc_(0x91 /* Y */);
|
||||
data[1] = read_adc_(0xD1 /* X */); // make 3 x-y measurements
|
||||
data[2] = read_adc_(0x91 /* Y */);
|
||||
data[3] = read_adc_(0xD1 /* X */);
|
||||
data[4] = read_adc_(0x91 /* Y */);
|
||||
}
|
||||
|
||||
touch = (this->z_raw >= this->threshold_);
|
||||
if (touch) {
|
||||
read_adc_(0x91 /* Y */); // dummy Y measure, 1st is always noisy
|
||||
data[0] = read_adc_(0xD1 /* X */);
|
||||
data[1] = read_adc_(0x91 /* Y */); // make 3 x-y measurements
|
||||
data[2] = read_adc_(0xD1 /* X */);
|
||||
data[3] = read_adc_(0x91 /* Y */);
|
||||
data[4] = read_adc_(0xD1 /* X */);
|
||||
data[5] = read_adc_(0xD0 /* X */); // Last X touch power down
|
||||
|
||||
disable();
|
||||
|
||||
if (touch) {
|
||||
this->x_raw = best_two_avg(data[1], data[3], data[5]);
|
||||
this->y_raw = best_two_avg(data[0], data[2], data[4]);
|
||||
|
||||
ESP_LOGVV(TAG, "Update [x, y] = [%d, %d], z = %d", this->x_raw, this->y_raw, this->z_raw);
|
||||
|
||||
TouchPoint touchpoint;
|
||||
|
||||
touchpoint.x = normalize(this->x_raw, this->x_raw_min_, this->x_raw_max_);
|
||||
touchpoint.y = normalize(this->y_raw, this->y_raw_min_, this->y_raw_max_);
|
||||
|
||||
if (this->swap_x_y_) {
|
||||
std::swap(touchpoint.x, touchpoint.y);
|
||||
}
|
||||
|
||||
data[5] = read_adc_(0x90 /* Y */); // Last Y touch power down
|
||||
if (this->invert_x_) {
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
}
|
||||
|
||||
disable();
|
||||
if (this->invert_y_) {
|
||||
touchpoint.y = 0xfff - touchpoint.y;
|
||||
}
|
||||
|
||||
if (touch) {
|
||||
this->x_raw = best_two_avg(data[0], data[2], data[4]);
|
||||
this->y_raw = best_two_avg(data[1], data[3], data[5]);
|
||||
|
||||
ESP_LOGVV(TAG, "Update [x, y] = [%d, %d], z = %d", this->x_raw, this->y_raw, this->z_raw);
|
||||
|
||||
TouchPoint touchpoint;
|
||||
|
||||
touchpoint.x = normalize(this->x_raw, this->x_raw_min_, this->x_raw_max_);
|
||||
touchpoint.y = normalize(this->y_raw, this->y_raw_min_, this->y_raw_max_);
|
||||
|
||||
if (this->swap_x_y_) {
|
||||
switch (static_cast<TouchRotation>(this->display_->get_rotation())) {
|
||||
case ROTATE_0_DEGREES:
|
||||
break;
|
||||
case ROTATE_90_DEGREES:
|
||||
std::swap(touchpoint.x, touchpoint.y);
|
||||
}
|
||||
|
||||
if (this->invert_x_) {
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
}
|
||||
|
||||
if (this->invert_y_) {
|
||||
touchpoint.y = 0xfff - touchpoint.y;
|
||||
}
|
||||
|
||||
switch (static_cast<TouchRotation>(this->display_->get_rotation())) {
|
||||
case ROTATE_0_DEGREES:
|
||||
break;
|
||||
case ROTATE_90_DEGREES:
|
||||
std::swap(touchpoint.x, touchpoint.y);
|
||||
touchpoint.y = 0xfff - touchpoint.y;
|
||||
break;
|
||||
case ROTATE_180_DEGREES:
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
touchpoint.y = 0xfff - touchpoint.y;
|
||||
break;
|
||||
case ROTATE_270_DEGREES:
|
||||
std::swap(touchpoint.x, touchpoint.y);
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
break;
|
||||
}
|
||||
|
||||
touchpoint.x = (int16_t)((int) touchpoint.x * this->display_->get_width() / 0xfff);
|
||||
touchpoint.y = (int16_t)((int) touchpoint.y * this->display_->get_height() / 0xfff);
|
||||
|
||||
if (!this->touched || (now - this->last_pos_ms_) >= this->report_millis_) {
|
||||
ESP_LOGV(TAG, "Touching at [%03X, %03X] => [%3d, %3d]", this->x_raw, this->y_raw, touchpoint.x, touchpoint.y);
|
||||
|
||||
this->defer([this, touchpoint]() { this->send_touch_(touchpoint); });
|
||||
|
||||
this->x = touchpoint.x;
|
||||
this->y = touchpoint.y;
|
||||
this->touched = true;
|
||||
this->last_pos_ms_ = now;
|
||||
}
|
||||
} else {
|
||||
this->x_raw = this->y_raw = 0;
|
||||
if (this->touched) {
|
||||
ESP_LOGV(TAG, "Released [%d, %d]", this->x, this->y);
|
||||
this->touched = false;
|
||||
for (auto *listener : this->touch_listeners_)
|
||||
listener->release();
|
||||
}
|
||||
break;
|
||||
case ROTATE_180_DEGREES:
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
touchpoint.y = 0xfff - touchpoint.y;
|
||||
break;
|
||||
case ROTATE_270_DEGREES:
|
||||
std::swap(touchpoint.x, touchpoint.y);
|
||||
touchpoint.x = 0xfff - touchpoint.x;
|
||||
break;
|
||||
}
|
||||
|
||||
touchpoint.x = (int16_t)((int) touchpoint.x * this->display_->get_width() / 0xfff);
|
||||
touchpoint.y = (int16_t)((int) touchpoint.y * this->display_->get_height() / 0xfff);
|
||||
|
||||
if (!this->touched || (now - this->last_pos_ms_) >= this->report_millis_) {
|
||||
ESP_LOGV(TAG, "Touching at [%03X, %03X] => [%3d, %3d]", this->x_raw, this->y_raw, touchpoint.x, touchpoint.y);
|
||||
|
||||
this->defer([this, touchpoint]() { this->send_touch_(touchpoint); });
|
||||
|
||||
this->x = touchpoint.x;
|
||||
this->y = touchpoint.y;
|
||||
this->touched = true;
|
||||
this->last_pos_ms_ = now;
|
||||
}
|
||||
}
|
||||
|
||||
if (!touch && this->touched) {
|
||||
this->x_raw = this->y_raw = this->z_raw = 0;
|
||||
ESP_LOGV(TAG, "Released [%d, %d]", this->x, this->y);
|
||||
this->touched = false;
|
||||
for (auto *listener : this->touch_listeners_)
|
||||
listener->release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +195,7 @@ int16_t XPT2046Component::read_adc_(uint8_t ctrl) { // NOLINT
|
||||
uint8_t data[2];
|
||||
|
||||
write_byte(ctrl);
|
||||
delay(1);
|
||||
data[0] = read_byte();
|
||||
data[1] = read_byte();
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ using namespace touchscreen;
|
||||
|
||||
struct XPT2046TouchscreenStore {
|
||||
volatile bool touch;
|
||||
ISRInternalGPIOPin pin;
|
||||
|
||||
static void gpio_intr(XPT2046TouchscreenStore *store);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2022.10.0b1"
|
||||
__version__ = "2022.10.2"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
@@ -947,6 +947,7 @@ DEVICE_CLASS_PM1 = "pm1"
|
||||
DEVICE_CLASS_PM10 = "pm10"
|
||||
DEVICE_CLASS_PM25 = "pm25"
|
||||
DEVICE_CLASS_POWER_FACTOR = "power_factor"
|
||||
DEVICE_CLASS_PRECIPITATION_INTENSITY = "precipitation_intensity"
|
||||
DEVICE_CLASS_PRESSURE = "pressure"
|
||||
DEVICE_CLASS_REACTIVE_POWER = "reactive_power"
|
||||
DEVICE_CLASS_SIGNAL_STRENGTH = "signal_strength"
|
||||
@@ -957,6 +958,8 @@ DEVICE_CLASS_TIMESTAMP = "timestamp"
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
||||
DEVICE_CLASS_VOLTAGE = "voltage"
|
||||
DEVICE_CLASS_VOLUME = "volume"
|
||||
DEVICE_CLASS_WATER = "water"
|
||||
DEVICE_CLASS_WIND_SPEED = "wind_speed"
|
||||
DEVICE_CLASS_WEIGHT = "weight"
|
||||
# device classes of both binary_sensor and button component
|
||||
DEVICE_CLASS_UPDATE = "update"
|
||||
|
||||
Reference in New Issue
Block a user