mirror of
https://gitlab.com/wirelos/sprocket-plugin-gpio.git
synced 2025-12-14 13:26:48 +01:00
overridable input check, startup delay
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user