Browse Source

struct for treppe parameters ->eeprom

tags/v1.0.0
Dominik Bartsch 3 years ago
parent
commit
42a927e383
2 changed files with 26 additions and 19 deletions
  1. 14
    12
      lib/treppe/treppe.cpp
  2. 12
    7
      lib/treppe/treppe.h

+ 14
- 12
lib/treppe/treppe.cpp View File

@@ -64,10 +64,10 @@ void Treppe::start_animation( dimmer_t* dimmer, bool dim_type,
else
dimmer->stufe = stufen - 1;

dimmer->ticks = time_per_stair / INT_TIME; // [ms]
dimmer->ticks = parameters.time_per_stair / INT_TIME; // [ms]
}
else { // DIM_LDR
dimmer->ticks = time_ldr / INT_TIME; // [ms]
dimmer->ticks = parameters.time_ldr / INT_TIME; // [ms]
}

if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN)
@@ -203,10 +203,10 @@ bool Treppe::check_ldr()
// follow up: averaging over many samples?
float ldr = read_ldr();

if (ldr < ldr_schwelle) {
if (ldr < parameters.ldr_schwelle) {
active = 1;
}
if (ldr > ldr_schwelle + LDR_HYS) {
if (ldr > parameters.ldr_schwelle + LDR_HYS) {
active = 0;
}
return active;
@@ -260,7 +260,7 @@ void Treppe::task()
fsm_outputs.status == ST_ABDIMMEN_RUNTER )
{
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
fsm_pend.anim_beendet = dimmer_tick(&dimmer_stufen, DIM_STUFEN);
}
@@ -319,14 +319,16 @@ void Treppe::setup()

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

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 {
idle_pwm_soll = new_pwm;
}
@@ -337,11 +339,11 @@ void Treppe::set_idle_pwm_max(const uint16_t new_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)
{
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);
}

+ 12
- 7
lib/treppe/treppe.h View File

@@ -16,14 +16,19 @@
class Treppe {
private:
const uint8_t stufen;
const uint16_t time_ldr = 500;
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_pwm_max = 100;
uint16_t idle_pwm_ist = idle_pwm_max;
uint16_t idle_pwm_soll = 0;
uint16_t active_pwm = 2000;

uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
struct stairway_param_t {
uint16_t time_ldr = 500;
uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_pwm_max = 100;
uint16_t active_pwm = 2000;
uint16_t ldr_schwelle = 2; // activation value for FSM [lx]
};
stairway_param_t parameters;

uint16_t idle_pwm_ist = parameters.idle_pwm_max;
uint16_t idle_pwm_soll = 0;
struct fsm_pending_inputs_t {
bool anim_beendet = true;
bool sensor_unten = false;

Loading…
Cancel
Save