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
web-this/radiator/web-radiator-script.js@91:8b192efd0288, 2020-06-10 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Jun 10 10:08:06 2020 +0000
- Revision:
- 91:8b192efd0288
- Parent:
- 53:c1bf7d9db507
- Child:
- 92:2d1ca4dcbca7
Changed the run on residual to a fixed 4 bit fraction temperature to allow better than one degree precision.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 47:229338b3adcb | 1 | //Radiator script |
andrewboyson | 47:229338b3adcb | 2 | 'use strict'; |
andrewboyson | 47:229338b3adcb | 3 | |
andrewboyson | 47:229338b3adcb | 4 | let hallTemperature = ''; |
andrewboyson | 47:229338b3adcb | 5 | let programTimerOutput = false; |
andrewboyson | 47:229338b3adcb | 6 | let radiatorMode = false; |
andrewboyson | 47:229338b3adcb | 7 | let radiatorOverride = false; |
andrewboyson | 47:229338b3adcb | 8 | let radiatorPump = false; |
andrewboyson | 47:229338b3adcb | 9 | let nightSetPoint = ''; |
andrewboyson | 47:229338b3adcb | 10 | let frostSetPoint = ''; |
andrewboyson | 47:229338b3adcb | 11 | |
andrewboyson | 47:229338b3adcb | 12 | function parse() |
andrewboyson | 47:229338b3adcb | 13 | { |
andrewboyson | 47:229338b3adcb | 14 | let lines = Ajax.response.split('\n'); |
andrewboyson | 91:8b192efd0288 | 15 | hallTemperature = OneWire.parseDS18B20 (lines[0]); |
andrewboyson | 47:229338b3adcb | 16 | programTimerOutput = Ajax.hexToBit (lines[1], 0); |
andrewboyson | 47:229338b3adcb | 17 | radiatorMode = Ajax.hexToBit (lines[1], 1); |
andrewboyson | 47:229338b3adcb | 18 | radiatorOverride = Ajax.hexToBit (lines[1], 2); |
andrewboyson | 47:229338b3adcb | 19 | radiatorPump = Ajax.hexToBit (lines[1], 3); |
andrewboyson | 47:229338b3adcb | 20 | nightSetPoint = Ajax.hexToSignedInt16(lines[2], 16); |
andrewboyson | 47:229338b3adcb | 21 | frostSetPoint = Ajax.hexToSignedInt16(lines[3], 16); |
andrewboyson | 47:229338b3adcb | 22 | } |
andrewboyson | 47:229338b3adcb | 23 | function display() |
andrewboyson | 47:229338b3adcb | 24 | { |
andrewboyson | 47:229338b3adcb | 25 | let elem; |
andrewboyson | 91:8b192efd0288 | 26 | elem = Ajax.getElementOrNull('ajax-hall-html' ); if (elem) elem.textContent = hallTemperature.toFixed(1); |
andrewboyson | 47:229338b3adcb | 27 | elem = Ajax.getElementOrNull('ajax-program-toggle' ); if (elem) elem.setAttribute('dir', programTimerOutput ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 28 | elem = Ajax.getElementOrNull('ajax-mode-toggle' ); if (elem) elem.setAttribute('dir', radiatorMode ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 29 | elem = Ajax.getElementOrNull('ajax-override-toggle'); if (elem) elem.setAttribute('dir', radiatorOverride ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 30 | elem = Ajax.getElementOrNull('ajax-radiator-toggle'); if (elem) elem.setAttribute('dir', radiatorPump ? 'rtl' : 'ltr'); |
andrewboyson | 47:229338b3adcb | 31 | elem = Ajax.getElementOrNull('ajax-night-set-point'); if (elem) elem.value = nightSetPoint; |
andrewboyson | 47:229338b3adcb | 32 | elem = Ajax.getElementOrNull('ajax-frost-set-point'); if (elem) elem.value = frostSetPoint; |
andrewboyson | 47:229338b3adcb | 33 | } |
andrewboyson | 47:229338b3adcb | 34 | |
andrewboyson | 47:229338b3adcb | 35 | Ajax.server = '/radiator-ajax'; |
andrewboyson | 47:229338b3adcb | 36 | Ajax.onResponse = function() { parse(); display(); }; |
andrewboyson | 47:229338b3adcb | 37 | Ajax.init(); |