Compare commits

..

2 Commits

Author SHA1 Message Date
J. Nick Koston
2f58cb89b6 address 2026-01-23 21:24:40 -10:00
J. Nick Koston
d558291403 [light] Use member array instead of heap allocation in AddressableLightWrapper 2026-01-23 21:19:26 -10:00
3 changed files with 15 additions and 19 deletions

View File

@@ -7,9 +7,7 @@ namespace esphome::light {
class AddressableLightWrapper : public light::AddressableLight {
public:
explicit AddressableLightWrapper(light::LightState *light_state) : light_state_(light_state) {
this->wrapper_state_ = new uint8_t[5]; // NOLINT(cppcoreguidelines-owning-memory)
}
explicit AddressableLightWrapper(light::LightState *light_state) : light_state_(light_state) {}
int32_t size() const override { return 1; }
@@ -118,7 +116,7 @@ class AddressableLightWrapper : public light::AddressableLight {
}
light::LightState *light_state_;
uint8_t *wrapper_state_;
mutable uint8_t wrapper_state_[5]{};
ColorMode color_mode_{ColorMode::UNKNOWN};
};

View File

@@ -1,6 +1,5 @@
#pragma once
#include <array>
#include <cstdint>
namespace esphome {
@@ -22,7 +21,7 @@ enum SmlMessageType : uint16_t { SML_PUBLIC_OPEN_RES = 0x0101, SML_GET_LIST_RES
const uint16_t START_MASK = 0x55aa; // 0x1b 1b 1b 1b 01 01 01 01
const uint16_t END_MASK = 0x0157; // 0x1b 1b 1b 1b 1a
constexpr std::array<uint8_t, 8> START_SEQ = {0x1b, 0x1b, 0x1b, 0x1b, 0x01, 0x01, 0x01, 0x01};
const std::vector<uint8_t> START_SEQ = {0x1b, 0x1b, 0x1b, 0x1b, 0x01, 0x01, 0x01, 0x01};
} // namespace sml
} // namespace esphome

View File

@@ -1060,11 +1060,11 @@ bool ThermostatClimate::cooling_required_() {
auto temperature = this->supports_two_points_ ? this->target_temperature_high : this->target_temperature;
if (this->supports_cool_) {
if (this->current_temperature >= temperature + this->cooling_deadband_) {
// if the current temperature reaches or exceeds the target + deadband, cooling is required
if (this->current_temperature > temperature + this->cooling_deadband_) {
// if the current temperature exceeds the target + deadband, cooling is required
return true;
} else if (this->current_temperature <= temperature - this->cooling_overrun_) {
// if the current temperature is less than or equal to the target - overrun, cooling should stop
} else if (this->current_temperature < temperature - this->cooling_overrun_) {
// if the current temperature is less than the target - overrun, cooling should stop
return false;
} else {
// if we get here, the current temperature is between target + deadband and target - overrun,
@@ -1081,11 +1081,11 @@ bool ThermostatClimate::fanning_required_() {
if (this->supports_fan_only_) {
if (this->supports_fan_only_cooling_) {
if (this->current_temperature >= temperature + this->cooling_deadband_) {
// if the current temperature reaches or exceeds the target + deadband, fanning is required
if (this->current_temperature > temperature + this->cooling_deadband_) {
// if the current temperature exceeds the target + deadband, fanning is required
return true;
} else if (this->current_temperature <= temperature - this->cooling_overrun_) {
// if the current temperature is less than or equal to the target - overrun, fanning should stop
} else if (this->current_temperature < temperature - this->cooling_overrun_) {
// if the current temperature is less than the target - overrun, fanning should stop
return false;
} else {
// if we get here, the current temperature is between target + deadband and target - overrun,
@@ -1103,12 +1103,11 @@ bool ThermostatClimate::heating_required_() {
auto temperature = this->supports_two_points_ ? this->target_temperature_low : this->target_temperature;
if (this->supports_heat_) {
if (this->current_temperature <= temperature - this->heating_deadband_) {
// if the current temperature is below or equal to the target - deadband, heating is required
if (this->current_temperature < temperature - this->heating_deadband_) {
// if the current temperature is below the target - deadband, heating is required
return true;
} else if (this->current_temperature >= temperature + this->heating_overrun_) {
// if the current temperature is above or equal to the target + overrun, heating should stop
} else if (this->current_temperature > temperature + this->heating_overrun_) {
// if the current temperature is above the target + overrun, heating should stop
return false;
} else {
// if we get here, the current temperature is between target - deadband and target + overrun,