UNPKG

rxpoweredup

Version:

A Typescript RxJS-based library for controlling LEGO Powered UP hubs & peripherals.

238 lines (237 loc) 6.38 kB
export declare const HUB_SERVICE_UUID = "00001623-1212-efde-1623-785feabcd123"; export declare const HUB_CHARACTERISTIC_UUID = "00001624-1212-efde-1623-785feabcd123"; export declare enum MessageType { properties = 1, action = 2, attachedIO = 4, genericError = 5, portInformationRequest = 33,// 33 portModeInformationRequest = 34,// 34 portInputFormatSetupSingle = 65,// 65 portInformation = 67,// 67 portModeInformation = 68,// 68 portValueSingle = 69,// 69 portInputFormatSetupSingleHandshake = 71,// 71 virtualPortSetup = 97,// 97 portOutputCommand = 129,// 129 portOutputCommandFeedback = 130 } export declare enum HubActionType { switchOff = 1, disconnect = 2, willSwitchOff = 48,// 48 willDisconnect = 49 } export type OutboundMessageTypes = MessageType.properties | MessageType.portInformationRequest | MessageType.portModeInformationRequest | MessageType.portInputFormatSetupSingle | MessageType.action | MessageType.virtualPortSetup; export declare enum PortModeInformationType { name = 0, rawRange = 1, pctRange = 2, siRange = 3, symbol = 4, mapping = 5, motorBias = 7, capabilityBits = 8, valueFormat = 9 } export declare enum PortInformationRequestType { portValue = 0, modeInfo = 1 } export declare enum PortInformationReplyType { modeInfo = 1 } export declare enum AttachIoEvent { Detached = 0, Attached = 1, AttachedVirtual = 2 } export declare enum IOType { motor = 1,// 1 systemTrainMotor = 2,// 2 button = 5,// 5 ledLight = 8,// 8 voltage = 20,// 20 current = 21,// 21 piezoTone = 22,// 22 rgbLight = 23,// 23 externalTiltSensor = 34,// 34 motionSensor = 35,// 35 visionSensor = 37,// 37 externalMotorWithTacho = 38,// 38 internalMotorWithTacho = 39,// 39 internalTilt = 40,// 40 largeTechnicMotor = 46,// 46 xLargeTechnicMotor = 47,// 47 gestureSensor = 54,// 54 handsetButtonGroup = 55,// 55 accelerometerSensor = 57,// 57 gyroscopeSensor = 58,// 58 tiltSensor = 59,// 59 temperatureSensor = 60,// 60 mediumTechnicAngularMotor = 75,// 75 largeTechnicAngularMotor = 76 } export declare enum HubPropertyOperation { setProperty = 1, enableUpdates = 2, disableUpdates = 3, reset = 4, requestUpdate = 5, update = 6 } export declare const MAX_NAME_SIZE = 14; export declare enum HubProperty { advertisingName = 1, button = 2, firmwareVersion = 3, hardwareVersion = 4, RSSI = 5, batteryVoltage = 6, manufacturerName = 8, systemTypeId = 11,// 11 primaryMacAddress = 13 } export declare enum HubType { WeDoHub = 0, DuploTrain = 1, BoostHub = 2, TwoPortHub = 3, TwoPortHandset = 4, Unknown = 5, FourPortHub = 6 } export declare const HUB_DEVICE_TYPE_MAP: { 0: HubType.WeDoHub; 32: HubType.DuploTrain; 64: HubType.BoostHub; 65: HubType.TwoPortHub; 66: HubType.TwoPortHandset; 128: HubType.FourPortHub; }; export declare enum PortModeName { speed = "SPEED", position = "POS", absolutePosition = "APOS", power = "POWER", color = "COL O", rgb = "RGB O", currentS = "CUR S", currentL = "CUR L", voltageS = "VLT S", voltageL = "VLT L", handsetRCKey = "RCKEY", handsetKeyA = "KEYA", handsetKeyR = "KEYR", handsetKeyD = "KEYD", handsetKeySD = "KEYSD", raw = "RAW", impact = "IMP", load = "LOAD", temperature = "TEMP", gravity = "GRV", gesture = "GEST", lpf2Train = "LPF2-TRAIN",// mode specific to 88011 lpf2MMotor = "LPF2-MMOTOR" } export declare enum PortModeSymbol { percent = "PCT", degree = "DEG", milliAmps = "mA", milliVolts = "mV", button = "btn", count = "CNT", generic = "", milliG = "mG" } export declare const MOTOR_LIMITS: { readonly maxSpeed: 100; readonly minSpeed: -100; readonly minPower: 0; readonly maxPower: 100; readonly minRawAngle: -134217727; readonly maxRawAngle: 134217727; readonly minServoDegreesRange: 15; readonly maxServoDegreesRange: 360; readonly maxAccDecTime: 10000; readonly minAccDecTime: 0; }; export declare enum MotorServoEndState { float = 0, hold = 126,// 126 brake = 127 } export declare enum PortOperationStartupInformation { bufferIfNecessary = 0, executeImmediately = 16 } export declare enum PortOperationCompletionInformation { noAction = 0, commandFeedback = 1 } export declare enum MotorUseProfile { dontUseProfiles = 0, useAccelerationProfile = 1, useDecelerationProfile = 2, useAccelerationAndDecelerationProfiles = 3 } export declare enum OutputSubCommand { setAccTime = 5, setDecTime = 6, startSpeed = 7, startSpeedSynchronized = 8, startSpeedForDegrees = 11, gotoAbsolutePosition = 13,// 13 gotoAbsolutePositionSynchronized = 14,// 14 writeDirectModeData = 81 } export declare enum PortCommandFeedbackMask { bufferEmptyCommandInProgress = 1,// 0b000001 // 1 bufferEmptyCommandCompleted = 2,// 0b000010 // 2 currentCommandDiscarded = 4,// 0b000100 // 4 idle = 8,// 0b001000 // 8 busyOrFull = 16,// 0b010000 // 16 executionError = 32 } export declare enum GenericErrorCode { ACK = 1, MACK = 2, bufferOverflow = 3, timeout = 4, commandNotRecognized = 5, invalidUse = 6, overcurrent = 7, internalError = 8 } export declare enum ButtonGroupButtonId { None = 0, Plus = 1, Red = 127, Minus = 255 } export declare const MOTOR_ACC_DEC_DEFAULT_PROFILE_ID = 0; export declare enum LogLevel { Debug = 0, Info = 1, Warning = 2, Error = 3 } export declare const WELL_KNOWN_PORT_MODE_IDS: { readonly motor: { readonly POWER: 0; readonly POS: 2; readonly APOS: 3; readonly "LPF2-TRAIN": 0; readonly "LPF2-MMOTOR": 0; }; readonly voltage: 0; readonly tilt: 0; readonly temperature: 0; readonly rgbLightRgbColor: 1; }; export declare enum VirtualPortSetupCommand { Disconnect = 0, Connect = 1 } export type SubscribableHubProperties = HubProperty.RSSI | HubProperty.batteryVoltage | HubProperty.button | HubProperty.advertisingName; export type WritableHubProperties = HubProperty.advertisingName;