Beagle Board - beagleboard.org

BoneScript Library

BoneScript is a Node.js library specifically optimized for the Beagle family and featuring familiar Arduino function calls, exported to the browser. Get started exploring the BoneScript Library to discover the great simplicity that is made possible by utilizing Linux.

References

Web-based learning

Books

Functions

The BoneScript library provides several functions useful for interacting with your hardware. Browse the menu to the left for examples to get you started.

JavaScript

Performing physical computing tasks in JavaScript is a rather different than C on microcontrollers. JavaScript and the Node.JS interpreter like to do everything asynchronously using callbacks. An event loop runs waiting on whatever the next system-blocking event is, such as waiting for a keypress or a file load to complete. The callbacks are then executed to completion before other event handlers are run.

Timers

Timing operations in JavaScript are provided by setting timers with callback event handlers. A nice overview of JavaScript timers can be found on www.w3schools.com.

  • var timer = setTimeout(callback, milliseconds)
  • clearTimeout(timer)
  • var timer = setInterval(callback, milliseconds)
  • clearInterval(timer)

Libraries

The BoneScript Library runs in Node.JS. You can run it directly on the board using the 'node' interpreter or the Cloud9 IDE that invokes the 'node' interpreter. You can also run it using the bonescript.js script within your browser via remote procedure calls using Socket.io and served up by the web server running on your Beagle.

Access to the library functions is provided through the "require('bonescript')" function call. The call returns an object containing all of the functions and constants exported by the library. The Node.JS API documentation on modules provides more information on the usage of 'require' within the 'node' interpreter.

Other JavaScript topics

The Chrome browser has a rather nice JavaScript debugger you can use to examine your code. You might also get good benefit out of 'console.log()'.

Because JavaScript is dynamically typed, you might find the 'typeof operator' rather useful to determine the type of a variable at run-time. A nice overview of the JavaScript typeof operator can be found at developer.mozilla.org.

Resources

To learn more about Cloud9 IDE and to synchronize the software on your board with cloud-hosted services, see www.c9.io.

For more information on Node.JS, the JavaScript interpreter, see www.nodejs.org. You can find the api documentation at nodejs.org/docs/v0.6.10/api.

The source code for BoneScript is hosted at github.com/jadonk/bonescript.


Last updated by jkridner.wordpress.com on Tue May 23 2017 12:12:57 GMT-0000 (UTC).
229029