JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q44973F
  • License MIT

Interface to the Lego Boost Move Hub

Package Exports

  • movehub

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (movehub) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

movehub

NPM version Dependency Status Build Status XO code style License

Node.js interface for the Lego Boost Move Hub

WORK IN PROGRESS - UNFINISHED!

Install

$ npm install movehub

TODO

  • LED control
  • Motor control
  • Sound playback
  • Emit distance sensor events
  • Emit color sensor events
  • Emit rotation events
  • Emit tilt sensor events
  • Emit changed rssi values
  • Connect to multiple Move Hubs
  • Generate API Docs
  • Command wrappers behaving like the command blocks in the app (specific for "Franky the Cat", "Vernie the Robot" etc)

API

Boost

Kind: global class

boost.disconnect()

Disconnect from Move Hub

Kind: instance method of Boost

boost.motorTime(port, seconds, [dutycycle], [callback])

Run a motor for specific time

Kind: instance method of Boost

Param Type Default Description
port string | number possible string values: A, B, AB, C, D
seconds number
[dutycycle] number 100 motor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
[callback] function

boost.motorAngle(port, angle, [dutycycle], [callback])

Turn a motor to specific angle

Kind: instance method of Boost

Param Type Default Description
port string | number possible string values: A, B, AB, C, D
angle number degrees to turn from 0 to 4026531839
[dutycycle] number 100 motor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
[callback] function

boost.led(color, [callback])

Control the LED on the Move Hub

Kind: instance method of Boost

Param Type Description
color boolean | number | string If set to boolean false the LED is switched off, if set to true the LED will be white. Possible string values: off, pink, purple, blue, lightblue, cyan, green, yellow, orange, red, white
[callback] function

boost.subscribe(port, [callback])

Subscribe for sensor notifications

Kind: instance method of Boost

Param Type Description
port string | number e.g. call .subscribe('C') if you have your distance/color sensor on port C.
[callback] function

boost.unsubscribe(port, [callback])

Unsubscribe from sensor notifications

Kind: instance method of Boost

Param Type
port string | number
[callback] function

"scanning" (scanning)

Kind: event emitted by Boost

Param Type Description
scanning boolean reports true/false when noble starts/stops to scan for BLE devices

"hub-found" (hub)

Fires when a Move Hub is found

Kind: event emitted by Boost

Param Type
hub object
hub.uuid string
hub.address string
hub.localName string
hub.rssi number

"connect"

Fires when a connection to the Move Hub is established

Kind: event emitted by Boost

"color" (color)

Fires on color sensor changes (you have to subscribe the port of the sensor to receive these events).

Kind: event emitted by Boost

Param Type
color string

"distance" (distance)

Fires on distance sensor changes (you have to subscribe the port of the sensor to receive these events).

Kind: event emitted by Boost

Param Type Description
distance number distance in millimeters

"port" (port)

Fires on port changes

Kind: event emitted by Boost

Param Type
port object
port.port string
port.action string

"disconnect"

Kind: event emitted by Boost

Contributing

Pull Requests welcome! :-)

Credits

Thanks to Jorge Pereira who analyzed and documented the move hub ble protocol: https://github.com/JorgePe/BOOSTreveng

Disclaimer

LEGO and BOOST are Trademarks from The LEGO Company, which does not support (most probably doesn't even know about) this project. And of course I'm not responsible for any damage on your LEGO BOOST devices - use it at your own risk.

License

MIT (c) Sebastian Raff