zero duty cycle fix

This commit is contained in:
2021-06-25 15:41:34 +02:00
parent 38c81ae182
commit 33499beb32
2 changed files with 9 additions and 6 deletions
+5 -3
View File
@@ -20,12 +20,10 @@ uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
pwmController.setChannelPWM(led, (uint16_t)startval);
lastled = led;
current_pwm = startval;
stepsize = 20*abs(stopval - startval)/(float)time_per_stair; // only valid at 1ms function call interval
stepsize = INT_TIME*abs(stopval - startval)/(float)time_per_stair; // only valid at 1ms function call interval
return 1;
}
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize) return 0;
// todo: duty cycle zero!
if(startval > stopval){
current_pwm -= stepsize;
}
@@ -34,6 +32,10 @@ uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
}
Serial.println((uint16_t)current_pwm);
pwmController.setChannelPWM(led, (uint16_t)current_pwm);
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize){
if(stopval == 0) pwmController.setChannelPWM(led, 0);
return 0;
}
return 1;
}