SmartRemote door E9

Dependencies:   EthernetInterface HTTPServer RemoteIR SDFileSystem mbed-rpc mbed-rtos mbed

Fork of SmartRemote by Sam Kirsch

Committer:
sammacjunkie
Date:
Wed Dec 04 17:44:29 2013 +0000
Revision:
16:2d23297857bc
MY HANDS ARE TYPING WORDS!; ; -also we fixed the transmit function from database; -in SupportingFiles folder is the HTML file and its javascript library for the webserver side

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sammacjunkie 16:2d23297857bc 1 <html>
sammacjunkie 16:2d23297857bc 2 <head>
sammacjunkie 16:2d23297857bc 3 <title>Smart Remote</title>
sammacjunkie 16:2d23297857bc 4 <script src="mbedRPC.js" type="text/javascript" language="javascript"></script>
sammacjunkie 16:2d23297857bc 5 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
sammacjunkie 16:2d23297857bc 6 <script type="text/javascript">
sammacjunkie 16:2d23297857bc 7 mbed = new HTTPRPC();
sammacjunkie 16:2d23297857bc 8
sammacjunkie 16:2d23297857bc 9 RPCRequest = new RPCVariable(mbed, "Request");
sammacjunkie 16:2d23297857bc 10 RPCLearn = new RPCVariable(mbed, "Learn");
sammacjunkie 16:2d23297857bc 11 RPCName0 = new RPCVariable(mbed, "Learn_name0");
sammacjunkie 16:2d23297857bc 12 RPCName1 = new RPCVariable(mbed, "Learn_name1");
sammacjunkie 16:2d23297857bc 13 RPCName2 = new RPCVariable(mbed, "Learn_name2");
sammacjunkie 16:2d23297857bc 14 RPCName3 = new RPCVariable(mbed, "Learn_name3");
sammacjunkie 16:2d23297857bc 15 RPCName4 = new RPCVariable(mbed, "Learn_name4");
sammacjunkie 16:2d23297857bc 16 RPCName5 = new RPCVariable(mbed, "Learn_name5");
sammacjunkie 16:2d23297857bc 17 RPCName6 = new RPCVariable(mbed, "Learn_name6");
sammacjunkie 16:2d23297857bc 18 RPCName7 = new RPCVariable(mbed, "Learn_name7");
sammacjunkie 16:2d23297857bc 19 RPCName8 = new RPCVariable(mbed, "Learn_name8");
sammacjunkie 16:2d23297857bc 20 RPCName9 = new RPCVariable(mbed, "Learn_name9");
sammacjunkie 16:2d23297857bc 21
sammacjunkie 16:2d23297857bc 22 function send_id(clicked_id)
sammacjunkie 16:2d23297857bc 23 {
sammacjunkie 16:2d23297857bc 24 RPCRequest.write(clicked_id);
sammacjunkie 16:2d23297857bc 25 }
sammacjunkie 16:2d23297857bc 26
sammacjunkie 16:2d23297857bc 27 function learner()
sammacjunkie 16:2d23297857bc 28 {
sammacjunkie 16:2d23297857bc 29 RPCLearn.write(1);
sammacjunkie 16:2d23297857bc 30 a = document.getElementById("button_name").value;
sammacjunkie 16:2d23297857bc 31 if( a.length > 10) { alert("Button name cannot exceed 10 characters!"); document.getElementById("button_name").value = "";}
sammacjunkie 16:2d23297857bc 32 a = a.split('');
sammacjunkie 16:2d23297857bc 33 for (i = 0; i < 10; i++) {
sammacjunkie 16:2d23297857bc 34 if (a[i] == undefined)
sammacjunkie 16:2d23297857bc 35 a[i] = '~';
sammacjunkie 16:2d23297857bc 36 }
sammacjunkie 16:2d23297857bc 37 for (i = 0; i < 10; i++) {
sammacjunkie 16:2d23297857bc 38 var x = eval("RPCName" + i);
sammacjunkie 16:2d23297857bc 39 x.write(a[i]);
sammacjunkie 16:2d23297857bc 40 }
sammacjunkie 16:2d23297857bc 41 }
sammacjunkie 16:2d23297857bc 42 </script>
sammacjunkie 16:2d23297857bc 43 <script>
sammacjunkie 16:2d23297857bc 44 $.get('/sd/SmartRemote/db.txt', function(data) {
sammacjunkie 16:2d23297857bc 45 //$('#text').append(data);
sammacjunkie 16:2d23297857bc 46 data = data.split("\n");
sammacjunkie 16:2d23297857bc 47 for (d in data) {
sammacjunkie 16:2d23297857bc 48 if(d%5 == 1) // Grab all the button names (every third entry)
sammacjunkie 16:2d23297857bc 49 $('#text').append("<button id="+data[d-1]+" onClick=\"send_id(this.id)\">" + data[d] + "</button>"); //set id's
sammacjunkie 16:2d23297857bc 50 }
sammacjunkie 16:2d23297857bc 51 });
sammacjunkie 16:2d23297857bc 52 </script>
sammacjunkie 16:2d23297857bc 53 </head>
sammacjunkie 16:2d23297857bc 54 <body>
sammacjunkie 16:2d23297857bc 55 <button id="learn" onClick="learner()">Learn</button><input type="text" id="button_name" />
sammacjunkie 16:2d23297857bc 56 <div id="text"></div>
sammacjunkie 16:2d23297857bc 57
sammacjunkie 16:2d23297857bc 58 </body>
sammacjunkie 16:2d23297857bc 59 </html>