mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Add fast update to HMC5883L (#6669)
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| #include "hmc5883l.h" | #include "hmc5883l.h" | ||||||
| #include "esphome/core/log.h" | #include "esphome/core/log.h" | ||||||
|  | #include "esphome/core/application.h" | ||||||
|  |  | ||||||
| namespace esphome { | namespace esphome { | ||||||
| namespace hmc5883l { | namespace hmc5883l { | ||||||
| @@ -31,6 +32,10 @@ void HMC5883LComponent::setup() { | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   if (this->get_update_interval() < App.get_loop_interval()) { | ||||||
|  |     high_freq_.start(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (id[0] != 0x48 || id[1] != 0x34 || id[2] != 0x33) { |   if (id[0] != 0x48 || id[1] != 0x34 || id[2] != 0x33) { | ||||||
|     this->error_code_ = ID_REGISTERS; |     this->error_code_ = ID_REGISTERS; | ||||||
|     this->mark_failed(); |     this->mark_failed(); | ||||||
|   | |||||||
| @@ -63,6 +63,7 @@ class HMC5883LComponent : public PollingComponent, public i2c::I2CDevice { | |||||||
|     COMMUNICATION_FAILED, |     COMMUNICATION_FAILED, | ||||||
|     ID_REGISTERS, |     ID_REGISTERS, | ||||||
|   } error_code_; |   } error_code_; | ||||||
|  |   HighFrequencyLoopRequester high_freq_; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace hmc5883l | }  // namespace hmc5883l | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user