Monitor motorhome leisure battery and provide simple control of habitation

Dependencies:   net lpc1768 crypto clock web fram log

Committer:
andrewboyson
Date:
Thu Jan 14 16:05:55 2021 +0000
Revision:
0:b843d647695c
Creation (mostly a copy of heating at the moment)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:b843d647695c 1 //Boiler script
andrewboyson 0:b843d647695c 2 'use strict';
andrewboyson 0:b843d647695c 3
andrewboyson 0:b843d647695c 4 let dateTime = '';
andrewboyson 0:b843d647695c 5 let tankTemperature = '';
andrewboyson 0:b843d647695c 6 let blrOutTemperature = '';
andrewboyson 0:b843d647695c 7 let blrRtnTemperature = '';
andrewboyson 0:b843d647695c 8 let boilerCall = false;
andrewboyson 0:b843d647695c 9 let boilerPump = false;
andrewboyson 0:b843d647695c 10 let tankSetPoint = '';
andrewboyson 0:b843d647695c 11 let tankHysteresis = '';
andrewboyson 0:b843d647695c 12 let blrRunOnDeg = '';
andrewboyson 0:b843d647695c 13 let blrRunOnTime = '';
andrewboyson 0:b843d647695c 14
andrewboyson 0:b843d647695c 15 function parse()
andrewboyson 0:b843d647695c 16 {
andrewboyson 0:b843d647695c 17 let lines = Ajax.response.split('\n');
andrewboyson 0:b843d647695c 18 tankTemperature = Ajax.hexToSignedInt16(lines[0]);
andrewboyson 0:b843d647695c 19 blrOutTemperature = Ajax.hexToSignedInt16(lines[1]);
andrewboyson 0:b843d647695c 20 blrRtnTemperature = Ajax.hexToSignedInt16(lines[2]);
andrewboyson 0:b843d647695c 21 boilerCall = Ajax.hexToBit (lines[3], 0);
andrewboyson 0:b843d647695c 22 boilerPump = Ajax.hexToBit (lines[3], 1);
andrewboyson 0:b843d647695c 23 tankSetPoint = Ajax.hexToSignedInt16(lines[4]);
andrewboyson 0:b843d647695c 24 tankHysteresis = Ajax.hexToSignedInt16(lines[5]);
andrewboyson 0:b843d647695c 25 blrRunOnDeg = Ajax.hexToSignedInt16(lines[6]);
andrewboyson 0:b843d647695c 26 blrRunOnTime = Ajax.hexToSignedInt16(lines[7]);
andrewboyson 0:b843d647695c 27 }
andrewboyson 0:b843d647695c 28 function display()
andrewboyson 0:b843d647695c 29 {
andrewboyson 0:b843d647695c 30 let elem;
andrewboyson 0:b843d647695c 31 elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature);
andrewboyson 0:b843d647695c 32 elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature);
andrewboyson 0:b843d647695c 33 elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrRtnTemperature);
andrewboyson 0:b843d647695c 34 elem = Ajax.getElementOrNull('ajax-blr-rise-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(blrOutTemperature - blrRtnTemperature);
andrewboyson 0:b843d647695c 35
andrewboyson 0:b843d647695c 36 elem = Ajax.getElementOrNull('ajax-blr-call-toggle'); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr');
andrewboyson 0:b843d647695c 37 elem = Ajax.getElementOrNull('ajax-blr-pump-toggle'); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr');
andrewboyson 0:b843d647695c 38 elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint;
andrewboyson 0:b843d647695c 39 elem = Ajax.getElementOrNull('ajax-tank-hysteresis'); if (elem) elem.value = tankHysteresis;
andrewboyson 0:b843d647695c 40 elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = OneWire.DS18B20ToString(blrRunOnDeg);
andrewboyson 0:b843d647695c 41 elem = Ajax.getElementOrNull('ajax-blr-run-on-time'); if (elem) elem.value = blrRunOnTime;
andrewboyson 0:b843d647695c 42
andrewboyson 0:b843d647695c 43 }
andrewboyson 0:b843d647695c 44
andrewboyson 0:b843d647695c 45 Ajax.server = '/boiler-ajax';
andrewboyson 0:b843d647695c 46 Ajax.onResponse = function() { parse(); display(); };
andrewboyson 0:b843d647695c 47 Ajax.init();