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