Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

oscon: WIP

  • Loading branch information...
commit fd05e6f6ead958d0ed6df68fefb8ea1b0d732efc 1 parent a61b6c7
@jadonk authored
View
4 bone101/client.js
@@ -29,7 +29,9 @@ var doAlert = function(m) {
};
var demoRun = function(id) {
- var myScript = document.getElementById(id).innerHTML
+ var myScript = document.getElementById(id).innerHTML;
+ myScript = myScript.replace("&lt;", "<");
+ myScript = myScript.replace("&gt;", ">");
eval(myScript);
};
View
24 bone101/index.html
@@ -265,20 +265,22 @@ <h2 style="margin-left: 1em;">Simplified Physical Computing with Node.JS</h2>
<h1>doEval</h1>
<h2>Run something remotely just once</h2>
<p>What if we want to invoke the previous example on the target, rather than the browser?</p>
- <p>Blink USR3 LED: <span class="dynlink" onclick="demoRun('doEval1')">run</span></p>
+ <p>Blink USR3 LED for 30 seconds: <span class="dynlink" onclick="demoRun('doEval1')">run</span></p>
<pre id="doEval1">
-doEval(function() {
- value = 0;
+doEval(function(callback) {
+ var value = 0;
pinMode(bone.USR3, 'out');
- interval = setInterval(function() {
- value = value ? 0 : 1;
- digitalWrite(bone.USR3, value);
+
+ var interval = setInterval(function() {
+ value = value ? 0 : 1;
+ digitalWrite(bone.USR3, value);
}, 100);
- return(interval);
+
+ setTimeout(function() {
+ clearInterval(interval);
+ callback({'notice':"Removing doEval demo interval function"});
+ }, 30000);
}, doAlert);</pre>
- <p>Halt function: <span class="dynlink" onclick="demoRun('doEval2')">run</span></p>
- <pre id="doEval2">
-doEval(function() { clearInterval(interval); };</pre>
</div>
<div class="slide">
@@ -354,7 +356,7 @@ <h2 style="margin-left: 1em;">Simplified Physical Computing with Node.JS</h2>
this.awValue = this.awValue + (this.awDirection*0.01);
if(this.awValue &gt; 1.0) { this.awValue = 1.0; this.awDirection = -1; }
else if(this.awValue &lt; 0.01) { this.awValue = 0.01; this.awDirection = 1; }
- }, 100, doAlert);</pre>
+ }, 10, doAlert);</pre>
<p>Halt all loops: <span class="dynlink" onclick="demoRun('analogWrite4')">
run</span></p>
<pre id="analogWrite4">
View
2  node_modules/bonescript/index.js
@@ -485,7 +485,7 @@ removeLoop = exports.removeLoop = function(loopId, callback) {
doEval = exports.doEval = function(evalFunc, callback) {
var evalFunc = (typeof evalFunc === "string") ? eval('(' + evalFunc + ')') : evalFunc;
- var value = evalFunc();
+ var value = evalFunc(callback);
if(callback) callback({'value':value});
return(value);
};
Please sign in to comment.
Something went wrong with that request. Please try again.