mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
fix esp8266 remote_transmitter using incorrect timings (#1465)
* replace delay by delayMicroseconds in delay_microseconds_accurate * Use delay(0) to let wifi and os function run * Linting * Remove unneeded delayMicroseconds, keep it for low usec * Avoid micros() overflow issue
This commit is contained in:
parent
4eeb111fa3
commit
f402c89539
1 changed files with 7 additions and 5 deletions
|
@ -171,15 +171,17 @@ uint8_t crc8(uint8_t *data, uint8_t len) {
|
||||||
}
|
}
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay_microseconds_accurate(uint32_t usec) {
|
void delay_microseconds_accurate(uint32_t usec) {
|
||||||
if (usec == 0)
|
if (usec == 0)
|
||||||
return;
|
return;
|
||||||
|
if (usec < 5000UL) {
|
||||||
if (usec <= 16383UL) {
|
|
||||||
delayMicroseconds(usec);
|
delayMicroseconds(usec);
|
||||||
} else {
|
return;
|
||||||
delay(usec / 1000UL);
|
}
|
||||||
delayMicroseconds(usec % 1000UL);
|
uint32_t start = micros();
|
||||||
|
while (micros() - start < usec) {
|
||||||
|
delay(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue