8000 Minor code simplification. · dok-net/arduino-esp8266@09debed · GitHub
[go: up one dir, main page]

Skip to content

Commit 09debed

Browse files
committed
Minor code simplification.
1 parent 53f7bb9 commit 09debed

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cores/esp8266/core_esp8266_waveform.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
337337
busyPins ^= pinBit;
338338
}
339339
else {
340-
const uint32_t overshootCcys = now - waveNextEventCcy;
341-
if (static_cast<int32_t>(overshootCcys) >= 0) {
340+
const int32_t overshootCcys = now - waveNextEventCcy;
341+
if (overshootCcys >= 0) {
342342
const int32_t periodCcys = scaleCcys(wave.periodCcys);
343343
if (waveform.states & pinBit) {
344344
// active configuration and forward are 100% duty
@@ -361,12 +361,11 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
361361
waveNextEventCcy = wave.nextPeriodCcy;
362362
}
363363
else {
364+
wave.nextPeriodCcy += periodCcys;
364365
if (!wave.dutyCcys) {
365-
wave.nextPeriodCcy += periodCcys;
366366
wave.endDutyCcy = wave.nextPeriodCcy;
367367
}
368368
else {
369-
wave.nextPeriodCcy += periodCcys;
370369
int32_t dutyCcys = scaleCcys(wave.dutyCcys);
371370
if (dutyCcys > wave.adjDutyCcys) {
372371
dutyCcys -= wave.adjDutyCcys;
@@ -377,7 +376,7 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
377376
dutyCcys = 0;
378377
}
379378
wave.endDutyCcy = now + dutyCcys;
380-
if (static_cast<int32_t>(wave.endDutyCcy - wave.nextPeriodCcy) >= 0) {
379+
if (static_cast<int32_t>(wave.endDutyCcy - wave.nextPeriodCcy) > 0) {
381380
wave.endDutyCcy = wave.nextPeriodCcy;
382381
}
383382
waveform.states |= pinBit;

0 commit comments

Comments
 (0)
0