add pending settings buffer, gets written in RUHEZUSTAND, add TODO point !
This commit is contained in:
parent
770c2436fd
commit
6807d0f0af
6
doku.md
6
doku.md
@ -113,8 +113,10 @@ linker puts them together ?!?
|
|||||||
- testing if dimming crashes when two animations
|
- testing if dimming crashes when two animations
|
||||||
-> ldr does not interrupt animation, animation get's finished and stairs fade out -> FSM works without collisions
|
-> ldr does not interrupt animation, animation get's finished and stairs fade out -> FSM works without collisions
|
||||||
- interrupt to pending from sensors
|
- interrupt to pending from sensors
|
||||||
|
-> rising edge trigger implemented, via pending input
|
||||||
- settings struct
|
- settings struct
|
||||||
-> implemented with EEPROM
|
-> implemented with EEPROM
|
||||||
|
-> adapted to only change on ruhezustand
|
||||||
- script for gdb on windows
|
- script for gdb on windows
|
||||||
-> [implemented](start_xtensa_gdb_stub.cmd)
|
-> [implemented](start_xtensa_gdb_stub.cmd)
|
||||||
- welcome animation ?
|
- welcome animation ?
|
||||||
@ -131,3 +133,7 @@ linker puts them together ?!?
|
|||||||
- behavior when someone enters stairway from opposite direction after animation finished but person 1 is still on stairway?
|
- behavior when someone enters stairway from opposite direction after animation finished but person 1 is still on stairway?
|
||||||
-> currently stairs fade off from direction 1
|
-> currently stairs fade off from direction 1
|
||||||
-> additional wait-state between "warten hoch/runter" and "abdimmen hoch/runter" after sensor detected person?
|
-> additional wait-state between "warten hoch/runter" and "abdimmen hoch/runter" after sensor detected person?
|
||||||
|
|
||||||
|
|
||||||
|
- active brightness can be lower than idle in the moment
|
||||||
|
- change idle to precentage of active !!!
|
@ -57,9 +57,9 @@ void Treppe::start_animation(dimmer_t *dimmer, bool dim_type, uint16_t on_pwm,
|
|||||||
else
|
else
|
||||||
dimmer->stufe = stufen - 1;
|
dimmer->stufe = stufen - 1;
|
||||||
|
|
||||||
dimmer->ticks = parameters.time_per_stair / INT_TIME; // [ms]
|
dimmer->ticks = param.time_per_stair / INT_TIME; // [ms]
|
||||||
} else { // DIM_LDR
|
} else { // DIM_LDR
|
||||||
dimmer->ticks = parameters.time_ldr / INT_TIME; // [ms]
|
dimmer->ticks = param.time_ldr / INT_TIME; // [ms]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) {
|
if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) {
|
||||||
@ -130,11 +130,11 @@ void Treppe::read_sensors() {
|
|||||||
fsm_pend.last_s_unten = s_unten;
|
fsm_pend.last_s_unten = s_unten;
|
||||||
|
|
||||||
// check for manipulation over webserver
|
// check for manipulation over webserver
|
||||||
if(fsm_pend.web_ctrl_s_oben) {
|
if (fsm_pend.web_ctrl_s_oben) {
|
||||||
fsm_pend.sensor_oben = true;
|
fsm_pend.sensor_oben = true;
|
||||||
fsm_pend.web_ctrl_s_oben = false;
|
fsm_pend.web_ctrl_s_oben = false;
|
||||||
}
|
}
|
||||||
if(fsm_pend.web_ctrl_s_unten) {
|
if (fsm_pend.web_ctrl_s_unten) {
|
||||||
fsm_pend.sensor_unten = true;
|
fsm_pend.sensor_unten = true;
|
||||||
fsm_pend.web_ctrl_s_unten = false;
|
fsm_pend.web_ctrl_s_unten = false;
|
||||||
}
|
}
|
||||||
@ -188,10 +188,10 @@ bool Treppe::check_ldr() {
|
|||||||
// follow up: averaging over many samples?
|
// follow up: averaging over many samples?
|
||||||
float ldr = read_ldr();
|
float ldr = read_ldr();
|
||||||
|
|
||||||
if (ldr < parameters.ldr_schwelle) {
|
if (ldr < param.ldr_schwelle) {
|
||||||
active = 1;
|
active = 1;
|
||||||
}
|
}
|
||||||
if (ldr > parameters.ldr_schwelle + LDR_HYS) {
|
if (ldr > param.ldr_schwelle + LDR_HYS) {
|
||||||
active = 0;
|
active = 0;
|
||||||
}
|
}
|
||||||
return active;
|
return active;
|
||||||
@ -247,7 +247,7 @@ void Treppe::task() {
|
|||||||
fsm_outputs.status == ST_AUFDIMMEN_RUNTER ||
|
fsm_outputs.status == ST_AUFDIMMEN_RUNTER ||
|
||||||
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, parameters.active_pwm,
|
start_animation(&dimmer_stufen, DIM_STUFEN, param.active_pwm,
|
||||||
idle_pwm_ist);
|
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);
|
||||||
@ -267,6 +267,12 @@ void Treppe::task() {
|
|||||||
if (!fsm_pend.anim_beendet) {
|
if (!fsm_pend.anim_beendet) {
|
||||||
fsm_pend.anim_beendet = dimmer_tick(&dimmer_ldr, DIM_LDR);
|
fsm_pend.anim_beendet = dimmer_tick(&dimmer_ldr, DIM_LDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param_changed) {
|
||||||
|
param_changed = false;
|
||||||
|
param = param_pend;
|
||||||
|
save_param_to_eeprom();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_TIMING
|
#ifdef DEBUG_TIMING
|
||||||
@ -287,7 +293,7 @@ void Treppe::setup() {
|
|||||||
|
|
||||||
// WARNING: before getting Parameters of Flash, make sure plausible parameters
|
// WARNING: before getting Parameters of Flash, make sure plausible parameters
|
||||||
// are written in flash!
|
// are written in flash!
|
||||||
EEPROM.get(EEP_START_ADDR, parameters); // get Parameters of flash
|
EEPROM.get(EEP_START_ADDR, param); // get Parameters of flash
|
||||||
|
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
pinMode(0, OUTPUT);
|
pinMode(0, OUTPUT);
|
||||||
@ -303,73 +309,73 @@ void Treppe::setup() {
|
|||||||
Serial.printf("Treppe: stufen=%d\n", stufen);
|
Serial.printf("Treppe: stufen=%d\n", stufen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::saveParam() {
|
void Treppe::save_param_to_eeprom() {
|
||||||
EEPROM.put(EEP_START_ADDR,
|
EEPROM.put(EEP_START_ADDR,
|
||||||
parameters); // copy Parameters so "EEPROM"-section in RAM
|
param); // copy Parameters so "EEPROM"-section in RAM
|
||||||
EEPROM.commit(); // write "EEPROM"-section to flash
|
EEPROM.commit(); // write "EEPROM"-section to flash
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_idle_pwm_max(const uint16_t value,
|
void Treppe::set_idle_pwm_max(const uint16_t value,
|
||||||
const vorgabe_typ_t vorgabe_typ) {
|
const vorgabe_typ_t vorgabe_typ) {
|
||||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||||
parameters.idle_pwm_max = parameters.active_pwm * value / 100;
|
param_pend.idle_pwm_max = param_pend.active_pwm * value / 100;
|
||||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||||
parameters.idle_pwm_max = value;
|
param_pend.idle_pwm_max = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.idle_pwm_max > parameters.active_pwm) {
|
if (param_pend.idle_pwm_max > param_pend.active_pwm) {
|
||||||
parameters.idle_pwm_max = parameters.active_pwm;
|
param_pend.idle_pwm_max = param_pend.active_pwm;
|
||||||
}
|
}
|
||||||
saveParam();
|
param_changed = true;
|
||||||
|
|
||||||
Serial.printf("Treppe: parameters.idle_pwm_max=%d\n",
|
Serial.printf("Treppe: param_pend.idle_pwm_max=%d\n",
|
||||||
parameters.idle_pwm_max);
|
param_pend.idle_pwm_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_active_pwm(const uint16_t value,
|
void Treppe::set_active_pwm(const uint16_t value,
|
||||||
const vorgabe_typ_t vorgabe_typ) {
|
const vorgabe_typ_t vorgabe_typ) {
|
||||||
|
|
||||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||||
parameters.active_pwm = 4095 * value / 100;
|
param_pend.active_pwm = 4095 * value / 100;
|
||||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||||
parameters.active_pwm = value;
|
param_pend.active_pwm = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.active_pwm > 4095) {
|
if (param_pend.active_pwm > 4095) {
|
||||||
parameters.idle_pwm_max = 4095;
|
param_pend.idle_pwm_max = 4095;
|
||||||
}
|
}
|
||||||
saveParam();
|
param_changed = true;
|
||||||
|
|
||||||
Serial.printf("Treppe: parameters.active_pwm=%d\n", parameters.active_pwm);
|
Serial.printf("Treppe: param_pend.active_pwm=%d\n", param_pend.active_pwm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_time_ldr(const uint16_t value) {
|
void Treppe::set_time_ldr(const uint16_t value) {
|
||||||
parameters.time_ldr = value;
|
param_pend.time_ldr = value;
|
||||||
if (parameters.time_ldr > TIME_MS_MAX)
|
if (param_pend.time_ldr > TIME_MS_MAX)
|
||||||
parameters.time_ldr = TIME_MS_MAX;
|
param_pend.time_ldr = TIME_MS_MAX;
|
||||||
saveParam();
|
param_changed = true;
|
||||||
|
|
||||||
Serial.printf("Treppe: time_ldr=%d\n", parameters.time_ldr);
|
Serial.printf("Treppe: time_ldr=%d\n", param_pend.time_ldr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_time_per_stair(const uint16_t value) {
|
void Treppe::set_time_per_stair(const uint16_t value) {
|
||||||
parameters.time_per_stair = value;
|
param_pend.time_per_stair = value;
|
||||||
if (parameters.time_per_stair > TIME_MS_MAX)
|
if (param_pend.time_per_stair > TIME_MS_MAX)
|
||||||
parameters.time_per_stair = TIME_MS_MAX;
|
param_pend.time_per_stair = TIME_MS_MAX;
|
||||||
saveParam();
|
param_changed = true;
|
||||||
|
|
||||||
Serial.printf("Treppe: time_per_stair=%d\n", parameters.time_per_stair);
|
Serial.printf("Treppe: time_per_stair=%d\n", param_pend.time_per_stair);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::set_ldr_schwelle(const uint16_t value,
|
void Treppe::set_ldr_schwelle(const uint16_t value,
|
||||||
const vorgabe_typ_t vorgabe_typ) {
|
const vorgabe_typ_t vorgabe_typ) {
|
||||||
if (vorgabe_typ == VORGABE_PROZENT) {
|
if (vorgabe_typ == VORGABE_PROZENT) {
|
||||||
// ?!
|
// ?!
|
||||||
parameters.ldr_schwelle = 10 * value / 100;
|
param_pend.ldr_schwelle = 10 * value / 100;
|
||||||
} else if (vorgabe_typ == VORGABE_12BIT) {
|
} else if (vorgabe_typ == VORGABE_12BIT) {
|
||||||
// parameters.ldr_schwelle = value;
|
// param_pend.ldr_schwelle = value;
|
||||||
}
|
}
|
||||||
saveParam();
|
param_changed = true;
|
||||||
|
|
||||||
Serial.printf("Treppe: ldr_schwelle=%d\n", parameters.ldr_schwelle);
|
Serial.printf("Treppe: ldr_schwelle=%d\n", param_pend.ldr_schwelle);
|
||||||
}
|
}
|
@ -30,9 +30,11 @@ private:
|
|||||||
uint16_t active_pwm = 2000;
|
uint16_t active_pwm = 2000;
|
||||||
uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
|
uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
|
||||||
};
|
};
|
||||||
stairway_param_t parameters;
|
stairway_param_t param;
|
||||||
|
stairway_param_t param_pend; // zwischenspeicher änderungen
|
||||||
|
bool param_changed = false;
|
||||||
|
|
||||||
uint16_t idle_pwm_ist = parameters.idle_pwm_max;
|
uint16_t idle_pwm_ist = param.idle_pwm_max;
|
||||||
uint16_t idle_pwm_soll = 0;
|
uint16_t idle_pwm_soll = 0;
|
||||||
|
|
||||||
struct fsm_pending_inputs_t {
|
struct fsm_pending_inputs_t {
|
||||||
@ -102,7 +104,7 @@ public:
|
|||||||
void task(); // call periodically
|
void task(); // call periodically
|
||||||
|
|
||||||
// Parameter section
|
// Parameter section
|
||||||
void saveParam();
|
void save_param_to_eeprom();
|
||||||
void set_idle_pwm_max(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
void set_idle_pwm_max(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
||||||
void set_active_pwm(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
void set_active_pwm(const uint16_t value, const vorgabe_typ_t vorgabe_typ);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user