diff --git a/esphome/components/am2320/am2320.cpp b/esphome/components/am2320/am2320.cpp index f32f8c139b..85f8b75ee9 100644 --- a/esphome/components/am2320/am2320.cpp +++ b/esphome/components/am2320/am2320.cpp @@ -14,19 +14,17 @@ static const char *TAG = "am2320"; // ---=== Calc CRC16 ===--- uint16_t crc_16(uint8_t *ptr, uint8_t length) { -uint16_t crc = 0xFFFF; -uint8_t i; -//------------------------------ - while(length--) + uint16_t crc = 0xFFFF; + uint8_t i; + //------------------------------ + while (length--) { crc ^= *ptr++; for (i = 0; i < 8; i++) - if ((crc & 0x01) != 0) - { + if ((crc & 0x01) != 0) { crc >>= 1; crc ^= 0xA001; - } - else + } else crc >>= 1; } return crc; @@ -74,7 +72,6 @@ void AM2320Component::dump_config() { float AM2320Component::get_setup_priority() const { return setup_priority::DATA; } bool AM2320Component::read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion) { - if (!this->write_bytes(a_register, data, 2)) { ESP_LOGW(TAG, "Writing bytes for AM2320 failed!"); return false; @@ -85,7 +82,6 @@ bool AM2320Component::read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len return this->parent_->raw_receive(this->address_, data, len); } - bool AM2320Component::read_data_(uint8_t *data) { // Wake up this->write_bytes(0, data, 0);