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

</div> </div>


<div class="param_block"> <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"> <div class="slider">
<input type="range" class="regler" id="range_ldr_shw" data-output="out_ldr_shw" min="0" max="100" value="50"> <input type="range" class="regler" id="range_ldr_shw" data-output="out_ldr_shw" min="0" max="100" value="50">
</div> </div>

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

logt("set_time_ldr = %d\n", arg(i).toInt()); logt("set_time_ldr = %d\n", arg(i).toInt());
} }
else if (argName(i).equals("range_ldr_shw")) { 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()); logt("set_ldr_schwelle = %d %\n", arg(i).toInt());
} }



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

float ldr_ohm = 40.57*(3.3-voltage)/voltage; float ldr_ohm = 40.57*(3.3-voltage)/voltage;
float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm); float ldr_value = 6526.6 / (ldr_ohm * ldr_ohm);
#ifdef LDRDEBUG #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 #endif
return ldr_value; return ldr_value;
} }
static uint8_t active = 0; static uint8_t active = 0;


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


// follow up: averaging over many samples? // follow up: averaging over many samples?
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();
}
}

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 #ifdef DEBUG_TIMING
// ?! // ?!
param_pend.ldr_schwelle = 10 * value / 100; param_pend.ldr_schwelle = 10 * value / 100;
} else if (vorgabe_typ == VORGABE_12BIT) { } else if (vorgabe_typ == VORGABE_12BIT) {
// param_pend.ldr_schwelle = value;
param_pend.ldr_schwelle = value;
} }
param_changed = true; param_changed = true;



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

#include "PCA9685.h" #include "PCA9685.h"
#include <EEPROM.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_OBEN 16
#define SENSOR_UNTEN 12 #define SENSOR_UNTEN 12
uint16_t time_per_stair = 300; // dimmtime per stair [ms] uint16_t time_per_stair = 300; // dimmtime per stair [ms]
uint16_t idle_pwm_max = 100; uint16_t idle_pwm_max = 100;
uint16_t active_pwm = 2000; 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;
stairway_param_t param_pend; // zwischenspeicher änderungen stairway_param_t param_pend; // zwischenspeicher änderungen

Loading…
Cancel
Save