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
GasUseCounter.h
- Committer:
- Bobty
- Date:
- 2015-10-05
- Revision:
- 19:0367cb46d003
- Parent:
- 5:5bccf48799d4
- Child:
- 20:7933076df5af
File content as of revision 19:0367cb46d003:
#ifndef __GASUSECOUNTER__H #define __GASUSECOUNTER__H #include "mbed.h" #include "PulsePin.h" #include "SDFileSystem.h" #include <RawSerial.h> const int MAX_GAS_COUNT_STR_LEN = 50; const int MAX_PULSES_BEFORE_STORE_NV = 1; // Store at each pulse class GasUseCounter { public: // Constructor GasUseCounter(const char* gasUseFilename1, const char* gasUseFilename2, DigitalIn& gasPulsePin, RawSerial &pc) : _gasPulsePin(gasPulsePin), _pc(pc) { _gasUseFilename1 = gasUseFilename1; _gasUseFilename2 = gasUseFilename2; _lastWrittenGasCount = 0; _pulseDetector = new PulsePin(_gasPulsePin, false, 200); } // Init (get count from NV) void Init(); // Callback from web server to handle getting current gas count char* getGasUseCallback(char* cmdStr, char* argStr); // Service function to detect pulses bool Service(); // Read/Write current gas count void GetGasCountFromSD(); void WriteGasCountToSD(); // Get Count int GetCount() { return _pulseDetector->GetPulseCount(); } // Set Count void SetCount(int gasUseCount) { _pulseDetector->SetPulseCount(gasUseCount); WriteGasCountToSD(); } // Get inter-pulse time int GetPulseRateMs() { return _pulseDetector->GetPulseRateMs(); } private: // Gas use filename for non-volatile const char* _gasUseFilename1; const char* _gasUseFilename2; int _curGasCount; int _lastWrittenGasCount; char _gasCountStr [MAX_GAS_COUNT_STR_LEN]; DigitalIn& _gasPulsePin; PulsePin* _pulseDetector; RawSerial& _pc; }; #endif