Monitor for central heating system (e.g. 2zones+hw) Supports up to 15 temp probes (DS18B20/DS18S20) 3 valve monitors Gas pulse meter recording Use stand-alone or with nodeEnergyServer See http://robdobson.com/2015/09/central-heating-monitor
Dependencies: EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src
Diff: VoltAlerter.cpp
- Revision:
- 10:72eb217def1f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VoltAlerter.cpp Sun Feb 22 20:23:43 2015 +0000 @@ -0,0 +1,34 @@ +// Detect stat of Volt-Alerter +// Device produces a square wave when voltage detected +// Cycle time of square wave around 100ms +// Rob Dobson, 2015 + +#include "VoltAlerter.h" + +VoltAlerter::VoltAlerter(PinName pinName) : + _inPin(pinName, PullUp) +{ + _curPinState = 0; + _consecutiveLows = 0; +} + +void VoltAlerter::Service() +{ + // Check pin + if (!_inPin) + { + _curPinState = 1; + _consecutiveLows = 0; + return; + } + + // Only set state low if we get X consecutive lows + _consecutiveLows++; + if (_consecutiveLows >= CONSECUTIVE_LOWS_REQD_FOR_LOW) + { + _curPinState = 0; + // The following is just to ensure the int doesn't overflow + _consecutiveLows = CONSECUTIVE_LOWS_REQD_FOR_LOW; + } +} +