mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 21:03:49 +01:00
[sps30] Clean up (#10998)
This commit is contained in:
@@ -45,16 +45,16 @@ void SPS30Component::setup() {
|
|||||||
}
|
}
|
||||||
ESP_LOGV(TAG, " Serial number: %s", this->serial_number_);
|
ESP_LOGV(TAG, " Serial number: %s", this->serial_number_);
|
||||||
|
|
||||||
|
bool result;
|
||||||
if (this->fan_interval_.has_value()) {
|
if (this->fan_interval_.has_value()) {
|
||||||
// override default value
|
// override default value
|
||||||
this->result_ =
|
result = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS, this->fan_interval_.value());
|
||||||
this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS, this->fan_interval_.value());
|
|
||||||
} else {
|
} else {
|
||||||
this->result_ = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS);
|
result = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->set_timeout(20, [this]() {
|
this->set_timeout(20, [this, result]() {
|
||||||
if (this->result_) {
|
if (result) {
|
||||||
uint16_t secs[2];
|
uint16_t secs[2];
|
||||||
if (this->read_data(secs, 2)) {
|
if (this->read_data(secs, 2)) {
|
||||||
this->fan_interval_ = secs[0] << 16 | secs[1];
|
this->fan_interval_ = secs[0] << 16 | secs[1];
|
||||||
|
@@ -30,7 +30,6 @@ class SPS30Component : public PollingComponent, public sensirion_common::Sensiri
|
|||||||
bool start_fan_cleaning();
|
bool start_fan_cleaning();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool result_{false};
|
|
||||||
bool setup_complete_{false};
|
bool setup_complete_{false};
|
||||||
uint16_t raw_firmware_version_;
|
uint16_t raw_firmware_version_;
|
||||||
char serial_number_[17] = {0}; /// Terminating NULL character
|
char serial_number_[17] = {0}; /// Terminating NULL character
|
||||||
|
Reference in New Issue
Block a user