|
|
|
|
|
|
|
|
//return static_cast<bool>(pegel); |
|
|
//return static_cast<bool>(pegel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
float Treppe::read_ldr(){ |
|
|
|
|
|
|
|
|
float Treppe::read_ldr() |
|
|
|
|
|
{ |
|
|
/* |
|
|
/* |
|
|
Reads Illuminance in Lux |
|
|
Reads Illuminance in Lux |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ldr_value; |
|
|
return ldr_value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Treppe::check_ldr() |
|
|
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); |
|
|
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? |
|
|
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() |
|
|
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_oben = read_sensor(SENSOR_OBEN); |
|
|
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN); |
|
|
fsm_inputs.sensor_unten = read_sensor(SENSOR_UNTEN); |