bugfixes
This commit is contained in:
parent
2f6502ce20
commit
8c507083a7
@ -140,7 +140,8 @@ bool Treppe::read_sensor(int sensor)
|
||||
//return static_cast<bool>(pegel);
|
||||
}
|
||||
|
||||
float Treppe::read_ldr(){
|
||||
float Treppe::read_ldr()
|
||||
{
|
||||
/*
|
||||
Reads Illuminance in Lux
|
||||
|
||||
@ -176,27 +177,28 @@ float Treppe::read_ldr(){
|
||||
return ldr_value;
|
||||
}
|
||||
|
||||
|
||||
bool Treppe::check_ldr()
|
||||
{
|
||||
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;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// follow up: averaging over many samples?
|
||||
if(read_ldr() < ldr_schwelle) active = 1;
|
||||
if(read_ldr() > ldr_schwelle + LDR_HYS) active = 0;
|
||||
float ldr = read_ldr();
|
||||
if (ldr < ldr_schwelle)
|
||||
active = 1;
|
||||
if (ldr > ldr_schwelle + LDR_HYS)
|
||||
active = 0;
|
||||
|
||||
return active;
|
||||
return active;
|
||||
}
|
||||
|
||||
void Treppe::task()
|
||||
{
|
||||
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
|
||||
fsm_inputs.ldr_schwelle = read_ldr(); // <=== LDR implementierung !!
|
||||
fsm_inputs.ldr_schwelle = check_ldr();
|
||||
|
||||
fsm_inputs.sensor_oben = read_sensor(SENSOR_OBEN);
|
||||
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN);
|
||||
|
Loading…
x
Reference in New Issue
Block a user