From 48a32d2124b936f2d779b7116122b17a40cb37aa Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Mon, 3 Dec 2018 16:52:27 +0100 Subject: [PATCH] overridable input check, startup delay --- src/inputs/digital/DigitalInputPlugin.h | 2 +- src/inputs/pir/PirInputPlugin.cpp | 4 ++++ src/inputs/pir/PirInputPlugin.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/inputs/digital/DigitalInputPlugin.h b/src/inputs/digital/DigitalInputPlugin.h index 3cf20ad..099f006 100644 --- a/src/inputs/digital/DigitalInputPlugin.h +++ b/src/inputs/digital/DigitalInputPlugin.h @@ -23,7 +23,7 @@ class DigitalInputPlugin : public Plugin { GpioConfig config; DigitalInputPlugin(GpioConfig cfg); void activate(Scheduler* userScheduler); - void checkInput(); + virtual void checkInput(); }; #endif diff --git a/src/inputs/pir/PirInputPlugin.cpp b/src/inputs/pir/PirInputPlugin.cpp index 9ee82e8..0a8305e 100644 --- a/src/inputs/pir/PirInputPlugin.cpp +++ b/src/inputs/pir/PirInputPlugin.cpp @@ -2,6 +2,10 @@ void PirInputPlugin::checkInput() { + + if(startupDelay > millis()){ + return; + } val = digitalRead(config.pin); // read input value if (val == HIGH) { // check if the input is HIGH diff --git a/src/inputs/pir/PirInputPlugin.h b/src/inputs/pir/PirInputPlugin.h index e657595..b607920 100644 --- a/src/inputs/pir/PirInputPlugin.h +++ b/src/inputs/pir/PirInputPlugin.h @@ -22,6 +22,7 @@ class PirInputPlugin : public DigitalInputPlugin { PirInputPlugin(GpioConfig cfg) : DigitalInputPlugin(cfg){} int pirState = LOW; // we start, assuming no motion detected int val = 0; + int startupDelay = 20000; // TODO move to cfg void checkInput(); };