New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

movehub

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

movehub

Interface to the Lego Boost Move Hub

latest
Source
npmnpm
Version
0.4.1
Version published
Weekly downloads
6
-80%
Maintainers
1
Weekly downloads
 
Created
Source

movehub

NPM version dependencies Status Build Status XO code style License

Node.js interface for the Lego Boost Move Hub 🤖 🐱 🎸 🚚

Install

$ npm install movehub

If you want to utilize the new async/await syntax see https://github.com/ttu/node-movehub-async which is based on this module.

Usage example

See test.js.

API

Classes

Boost
Hub

Boost

Kind: global class

boost.connect(address, callback)

Kind: instance method of Boost

ParamTypeDescription
addressstringMAC Address of the Hub
callbackconnectCallback

"ble-ready" (bleReady)

Kind: event emitted by Boost

ParamTypeDescription
bleReadybooleanreports true/false when BLE is active

"hub-found" (hub)

Fires when a Move Hub is found

Kind: event emitted by Boost

ParamType
hubobject
hub.uuidstring
hub.addressstring
hub.localNamestring

boost.connectCallback : function

Kind: instance typedef of Boost

ParamTypeDescription
errornull | error
hubHubinstance of the Hub Class

Hub

Kind: global class

hub.disconnect()

Disconnect from Move Hub

Kind: instance method of Hub

hub.motorTime(port, seconds, [dutyCycle], [callback])

Run a motor for specific time

Kind: instance method of Hub

ParamTypeDefaultDescription
portstring | numberpossible string values: A, B, AB, C, D.
secondsnumber
[dutyCycle]number100motor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
[callback]function

hub.motorTimeMulti(seconds, dutyCycleA, dutyCycleB, callback)

Run both motors (A and B) for specific time

Kind: instance method of Hub

ParamTypeDescription
secondsnumber
dutyCycleAnumbermotor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
dutyCycleBnumbermotor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
callbackfunction

hub.motorAngle(port, angle, [dutyCycle], [callback])

Turn a motor by specific angle

Kind: instance method of Hub

ParamTypeDefaultDescription
portstring | numberpossible string values: A, B, AB, C, D.
anglenumberdegrees to turn from 0 to 2147483647
[dutyCycle]number100motor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
[callback]function

hub.motorAngleMulti(angle, dutyCycleA, dutyCycleB, callback)

Turn both motors (A and B) by specific angle

Kind: instance method of Hub

ParamTypeDescription
anglenumberdegrees to turn from 0 to 2147483647
dutyCycleAnumbermotor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
dutyCycleBnumbermotor power percentage from -100 to 100. If a negative value is given rotation is counterclockwise.
callbackfunction

hub.led(color, [callback])

Control the LED on the Move Hub

Kind: instance method of Hub

ParamTypeDescription
colorboolean | number | stringIf 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

hub.subscribe(port, [option], [callback])

Subscribe for sensor notifications

Kind: instance method of Hub

ParamTypeDefaultDescription
portstring | numbere.g. call .subscribe('C') if you have your distance/color sensor on port C.
[option]number0Unknown meaning. Needs to be 0 for distance/color, 2 for motors, 8 for tilt
[callback]function

hub.unsubscribe(port, [option], [callback])

Unsubscribe from sensor notifications

Kind: instance method of Hub

ParamTypeDefaultDescription
portstring | number
[option]number0Unknown meaning. Needs to be 0 for distance/color, 2 for motors, 8 for tilt
[callback]function

hub.write(data, callback)

Send data over BLE

Kind: instance method of Hub

ParamTypeDescription
datastring | BufferIf a string is given it has to have hex bytes separated by spaces, e.g. 0a 01 c3 b2
callbackfunction

"rssi" (rssi)

Kind: event emitted by Hub

ParamType
rssinumber

"disconnect"

Kind: event emitted by Hub

"connect"

Fires when a connection to the Move Hub is established

Kind: event emitted by Hub

"port" (port)

Fires on port changes

Kind: event emitted by Hub

ParamType
portobject
port.portstring
port.actionstring

"color" (color)

Kind: event emitted by Hub

ParamType
colorstring

"distance" (distance)

Kind: event emitted by Hub

ParamTypeDescription
distancenumberdistance in millimeters

"tilt" (tilt)

Kind: event emitted by Hub

ParamType
tiltobject
tilt.rollnumber
tilt.pitchnumber

"rotation" (rotation)

Kind: event emitted by Hub

ParamType
rotationobject
rotation.portstring
rotation.angle

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

Keywords

Lego

FAQs

Package last updated on 23 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts