Controls the central heating system and the lights.

Dependencies:   1-wire clock crypto fram log lpc1768 net web wiz mbed

Committer:
andrewboyson
Date:
Sat Nov 12 10:03:38 2022 +0000
Revision:
8:8ac076ce51af
Parent:
5:3579001bea1b
Updated LPC1768 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:22b158d3c76f 1 //Radiator script
andrewboyson 0:22b158d3c76f 2 'use strict';
andrewboyson 0:22b158d3c76f 3
andrewboyson 0:22b158d3c76f 4 let hallTemperature = '';
andrewboyson 5:3579001bea1b 5 let tankTemperature = '';
andrewboyson 0:22b158d3c76f 6 let programTimerOutput = false;
andrewboyson 0:22b158d3c76f 7 let radiatorMode = false;
andrewboyson 0:22b158d3c76f 8 let radiatorOverride = false;
andrewboyson 0:22b158d3c76f 9 let radiatorPump = false;
andrewboyson 5:3579001bea1b 10 let hotWaterProtectOn = false;
andrewboyson 8:8ac076ce51af 11 let radiatorsOn = false;
andrewboyson 0:22b158d3c76f 12 let overrideCancelHour = '';
andrewboyson 0:22b158d3c76f 13 let overrideCancelMinute = '';
andrewboyson 0:22b158d3c76f 14 let nightSetPoint = '';
andrewboyson 0:22b158d3c76f 15 let frostSetPoint = '';
andrewboyson 5:3579001bea1b 16 let hotWaterProtectTemp = '';
andrewboyson 0:22b158d3c76f 17
andrewboyson 0:22b158d3c76f 18 function parse()
andrewboyson 0:22b158d3c76f 19 {
andrewboyson 0:22b158d3c76f 20 let lines = Ajax.response.split('\n');
andrewboyson 0:22b158d3c76f 21 hallTemperature = Ajax.hexToSignedInt16(lines[0]);
andrewboyson 5:3579001bea1b 22 tankTemperature = Ajax.hexToSignedInt16(lines[1]);
andrewboyson 5:3579001bea1b 23 programTimerOutput = Ajax.hexToBit (lines[2], 0);
andrewboyson 5:3579001bea1b 24 radiatorMode = Ajax.hexToBit (lines[2], 1);
andrewboyson 5:3579001bea1b 25 radiatorOverride = Ajax.hexToBit (lines[2], 2);
andrewboyson 5:3579001bea1b 26 radiatorPump = Ajax.hexToBit (lines[2], 3);
andrewboyson 5:3579001bea1b 27 hotWaterProtectOn = Ajax.hexToBit (lines[2], 4);
andrewboyson 8:8ac076ce51af 28 radiatorsOn = Ajax.hexToBit (lines[2], 5);
andrewboyson 5:3579001bea1b 29 overrideCancelHour = Ajax.hexToSignedInt8 (lines[3]);
andrewboyson 5:3579001bea1b 30 overrideCancelMinute = Ajax.hexToSignedInt8 (lines[4]);
andrewboyson 5:3579001bea1b 31 nightSetPoint = Ajax.hexToSignedInt16(lines[5]);
andrewboyson 5:3579001bea1b 32 frostSetPoint = Ajax.hexToSignedInt16(lines[6]);
andrewboyson 5:3579001bea1b 33 hotWaterProtectTemp = Ajax.hexToSignedInt8 (lines[7]);
andrewboyson 0:22b158d3c76f 34 }
andrewboyson 0:22b158d3c76f 35 function display()
andrewboyson 0:22b158d3c76f 36 {
andrewboyson 0:22b158d3c76f 37 let elem;
andrewboyson 5:3579001bea1b 38 elem = Ajax.getElementOrNull('ajax-hall-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(hallTemperature);
andrewboyson 5:3579001bea1b 39 elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = OneWire.DS18B20ToString(tankTemperature);
andrewboyson 5:3579001bea1b 40 elem = Ajax.getElementOrNull('ajax-program-toggle' ); if (elem) elem.setAttribute('dir', programTimerOutput ? 'rtl' : 'ltr');
andrewboyson 5:3579001bea1b 41 elem = Ajax.getElementOrNull('ajax-mode-toggle' ); if (elem) elem.setAttribute('dir', radiatorMode ? 'rtl' : 'ltr');
andrewboyson 5:3579001bea1b 42 elem = Ajax.getElementOrNull('ajax-override-toggle' ); if (elem) elem.setAttribute('dir', radiatorOverride ? 'rtl' : 'ltr');
andrewboyson 8:8ac076ce51af 43 elem = Ajax.getElementOrNull('ajax-radiator-pump-toggle' ); if (elem) elem.setAttribute('dir', radiatorPump ? 'rtl' : 'ltr');
andrewboyson 5:3579001bea1b 44 elem = Ajax.getElementOrNull('ajax-hw-prot-toggle' ); if (elem) elem.setAttribute('dir', hotWaterProtectOn ? 'rtl' : 'ltr');
andrewboyson 8:8ac076ce51af 45 elem = Ajax.getElementOrNull('ajax-radiators-on-toggle' ); if (elem) elem.setAttribute('dir', radiatorsOn ? 'rtl' : 'ltr');
andrewboyson 5:3579001bea1b 46 elem = Ajax.getElementOrNull('ajax-override-cancel-minute'); if (elem)
andrewboyson 0:22b158d3c76f 47 {
andrewboyson 0:22b158d3c76f 48 elem.value = String(overrideCancelHour*100 + overrideCancelMinute).padStart(4, '0');
andrewboyson 0:22b158d3c76f 49 }
andrewboyson 0:22b158d3c76f 50 elem = Ajax.getElementOrNull('ajax-night-set-point' ); if (elem) elem.value = nightSetPoint;
andrewboyson 0:22b158d3c76f 51 elem = Ajax.getElementOrNull('ajax-frost-set-point' ); if (elem) elem.value = frostSetPoint;
andrewboyson 5:3579001bea1b 52 elem = Ajax.getElementOrNull('ajax-hw-prot-temp' ); if (elem) elem.value = hotWaterProtectTemp;
andrewboyson 0:22b158d3c76f 53 }
andrewboyson 0:22b158d3c76f 54
andrewboyson 0:22b158d3c76f 55 Ajax.server = '/radiator-ajax';
andrewboyson 0:22b158d3c76f 56 Ajax.onResponse = function() { parse(); display(); };
andrewboyson 0:22b158d3c76f 57 Ajax.init();