mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[remote_transmitter] Fix issues with 32bit rollover on esp8266 and libretiny (#8056)
Co-authored-by: Jonathan Swoboda <jonathan.swoboda>
This commit is contained in:
		| @@ -37,7 +37,7 @@ void RemoteTransmitterComponent::await_target_time_() { | ||||
|   const uint32_t current_time = micros(); | ||||
|   if (this->target_time_ == 0) { | ||||
|     this->target_time_ = current_time; | ||||
|   } else if (this->target_time_ > current_time) { | ||||
|   } else if ((int32_t) (this->target_time_ - current_time) > 0) { | ||||
|     delayMicroseconds(this->target_time_ - current_time); | ||||
|   } | ||||
| } | ||||
| @@ -50,13 +50,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint | ||||
|   if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) { | ||||
|     while (true) {  // Modulate with carrier frequency | ||||
|       this->target_time_ += on_time; | ||||
|       if (this->target_time_ >= target) | ||||
|       if ((int32_t) (this->target_time_ - target) >= 0) | ||||
|         break; | ||||
|       this->await_target_time_(); | ||||
|       this->pin_->digital_write(false); | ||||
|  | ||||
|       this->target_time_ += off_time; | ||||
|       if (this->target_time_ >= target) | ||||
|       if ((int32_t) (this->target_time_ - target) >= 0) | ||||
|         break; | ||||
|       this->await_target_time_(); | ||||
|       this->pin_->digital_write(true); | ||||
|   | ||||
| @@ -38,7 +38,7 @@ void RemoteTransmitterComponent::await_target_time_() { | ||||
|   if (this->target_time_ == 0) { | ||||
|     this->target_time_ = current_time; | ||||
|   } else { | ||||
|     while (this->target_time_ > micros()) { | ||||
|     while ((int32_t) (this->target_time_ - micros()) > 0) { | ||||
|       // busy loop that ensures micros is constantly called | ||||
|     } | ||||
|   } | ||||
| @@ -52,13 +52,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint | ||||
|   if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) { | ||||
|     while (true) {  // Modulate with carrier frequency | ||||
|       this->target_time_ += on_time; | ||||
|       if (this->target_time_ >= target) | ||||
|       if ((int32_t) (this->target_time_ - target) >= 0) | ||||
|         break; | ||||
|       this->await_target_time_(); | ||||
|       this->pin_->digital_write(false); | ||||
|  | ||||
|       this->target_time_ += off_time; | ||||
|       if (this->target_time_ >= target) | ||||
|       if ((int32_t) (this->target_time_ - target) >= 0) | ||||
|         break; | ||||
|       this->await_target_time_(); | ||||
|       this->pin_->digital_write(true); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user