{"id":17551037,"url":"https://github.com/ttu/node-movehub-async","last_synced_at":"2025-10-04T16:33:07.246Z","repository":{"id":57303286,"uuid":"124135198","full_name":"ttu/node-movehub-async","owner":"ttu","description":"Simple to use asynchronous methods for the Lego Boost Move Hub","archived":false,"fork":false,"pushed_at":"2018-12-26T22:09:58.000Z","size":78,"stargazers_count":16,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T19:48:25.700Z","etag":null,"topics":["async","boost","hub","lego","lego-boost","move","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-06T20:35:28.000Z","updated_at":"2023-12-07T06:25:22.000Z","dependencies_parsed_at":"2022-09-17T10:10:59.455Z","dependency_job_id":null,"html_url":"https://github.com/ttu/node-movehub-async","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttu%2Fnode-movehub-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttu%2Fnode-movehub-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttu%2Fnode-movehub-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttu%2Fnode-movehub-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttu","download_url":"https://codeload.github.com/ttu/node-movehub-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546363,"owners_count":21448313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","boost","hub","lego","lego-boost","move","nodejs"],"created_at":"2024-10-21T04:44:41.557Z","updated_at":"2025-10-04T16:33:07.133Z","avatar_url":"https://github.com/ttu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# movehub async\n\n[![npm version](https://badge.fury.io/js/movehub-async.svg)](https://badge.fury.io/js/movehub-async)\n\nSimple to use asynchronous methods for the [Move Hub](https://github.com/hobbyquaker/node-movehub)\n\n_Move Hub is central controller block of [LEGO® Boost Robotics Set](https://www.lego.com/en-us/boost)._\n\n## Setup\n\n* Install [Noble prerequisites](https://github.com/noble/noble#prerequisites)\n\n* Install movehub-async\n\n```sh\n$ npm install movehub-async\n```\n\n## Usage\n\n```js\nconst boost = require('movehub-async');\n\nconst hub = await boost.getHubAsync();\n\n// Turn light from red to green\nawait hub.ledAsync('red');\nawait hub.ledAsync('yellow');\nawait hub.ledAsync('green');\n\n// Turn A \u0026 B motors for 10 seconds with power 20\nawait hub.motorTimeMultiAsync(10, 20, 20);\n// Turn motor C 600 degrees with power 5\nawait hub.motorAngleAsync('C', 600, 5);\n```\n\nIt is also possible to wait that motor execution has stopped\n\n```js\nawait hub.ledAsync('red');\n// Continue when led is red\nawait hub.motorTimeMultiAsync(10, 20, 20, true);\n// Continue 10 sec later\nawait hub.motorTimeMultiAsync(5, 20, 20, true);\n// Continue 5 sec later\nawait hub.motorAngleAsync('C', 800, 50, true);\n// Continue some time later\nawait hub.ledAsync('green');\n// Continue when led is green\n```\n\nPackage contains also simple methods to drive for a specified distance and turn a specified angle. By default drive and turn methods will wait the execution has stopped.\n\n```js\n// Drive 2 meters forward\nawait hub.drive(200);\n// After 2 meter drive, turn 90 degrees to the right\nawait hub.turn(90);\n// Drive 1 meter backwards\nawait hub.drive(-100);\n// Turn 180 degrees to the left\nawait hub.turn(-180); \n```\n\n## API\n\nCheck complete non-async API definition from [Lego Boost Move Hub](https://github.com/hobbyquaker/node-movehub). Asynchronous version of the method has an _Async_-suffix in the name, e.g. `motorTimeMulti` -\u003e `motorTimeMultiAsync`.\n\n## Boost\n\n### boost.getHubAsync()\n\nCreate a connection to the Hub. Internally calls `bleReadyAsync`, `hubFoundAsync` and `connectAsync`.\n\n```js\nconst hub = await boost.getHubAsync();\n```\n\n### boost.bleReadyAsync()\n\nWait for BLE device to be ready.\n\n```js\nawait boost.bleReadyAsync();\n```\n\n### boost.hubFoundAsync()\n\nWait for MoveHub found event.\n\n```js\nconst connectDetails = await boost.hubFoundAsync();\n```\n\n### boost.connectAsync(connectDetails)\n\nInitialize and wait for the connection to the Hub.\n\n```js\nconst hub = await boost.connectAsync(connectDetails);\n```\n\n## Hub\n\n### hub.ledAsync(color)\n\nControl the LED on the Move Hub.\n\n```js\nawait hub.ledAsync('red');\n```\n\n### hub.motorTimeAsync(port, seconds, dutyCycle = 100, wait = false)\n\nRun a motor for specific time. Await returns when command is sent to Hub.\n\n```js\nawait hub.motorTimeAsync('C', 5, 50);\n// Continue almost immediately when command is sent to Hub\n\nawait hub.motorTimeAsync('C', 5, 50, true);\n// Continue 5 seconds later\n```\n\n### hub.motorTimeMultiAsync(seconds, dutyCycleA = 100, dutyCycleB = 100, wait = false)\n\nRun both motors (A and B) for specific time. Await returns when command is sent to Hub.\n\n```js\n// Drive forward for 10 seconds\nawait hub.motorTimeMultiAsync(10, 20, 20, true);\n// Continue 10 seconds later\n```\n\n### hub.motorAngleAsync(port, angle, dutyCycle = 100, wait = false)\n\nTurn a motor by specific angle. Await returns when command is sent to Hub.\n\n```js\n// Turn ~180 degrees  \nawait hub.motorAngleAsync('B', 980, 100, true);\n// Continue after the turn\n```\n\n### hub.motorAngleMultiAsync(angle, dutyCycleA = 100, dutyCycleB = 100, wait = false)\n\nTurn both motors (A and B) by specific angle. Await returns when command is sent to Hub.\n\n```js\n// Drive forward\nawait hub.motorAngleMultiAsync(500, 100, 100);\n// Continue immediately after command is sent to Hub\n```\n\n### hub.drive(centimeters, wait = true)\n\nDrive specified distance. By default drive-method's return promise will resolve when the distance has been driven.\n\n__Note:__ Drive method is implemented with Lego Boost Vernie\n\n```js\n// Drive forward 2 meters\nawait hub.drive(200);\n// Continue after drive is finished\n```\n\n### hub.useMetricUnits()\n\nUse metric untis in drive-method. Metric is default.\n\n```js\n// Drive forward 200 cm\nawait hub.drive(200);\n\nhub.useImperialUnits();\n\n// Drive forward 200 inches\nawait hub.drive(200);\n```\n\n### hub.useImperialUnits()\n\nUse imperial units with drive-method.\n\n### hub.setFrictionModifier(modifier)\n\nIf drive method's distance is not correct, friction modifier can be changed.\n\n```js\n// Drive forward 100cm\nawait hub.drive(100);\n\n// Distance was only 90cm, update modifier\nhub.setFrictionModifier(1.1);\n\n// Drive 100cm\nawait hub.drive(100);\n```\n\n### hub.turn(degrees, wait = true)\n\nTurn specified angle to either right (positive number) or left (negative number). By default turn-method's promise will resolve when the angle has been turned.\n\n__Note:__ Turn method is implemented with Lego Boost Vernie\n\n```js\nconst hub = await boost.getHubAsync();\n// Drive 1 meter square\nawait hub.drive(100);\nawait hub.turn(90);\nawait hub.drive(100);\nawait hub.turn(90);\nawait hub.drive(100);\nawait hub.turn(90);\nawait hub.drive(100);\nawait hub.turn(90);\n```\n\n### hub.driveUntil(distance = 0, wait = true)\n\nDrive until the sensor shows an object in defined distance. The distance sensor is not very sensitive or accurate. By default the bot will stop when the sensor notices a wall for the first time. Sensor distance values are usualy between 110-50.\n\n```js\nawait hub.driveUntil();\n```\n\n### hub.turnUntil(direction = 1, wait = true)\n\nTurn until sensor doesn't detect any blocking object. 1 or any positive number turns to the right (default) and 0 or any negative number turns to the left.\n\n```js\n// Turn to the right\nawait hub.turnUntil();\n// Turn to the right\nawait hub.turnUntil(1);\n// Turn to the left\nawait hub.turnUntil(0);\n```\n\n## Example project\n\n[lego-boost-ai](https://github.com/ttu/lego-boost-ai) has a simple AI and manual controls for Lego Boost.\n\n## Unit tests\n\nRun ESLint and Mocha tests.\n\n```sh\n$ npm run test\n```\n\nRun only Mocha tests.\n\n```sh\n$ npm run mocha\n```\n\n## Tester\n\n[tester.js](https://github.com/ttu/node-movehub-async/blob/master/tester.js)\n\n## Use development version\n\nIt is possible to use development version from GitHub, which may contain unreleased features.\n\n```sh\n$ npm install git+https://git@github.com/ttu/node-movehub-async.git\n```\n\n## Changelog\n\n[Changelog](https://github.com/ttu/node-movehub-async/blob/master/CHANGELOG.md)\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## Disclaimer\n\nLEGO and BOOST are Trademarks from The LEGO Company, which do not support this project. \n\nI'm not responsible for any damage on your LEGO BOOST devices - use it at your own risk.\n\n## License\n\nLicensed under the [MIT](https://github.com/ttu/node-movehub-async/blob/master/LICENSE) License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttu%2Fnode-movehub-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttu%2Fnode-movehub-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttu%2Fnode-movehub-async/lists"}