diff options
author | Olivier Ortigues <o.ortigues@gmail.com> | 2018-02-12 23:43:40 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-02-15 11:12:41 +1100 |
commit | 5c83d05b493af58bb14cba9dbfc2bf2d85de2962 (patch) | |
tree | e59ee6fb2fe95b7dd13f3fccba4fc7892b1b8f55 | |
parent | ab7819c3149326a4edd4a6ee833a2f4b733ae2d0 (diff) |
esp8266/esppwm: Clip negative duty numbers to 0.
Prior to this patch a negative duty would lead to full PWM.
-rw-r--r-- | ports/esp8266/esppwm.c | 4 | ||||
-rw-r--r-- | ports/esp8266/esppwm.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/ports/esp8266/esppwm.c b/ports/esp8266/esppwm.c index f1d7060df..f56eafc1b 100644 --- a/ports/esp8266/esppwm.c +++ b/ports/esp8266/esppwm.c @@ -210,12 +210,12 @@ pwm_start(void) /****************************************************************************** * FunctionName : pwm_set_duty * Description : set each channel's duty params - * Parameters : uint8 duty : 0 ~ PWM_DEPTH + * Parameters : int16_t duty : 0 ~ PWM_DEPTH * uint8 channel : channel index * Returns : NONE *******************************************************************************/ void ICACHE_FLASH_ATTR -pwm_set_duty(uint16 duty, uint8 channel) +pwm_set_duty(int16_t duty, uint8 channel) { uint8 i; for(i=0;i<pwm_channel_num;i++){ diff --git a/ports/esp8266/esppwm.h b/ports/esp8266/esppwm.h index 1ee4a2f55..288ef6d53 100644 --- a/ports/esp8266/esppwm.h +++ b/ports/esp8266/esppwm.h @@ -7,7 +7,7 @@ void pwm_init(void); void pwm_start(void); -void pwm_set_duty(uint16_t duty, uint8_t channel); +void pwm_set_duty(int16_t duty, uint8_t channel); uint16_t pwm_get_duty(uint8_t channel); void pwm_set_freq(uint16_t freq, uint8_t channel); uint16_t pwm_get_freq(uint8_t channel); |