Mercurial > code > home > repos > homeauto
view service/garageArduino/index.html @ 390:e220d5c875b3
rm some very old code
Ignore-this: f0ba6a8f4ff090a561a51e7f9be0931c
author | drewp@bigasterisk.com |
---|---|
date | Mon, 14 Jan 2019 22:40:23 -0800 |
parents | a442bc778862 |
children |
line wrap: on
line source
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>garageArduino</title> <link rel="alternate" type="application/x-trig" title="RDF graph" href="graph" /> <style type="text/css" media="all"> /* <![CDATA[ */ .val { font-weight: bold; } .colorpicker { display: inline-block; } /* ]]> */ </style> </head> <body> <h1>garageArduino service</h1> <p>Talking to an arduino uno on host <tt>slash</tt></p> <p>Pulse pin 3 to trigger garage door opener <form method="post" action="garageDoorOpen"><input type="submit" value="Garage door opener"/></form></p> <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> <p><a href="http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&productId=2006414&catalogId=10001&freeText=2006414&app.products.maxperpage=15&storeId=10001&search_type=jamecoall&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> <p>Recent raw IR sensor data: <div><img src="" id="raw"/></div></p> <p><button type="submit" id="refresh">refresh</button></p> <p>Bathroom LEDs</p> <div><input id="lockColor" type="checkbox"/> Send first color to all LEDs</div> <div class="colorpicker" id="p0"></div> <div class="colorpicker" id="p1"></div> <div class="colorpicker" id="p2"></div> <div class="colorpicker" id="p3"></div> <script type="text/javascript" src="//bigasterisk.com/lib/jquery-2.0.3.min.js"/> <script type="text/javascript" src="//bigasterisk.com/lib/farbtastic-1.2/farbtastic.js"></script> <link rel="stylesheet" href="//bigasterisk.com/lib/farbtastic-1.2/farbtastic.css" type="text/css" /> <script type="text/javascript"> // <![CDATA[ $(function () { function setTexts(data) { $.each(data, function (k,v) { $("#"+k).text(v); }) } function refresh() { $.getJSON("frontDoorMotion", setTexts); $.getJSON("housePower", setTexts); $.getJSON("housePower/raw", function (data) { var xp=[], yp=[]; var start = data.irLevels[0][0]; var maxTime = 0; $.each(data.irLevels, function (i, xy) { maxTime = xy[0] - start; xp.push(maxTime.toPrecision(3)); yp.push(xy[1]); }); // edit with http://imagecharteditor.appspot.com/ $("#raw").attr("src", "http://chart.apis.google.com/chart"+ "?chxr=0,0,"+maxTime+"|1,0,1024"+ "&chds=0,"+maxTime+",0,1024"+ "&chxl=2:|seconds"+ "&chxs=0,676767,11.5,0,lt,676767|1,676767,11.5,-0.5,l,676767"+ "&chxt=x,y,x"+ "&chs=600x200"+ "&cht=lxy"+ "&chco=76A4FB"+ "&chd=t:"+xp.join(",")+"|"+yp.join(",")+ "&chg=10,20"+ "&chls=2"+ "&chma=40,20,20,30"+ "&chm=h,FF0000,0,0.7:50:2,1"); }); } refresh(); $("#refresh").click(refresh); var inProgress = false; var pending = {}; // url : data function sendColor(url, newColor) { inProgress = 1; $.ajax({ type: "put", url: url, contentType: "text/plain", data: newColor, success: function () { inProgress = false; $.each(pending, function (u, n) { delete pending[u]; sendColor(u, n); }); } }); } function copyColor(newColor) { $.farbtastic("#p1").setColor(newColor); $.farbtastic("#p2").setColor(newColor); $.farbtastic("#p3").setColor(newColor); } $("#lockColor").click(function () { copyColor($.farbtastic("#p0").color); }); $.each([ ["#p0", "brite/0"], ["#p1", "brite/1"], ["#p2", "brite/2"], ["#p3", "brite/3"], ], function (i, row) { var picker = $.farbtastic(row[0], function (newColor) { if (row[1] == "brite/0" && $("#lockColor")[0].checked) { copyColor(newColor); } if (inProgress) { pending[row[1]] = newColor; return; } sendColor(row[1], newColor); }); $.get(row[1], picker.setColor); }); }); // ]]> </script> </body> </html>