PowerUp


Repository| Issues

The PowerUp uses Bluetooth LE to control your self-made paper airplane.

For more info about PowerUp click here.

How to Install

Install the module with:

$ npm install cylon cylon-powerup

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: {
    controller: { driver: 'dualshock-3', connection: 'joystick' },
    powerup: { driver: 'powerup' }
  },

  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();

How to Connect

The Powerup is a Bluetooth Low-Energy device, and is connected as with any other BLE device. For more info, check out the BLE platform page.