can set idle_pwm from webserver, but not working properly

This commit is contained in:
2021-07-05 19:51:55 +02:00
parent 2754bd5247
commit 66d220cdb0
7 changed files with 43 additions and 24 deletions
+23 -7
View File
@@ -213,8 +213,11 @@ void Treppe::task()
if (fsm_outputs.status > ST_RUHEZUSTAND)
{
if (anim_beendet == true &&
(fsm_outputs.status == ST_AUFDIMMEN_HOCH || fsm_outputs.status == ST_ABDIMMEN_HOCH ||
fsm_outputs.status == ST_AUFDIMMEN_RUNTER || fsm_outputs.status == ST_ABDIMMEN_RUNTER))
(fsm_outputs.status == ST_AUFDIMMEN_HOCH ||
fsm_outputs.status == ST_ABDIMMEN_HOCH ||
fsm_outputs.status == ST_AUFDIMMEN_RUNTER ||
fsm_outputs.status == ST_ABDIMMEN_RUNTER)
)
{
start_animation();
}
@@ -226,7 +229,7 @@ void Treppe::task()
void Treppe::berechne_dimmer()
{
ticks_pro_stufe = time_per_stair / INT_TIME; // [ms]
differenz_pwm_pro_tick = (float)(active_brightness - idle_brightness) / (float)ticks_pro_stufe;
differenz_pwm_pro_tick = (float)(active_brightness - idle_bright_internal) / (float)ticks_pro_stufe;
}
void Treppe::setup()
@@ -250,15 +253,27 @@ void Treppe::setup()
Serial.printf("Treppe: initial parameters: stufen=%d\n", stufen);
}
// ###################################################################################################################
// GEBUFFERT => Erst im Ruhezustand übernehmen !!!!
void Treppe::set_idle_prozent(int prozent) {
uint16_t new_pwm = 0xFFF * prozent / 100;
set_idle_pwm(new_pwm);
}
void Treppe::set_idle_pwm(uint16_t _idle_brightness)
{
idle_brightness = _idle_brightness;
if(_idle_brightness > active_brightness) {
idle_bright_internal = active_brightness;
} else {
idle_bright_internal = _idle_brightness;
}
Serial.printf("Treppe: idle_bright_internal=%d\n", idle_bright_internal);
berechne_dimmer();
Serial.printf("Treppe: idle_brightness=%d\n", idle_brightness);
pwmController.setAllChannelsPWM(idle_bright_internal);
}
void Treppe::activate_idle_pwm(bool active)
{
static uint8_t former_active = 0;
@@ -274,6 +289,7 @@ void Treppe::activate_idle_pwm(bool active)
}
}
}
void Treppe::set_active_pwm(uint16_t _active_brightness)
{
active_brightness = _active_brightness;
+1
View File
@@ -82,6 +82,7 @@ public:
void task(); // call periodically
// Parameter section
void set_idle_prozent(int prozent);
void set_idle_pwm(uint16_t _idle_brightness);
void activate_idle_pwm(bool active);
void set_active_pwm(uint16_t _active_brightness);