Skip to content

Commit

Permalink
Fix wrong range of duty cycle (espressif#1353)
Browse files Browse the repository at this point in the history
The esp-idf expects duty values for the the sigma delta modulator in the range of -128 to 127
The arduino framework is supposed to use the range 0-255 thus the offset caclulation was wrong.
  • Loading branch information
mmone authored and me-no-dev committed May 14, 2018
1 parent f14de5c commit dd639c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cores/esp32/esp32-hal-sigmadelta.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
if(channel > 7) {
return;
}
duty += 128;
duty -= 128;
SD_MUTEX_LOCK();
SIGMADELTA.channel[channel].duty = duty;
SD_MUTEX_UNLOCK();
Expand All @@ -72,7 +72,7 @@ uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
return 0;
}
SD_MUTEX_LOCK();
uint8_t duty = SIGMADELTA.channel[channel].duty - 128;
uint8_t duty = SIGMADELTA.channel[channel].duty + 128;
SD_MUTEX_UNLOCK();
return duty;
}
Expand Down

0 comments on commit dd639c4

Please sign in to comment.