Browse Source

bugfixes

tags/v1.0.0
Dominik Bartsch 3 years ago
parent
commit
8c507083a7
1 changed files with 12 additions and 10 deletions
  1. 12
    10
      lib/treppe/treppe.cpp

+ 12
- 10
lib/treppe/treppe.cpp View File

//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);

Loading…
Cancel
Save