diff --git a/code/espurna/config/defaults.h b/code/espurna/config/defaults.h index ec06f940..10dc9f92 100644 --- a/code/espurna/config/defaults.h +++ b/code/espurna/config/defaults.h @@ -552,6 +552,64 @@ #define LED8_RELAY 8 #endif +// ----------------------------------------------------------------------------- +// Digital Inputs +// ----------------------------------------------------------------------------- + +#ifndef DIGITAL1_PIN +#define DIGITAL1_PIN GPIO_NONE +#endif +#ifndef DIGITAL2_PIN +#define DIGITAL2_PIN GPIO_NONE +#endif +#ifndef DIGITAL3_PIN +#define DIGITAL3_PIN GPIO_NONE +#endif +#ifndef DIGITAL4_PIN +#define DIGITAL4_PIN GPIO_NONE +#endif +#ifndef DIGITAL5_PIN +#define DIGITAL5_PIN GPIO_NONE +#endif +#ifndef DIGITAL6_PIN +#define DIGITAL6_PIN GPIO_NONE +#endif +#ifndef DIGITAL7_PIN +#define DIGITAL7_PIN GPIO_NONE +#endif +#ifndef DIGITAL8_PIN +#define DIGITAL8_PIN GPIO_NONE +#endif + +// ----------------------------------------------------------------------------- +// Events +// ----------------------------------------------------------------------------- + +#ifndef EVENTS1_PIN +#define EVENTS1_PIN GPIO_NONE +#endif +#ifndef EVENTS2_PIN +#define EVENTS2_PIN GPIO_NONE +#endif +#ifndef EVENTS3_PIN +#define EVENTS3_PIN GPIO_NONE +#endif +#ifndef EVENTS4_PIN +#define EVENTS4_PIN GPIO_NONE +#endif +#ifndef EVENTS5_PIN +#define EVENTS5_PIN GPIO_NONE +#endif +#ifndef EVENTS6_PIN +#define EVENTS6_PIN GPIO_NONE +#endif +#ifndef EVENTS7_PIN +#define EVENTS7_PIN GPIO_NONE +#endif +#ifndef EVENTS8_PIN +#define EVENTS8_PIN GPIO_NONE +#endif + // ----------------------------------------------------------------------------- // General // ----------------------------------------------------------------------------- diff --git a/code/espurna/config/deprecated.h b/code/espurna/config/deprecated.h index a631b548..563540d3 100644 --- a/code/espurna/config/deprecated.h +++ b/code/espurna/config/deprecated.h @@ -13,3 +13,15 @@ #warning RF_PIN is deprecated! Please use RFB_RX_PIN instead #define RFB_RX_PIN RF_PIN #endif + +// 1.13.6 allow multiple digitals +#ifdef DIGITAL_PIN +#warning DIGITAL_PIN is deprecated! Please use DIGITAL1_PIN instead +#define DIGITAL1_PIN DIGITAL_PIN +#endif + +// 1.13.6 allow multiple events +#ifdef EVENTS_PIN +#warning EVENTS_PIN is deprecated! Please use EVENTS1_PIN instead +#define EVENTS1_PIN EVENTS_PIN +#endif \ No newline at end of file diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 79651e9c..2992e2bf 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -2521,8 +2521,9 @@ #ifndef DIGITAL_SUPPORT #define DIGITAL_SUPPORT 1 #endif - #define DIGITAL_PIN 16 - #define DIGITAL_PIN_MODE INPUT + #define DIGITAL1_PIN 16 + #define DIGITAL1_PIN_MODE INPUT + #define DIGITAL1_DEFAULT_STATE 0 // ----------------------------------------------------------------------------- // Heltec Touch Relay @@ -3942,7 +3943,7 @@ // A bit of EVENTS - pin 10 #define EVENTS_SUPPORT 1 - #define EVENTS_PIN 6 + #define EVENTS1_PIN 6 // Sonar #define SONAR_SUPPORT 1 diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index 24cd9929..0409ce61 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -260,16 +260,100 @@ #define DIGITAL_SUPPORT 0 #endif -#ifndef DIGITAL_PIN -#define DIGITAL_PIN 2 +#ifndef DIGITAL1_PIN +#define DIGITAL1_PIN 2 #endif -#ifndef DIGITAL_PIN_MODE -#define DIGITAL_PIN_MODE INPUT_PULLUP +#ifndef DIGITAL1_PIN_MODE +#define DIGITAL1_PIN_MODE INPUT_PULLUP #endif -#ifndef DIGITAL_DEFAULT_STATE -#define DIGITAL_DEFAULT_STATE 1 +#ifndef DIGITAL1_DEFAULT_STATE +#define DIGITAL1_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL2_PIN +#define DIGITAL2_PIN 2 +#endif + +#ifndef DIGITAL2_PIN_MODE +#define DIGITAL2_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL2_DEFAULT_STATE +#define DIGITAL2_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL3_PIN +#define DIGITAL3_PIN 2 +#endif + +#ifndef DIGITAL3_PIN_MODE +#define DIGITAL3_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL3_DEFAULT_STATE +#define DIGITAL3_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL4_PIN +#define DIGITAL4_PIN 2 +#endif + +#ifndef DIGITAL4_PIN_MODE +#define DIGITAL4_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL4_DEFAULT_STATE +#define DIGITAL4_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL5_PIN +#define DIGITAL5_PIN 2 +#endif + +#ifndef DIGITAL5_PIN_MODE +#define DIGITAL5_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL5_DEFAULT_STATE +#define DIGITAL5_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL6_PIN +#define DIGITAL6_PIN 2 +#endif + +#ifndef DIGITAL6_PIN_MODE +#define DIGITAL6_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL6_DEFAULT_STATE +#define DIGITAL6_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL7_PIN +#define DIGITAL7_PIN 2 +#endif + +#ifndef DIGITAL7_PIN_MODE +#define DIGITAL7_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL7_DEFAULT_STATE +#define DIGITAL7_DEFAULT_STATE 1 +#endif + +#ifndef DIGITAL8_PIN +#define DIGITAL8_PIN 2 +#endif + +#ifndef DIGITAL8_PIN_MODE +#define DIGITAL8_PIN_MODE INPUT_PULLUP +#endif + +#ifndef DIGITAL8_DEFAULT_STATE +#define DIGITAL8_DEFAULT_STATE 1 #endif //------------------------------------------------------------------------------ @@ -366,24 +450,173 @@ #define EVENTS_SUPPORT 0 // Do not build with counter support by default #endif -#ifndef EVENTS_TRIGGER -#define EVENTS_TRIGGER 1 // 1 to trigger callback on events, +#ifndef EVENTS1_TRIGGER +#define EVENTS1_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS1_PIN +#define EVENTS1_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS1_PIN_MODE +#define EVENTS1_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS1_INTERRUPT_MODE +#define EVENTS1_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS1_DEBOUNCE +#define EVENTS1_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS2_TRIGGER +#define EVENTS2_TRIGGER 1 // 1 to trigger callback on events, // 0 to only count them and report periodically #endif -#ifndef EVENTS_PIN -#define EVENTS_PIN 2 // GPIO to monitor +#ifndef EVENTS2_PIN +#define EVENTS2_PIN 2 // GPIO to monitor #endif -#ifndef EVENTS_PIN_MODE -#define EVENTS_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#ifndef EVENTS2_PIN_MODE +#define EVENTS2_PIN_MODE INPUT // INPUT, INPUT_PULLUP #endif -#ifndef EVENTS_INTERRUPT_MODE -#define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#ifndef EVENTS2_INTERRUPT_MODE +#define EVENTS2_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE #endif -#define EVENTS_DEBOUNCE 50 // Do not register events within less than 50 millis +#ifndef EVENTS2_DEBOUNCE +#define EVENTS2_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS3_TRIGGER +#define EVENTS3_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS3_PIN +#define EVENTS3_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS3_PIN_MODE +#define EVENTS3_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS3_INTERRUPT_MODE +#define EVENTS3_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS3_DEBOUNCE +#define EVENTS3_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS4_TRIGGER +#define EVENTS4_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS4_PIN +#define EVENTS4_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS4_PIN_MODE +#define EVENTS4_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS4_INTERRUPT_MODE +#define EVENTS4_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS4_DEBOUNCE +#define EVENTS4_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS5_TRIGGER +#define EVENTS5_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS5_PIN +#define EVENTS5_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS5_PIN_MODE +#define EVENTS5_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS5_INTERRUPT_MODE +#define EVENTS5_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS5_DEBOUNCE +#define EVENTS5_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS6_TRIGGER +#define EVENTS6_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS6_PIN +#define EVENTS6_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS6_PIN_MODE +#define EVENTS6_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS6_INTERRUPT_MODE +#define EVENTS6_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS6_DEBOUNCE +#define EVENTS6_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS7_TRIGGER +#define EVENTS7_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS7_PIN +#define EVENTS7_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS7_PIN_MODE +#define EVENTS7_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS7_INTERRUPT_MODE +#define EVENTS7_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS7_DEBOUNCE +#define EVENTS7_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif + +#ifndef EVENTS8_TRIGGER +#define EVENTS8_TRIGGER 1 // 1 to trigger callback on events, + // 0 to only count them and report periodically +#endif + +#ifndef EVENTS8_PIN +#define EVENTS8_PIN 2 // GPIO to monitor +#endif + +#ifndef EVENTS8_PIN_MODE +#define EVENTS8_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef EVENTS8_INTERRUPT_MODE +#define EVENTS8_INTERRUPT_MODE RISING // RISING, FALLING, CHANGE +#endif + +#ifndef EVENTS8_DEBOUNCE +#define EVENTS8_DEBOUNCE 50 // Do not register events within less than 50 millis +#endif //------------------------------------------------------------------------------ // Geiger sensor @@ -669,7 +902,6 @@ #ifndef PULSEMETER_SUPPORT #define PULSEMETER_SUPPORT 0 #endif - #ifndef PULSEMETER_PIN #define PULSEMETER_PIN 5 #endif diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index 45fb55c2..b8d44153 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -574,11 +574,85 @@ void _sensorLoad() { #if DIGITAL_SUPPORT { - DigitalSensor * sensor = new DigitalSensor(); - sensor->setGPIO(DIGITAL_PIN); - sensor->setMode(DIGITAL_PIN_MODE); - sensor->setDefault(DIGITAL_DEFAULT_STATE); - _sensors.push_back(sensor); + #if (DIGITAL1_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL1_PIN); + sensor->setMode(DIGITAL1_PIN_MODE); + sensor->setDefault(DIGITAL1_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL2_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL2_PIN); + sensor->setMode(DIGITAL2_PIN_MODE); + sensor->setDefault(DIGITAL2_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL3_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL3_PIN); + sensor->setMode(DIGITAL3_PIN_MODE); + sensor->setDefault(DIGITAL3_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL4_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL4_PIN); + sensor->setMode(DIGITAL4_PIN_MODE); + sensor->setDefault(DIGITAL4_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL5_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL5_PIN); + sensor->setMode(DIGITAL5_PIN_MODE); + sensor->setDefault(DIGITAL5_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL6_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL6_PIN); + sensor->setMode(DIGITAL6_PIN_MODE); + sensor->setDefault(DIGITAL6_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL7_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL7_PIN); + sensor->setMode(DIGITAL7_PIN_MODE); + sensor->setDefault(DIGITAL7_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif + + #if (DIGITAL8_PIN != GPIO_NONE) + { + DigitalSensor * sensor = new DigitalSensor(); + sensor->setGPIO(DIGITAL8_PIN); + sensor->setMode(DIGITAL8_PIN_MODE); + sensor->setDefault(DIGITAL8_DEFAULT_STATE); + _sensors.push_back(sensor); + } + #endif } #endif @@ -631,13 +705,101 @@ void _sensorLoad() { #if EVENTS_SUPPORT { - EventSensor * sensor = new EventSensor(); - sensor->setGPIO(EVENTS_PIN); - sensor->setTrigger(EVENTS_TRIGGER); - sensor->setPinMode(EVENTS_PIN_MODE); - sensor->setDebounceTime(EVENTS_DEBOUNCE); - sensor->setInterruptMode(EVENTS_INTERRUPT_MODE); - _sensors.push_back(sensor); + #if (EVENTS1_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS1_PIN); + sensor->setTrigger(EVENTS1_TRIGGER); + sensor->setPinMode(EVENTS1_PIN_MODE); + sensor->setDebounceTime(EVENTS1_DEBOUNCE); + sensor->setInterruptMode(EVENTS1_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS2_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS2_PIN); + sensor->setTrigger(EVENTS2_TRIGGER); + sensor->setPinMode(EVENTS2_PIN_MODE); + sensor->setDebounceTime(EVENTS2_DEBOUNCE); + sensor->setInterruptMode(EVENTS2_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS3_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS3_PIN); + sensor->setTrigger(EVENTS3_TRIGGER); + sensor->setPinMode(EVENTS3_PIN_MODE); + sensor->setDebounceTime(EVENTS3_DEBOUNCE); + sensor->setInterruptMode(EVENTS3_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS4_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS4_PIN); + sensor->setTrigger(EVENTS4_TRIGGER); + sensor->setPinMode(EVENTS4_PIN_MODE); + sensor->setDebounceTime(EVENTS4_DEBOUNCE); + sensor->setInterruptMode(EVENTS4_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS5_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS5_PIN); + sensor->setTrigger(EVENTS5_TRIGGER); + sensor->setPinMode(EVENTS5_PIN_MODE); + sensor->setDebounceTime(EVENTS5_DEBOUNCE); + sensor->setInterruptMode(EVENTS5_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS6_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS6_PIN); + sensor->setTrigger(EVENTS6_TRIGGER); + sensor->setPinMode(EVENTS6_PIN_MODE); + sensor->setDebounceTime(EVENTS6_DEBOUNCE); + sensor->setInterruptMode(EVENTS6_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS7_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS7_PIN); + sensor->setTrigger(EVENTS7_TRIGGER); + sensor->setPinMode(EVENTS7_PIN_MODE); + sensor->setDebounceTime(EVENTS7_DEBOUNCE); + sensor->setInterruptMode(EVENTS7_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif + + #if (EVENTS8_PIN != GPIO_NONE) + { + EventSensor * sensor = new EventSensor(); + sensor->setGPIO(EVENTS8_PIN); + sensor->setTrigger(EVENTS8_TRIGGER); + sensor->setPinMode(EVENTS8_PIN_MODE); + sensor->setDebounceTime(EVENTS8_DEBOUNCE); + sensor->setInterruptMode(EVENTS8_INTERRUPT_MODE); + _sensors.push_back(sensor); + } + #endif } #endif @@ -756,9 +918,11 @@ void _sensorLoad() { #if PULSEMETER_SUPPORT { + PulseMeterSensor * sensor = new PulseMeterSensor(); sensor->setGPIO(PULSEMETER_PIN); sensor->setEnergyRatio(PULSEMETER_ENERGY_RATIO); + sensor->setInterruptMode(PULSEMETER_INTERRUPT_ON); sensor->setDebounceTime(PULSEMETER_DEBOUNCE); _sensors.push_back(sensor); } @@ -1043,10 +1207,10 @@ void _sensorInit() { #endif // CSE7766_SUPPORT - #if PULSEMETER_SUPPORT + #if PULSEMETER_SUPPORT if (_sensors[i]->getID() == SENSOR_PULSEMETER_ID) { PulseMeterSensor * sensor = (PulseMeterSensor *) _sensors[i]; - sensor->setEnergyRatio(getSetting("pwrRatioE", PULSEMETER_ENERGY_RATIO).toInt()); + sensor->setEnergyRatio(getSetting("pwrRatioE", sensor->getEnergyRatio()).toInt()); } #endif // PULSEMETER_SUPPORT @@ -1235,7 +1399,7 @@ void _sensorConfigure() { _sensorResetTS(); } - sensor->setEnergyRatio(getSetting("pwrRatioE", PULSEMETER_ENERGY_RATIO).toInt()); + sensor->setEnergyRatio(getSetting("pwrRatioE", sensor->getEnergyRatio()).toInt()); } #endif // PULSEMETER_SUPPORT diff --git a/code/espurna/sensors/EventSensor.h b/code/espurna/sensors/EventSensor.h index 09cf5471..d12671a4 100644 --- a/code/espurna/sensors/EventSensor.h +++ b/code/espurna/sensors/EventSensor.h @@ -190,7 +190,7 @@ class EventSensor : public BaseSensor { volatile unsigned long _counter = 0; unsigned char _value = 0; unsigned long _last = 0; - unsigned long _debounce = microsecondsToClockCycles(EVENTS_DEBOUNCE * 1000); + unsigned long _debounce = microsecondsToClockCycles(EVENTS1_DEBOUNCE * 1000); bool _trigger = false; bool _trigger_flag = false; diff --git a/code/espurna/sensors/PulseMeterSensor.h b/code/espurna/sensors/PulseMeterSensor.h index 7bb4d3d7..d3012890 100644 --- a/code/espurna/sensors/PulseMeterSensor.h +++ b/code/espurna/sensors/PulseMeterSensor.h @@ -43,6 +43,10 @@ class PulseMeterSensor : public BaseSensor { if (ratio > 0) _ratio = ratio; } + void setInterruptMode(unsigned char interrupt_mode) { + _interrupt_mode = interrupt_mode; + } + void setDebounceTime(unsigned long debounce) { _debounce = debounce; } @@ -57,6 +61,10 @@ class PulseMeterSensor : public BaseSensor { return _ratio; } + unsigned char getInterruptMode() { + return _interrupt_mode; + } + unsigned long getDebounceTime() { return _debounce; } @@ -144,7 +152,7 @@ class PulseMeterSensor : public BaseSensor { if (_gpio != _previous) { if (_previous != GPIO_NONE) _detach(_previous); - _attach(this, _gpio, PULSEMETER_INTERRUPT_ON); + _attach(this, _gpio, _interrupt_mode); _previous = _gpio; } @@ -171,6 +179,8 @@ class PulseMeterSensor : public BaseSensor { unsigned long _previous_pulses = 0; unsigned long _previous_time = 0; + unsigned char _interrupt_mode = FALLING; + };