From: Jan "Yenya" Kasprzak Date: Fri, 19 Jul 2013 21:03:57 +0000 (+0200) Subject: pwmled.c: mode stabilization X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=e15cb822c9a62b4f740ea3951f45bd764f051e9c;hp=e15cb822c9a62b4f740ea3951f45bd764f051e9c;p=bike-lights.git pwmled.c: mode stabilization When changing brightness via pwmled_set_brightness() below, we want to converge to the target value as fast as possible. Also, we would like to somehow initialize the mode 3, which is used as "mode 2 + other PWMLED on". So after the brightness is set, we also set pwmleds[n].modes_not_yet_stable to MODE_STABILIZATION_TIME. When modes_not_yet_stable is non-zero, we allow only mode 2 to be set regardless of what is fed to pwmled_set_mode. We will then converge to the target value of mode 2 only, and after MODE_STABILIZATION_TIME ADC measurements, we copy the mode_pwm value to all other modes. Only then it is allowed to set the other modes. ---