1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4 <hopobject id="2471" name="BoneScript" prototype="Page" created="1366427239709" lastModified="1386722178681">
5 <hop:parent idref="121" prototyperef="Page"/>
6 <is_xhtml type="boolean">true</is_xhtml>
7 <http_remotehost>68.43.104.104</http_remotehost>
8 <http_language>en-US,en;q=0.8</http_language>
10 <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36</http_browser>
11 <time type="date">10.12.2013 18:36:18 CST</time>
12 <hopsession>68.43.104.occnfohvio7s</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
15 <div id='side-menu' class="t3_sidebar">
\r
16 <ul class="left-menu"><strong>Navigation</strong>
\r
17 <li><a href="/Support/BoneScript/menu/">Menu contents</a></li>
\r
20 <div class="t3_content_1"><div id='connect-status'></div><div id="content_child">
\r
21 <h1>BoneScript Library</h1>
\r
22 <p>BoneScript is a <a href="http://nodejs.org" class="External">Node.js</a> library specifically
\r
23 optimized for the Beagle family
\r
24 and featuring familiar Arduino function calls, exported to the browser. Get
\r
25 started exploring the BoneScript Library to discover the great simplicity
\r
26 that is made possible by utilizing Linux.</p>
\r
27 <h2>References</h2>
\r
28 <h3>Web-based learning</h3>
\r
30 <li><a href="http://www.nodejs.org/docs/v0.8.22/api/" class="external">Node.JS API reference</a></li>
\r
31 <li><a href="http://www.w3schools.com/js/default.asp" class="external">W3Schools JavaScript tutorial</a></li>
\r
32 <li><a href="http://khanacademy.org/cs/programming" class="external">Khan Academy</a></li>
\r
34 <h3>Books</h3>
\r
36 <li><a href="/bad-to-the-bone">Bad to the Bone: Crafting Electronics Systems
\r
37 with BeagleBone and BeagleBone Black</a> (<a
\r
38 href="http://www.amazon.com/dp/1627051376/?tag=bloghanerhead-20" Class="external">Amazon</a>)</li>
\r
39 <li><a href="http://www.amazon.com/dp/1449345379/?tag=bloghanerhead-20"
\r
40 Class="external">Getting Started with BeagleBone</a></li>
\r
41 <li><a href="http://www.amazon.com/dp/1449398588/?tag=bloghanerhead-20"
\r
42 Class="external">Node: Up and Running</a></li>
\r
45 <h2 id="functions">Functions</h2>
\r
46 <p>The BoneScript library provides several functions useful for interacting
\r
47 with your hardware. Browse the menu to the left for examples to get you
\r
50 <h2 id="javascript">JavaScript</h2>
\r
51 <p>Performing physical computing tasks in JavaScript is a rather different than
\r
52 C on microcontrollers. JavaScript and the
\r
53 Node.JS interpreter like to do everything asynchronously using callbacks.
\r
54 An event loop runs waiting on whatever the next
\r
55 system-blocking event is, such as waiting for a keypress or a file
\r
56 load to complete. The callbacks are then executed
\r
57 to completion before other event handlers are run.
\r
59 <h3 id="timers">Timers</h3>
\r
60 <p>Timing operations in JavaScript are provided by setting timers with
\r
61 callback event handlers. A nice overview of
\r
62 JavaScript timers can be found on <a
\r
63 href="http://www.w3schools.com/js/js_timing.asp" target="_blank"
\r
64 class="external">www.w3schools.com</a>.</p>
\r
66 <li>var timer = setTimeout(callback, milliseconds)</li>
\r
67 <li>clearTimeout(timer)</li>
\r
68 <li>var timer = setInterval(callback, milliseconds)</li>
\r
69 <li>clearInterval(timer)</li>
\r
71 <h3 id="libraries">Libraries</h3>
\r
72 <p>The BoneScript Library runs in Node.JS. You can run it
\r
73 directly on the board using the 'node' interpreter or the Cloud9 IDE that
\r
74 invokes the 'node' interpreter. You can
\r
75 also run it using the <a href="/bonescript.js">bonescript.js</a> script
\r
76 within your browser via remote procedure calls
\r
77 using Socket.io and served up by the web server running on your Beagle.</p>
\r
78 <p id="require">Access to the library functions is provided through the
\r
79 "require('bonescript')" function call. The
\r
80 call returns an object containing all of the functions and constants
\r
81 exported by the library. The Node.JS API documentation
\r
82 on <a href="http://www.nodejs.org/docs/v0.8.22/api/modules.html"
\r
83 target="_blank" class="External">modules</a> provides more information on the usage
\r
84 of 'require' within the 'node' interpreter.</p>
\r
85 <h3>Other JavaScript topics</h3>
\r
86 <p id="console">The Chrome browser has a rather nice JavaScript debugger you
\r
87 can use to examine your code. You might
\r
88 also get good benefit out of 'console.log()'.</p>
\r
89 <p id="typeof">Because JavaScript is dynamically typed, you might find the
\r
90 'typeof operator' rather useful to determine
\r
91 the type of a variable at run-time. A nice overview of the JavaScript typeof
\r
92 operator can be found at
\r
93 <a target="_blank"
\r
94 href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/typeof"
\r
95 class="external">
\r
96 developer.mozilla.org</a>.</p>
\r
99 <h3>Resources</h3>
\r
100 <a id="console"></a>
\r
101 <a id="typeof"></a>
\r
102 <p>To learn more about Cloud9 IDE and to synchronize the software on your board
\r
103 with cloud-hosted services, see
\r
104 <a target="_blank" href="http://c9.io">www.c9.io</a>.</p>
\r
105 <p>For more information on Node.JS, the JavaScript interpreter, see <a
\r
106 target="_blank" href="http://nodejs.org" class="external">www.nodejs.org</a>.
\r
107 You can find the api documentation
\r
108 at <a target="_blank" href="http://nodejs.org/docs/v0.8.22/api"
\r
109 class="external">www.nodejs.org/docs/v0.8.22/api</a>.
\r
111 <p>The source code for BoneScript is hosted at
\r
112 <a href="https://github.com/jadonk/bonescript">Github.com/jadonk/bonescript</a>.</p>
\r
114 </div></div><div style="clear: both;"></div></body>
115 <pseudoparent idref="121" prototyperef="Page"/>
116 <http_referer>http://beagleboard.org/support/BoneScript/edit</http_referer>
117 <http_host>beagleboard.org</http_host>
118 <user>jkridner@gmail.com</user>
120 <hop:child idref="2477" prototyperef="Page"/>
121 <hop:child idref="2478" prototyperef="Page"/>
122 <hop:child idref="2479" prototyperef="Page"/>
123 <hop:child idref="2563" prototyperef="Page"/>
124 <hop:child idref="2564" prototyperef="Page"/>
125 <hop:child idref="2607" prototyperef="Page"/>
126 <hop:child idref="2640" prototyperef="Page"/>
127 <hop:child idref="2737" prototyperef="Page"/>
128 <hop:child idref="2738" prototyperef="Page"/>
129 <hop:child idref="2768" prototyperef="Page"/>
130 <hop:child idref="2769" prototyperef="Page"/>
131 <hop:child idref="2779" prototyperef="Page"/>
132 <hop:child idref="2780" prototyperef="Page"/>
133 <hop:child idref="2781" prototyperef="Page"/>
134 <hop:child idref="2782" prototyperef="Page"/>
135 <hop:child idref="2783" prototyperef="Page"/>
136 <hop:child idref="2784" prototyperef="Page"/>
137 <hop:child idref="2785" prototyperef="Page"/>
138 <hop:child idref="2798" prototyperef="Page"/>
139 <hop:child idref="2805" prototyperef="Page"/>
140 <hop:child idref="2806" prototyperef="Page"/>
141 <hop:child idref="2808" prototyperef="Page"/>
142 <hop:child idref="2809" prototyperef="Page"/>
143 <hop:child idref="2814" prototyperef="Page"/>
144 <hop:child idref="2819" prototyperef="Page"/>
145 <hop:child idref="2825" prototyperef="Page"/>
146 <hop:child idref="2836" prototyperef="Page"/>
147 <hop:child idref="2891" prototyperef="Page"/>
148 <hop:child idref="2892" prototyperef="Page"/>
149 <hop:child idref="2894" prototyperef="Page"/>
150 <hop:child idref="2993" prototyperef="Page"/>
151 <hop:child idref="2994" prototyperef="Page"/>
152 <hop:child idref="2995" prototyperef="Page"/>
153 <hop:child idref="3004" prototyperef="Page"/>
154 <hop:child idref="3016" prototyperef="Page"/>
155 <hop:child idref="3176" prototyperef="Page"/>
156 <hop:child idref="3277" prototyperef="Page"/>