Commit dd639c4a authored by mmone's avatar mmone Committed by Me No Dev

Fix wrong range of duty cycle (#1353)

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.
parent f14de5cf
...@@ -60,7 +60,7 @@ void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit ...@@ -60,7 +60,7 @@ void sigmaDeltaWrite(uint8_t channel, uint8_t duty) //chan 0-7 duty 8 bit
if(channel > 7) { if(channel > 7) {
return; return;
} }
duty += 128; duty -= 128;
SD_MUTEX_LOCK(); SD_MUTEX_LOCK();
SIGMADELTA.channel[channel].duty = duty; SIGMADELTA.channel[channel].duty = duty;
SD_MUTEX_UNLOCK(); SD_MUTEX_UNLOCK();
...@@ -72,7 +72,7 @@ uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7 ...@@ -72,7 +72,7 @@ uint8_t sigmaDeltaRead(uint8_t channel) //chan 0-7
return 0; return 0;
} }
SD_MUTEX_LOCK(); SD_MUTEX_LOCK();
uint8_t duty = SIGMADELTA.channel[channel].duty - 128; uint8_t duty = SIGMADELTA.channel[channel].duty + 128;
SD_MUTEX_UNLOCK(); SD_MUTEX_UNLOCK();
return duty; return duty;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment