|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
dimmer->stufe = stufen - 1; |
|
|
dimmer->stufe = stufen - 1; |
|
|
|
|
|
|
|
|
dimmer->ticks = time_per_stair / INT_TIME; // [ms] |
|
|
|
|
|
|
|
|
dimmer->ticks = parameters.time_per_stair / INT_TIME; // [ms] |
|
|
} |
|
|
} |
|
|
else { // DIM_LDR |
|
|
else { // DIM_LDR |
|
|
dimmer->ticks = time_ldr / INT_TIME; // [ms] |
|
|
|
|
|
|
|
|
dimmer->ticks = parameters.time_ldr / INT_TIME; // [ms] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) |
|
|
if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) |
|
|
|
|
|
|
|
|
// follow up: averaging over many samples? |
|
|
// follow up: averaging over many samples? |
|
|
float ldr = read_ldr(); |
|
|
float ldr = read_ldr(); |
|
|
|
|
|
|
|
|
if (ldr < ldr_schwelle) { |
|
|
|
|
|
|
|
|
if (ldr < parameters.ldr_schwelle) { |
|
|
active = 1; |
|
|
active = 1; |
|
|
} |
|
|
} |
|
|
if (ldr > ldr_schwelle + LDR_HYS) { |
|
|
|
|
|
|
|
|
if (ldr > parameters.ldr_schwelle + LDR_HYS) { |
|
|
active = 0; |
|
|
active = 0; |
|
|
} |
|
|
} |
|
|
return active; |
|
|
return active; |
|
|
|
|
|
|
|
|
fsm_outputs.status == ST_ABDIMMEN_RUNTER ) |
|
|
fsm_outputs.status == ST_ABDIMMEN_RUNTER ) |
|
|
{ |
|
|
{ |
|
|
if(fsm_pend.anim_beendet) |
|
|
if(fsm_pend.anim_beendet) |
|
|
start_animation(&dimmer_stufen, DIM_STUFEN, active_pwm, idle_pwm_ist); |
|
|
|
|
|
|
|
|
start_animation(&dimmer_stufen, DIM_STUFEN, parameters.active_pwm, idle_pwm_ist); |
|
|
else |
|
|
else |
|
|
fsm_pend.anim_beendet = dimmer_tick(&dimmer_stufen, DIM_STUFEN); |
|
|
fsm_pend.anim_beendet = dimmer_tick(&dimmer_stufen, DIM_STUFEN); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Treppe::set_idle_prozent(const int prozent) |
|
|
void Treppe::set_idle_prozent(const int prozent) |
|
|
{ |
|
|
{ |
|
|
uint16_t new_pwm = active_pwm * prozent / 100; |
|
|
|
|
|
|
|
|
// future use: parameters.idle_max_pwm |
|
|
|
|
|
uint16_t new_pwm = parameters.active_pwm * prozent / 100; |
|
|
set_idle_pwm_max(new_pwm); |
|
|
set_idle_pwm_max(new_pwm); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Treppe::set_idle_pwm_max(const uint16_t new_pwm) |
|
|
void Treppe::set_idle_pwm_max(const uint16_t new_pwm) |
|
|
{ |
|
|
{ |
|
|
if(new_pwm > active_pwm) { |
|
|
|
|
|
idle_pwm_soll = active_pwm; |
|
|
|
|
|
|
|
|
// future use: parameters.idle_max_pwm |
|
|
|
|
|
if(new_pwm > parameters.active_pwm) { |
|
|
|
|
|
idle_pwm_soll = parameters.active_pwm; |
|
|
} else { |
|
|
} else { |
|
|
idle_pwm_soll = new_pwm; |
|
|
idle_pwm_soll = new_pwm; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Treppe::set_active_pwm(uint16_t _active_pwm) |
|
|
void Treppe::set_active_pwm(uint16_t _active_pwm) |
|
|
{ |
|
|
{ |
|
|
active_pwm = _active_pwm; |
|
|
|
|
|
Serial.printf("Treppe: active_pwm=%d\n", active_pwm); |
|
|
|
|
|
|
|
|
parameters.active_pwm = _active_pwm; |
|
|
|
|
|
Serial.printf("Treppe: active_pwm=%d\n", parameters.active_pwm); |
|
|
} |
|
|
} |
|
|
void Treppe::set_time_per_stair(uint16_t _time_per_stair) |
|
|
void Treppe::set_time_per_stair(uint16_t _time_per_stair) |
|
|
{ |
|
|
{ |
|
|
time_per_stair = _time_per_stair; |
|
|
|
|
|
Serial.printf("Treppe: time_per_stair=%d\n", time_per_stair); |
|
|
|
|
|
|
|
|
parameters.time_per_stair = _time_per_stair; |
|
|
|
|
|
Serial.printf("Treppe: time_per_stair=%d\n", parameters.time_per_stair); |
|
|
} |
|
|
} |