annotate service/garageArduino/index.html @ 1141:34fa399dc5c9

docker and makefile for arduinoNode Ignore-this: bdff7ca263b699f7829da324807a557 darcs-hash:e5ad82fef1f11b07fcb3d6d73bd5d3c8863308d5
author drewp <drewp@bigasterisk.com>
date Sat, 03 Mar 2018 18:01:02 -0800
parents e7532dfa1a39
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
1 <?xml version="1.0" encoding="iso-8859-1"?>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
4 <html xmlns="http://www.w3.org/1999/xhtml">
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 <head>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 <title>garageArduino</title>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
7 <link rel="alternate" type="application/x-trig" title="RDF graph" href="graph" />
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
8 <style type="text/css" media="all">
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
9 /* <![CDATA[ */
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
10 .val {
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
11 font-weight: bold;
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12 }
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
13 .colorpicker {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
14 display: inline-block;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
15 }
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
16 /* ]]> */
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
17 </style>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
18 </head>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
19 <body>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
20
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
21 <h1>garageArduino service</h1>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
22
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
23 <p>Talking to an arduino uno on host <tt>slash</tt></p>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
24
810
44e1ca03ddf1 move garage door opener from parport to arduino
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
25 <p>Pulse pin 3 to trigger garage door opener <form method="post" action="garageDoorOpen"><input type="submit" value="Garage door opener"/></form></p>
44e1ca03ddf1 move garage door opener from parport to arduino
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
26
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
27 <p><a href="http://octopart.com/555-28027-parallax-708653">PIR sensor</a> (in <a href="http://octopart.com/1551ggy-hammond-15686">a box</a>) measuring front door motion: <span class="val" id="frontDoorMotion"/></p>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
28
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
29 <p><a href="http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&amp;productId=2006414&amp;catalogId=10001&amp;freeText=2006414&amp;app.products.maxperpage=15&amp;storeId=10001&amp;search_type=jamecoall&amp;ddkey=http:StoreCatalogDrillDownView">phototransistor</a> watching IR pulses on the power meter: last pulse was <span class="val" id="lastPulseAgo"/>; current power usage is <span class="val"><span id="currentWatts"/> watts</span> (assuming <span class="val" id="kwhPerBlink"/> kwh/blink)</p>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
30
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
31 <p>Recent raw IR sensor data: <div><img src="" id="raw"/></div></p>
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
32
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
33 <p><button type="submit" id="refresh">refresh</button></p>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
34
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
35 <p>Bathroom LEDs</p>
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
36 <div><input id="lockColor" type="checkbox"/> Send first color to all LEDs</div>
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
37 <div class="colorpicker" id="p0"></div>
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
38 <div class="colorpicker" id="p1"></div>
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
39 <div class="colorpicker" id="p2"></div>
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
40 <div class="colorpicker" id="p3"></div>
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
41
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
42 <script type="text/javascript" src="//bigasterisk.com/lib/jquery-2.0.3.min.js"/>
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
43 <script type="text/javascript" src="//bigasterisk.com/lib/farbtastic-1.2/farbtastic.js"></script>
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
44 <link rel="stylesheet" href="//bigasterisk.com/lib/farbtastic-1.2/farbtastic.css" type="text/css" />
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
45
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
46 <script type="text/javascript">
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
47 // <![CDATA[
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
48 $(function () {
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
49 function setTexts(data) {
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
50 $.each(data, function (k,v) { $("#"+k).text(v); })
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
51 }
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
52 function refresh() {
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
53 $.getJSON("frontDoorMotion", setTexts);
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
54 $.getJSON("housePower", setTexts);
809
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
55
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
56 $.getJSON("housePower/raw", function (data) {
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
57 var xp=[], yp=[];
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
58 var start = data.irLevels[0][0];
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
59 var maxTime = 0;
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
60 $.each(data.irLevels, function (i, xy) {
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
61 maxTime = xy[0] - start;
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
62 xp.push(maxTime.toPrecision(3));
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
63 yp.push(xy[1]);
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
64 });
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
65 // edit with http://imagecharteditor.appspot.com/
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
66 $("#raw").attr("src",
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
67 "http://chart.apis.google.com/chart"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
68 "?chxr=0,0,"+maxTime+"|1,0,1024"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
69 "&chds=0,"+maxTime+",0,1024"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
70 "&chxl=2:|seconds"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
71 "&chxs=0,676767,11.5,0,lt,676767|1,676767,11.5,-0.5,l,676767"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
72 "&chxt=x,y,x"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
73 "&chs=600x200"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
74 "&cht=lxy"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
75 "&chco=76A4FB"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
76 "&chd=t:"+xp.join(",")+"|"+yp.join(",")+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
77 "&chg=10,20"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
78 "&chls=2"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
79 "&chma=40,20,20,30"+
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
80 "&chm=h,FF0000,0,0.7:50:2,1");
bebb8f7c5a3e move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents: 805
diff changeset
81 });
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
82 }
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
83 refresh();
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
84 $("#refresh").click(refresh);
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
85
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
86 var inProgress = false;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
87 var pending = {}; // url : data
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
88 function sendColor(url, newColor) {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
89 inProgress = 1;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
90 $.ajax({
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
91 type: "put", url: url,
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
92 contentType: "text/plain", data: newColor,
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
93 success: function () {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
94 inProgress = false;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
95 $.each(pending, function (u, n) {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
96 delete pending[u];
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
97 sendColor(u, n);
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
98 });
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
99 }
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
100 });
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
101 }
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
102 function copyColor(newColor) {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
103 $.farbtastic("#p1").setColor(newColor);
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
104 $.farbtastic("#p2").setColor(newColor);
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
105 $.farbtastic("#p3").setColor(newColor);
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
106 }
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
107 $("#lockColor").click(function () { copyColor($.farbtastic("#p0").color); });
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
108 $.each([
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
109 ["#p0", "brite/0"],
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
110 ["#p1", "brite/1"],
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
111 ["#p2", "brite/2"],
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
112 ["#p3", "brite/3"],
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
113 ], function (i, row) {
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
114 var picker = $.farbtastic(row[0], function (newColor) {
929
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
115 if (row[1] == "brite/0" && $("#lockColor")[0].checked) {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
116 copyColor(newColor);
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
117 }
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
118 if (inProgress) {
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
119 pending[row[1]] = newColor;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
120 return;
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
121 }
e7532dfa1a39 fix up garagearduino web ui color pickers
drewp <drewp@bigasterisk.com>
parents: 839
diff changeset
122 sendColor(row[1], newColor);
839
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
123 });
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
124 $.get(row[1], picker.setColor);
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
125 });
9cf01cee74f6 garage: videoselect and shiftbrite move from parallel to arduino
drewp <drewp@bigasterisk.com>
parents: 810
diff changeset
126
805
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
127 });
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
128 // ]]>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
129 </script>
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
130 </body>
810
44e1ca03ddf1 move garage door opener from parport to arduino
drewp <drewp@bigasterisk.com>
parents: 809
diff changeset
131 </html>