PowerUp
This is the Cylon driver for the PowerUp Bluetooth LE paper airplane controller.
How To Connect
Cylon.robot({ connections: { bluetooth: { adaptor: 'ble', uuid: '84dd20eb3d89' }, joystick: { adaptor: 'joystick' } }, devices: { powerup: { driver: 'powerup', connection: 'bluetooth' }, controller: { driver: 'dualshock-3', connection: 'joystick' } } });
How To Use
Here's an example of flying the powerup with a dualshock3 controller
var Cylon = require('cylon'); Cylon.robot({ connections: { bluetooth: { adaptor: 'ble', uuid: '84dd20eb3d89' }, joystick: { adaptor: 'joystick' } }, devices: { powerup: { driver: 'powerup', connection: 'bluetooth' }, controller: { driver: 'dualshock-3', connection: 'joystick' } } work: function(my) { var thrust = 0; var rudder = 0; var canRudder = false; var cb = function(err) { if (!!err) { console.log(err); } else { if (canRudder) { canRudder = false; my.powerup.setRudder(rudder, cb); } else { my.powerup.setThrust(thrust, cb); } } } my.powerup.setThrust(thrust, cb); my.controller.on("left_y:move", function(data) { if (data < 0) { thrust = Math.abs(data/32768*254) | 0; } else { thrust = 0; } }); my.controller.on("right_x:move", function(data) { var tmp = data/32768*127 | 0; if (tmp !== rudder) { rudder = tmp; canRudder = true; } }); } }).start();
Commands
setThrust
Sets the thrust value of the Powerup
Params
-
value (
Number
) the new value for the Powerup's thrust -
callback (
Function
) to be triggered when the value is written
Returns
- (
undefined
)
setRudder
Sets the rudder value of the Powerup
Params
-
value (
Number
) the new value for the Powerup's rudder -
callback (
Function
) to be triggered when the value is written
Returns
- (
undefined
)