process_lightdata function fixed - division by 0 was possible.

This commit is contained in:
Kai Lauterbach 2023-05-12 12:23:45 +02:00
parent 2e340d0cc8
commit 7452882ea7
2 changed files with 5 additions and 1 deletions

View file

@ -116,6 +116,10 @@ void apply_scene(uint8_t new_scene, uint8_t light)
void process_lightdata(uint8_t light, float tt) void process_lightdata(uint8_t light, float tt)
{ {
if (tt <= 0)
{
tt = default_transitiontime;
}
if (light_state[light]) if (light_state[light])
{ {
step_level[light] = (bri[light] - current_bri[light]) / tt; step_level[light] = (bri[light] - current_bri[light]) / tt;

View file

@ -187,7 +187,7 @@ void tc_update_main()
bri[i] = 0; bri[i] = 0;
current_bri[i] = 0; current_bri[i] = 0;
current_pwm[i] = 0; current_pwm[i] = 0;
transitiontime[i] = 0; transitiontime[i] = default_transitiontime;
process_lightdata(i, transitiontime[i]); process_lightdata(i, transitiontime[i]);
} }