Browse Source

ldr schwelle [lx], parameter change when inactive

tags/v1.0.0
Dominik Bartsch 3 years ago
parent
commit
767df957cc
4 changed files with 18 additions and 14 deletions
  1. 1
    1
      data/index.html
  2. 1
    1
      lib/httpserver/httpserver.cpp
  3. 13
    9
      lib/treppe/treppe.cpp
  4. 3
    3
      lib/treppe/treppe.h

+ 1
- 1
data/index.html View File

@@ -49,7 +49,7 @@
</div>

<div class="param_block">
LDR Schwelle [%]: <output id="out_ldr_shw" class="val_range">50</output> %
LDR Schwelle [lx]: <output id="out_ldr_shw" class="val_range">50</output> lx
<div class="slider">
<input type="range" class="regler" id="range_ldr_shw" data-output="out_ldr_shw" min="0" max="100" value="50">
</div>

+ 1
- 1
lib/httpserver/httpserver.cpp View File

@@ -76,7 +76,7 @@ void HTTPServer::start_apps() {
logt("set_time_ldr = %d\n", arg(i).toInt());
}
else if (argName(i).equals("range_ldr_shw")) {
treppe->set_ldr_schwelle(arg(i).toInt(), VORGABE_PROZENT);
treppe->set_ldr_schwelle(arg(i).toInt(), VORGABE_12BIT);
logt("set_ldr_schwelle = %d %\n", arg(i).toInt());
}


+ 13
- 9
lib/treppe/treppe.cpp View File

@@ -177,7 +177,7 @@ float Treppe::read_ldr() {
float ldr_ohm = 40.57*(3.3-voltage)/voltage;
float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm);
#ifdef LDRDEBUG
Serial.printf("Ohm: %f lux: %f\n", ldr_ohm,ldr_value);
Serial.printf("Ohm: %f lux: %f Comp: %d\n", ldr_ohm,ldr_value, param.ldr_schwelle);
#endif
return ldr_value;
}
@@ -186,8 +186,7 @@ bool Treppe::check_ldr() {
static uint8_t active = 0;

#ifdef LDRDEBUG
Serial.printf("R(LDR) = %f kOhm %f lux\n", ldr_value, lux);
return true;
//return true;
#endif

// follow up: averaging over many samples?
@@ -273,11 +272,16 @@ void Treppe::task() {
fsm_pend.anim_beendet = dimmer_tick(&dimmer_ldr, DIM_LDR);
}

if (param_changed) {
param_changed = false;
param = param_pend;
save_param_to_eeprom();
}
}

if (fsm_outputs.status == ST_RUHEZUSTAND ||
fsm_outputs.status == ST_INAKTIV_LDR){
if (param_changed) {
param_changed = false;
param = param_pend;
save_param_to_eeprom();
Serial.printf("Parameter Change applied!\n");
}
}

#ifdef DEBUG_TIMING
@@ -378,7 +382,7 @@ void Treppe::set_ldr_schwelle(const uint16_t value,
// ?!
param_pend.ldr_schwelle = 10 * value / 100;
} else if (vorgabe_typ == VORGABE_12BIT) {
// param_pend.ldr_schwelle = value;
param_pend.ldr_schwelle = value;
}
param_changed = true;


+ 3
- 3
lib/treppe/treppe.h View File

@@ -5,8 +5,8 @@
#include "PCA9685.h"
#include <EEPROM.h>

// #define LDRDEBUG // comment in to override LDR measurement
#define LDR_HYS 5 // Hysteresis for switching off FSM [lux]
//#define LDRDEBUG // comment in to override LDR measurement
#define LDR_HYS 8 // Hysteresis for switching off FSM [lux]

#define SENSOR_OBEN 16
#define SENSOR_UNTEN 12
@@ -28,7 +28,7 @@ private:
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]
uint16_t ldr_schwelle = 30; // activation value for FSM [lx]
};
stairway_param_t param;
stairway_param_t param_pend; // zwischenspeicher änderungen

Loading…
Cancel
Save