Central Heating controller using the real time clock, PHY module for internet, 1-wire interface for temperature sensors, a system log and a configuration file
Dependencies: net 1-wire lpc1768 crypto clock web fram log
/media/uploads/andrewboyson/heating.sch
/media/uploads/andrewboyson/heating.brd
/media/uploads/andrewboyson/eagle.epf
http-derived/boiler/http-boiler-script.js@47:229338b3adcb, 2019-04-23 (annotated)
- Committer:
- andrewboyson
- Date:
- Tue Apr 23 18:47:47 2019 +0000
- Revision:
- 47:229338b3adcb
Provided individual scripts per page and moved most inputs to ajax.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 47:229338b3adcb | 1 | //Boiler script |
andrewboyson | 47:229338b3adcb | 2 | 'use strict'; |
andrewboyson | 47:229338b3adcb | 3 | |
andrewboyson | 47:229338b3adcb | 4 | let dateTime = ''; |
andrewboyson | 47:229338b3adcb | 5 | let tankTemperature = ''; |
andrewboyson | 47:229338b3adcb | 6 | let blrOutTemperature = ''; |
andrewboyson | 47:229338b3adcb | 7 | let blrRtnTemperature = ''; |
andrewboyson | 47:229338b3adcb | 8 | let boilerCall = false; |
andrewboyson | 47:229338b3adcb | 9 | let boilerPump = false; |
andrewboyson | 47:229338b3adcb | 10 | let tankSetPoint = ''; |
andrewboyson | 47:229338b3adcb | 11 | let tankHysteresis = ''; |
andrewboyson | 47:229338b3adcb | 12 | let blrRunOnDeg = ''; |
andrewboyson | 47:229338b3adcb | 13 | let blrRunOnTime = ''; |
andrewboyson | 47:229338b3adcb | 14 | |
andrewboyson | 47:229338b3adcb | 15 | function parse() |
andrewboyson | 47:229338b3adcb | 16 | { |
andrewboyson | 47:229338b3adcb | 17 | let lines = Ajax.response.split('\n'); |
andrewboyson | 47:229338b3adcb | 18 | tankTemperature = OneWire.DS18B20ToString (lines[0]); |
andrewboyson | 47:229338b3adcb | 19 | blrOutTemperature = OneWire.DS18B20ToString (lines[1]); |
andrewboyson | 47:229338b3adcb | 20 | blrRtnTemperature = OneWire.DS18B20ToString (lines[2]); |
andrewboyson | 47:229338b3adcb | 21 | boilerCall = Ajax.hexToBit (lines[3], 0); |
andrewboyson | 47:229338b3adcb | 22 | boilerPump = Ajax.hexToBit (lines[3], 1); |
andrewboyson | 47:229338b3adcb | 23 | tankSetPoint = Ajax.hexToSignedInt16(lines[4]); |
andrewboyson | 47:229338b3adcb | 24 | tankHysteresis = Ajax.hexToSignedInt16(lines[5]); |
andrewboyson | 47:229338b3adcb | 25 | blrRunOnDeg = Ajax.hexToSignedInt16(lines[6]); |
andrewboyson | 47:229338b3adcb | 26 | blrRunOnTime = Ajax.hexToSignedInt16(lines[7]); |
andrewboyson | 47:229338b3adcb | 27 | } |
andrewboyson | 47:229338b3adcb | 28 | function display() |
andrewboyson | 47:229338b3adcb | 29 | { |
andrewboyson | 47:229338b3adcb | 30 | let elem; |
andrewboyson | 47:229338b3adcb | 31 | elem = Ajax.getElementOrNull('ajax-tank-html' ); if (elem) elem.textContent = tankTemperature; |
andrewboyson | 47:229338b3adcb | 32 | elem = Ajax.getElementOrNull('ajax-blr-out-html' ); if (elem) elem.textContent = blrOutTemperature; |
andrewboyson | 47:229338b3adcb | 33 | elem = Ajax.getElementOrNull('ajax-blr-rtn-html' ); if (elem) elem.textContent = blrRtnTemperature; |
andrewboyson | 47:229338b3adcb | 34 | elem = Ajax.getElementOrNull('ajax-blr-call-toggle'); if (elem) elem.setAttribute('dir', boilerCall ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 35 | elem = Ajax.getElementOrNull('ajax-blr-pump-toggle'); if (elem) elem.setAttribute('dir', boilerPump ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 36 | elem = Ajax.getElementOrNull('ajax-tank-set-point' ); if (elem) elem.value = tankSetPoint; |
andrewboyson | 47:229338b3adcb | 37 | elem = Ajax.getElementOrNull('ajax-tank-hysteresis'); if (elem) elem.value = tankHysteresis; |
andrewboyson | 47:229338b3adcb | 38 | elem = Ajax.getElementOrNull('ajax-blr-run-on-deg' ); if (elem) elem.value = blrRunOnDeg; |
andrewboyson | 47:229338b3adcb | 39 | elem = Ajax.getElementOrNull('ajax-blr-run-on-time'); if (elem) elem.value = blrRunOnTime; |
andrewboyson | 47:229338b3adcb | 40 | |
andrewboyson | 47:229338b3adcb | 41 | } |
andrewboyson | 47:229338b3adcb | 42 | |
andrewboyson | 47:229338b3adcb | 43 | Ajax.server = '/boiler-ajax'; |
andrewboyson | 47:229338b3adcb | 44 | Ajax.onResponse = function() { parse(); display(); }; |
andrewboyson | 47:229338b3adcb | 45 | Ajax.init(); |