mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	remove delay from tmp102 (#6577)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
		| @@ -28,23 +28,24 @@ void TMP102Component::dump_config() { | |||||||
| } | } | ||||||
|  |  | ||||||
| void TMP102Component::update() { | void TMP102Component::update() { | ||||||
|   int16_t raw_temperature; |  | ||||||
|   if (this->write(&TMP102_REGISTER_TEMPERATURE, 1) != i2c::ERROR_OK) { |   if (this->write(&TMP102_REGISTER_TEMPERATURE, 1) != i2c::ERROR_OK) { | ||||||
|     this->status_set_warning(); |     this->status_set_warning(); | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   delay(50);  // NOLINT |   this->set_timeout("read_temp", 50, [this]() { | ||||||
|   if (this->read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) != i2c::ERROR_OK) { |     int16_t raw_temperature; | ||||||
|     this->status_set_warning(); |     if (this->read(reinterpret_cast<uint8_t *>(&raw_temperature), 2) != i2c::ERROR_OK) { | ||||||
|     return; |       this->status_set_warning(); | ||||||
|   } |       return; | ||||||
|   raw_temperature = i2c::i2ctohs(raw_temperature); |     } | ||||||
|   raw_temperature = raw_temperature >> 4; |     raw_temperature = i2c::i2ctohs(raw_temperature); | ||||||
|   float temperature = raw_temperature * TMP102_CONVERSION_FACTOR; |     raw_temperature = raw_temperature >> 4; | ||||||
|   ESP_LOGD(TAG, "Got Temperature=%.1f°C", temperature); |     float temperature = raw_temperature * TMP102_CONVERSION_FACTOR; | ||||||
|  |     ESP_LOGD(TAG, "Got Temperature=%.1f°C", temperature); | ||||||
|  |  | ||||||
|   this->publish_state(temperature); |     this->publish_state(temperature); | ||||||
|   this->status_clear_warning(); |     this->status_clear_warning(); | ||||||
|  |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
| float TMP102Component::get_setup_priority() const { return setup_priority::DATA; } | float TMP102Component::get_setup_priority() const { return setup_priority::DATA; } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user