
Controls the central heating system and the lights.
Dependencies: 1-wire clock crypto fram log lpc1768 net web wiz mbed
web-this/program/web-program-script.inc@8:8ac076ce51af, 2022-11-12 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Nov 12 10:03:38 2022 +0000
- Revision:
- 8:8ac076ce51af
- Parent:
- 0:22b158d3c76f
Updated LPC1768 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:22b158d3c76f | 1 | "//Program script\n" |
andrewboyson | 0:22b158d3c76f | 2 | "'use strict';\n" |
andrewboyson | 0:22b158d3c76f | 3 | "\n" |
andrewboyson | 0:22b158d3c76f | 4 | "let programOut = false;\n" |
andrewboyson | 0:22b158d3c76f | 5 | "let program1 = '';\n" |
andrewboyson | 0:22b158d3c76f | 6 | "let program2 = '';\n" |
andrewboyson | 0:22b158d3c76f | 7 | "let program3 = '';\n" |
andrewboyson | 0:22b158d3c76f | 8 | "let monProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 9 | "let tueProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 10 | "let wedProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 11 | "let thuProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 12 | "let friProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 13 | "let satProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 14 | "let sunProgram = 0;\n" |
andrewboyson | 0:22b158d3c76f | 15 | "let newDayHour = 0;\n" |
andrewboyson | 0:22b158d3c76f | 16 | "\n" |
andrewboyson | 0:22b158d3c76f | 17 | "function parseDayPrograms(line)\n" |
andrewboyson | 0:22b158d3c76f | 18 | "{\n" |
andrewboyson | 0:22b158d3c76f | 19 | " let fields = line.split(',');\n" |
andrewboyson | 0:22b158d3c76f | 20 | " monProgram = parseInt(fields[0]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 21 | " tueProgram = parseInt(fields[1]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 22 | " wedProgram = parseInt(fields[2]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 23 | " thuProgram = parseInt(fields[3]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 24 | " friProgram = parseInt(fields[4]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 25 | " satProgram = parseInt(fields[5]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 26 | " sunProgram = parseInt(fields[6]) + 1;\n" |
andrewboyson | 0:22b158d3c76f | 27 | "}\n" |
andrewboyson | 0:22b158d3c76f | 28 | "function parse()\n" |
andrewboyson | 0:22b158d3c76f | 29 | "{\n" |
andrewboyson | 0:22b158d3c76f | 30 | " let lines = Ajax.response.split('\\n');\n" |
andrewboyson | 0:22b158d3c76f | 31 | " programOut = Ajax.hexToBit(lines[0], 0);\n" |
andrewboyson | 0:22b158d3c76f | 32 | " newDayHour = Ajax.hexToSignedInt8(lines[1]);\n" |
andrewboyson | 0:22b158d3c76f | 33 | " parseDayPrograms (lines[2]);\n" |
andrewboyson | 0:22b158d3c76f | 34 | " program1 = lines[3];\n" |
andrewboyson | 0:22b158d3c76f | 35 | " program2 = lines[4];\n" |
andrewboyson | 0:22b158d3c76f | 36 | " program3 = lines[5];\n" |
andrewboyson | 0:22b158d3c76f | 37 | "}\n" |
andrewboyson | 0:22b158d3c76f | 38 | "function display()\n" |
andrewboyson | 0:22b158d3c76f | 39 | "{\n" |
andrewboyson | 0:22b158d3c76f | 40 | " let elem;\n" |
andrewboyson | 0:22b158d3c76f | 41 | " elem = Ajax.getElementOrNull('ajax-program-toggle' ); if (elem) elem.setAttribute('dir', programOut ? 'rtl' : 'ltr');\n" |
andrewboyson | 0:22b158d3c76f | 42 | " elem = Ajax.getElementOrNull('ajax-program-1' ); if (elem) elem.value = program1;\n" |
andrewboyson | 0:22b158d3c76f | 43 | " elem = Ajax.getElementOrNull('ajax-program-2' ); if (elem) elem.value = program2;\n" |
andrewboyson | 0:22b158d3c76f | 44 | " elem = Ajax.getElementOrNull('ajax-program-3' ); if (elem) elem.value = program3;\n" |
andrewboyson | 0:22b158d3c76f | 45 | " elem = Ajax.getElementOrNull('ajax-mon-program' ); if (elem) elem.value = monProgram;\n" |
andrewboyson | 0:22b158d3c76f | 46 | " elem = Ajax.getElementOrNull('ajax-tue-program' ); if (elem) elem.value = tueProgram;\n" |
andrewboyson | 0:22b158d3c76f | 47 | " elem = Ajax.getElementOrNull('ajax-wed-program' ); if (elem) elem.value = wedProgram;\n" |
andrewboyson | 0:22b158d3c76f | 48 | " elem = Ajax.getElementOrNull('ajax-thu-program' ); if (elem) elem.value = thuProgram;\n" |
andrewboyson | 0:22b158d3c76f | 49 | " elem = Ajax.getElementOrNull('ajax-fri-program' ); if (elem) elem.value = friProgram;\n" |
andrewboyson | 0:22b158d3c76f | 50 | " elem = Ajax.getElementOrNull('ajax-sat-program' ); if (elem) elem.value = satProgram;\n" |
andrewboyson | 0:22b158d3c76f | 51 | " elem = Ajax.getElementOrNull('ajax-sun-program' ); if (elem) elem.value = sunProgram;\n" |
andrewboyson | 0:22b158d3c76f | 52 | " elem = Ajax.getElementOrNull('ajax-new-day-hour' ); if (elem) elem.value = newDayHour;\n" |
andrewboyson | 0:22b158d3c76f | 53 | "}\n" |
andrewboyson | 0:22b158d3c76f | 54 | "\n" |
andrewboyson | 0:22b158d3c76f | 55 | "Ajax.server = '/program-ajax';\n" |
andrewboyson | 0:22b158d3c76f | 56 | "Ajax.onResponse = function() { parse(); display(); };\n" |
andrewboyson | 0:22b158d3c76f | 57 | "Ajax.init();\n" |
andrewboyson | 0:22b158d3c76f | 58 | "" |