zero duty cycle fix
This commit is contained in:
parent
38c81ae182
commit
33499beb32
@ -5,12 +5,13 @@
|
|||||||
#define SENSOR1 15
|
#define SENSOR1 15
|
||||||
#define SENSOR2 12
|
#define SENSOR2 12
|
||||||
|
|
||||||
|
#define INT_TIME 20 // interrupt intervall [ms]
|
||||||
class Treppe {
|
class Treppe {
|
||||||
private:
|
private:
|
||||||
uint8_t stairs;
|
uint8_t stairs;
|
||||||
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
|
uint16_t time_per_stair = 200; // dimmtime per stair [ms]
|
||||||
uint16_t idle_brightness = 200;
|
uint16_t idle_brightness = 0;
|
||||||
uint16_t active_brightness = 2048;
|
uint16_t active_brightness = 1048;
|
||||||
|
|
||||||
uint8_t direction = 0;
|
uint8_t direction = 0;
|
||||||
uint8_t switch_direction = 0;
|
uint8_t switch_direction = 0;
|
||||||
|
@ -20,12 +20,10 @@ uint8_t Treppe::softstart_led(uint8_t led, uint16_t startval, uint16_t stopval){
|
|||||||
pwmController.setChannelPWM(led, (uint16_t)startval);
|
pwmController.setChannelPWM(led, (uint16_t)startval);
|
||||||
lastled = led;
|
lastled = led;
|
||||||
current_pwm = startval;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_pwm > stopval - stepsize && current_pwm < stopval + stepsize) return 0;
|
|
||||||
// todo: duty cycle zero!
|
|
||||||
if(startval > stopval){
|
if(startval > stopval){
|
||||||
current_pwm -= stepsize;
|
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);
|
Serial.println((uint16_t)current_pwm);
|
||||||
pwmController.setChannelPWM(led, (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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user