From fa264a9a39ceb44177a6a0a02d9c5845fb9a1ba6 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Sun, 16 Dec 2012 17:28:39 +0100 Subject: [PATCH] pwmled.c: do not regulate just after mode change --- firmware/pwmled.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/pwmled.c b/firmware/pwmled.c index 9a8deac..70cbcf1 100644 --- a/firmware/pwmled.c +++ b/firmware/pwmled.c @@ -5,7 +5,10 @@ typedef struct { uint16_t target, pwm; int16_t err_sum; - unsigned char mode, state, probe_steady; + unsigned char mode, state; + union { + unsigned char probe_steady, mode_changed; + }; uint16_t mode_pwm[N_PWMLED_MODES]; int16_t err_sums[N_PWMLED_MODES]; } pwmled_t; @@ -122,6 +125,7 @@ void pwmled_set_mode(unsigned char n, unsigned char mode) led->state = ST_ON; led->pwm = led->mode_pwm[mode - 1]; led->err_sum = led->err_sums[mode - 1]; + led->mode_changed = 1; pwm_set(n, led->pwm); } else { led->state = ST_OFF; @@ -202,6 +206,10 @@ void pwmled_adc(unsigned char n, uint16_t adcval) if (!ST_IS_ON(led->state)) return; + if (led->state == ST_ON && led->mode_changed) { + led->mode_changed--; + return; + } // FIXME: test for maximum adcval value (adc_max[n]) old_pwm = led->pwm; -- 2.43.5