overridable input check, startup delay

This commit is contained in:
2018-12-03 16:52:27 +01:00
parent d906286eda
commit 48a32d2124
3 changed files with 6 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ class DigitalInputPlugin : public Plugin {
GpioConfig config; GpioConfig config;
DigitalInputPlugin(GpioConfig cfg); DigitalInputPlugin(GpioConfig cfg);
void activate(Scheduler* userScheduler); void activate(Scheduler* userScheduler);
void checkInput(); virtual void checkInput();
}; };
#endif #endif

View File

@@ -2,6 +2,10 @@
void PirInputPlugin::checkInput() void PirInputPlugin::checkInput()
{ {
if(startupDelay > millis()){
return;
}
val = digitalRead(config.pin); // read input value val = digitalRead(config.pin); // read input value
if (val == HIGH) if (val == HIGH)
{ // check if the input is HIGH { // check if the input is HIGH

View File

@@ -22,6 +22,7 @@ class PirInputPlugin : public DigitalInputPlugin {
PirInputPlugin(GpioConfig cfg) : DigitalInputPlugin(cfg){} PirInputPlugin(GpioConfig cfg) : DigitalInputPlugin(cfg){}
int pirState = LOW; // we start, assuming no motion detected int pirState = LOW; // we start, assuming no motion detected
int val = 0; int val = 0;
int startupDelay = 20000; // TODO move to cfg
void checkInput(); void checkInput();
}; };