File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,7 +133,9 @@ var initClient = function() {
133133 'platform' : [ ] ,
134134 'shell' : [ 'command' ] ,
135135 'echo' : [ 'data' ] ,
136- 'addLoop' : [ 'loopFunc' , 'loopDelay' ]
136+ 'addLoop' : [ 'loopFunc' , 'loopDelay' ] ,
137+ 'getLoops' : [ ] ,
138+ 'removeLoop' : [ 'loopid' ]
137139 } ;
138140 for ( var x in myfuncs ) {
139141 socket . on ( x , function ( data ) {
@@ -143,6 +145,9 @@ var initClient = function() {
143145 var objString = '' ;
144146 for ( var y in myargs ) {
145147 if ( isNaN ( y ) ) continue ; // Need to find the source of this bug
148+ objString += ' if(typeof ' + myargs [ y ] + ' == "function") {\n' ;
149+ objString += ' ' + myargs [ y ] + ' = ' + myargs [ y ] + '.toString();\n' ;
150+ objString += ' }\n' ;
146151 objString += ' calldata.' + myargs [ y ] + ' = ' + myargs [ y ] + ';\n' ;
147152 }
148153 myargs . push ( 'callback' ) ;
Original file line number Diff line number Diff line change 1+ require ( 'bonescript' ) ;
2+
3+ ledPin = bone . USR3 ;
4+ outputPin = bone . P8_3 ;
5+
6+ setup = function ( ) {
7+ console . log ( "Running setup" ) ;
8+ pinMode ( ledPin , OUTPUT ) ;
9+ pinMode ( outputPin , OUTPUT ) ;
10+ digitalWrite ( ledPin , LOW ) ;
11+ digitalWrite ( outputPin , LOW ) ;
12+ console . log ( "getLoops() = " + JSON . stringify ( getLoops ( ) ) ) ;
13+
14+ // Start toggling after 5 seconds
15+ setTimeout ( function ( ) {
16+ console . log ( "Flashing LED for 5 seconds" ) ;
17+ loopid = addLoop ( function ( ) {
18+ digitalWrite ( ledPin , HIGH ) ;
19+ digitalWrite ( outputPin , HIGH ) ;
20+ delay ( 100 ) ;
21+ digitalWrite ( ledPin , LOW ) ;
22+ digitalWrite ( outputPin , LOW ) ;
23+ } , 150 ) ;
24+ console . log ( "loopid = " + loopid ) ;
25+ console . log ( "getLoops() = " + JSON . stringify ( getLoops ( ) ) ) ;
26+
27+ // Stop toggling after 5 seconds
28+ setTimeout ( function ( ) {
29+ removeLoop ( loopid )
30+ console . log ( "Halting flashing of LED" ) ;
31+ } , 5000 ) ;
32+ } , 5000 ) ;
33+ } ;
34+
35+ run ( setup ) ;
You can’t perform that action at this time.
0 commit comments