mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[esp32] Fix some compiler warnings & bugs (#15610)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
@@ -111,14 +111,14 @@ class ATM90E32Component : public PollingComponent,
|
|||||||
#endif
|
#endif
|
||||||
float get_reference_voltage(uint8_t phase) {
|
float get_reference_voltage(uint8_t phase) {
|
||||||
#ifdef USE_NUMBER
|
#ifdef USE_NUMBER
|
||||||
return (phase >= 0 && phase < 3 && ref_voltages_[phase]) ? ref_voltages_[phase]->state : 120.0; // Default voltage
|
return (phase < 3 && ref_voltages_[phase]) ? ref_voltages_[phase]->state : 120.0; // Default voltage
|
||||||
#else
|
#else
|
||||||
return 120.0; // Default voltage
|
return 120.0; // Default voltage
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
float get_reference_current(uint8_t phase) {
|
float get_reference_current(uint8_t phase) {
|
||||||
#ifdef USE_NUMBER
|
#ifdef USE_NUMBER
|
||||||
return (phase >= 0 && phase < 3 && ref_currents_[phase]) ? ref_currents_[phase]->state : 5.0f; // Default current
|
return (phase < 3 && ref_currents_[phase]) ? ref_currents_[phase]->state : 5.0f; // Default current
|
||||||
#else
|
#else
|
||||||
return 5.0f; // Default current
|
return 5.0f; // Default current
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ void AirConditioner::on_status_change() {
|
|||||||
if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK &&
|
if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK &&
|
||||||
this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) {
|
this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) {
|
||||||
// Read existing presets (set by codegen), append frost protection, write back
|
// Read existing presets (set by codegen), append frost protection, write back
|
||||||
const auto &existing = this->get_traits().get_supported_custom_presets();
|
auto traits = this->get_traits();
|
||||||
|
const auto &existing = traits.get_supported_custom_presets();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const char *p : existing) {
|
for (const char *p : existing) {
|
||||||
if (strcmp(p, Constants::FREEZE_PROTECTION) == 0) {
|
if (strcmp(p, Constants::FREEZE_PROTECTION) == 0) {
|
||||||
|
|||||||
@@ -234,9 +234,9 @@ class MipiSpi : public display::Display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dump_config() override {
|
void dump_config() override {
|
||||||
internal_dump_config(this->model_, this->get_width(), this->get_height(), OFFSET_WIDTH, OFFSET_HEIGHT, MADCTL,
|
internal_dump_config(this->model_, this->get_width(), this->get_height(), OFFSET_WIDTH, OFFSET_HEIGHT,
|
||||||
this->invert_colors_, DISPLAYPIXEL * 8, IS_BIG_ENDIAN, this->brightness_, this->cs_,
|
(uint8_t) MADCTL, this->invert_colors_, DISPLAYPIXEL * 8, IS_BIG_ENDIAN, this->brightness_,
|
||||||
this->reset_pin_, this->dc_pin_, this->mode_, this->data_rate_, BUS_TYPE,
|
this->cs_, this->reset_pin_, this->dc_pin_, this->mode_, this->data_rate_, BUS_TYPE,
|
||||||
HAS_HARDWARE_ROTATION);
|
HAS_HARDWARE_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ class MipiSpi : public display::Display,
|
|||||||
this->write_command_(BRIGHTNESS, this->brightness_.value());
|
this->write_command_(BRIGHTNESS, this->brightness_.value());
|
||||||
|
|
||||||
// calculate new madctl value from base value adjusted for rotation
|
// calculate new madctl value from base value adjusted for rotation
|
||||||
uint8_t madctl = MADCTL; // lower 8 bits only
|
uint8_t madctl = (uint8_t) MADCTL; // lower 8 bits only
|
||||||
constexpr bool use_flips = (MADCTL & MADCTL_FLIP_FLAG) != 0;
|
constexpr bool use_flips = (MADCTL & MADCTL_FLIP_FLAG) != 0;
|
||||||
constexpr uint8_t x_mask = use_flips ? MADCTL_XFLIP : MADCTL_MX;
|
constexpr uint8_t x_mask = use_flips ? MADCTL_XFLIP : MADCTL_MX;
|
||||||
constexpr uint8_t y_mask = use_flips ? MADCTL_YFLIP : MADCTL_MY;
|
constexpr uint8_t y_mask = use_flips ? MADCTL_YFLIP : MADCTL_MY;
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ void TCS34725Component::set_integration_time(TCS34725IntegrationTime integration
|
|||||||
my_integration_time_regval = integration_time;
|
my_integration_time_regval = integration_time;
|
||||||
this->integration_time_auto_ = false;
|
this->integration_time_auto_ = false;
|
||||||
}
|
}
|
||||||
this->integration_time_ = (256.f - my_integration_time_regval) * 2.4f;
|
this->integration_time_ = (256.f - (float) my_integration_time_regval) * 2.4f;
|
||||||
ESP_LOGI(TAG, "TCS34725I Integration time set to: %.1fms", this->integration_time_);
|
ESP_LOGI(TAG, "TCS34725I Integration time set to: %.1fms", this->integration_time_);
|
||||||
}
|
}
|
||||||
void TCS34725Component::set_gain(TCS34725Gain gain) {
|
void TCS34725Component::set_gain(TCS34725Gain gain) {
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ def _generate_source_table_code(
|
|||||||
entries = ", ".join(var_names)
|
entries = ", ".join(var_names)
|
||||||
lines.append(f"static const char *const {table_var}[] PROGMEM = {{{entries}}};")
|
lines.append(f"static const char *const {table_var}[] PROGMEM = {{{entries}}};")
|
||||||
lines.append(f"const LogString *{lookup_fn}(uint8_t index) {{")
|
lines.append(f"const LogString *{lookup_fn}(uint8_t index) {{")
|
||||||
lines.append(f' if (index == 0 || index > {count}) return LOG_STR("<unknown>");')
|
cond = "index == 0" if count >= 255 else f"index == 0 || index > {count}"
|
||||||
|
lines.append(f' if ({cond}) return LOG_STR("<unknown>");')
|
||||||
lines.append(" return reinterpret_cast<const LogString *>(")
|
lines.append(" return reinterpret_cast<const LogString *>(")
|
||||||
lines.append(f" progmem_read_ptr(&{table_var}[index - 1]));")
|
lines.append(f" progmem_read_ptr(&{table_var}[index - 1]));")
|
||||||
lines.append("}")
|
lines.append("}")
|
||||||
|
|||||||
Reference in New Issue
Block a user