Browse Source

bugfixes

tags/v1.0.0
Dominik Bartsch 2 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

@@ -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…
Cancel
Save