mirror of
https://github.com/esphome/esphome.git
synced 2026-09-01 02:26:01 +00:00
[multiple] Fix cast/operator precedence bugs (#14560)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3db436e48e
commit
7b8ba9bf20
@@ -91,7 +91,7 @@ class DateCall {
|
||||
|
||||
DateEntity *parent_;
|
||||
|
||||
optional<int16_t> year_;
|
||||
optional<uint16_t> year_;
|
||||
optional<uint8_t> month_;
|
||||
optional<uint8_t> day_;
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ uint8_t ES7210::es7210_gain_reg_value_(float mic_gain) {
|
||||
// reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB
|
||||
mic_gain += 0.5;
|
||||
if (mic_gain <= 33.0) {
|
||||
return (uint8_t) mic_gain / 3;
|
||||
return (uint8_t) (mic_gain / 3);
|
||||
}
|
||||
if (mic_gain < 36.0) {
|
||||
return 12;
|
||||
|
||||
@@ -199,7 +199,7 @@ void SGP4xComponent::measure_raw_() {
|
||||
response_words = 2;
|
||||
}
|
||||
}
|
||||
uint16_t rhticks = llround((uint16_t) ((humidity * 65535) / 100));
|
||||
uint16_t rhticks = (uint16_t) llround((humidity * 65535) / 100);
|
||||
uint16_t tempticks = (uint16_t) (((temperature + 45) * 65535) / 175);
|
||||
// first parameter are the relative humidity ticks
|
||||
data[0] = rhticks;
|
||||
|
||||
@@ -327,7 +327,9 @@ uint16_t TSL2591Component::get_illuminance(TSL2591SensorChannel channel, uint32_
|
||||
return (combined_illuminance >> 16);
|
||||
} else if (channel == TSL2591_SENSOR_CHANNEL_VISIBLE) {
|
||||
// Reads all and subtracts out the infrared
|
||||
return ((combined_illuminance & 0xFFFF) - (combined_illuminance >> 16));
|
||||
uint16_t full = combined_illuminance & 0xFFFF;
|
||||
uint16_t ir = combined_illuminance >> 16;
|
||||
return (ir > full) ? 0 : (full - ir);
|
||||
}
|
||||
// unknown channel!
|
||||
ESP_LOGE(TAG, "get_illuminance() caller requested an unknown channel: %d", channel);
|
||||
|
||||
Reference in New Issue
Block a user