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;
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;
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;