mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 01:34:18 +01:00
Update esphome/components/lps22/lps22.cpp
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
ff66c43d37
commit
85eafdf8ff
1 changed files with 6 additions and 5 deletions
|
@ -60,11 +60,12 @@ RetryResult LPS22Component::try_read_() {
|
|||
float temp =
|
||||
TEMPERATURE_SCALE * static_cast<float>(static_cast<int16_t>(t_buf[1]) << 8 | static_cast<int16_t>(t_buf[0]));
|
||||
this->temperature_sensor_->publish_state(temp);
|
||||
uint8_t p_buf[3]{0};
|
||||
this->read_register(PRES_OUT_XL, p_buf, 3);
|
||||
uint32_t p_lsb =
|
||||
static_cast<uint32_t>(p_buf[2]) << 16 | static_cast<uint32_t>(p_buf[1]) << 8 | static_cast<uint32_t>(p_buf[0]);
|
||||
this->pressure_sensor_->publish_state(PRESSURE_SCALE * static_cast<float>(p_lsb));
|
||||
if (this->pressure_sensor_ != nullptr) {
|
||||
uint8_t p_buf[3]{0};
|
||||
this->read_register(PRES_OUT_XL, p_buf, 3);
|
||||
uint32_t p_lsb = encode_uint24(p_buf[2], p_buf[1], p_buf[0]);
|
||||
this->pressure_sensor_->publish_state(PRESSURE_SCALE * static_cast<float>(p_lsb));
|
||||
}
|
||||
return RetryResult::DONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue