With The New Cylon.js 0.19.0, You Can Be Fluent Too
Update: - we've updated the examples to use the newer version of the fluent syntax.
We've just finished cutting Cylon.js 0.19.0
, another big step forward leading to our 1.0.0
release.
There are a number of exciting, yet potentially-breaking interface changes; particularly for module developers.
But don't fear!
We're here to let you know what these changes are and what else is new.
For Application Developers
-
Fluent syntax - Useful to those familiar with jQuery or similar frameworks. You can choose which syntax you prefer based on your specific application scenario, either the new fluent style, or the current declarative style. Here is an example of a Arduino-based robot, written in the fluent syntax:
var Cylon = require('cylon'); Cylon .robot() .connection('arduino', { adaptor: 'firmata', port: '/dev/ttyACM0' }) .device('led', { driver: 'led', pin: 13 }) .device('button', { driver: 'button', pin: 2 }) .on('error', console.log) .on('ready', function(bot) { bot.button.on('push', function() { bot.led.toggle(); }); }); Cylon.start();
This is how the same example looks with the current declarative syntax:
var Cylon = require('cylon'); Cylon.robot({ connections: { arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' } }, devices: [ { name: 'led', driver: 'led', pin: 13 }, { name: 'button', driver: 'button', pin: 2 } ], work: function(bot) { bot.button.on('push', function() { bot.led.toggle(); }); }, error: function(err) { console.log(err); } }).start();
See what we mean? You can now choose the best syntax for your preferred style of code. Have it your way!
-
Configuration with
Cylon#configure(obj)
. This method takes an object as an argument, and merges it with Cylon's interal configuration. It then returns the current configuration. -
API configuration has been moved to the
Cylon#configure
block.Cylon#api()
will now start an API instance with the current configuration. -
Auto-start mode - Cylon can now automatically start robots for you, as soon as they're instantiated. To enable this behaviour, enable it in the configuration -
Cylon.config({ mode: 'auto' })
. -
No more name collisions - Cylon will now automatically rename Devices, Connections, and Robots if they'd conflict with the name of an existing object.
-
Adjustable halt timeout - by default, Cylon will automatically hard-terminate if it can't gracefully shut down inside 3 seconds. This timeout is adjustable in config as
haltTimeout
in milliseconds.
For Platform Developers
-
Adaptor
#connect
/#disconnect
+ Driver#start
/#halt
methods now take a callback. The#halt
/#disconnect
methods must be implemented in Adaptor/Driver subclasses, and trigger the provided callback when they're done their own work. This is to help ensure Cylon can shut down efficiently and safely. -
Methods are automatically proxied from Adaptors -> Connections and Drivers -> Devices. You no longer have to manually provide an Adaptor commands array.
-
Driver
subclasses will now receive a default interval of 1000ms. This is adjustable by users in the device configuration hash. -
Direct Adaptor access inside Drivers - inside Driver subclasses, instances will now have direct access to the Adaptor they're communicating with under
this.adaptor
. -
For Test Driven Robotics (TDR) and inside the Robot class, testing mode is now triggered by
NODE_ENV
rather than a global variable.
More Hardware Support
Of course, no Cylon.js release would be complete without some new hardware platform updates, so we've added support for the Phillips Hue wireless lighting system with cylon-hue, as well as updating cylon-spark to use the new Spark.js library with the Spark Core wireless microcontroller.
We are really excited about this big update to Cylon.js, and we hope you are too. It is now just that much easier to create robots and connected devices.
For more updates, be sure to follow us on Twitter at @CylonJS.
Posts
- Cylon.js Off And Rolling In 2016
- Cylon.js 1.2.0 - Logging and Timing and BLE! Oh my!
- Cylon.js 1.1.0 - The Big Cleanup
- Hello, Node Bebop Drone
- Cylon.js featured in Wired
- Cylon.js 1.0.0 is here!
- Using Socket.io With The Cylon.js API
- Cylon 0.22.0 - A New Year's Release
- Cylon 0.21.0 is out!
- Creating Multiplatform Precompiled Binaries for Node.js Modules
- Cylon 0.20.0 is out!
- Running Robots From Your Browser With Cylon.js
- Winning the Dreamforce 500 With Cylon.js
- With The New Cylon.js 0.19.0, You Can Be Fluent Too
- Cylon.js on Intel Edison
- Cylon Takes Off on NodeBots Day
- Cylon.js Fun With The Arduino Yun
- Control Robots From Your Pebble
- Making Moves With Intel Galileo
- The Cylon Nest
- Announcing Full Tessel Support!
- Cylon 0.15.0 is Out!
- Cylon.js in Make Magazine!
- Cylon.js At JSConf 2014
- Cylon.js Takes The Stage At MakerFaire
- Cylon.js In Scotland
- Robots Are The New Normal At NextBerlin
- Thingscon - Ich Bin Ein Cylon
- National Robotics Week at the Robotics Society of Southern California
- Functional Robots With Wisp
- Release 0.12 Is For RobotOps
- Making Waves At Makerland
- This One Goes To 0.11 Of Pure JavaScript
- Tipping SCaLE12X
- Intro Robeaux- A Universal User Interface To Robotic Devices
- ng-robots! A Fun Robot Hackathon At The First ng-conf
- Number 9! The Release In Which We Add A Web UX, More Platforms, and Tools
- Release 0.8.0 Makes 10 Platforms
- RobotsConf Was Remarkable
- Dreamforce Means Connected Devices Are A Thing
- Dreamforce Is Coming!
- Welcome, Cylon.js