tekiela / powered-up

A Node.js SDK for programming the LEGO® Powered Up platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PoweredUpJS

Build Status Package Version

A Node.js SDK for programming the LEGO® Powered Up platform.

Disclaimer: LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this software.

Getting started

Please install the @powered-up/api package as described here.

The following example uses a Smart Move Hub (included in the LEGO® Boost Set 17101) and activates the built-in motor A while the button is held down:

// @ts-check

const {SmartMoveRobot} = require('@powered-up/api');
const {autorun} = require('mobx');

const moveRobot = new SmartMoveRobot();

autorun(() => {
  const {buttonPressed, encodedMotorA, rgbLight} = moveRobot;

  if (!encodedMotorA || !rgbLight) {
    return;
  }

  if (buttonPressed) {
    rgbLight.setColor({red: 0, green: 255, blue: 0});

    encodedMotorA.runWithPower(100);
  } else {
    rgbLight.setColor({red: 255, green: 0, blue: 0});

    encodedMotorA.brake();
  }
});

You can find some more examples in the demo package.

Implementation status

Smart Move Hub 2 I/O (Robot) Smart Hub 2 I/O (Robot)
Button Supported Supported
VoltageSensor Supported Supported
CurrentSensor Supported ✅ Supported
RGBLight ✅ Supported Supported
InternalEncodedMotor Supported ❌ N/A
InternalTiltSensor ⚠️ Not yet implemented N/A
Motor Supported Supported
EncodedMotor Supported ⚠️ Not yet implemented
VisionSensor ⚠️ Not yet implemented ⚠️ Not yet implemented

Packages

@powered-up/api

A reactive library for controlling LEGO® Powered Up devices.

Internal packages

@powered-up/ble

A reactive library for managing BLE connections to LEGO® Powered Up hubs.

@powered-up/protocol

A partial implementation of the LEGO® Powered Up BLE protocol in JavaScript.

Related links


Copyright (c) 2018-present, Clemens Akens. Released under the terms of the MIT License.

About

A Node.js SDK for programming the LEGO® Powered Up platform.

License:MIT License


Languages

Language:TypeScript 94.8%Language:JavaScript 5.1%Language:Shell 0.1%