Browse Source

activate / inactivate idle brightess w LDR

tags/v1.0.0
Dominik Bartsch 2 years ago
parent
commit
c1e24d633b
2 changed files with 18 additions and 5 deletions
  1. 14
    3
      lib/treppe/treppe.cpp
  2. 4
    2
      lib/treppe/treppe.h

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



if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN) if (fsm_outputs.dimmrichtung == DR_AUFDIMMEN)
{ {
start_pwm = idle_brightness;
start_pwm = idle_bright_internal;
ziel_pwm = active_brightness; ziel_pwm = active_brightness;
} }
else else
{ {
start_pwm = active_brightness; start_pwm = active_brightness;
ziel_pwm = idle_brightness;
ziel_pwm = idle_bright_internal;
} }


current_tick = 0; current_tick = 0;
active = 1; active = 1;
if (ldr > ldr_schwelle + LDR_HYS) if (ldr > ldr_schwelle + LDR_HYS)
active = 0; active = 0;
activate_idle_pwm(active);
return active; return active;
} }


berechne_dimmer(); berechne_dimmer();
Serial.printf("Treppe: idle_brightness=%d\n", idle_brightness); Serial.printf("Treppe: idle_brightness=%d\n", idle_brightness);
} }

void Treppe::activate_idle_pwm(bool active){
static uint8_t former_active = 0;

if(active != former_active && fsm_outputs.status == ST_RUHEZUSTAND){
idle_bright_internal = idle_brightness * active;
// Dimming Function for all LEDS ?
pwmController.setAllChannelsPWM(idle_bright_internal);
former_active = active;
}
}
void Treppe::set_active_pwm(uint16_t _active_brightness) void Treppe::set_active_pwm(uint16_t _active_brightness)
{ {
active_brightness = _active_brightness; active_brightness = _active_brightness;

+ 4
- 2
lib/treppe/treppe.h View File



#define LDR_HYS 5.0 // Hysteresis for switching off FSM [lux] #define LDR_HYS 5.0 // Hysteresis for switching off FSM [lux]


#define SENSOR_OBEN 2
#define SENSOR_OBEN 16
#define SENSOR_UNTEN 12 #define SENSOR_UNTEN 12
#define OE 14 #define OE 14


private: private:
const uint8_t stufen; const uint8_t stufen;
uint16_t time_per_stair = 300; // dimmtime per stair [ms] uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_brightness = 0;
uint16_t idle_brightness = 100;
uint16_t idle_bright_internal = 0;
uint16_t active_brightness = 500; uint16_t active_brightness = 500;


uint16_t ldr_schwelle = 7; // activation value for FSM [lx] uint16_t ldr_schwelle = 7; // activation value for FSM [lx]


// Parameter section // Parameter section
void set_idle_pwm(uint16_t _idle_brightness); void set_idle_pwm(uint16_t _idle_brightness);
void activate_idle_pwm(bool active);
void set_active_pwm(uint16_t _active_brightness); void set_active_pwm(uint16_t _active_brightness);
void set_time_per_stair(uint16_t _time_per_stair); void set_time_per_stair(uint16_t _time_per_stair);
}; };

Loading…
Cancel
Save