Represents a Pixels die. Most of its methods require the instance to be connected to the Pixel device. Call the () method to initiate a connection.

Call addEventListener to get notified for rolls, connection and disconnection events and more.

Call addPropertyListener to get notified on property changes.

Hierarchy (view full)

Implements

Constructors

  • Instantiates a Pixel.

    Parameters

    • session: PixelSession

      The session used to communicate with the Pixel.

    • Optionalinfo: Partial<Pick<Readonly<{
          batteryLevel: number;
          colorway:
              | "custom"
              | "unknown"
              | "onyxBlack"
              | "hematiteGrey"
              | "midnightGalaxy"
              | "auroraSky"
              | "clear"
              | "whiteAurora";
          currentFace: number;
          currentFaceIndex: number;
          dieType:
              | "unknown"
              | "d4"
              | "d6"
              | "d8"
              | "d10"
              | "d00"
              | "d12"
              | "d20"
              | "d6pipped"
              | "d6fudge";
          firmwareDate: Date;
          isCharging: boolean;
          ledCount: number;
          name: string;
          pixelId: number;
          rollState:
              | "unknown"
              | "rolled"
              | "handling"
              | "rolling"
              | "crooked"
              | "onFace";
          rssi: number;
          systemId: string;
      }>,
          | "pixelId"
          | "ledCount"
          | "colorway"
          | "dieType"
          | "firmwareDate">>

    Returns Pixel

Properties

_msgEvEmitter: EventEmitter<DefaultEventMap>
_serializer: MessageSerializer<
    | "rssi"
    | "batteryLevel"
    | "rollState"
    | "blink"
    | "none"
    | "whoAreYou"
    | "bulkSetup"
    | "bulkSetupAck"
    | "bulkData"
    | "bulkDataAck"
    | "transferSettings"
    | "transferSettingsAck"
    | "transferSettingsFinished"
    | "debugLog"
    | "requestSettings"
    | "blinkAck"
    | "requestBatteryLevel"
    | "requestRssi"
    | "notifyUser"
    | "notifyUserAck"
    | "programDefaultParameters"
    | "programDefaultParametersFinished"
    | "setName"
    | "setNameAck"
    | "requestTemperature"
    | "temperature"
    | "testBulkSend"
    | "testBulkReceive"
    | "attractMode"
    | "printA2DReadings"
    | "printAnimationControllerState"
    | "iAmADie"
    | "telemetry"
    | "transferAnimationSet"
    | "transferAnimationSetAck"
    | "transferAnimationSetFinished"
    | "transferTestAnimationSet"
    | "transferTestAnimationSetAck"
    | "transferTestAnimationSetFinished"
    | "playAnimation"
    | "playAnimationEvent"
    | "stopAnimation"
    | "remoteAction"
    | "requestRollState"
    | "requestAnimationSet"
    | "requestTelemetry"
    | "programDefaultAnimationSet"
    | "programDefaultAnimationSetFinished"
    | "requestDefaultAnimationSetColor"
    | "defaultAnimationSetColor"
    | "calibrate"
    | "calibrateFace"
    | "testHardware"
    | "storeValue"
    | "storeValueAck"
    | "setTopLevelState"
    | "setDesignAndColor"
    | "setDesignAndColorAck"
    | "setCurrentBehavior"
    | "setCurrentBehaviorAck"
    | "powerOperation"
    | "exitValidation"
    | "transferInstantAnimationSet"
    | "transferInstantAnimationSetAck"
    | "transferInstantAnimationSetFinished"
    | "playInstantAnimation"
    | "stopAllAnimations"
    | "setBatteryControllerMode"
    | "_unused"
    | "discharge"
    | "blinkId"
    | "blinkIdAck"
    | "transferTest"
    | "transferTestAck"
    | "transferTestFinished"
    | "clearSettings"
    | "clearSettingsAck"
    | "setAllLEDsToColor"
    | "printNormals"
    | "lightUpFace"
    | "setLEDToColor">
isNotifier = true
type = "die"

Device type is Pixels die.

MutablePropsList: readonly (
    | "systemId"
    | "name"
    | "rssi"
    | "pixelId"
    | "ledCount"
    | "colorway"
    | "dieType"
    | "firmwareDate"
    | "batteryLevel"
    | "isCharging"
    | "rollState"
    | "currentFace"
    | "currentFaceIndex")[]

Accessors

  • get batteryLevel(): number
  • Gets the Pixel battery level (percentage).

    Returns number

    This value is automatically updated when the die is connected.

  • get colorway():
        | "custom"
        | "unknown"
        | "onyxBlack"
        | "hematiteGrey"
        | "midnightGalaxy"
        | "auroraSky"
        | "clear"
        | "whiteAurora"
  • Gets the color of the Pixel.

    Returns
        | "custom"
        | "unknown"
        | "onyxBlack"
        | "hematiteGrey"
        | "midnightGalaxy"
        | "auroraSky"
        | "clear"
        | "whiteAurora"

  • get currentFace(): number
  • Gets the die face value that is currently facing up.

    Returns number

    Fudge die returns +1, 0 and -1. This value is automatically updated when the die is connected.

  • get currentFaceIndex(): number
  • Gets the 0-based index of the die face that is currently facing up.

    Returns number

    This value is automatically updated when the die is connected.

    PixelInfo.currentFaceIndex for more details.

  • get dieFaceCount(): number
  • Gets the number of faces of the Pixel.

    Returns number

  • get dieType():
        | "unknown"
        | "d4"
        | "d6"
        | "d8"
        | "d10"
        | "d00"
        | "d12"
        | "d20"
        | "d6pipped"
        | "d6fudge"
  • Gets the die type of the Pixel.

    Returns
        | "unknown"
        | "d4"
        | "d6"
        | "d8"
        | "d10"
        | "d00"
        | "d12"
        | "d20"
        | "d6pipped"
        | "d6fudge"

  • get firmwareDate(): Date
  • Gets the Pixel firmware build date.

    Returns Date

  • get isCharging(): boolean
  • Gets whether the Pixel battery is charging or not. Returns 'true' if fully charged but still on charger.

    Returns boolean

    This value is automatically updated when the die is connected.

  • get isTransferring(): boolean
  • Whether data is being transferred from or to the die.

    Returns boolean

  • get ledCount(): number
  • Gets the number of LEDs for the Pixel, may be 0 until connected to device.

    Returns number

  • get logger(): undefined | null | ((msg: string) => void)
  • Set logger to use by this instance.

    Returns undefined | null | ((msg: string) => void)

  • set logger(logger): void
  • Parameters

    • logger: undefined | null | ((msg: string) => void)

    Returns void

  • get logMessages(): boolean
  • Toggle logging information about each send and received message.

    Returns boolean

  • set logMessages(enabled): void
  • Parameters

    • enabled: boolean

    Returns void

  • get logMessagesSerializedData(): boolean
  • Toggle logging the serialized (binary) data for each send and received message.

    Returns boolean

  • set logMessagesSerializedData(enabled): void
  • Parameters

    • enabled: boolean

    Returns void

  • get name(): string
  • Gets the Pixel name, may be empty until connected to device.

    Returns string

  • get pixelId(): number
  • Gets the unique Pixel id of the device, may be 0 until connected.

    Returns number

  • get profileHash(): number
  • Gets the on-die profile hash value. This can be used as an identifier for the current profile.

    Returns number

  • get rollState():
        | "unknown"
        | "rolled"
        | "handling"
        | "rolling"
        | "crooked"
        | "onFace"
  • Gets the Pixel roll state.

    Returns
        | "unknown"
        | "rolled"
        | "handling"
        | "rolling"
        | "crooked"
        | "onFace"

    This value is automatically updated when the die is connected.

  • get rssi(): number
  • Gets the last RSSI value notified by the Pixel.

    Returns number

    Call () to automatically update the RSSI value.

  • get sessionDeviceName(): undefined | string
  • Returns undefined | string

  • get status(): PixelStatus
  • Gets the Pixel last known connection status.

    Returns PixelStatus

  • get systemId(): string
  • Gets the unique id assigned by the system to the Pixel Bluetooth peripheral.

    Returns string

Methods

  • Parameters

    • OptionaltimeoutMs: number

    Returns Promise<void>

  • Immediately disconnects from the die.

    Returns Promise<void>

    A promise that resolves once the disconnect request has been processed.

  • Sends a message to the Pixel and wait for a specific response.

    Parameters

    • msgOrTypeToSend:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"
          | PixelMessage

      Message with the data to send or just a message type.

    • responseType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"

      Expected response type.

    • OptionaltimeoutMs: number

      Timeout in mill-seconds before aborting waiting for the response.

    Returns Promise<
        | "rssi"
        | "batteryLevel"
        | "rollState"
        | "blink"
        | "none"
        | "whoAreYou"
        | "bulkSetup"
        | "bulkSetupAck"
        | "bulkData"
        | "bulkDataAck"
        | "transferSettings"
        | "transferSettingsAck"
        | "transferSettingsFinished"
        | "debugLog"
        | "requestSettings"
        | "blinkAck"
        | "requestBatteryLevel"
        | "requestRssi"
        | "notifyUser"
        | "notifyUserAck"
        | "programDefaultParameters"
        | "programDefaultParametersFinished"
        | "setName"
        | "setNameAck"
        | "requestTemperature"
        | "temperature"
        | "testBulkSend"
        | "testBulkReceive"
        | "attractMode"
        | "printA2DReadings"
        | "printAnimationControllerState"
        | "iAmADie"
        | "telemetry"
        | "transferAnimationSet"
        | "transferAnimationSetAck"
        | "transferAnimationSetFinished"
        | "transferTestAnimationSet"
        | "transferTestAnimationSetAck"
        | "transferTestAnimationSetFinished"
        | "playAnimation"
        | "playAnimationEvent"
        | "stopAnimation"
        | "remoteAction"
        | "requestRollState"
        | "requestAnimationSet"
        | "requestTelemetry"
        | "programDefaultAnimationSet"
        | "programDefaultAnimationSetFinished"
        | "requestDefaultAnimationSetColor"
        | "defaultAnimationSetColor"
        | "calibrate"
        | "calibrateFace"
        | "testHardware"
        | "storeValue"
        | "storeValueAck"
        | "setTopLevelState"
        | "setDesignAndColor"
        | "setDesignAndColorAck"
        | "setCurrentBehavior"
        | "setCurrentBehaviorAck"
        | "powerOperation"
        | "exitValidation"
        | "transferInstantAnimationSet"
        | "transferInstantAnimationSetAck"
        | "transferInstantAnimationSetFinished"
        | "playInstantAnimation"
        | "stopAllAnimations"
        | "setBatteryControllerMode"
        | "_unused"
        | "discharge"
        | "blinkId"
        | "blinkIdAck"
        | "transferTest"
        | "transferTestAck"
        | "transferTestFinished"
        | "clearSettings"
        | "clearSettingsAck"
        | "setAllLEDsToColor"
        | "printNormals"
        | "lightUpFace"
        | "setLEDToColor"
        | PixelMessage>

    A promise resolving to the response in the form of a message type or a message object.

  • Sends a message to the Pixel and wait for a specific response which is returned casted to the expected type.

    Type Parameters

    • T extends PixelMessage

    Parameters

    • msgOrTypeToSend:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"
          | PixelMessage

      Message with the data to send or just a message type.

    • responseType: (new () => T)

      Expected response class type.

        • new (): T
        • Returns T

    • OptionaltimeoutMs: number

    Returns Promise<T>

    A promise resolving to a message object of the expected type.

  • Sends a message to the Pixel.

    Parameters

    • msgOrType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"
          | PixelMessage

      Message with the data to send or just a message type.

    • OptionalwithoutAck: boolean

      Whether to request a confirmation that the message was received.

    Returns Promise<void>

    A promise that resolves once the message has been send.

  • Returns Promise<void>

  • Waits for a message from the Pixel.

    Parameters

    • expectedMsgType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"

      Type of the message to expect.

    • OptionaltimeoutMs: number

      Timeout before aborting the wait.

    Returns Promise<
        | "rssi"
        | "batteryLevel"
        | "rollState"
        | "blink"
        | "none"
        | "whoAreYou"
        | "bulkSetup"
        | "bulkSetupAck"
        | "bulkData"
        | "bulkDataAck"
        | "transferSettings"
        | "transferSettingsAck"
        | "transferSettingsFinished"
        | "debugLog"
        | "requestSettings"
        | "blinkAck"
        | "requestBatteryLevel"
        | "requestRssi"
        | "notifyUser"
        | "notifyUserAck"
        | "programDefaultParameters"
        | "programDefaultParametersFinished"
        | "setName"
        | "setNameAck"
        | "requestTemperature"
        | "temperature"
        | "testBulkSend"
        | "testBulkReceive"
        | "attractMode"
        | "printA2DReadings"
        | "printAnimationControllerState"
        | "iAmADie"
        | "telemetry"
        | "transferAnimationSet"
        | "transferAnimationSetAck"
        | "transferAnimationSetFinished"
        | "transferTestAnimationSet"
        | "transferTestAnimationSetAck"
        | "transferTestAnimationSetFinished"
        | "playAnimation"
        | "playAnimationEvent"
        | "stopAnimation"
        | "remoteAction"
        | "requestRollState"
        | "requestAnimationSet"
        | "requestTelemetry"
        | "programDefaultAnimationSet"
        | "programDefaultAnimationSetFinished"
        | "requestDefaultAnimationSetColor"
        | "defaultAnimationSetColor"
        | "calibrate"
        | "calibrateFace"
        | "testHardware"
        | "storeValue"
        | "storeValueAck"
        | "setTopLevelState"
        | "setDesignAndColor"
        | "setDesignAndColorAck"
        | "setCurrentBehavior"
        | "setCurrentBehaviorAck"
        | "powerOperation"
        | "exitValidation"
        | "transferInstantAnimationSet"
        | "transferInstantAnimationSetAck"
        | "transferInstantAnimationSetFinished"
        | "playInstantAnimation"
        | "stopAllAnimations"
        | "setBatteryControllerMode"
        | "_unused"
        | "discharge"
        | "blinkId"
        | "blinkIdAck"
        | "transferTest"
        | "transferTestAck"
        | "transferTestFinished"
        | "clearSettings"
        | "clearSettingsAck"
        | "setAllLEDsToColor"
        | "printNormals"
        | "lightUpFace"
        | "setLEDToColor"
        | PixelMessage>

    A promise with the received message of the expected type.

  • Parameters

    • msg: unknown

    Returns void

  • Parameters

    • arr: ArrayBuffer

    Returns void

  • Parameters

    • ev: Readonly<{
          lastStatus: PixelStatus;
          reason?:
              | "unknown"
              | "peripheral"
              | "success"
              | "canceled"
              | "notSupported"
              | "timeout"
              | "linkLoss"
              | "bluetoothOff"
              | "host";
          status: PixelStatus;
      }>

    Returns void

  • Parameters

    • str: string

    Returns string

  • Parameters

    • msg: unknown

    Returns void

  • Registers a listener function that will be called when the specified event is raised. See PixelEventMap for the list of events and their associated data.

    Type Parameters

    • K extends
          | "rollState"
          | "remoteAction"
          | "battery"
          | "statusChanged"
          | "messageReceived"
          | "messageSend"
          | "roll"
          | "userMessage"
          | "dataTransfer"

    Parameters

    • type: K

      A case-sensitive string representing the event type to listen for.

    • listener: EventReceiver<Readonly<{
          battery: Readonly<{
              isCharging: boolean;
              level: number;
          }>;
          dataTransfer: Readonly<{
              totalBytes: number;
              type: "starting" | "preparing" | "completed";
          } | {
              error:
                  | "unknown"
                  | "disconnected"
                  | "timeout"
                  | "outOfMemory";
              type: "failed";
          } | {
              type: "progress";
          } & Readonly<{
              progressPercent: number;
              totalBytes: number;
              transferredBytes: number;
          }>>;
          messageReceived: MessageOrType;
          messageSend: MessageOrType;
          remoteAction: number;
          roll: number;
          rollState: Readonly<{
              face: number;
              faceIndex: number;
              state:
                  | "unknown"
                  | "rolled"
                  | "handling"
                  | "rolling"
                  | "crooked"
                  | "onFace";
          }>;
          statusChanged: Readonly<{
              lastStatus: PixelStatus;
              reason?:
                  | "unknown"
                  | "peripheral"
                  | "success"
                  | "canceled"
                  | "notSupported"
                  | "timeout"
                  | "linkLoss"
                  | "bluetoothOff"
                  | "host";
              status: PixelStatus;
          }>;
          userMessage: Readonly<{
              message: string;
              response: ((okCancel: boolean) => Promise<void>);
              withCancel: boolean;
          }>;
      }>[K]>

      The callback function.

    Returns void

  • Registers a listener function that will be called on receiving raw messages of a given type from the Pixel.

    Parameters

    • msgType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"

      The type of message to watch for.

    • listener: ((this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>, message:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"
          | PixelMessage) => void)

      The callback function.

        • (this, message): void
        • Parameters

          • this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>
          • message:
                | "rssi"
                | "batteryLevel"
                | "rollState"
                | "blink"
                | "none"
                | "whoAreYou"
                | "bulkSetup"
                | "bulkSetupAck"
                | "bulkData"
                | "bulkDataAck"
                | "transferSettings"
                | "transferSettingsAck"
                | "transferSettingsFinished"
                | "debugLog"
                | "requestSettings"
                | "blinkAck"
                | "requestBatteryLevel"
                | "requestRssi"
                | "notifyUser"
                | "notifyUserAck"
                | "programDefaultParameters"
                | "programDefaultParametersFinished"
                | "setName"
                | "setNameAck"
                | "requestTemperature"
                | "temperature"
                | "testBulkSend"
                | "testBulkReceive"
                | "attractMode"
                | "printA2DReadings"
                | "printAnimationControllerState"
                | "iAmADie"
                | "telemetry"
                | "transferAnimationSet"
                | "transferAnimationSetAck"
                | "transferAnimationSetFinished"
                | "transferTestAnimationSet"
                | "transferTestAnimationSetAck"
                | "transferTestAnimationSetFinished"
                | "playAnimation"
                | "playAnimationEvent"
                | "stopAnimation"
                | "remoteAction"
                | "requestRollState"
                | "requestAnimationSet"
                | "requestTelemetry"
                | "programDefaultAnimationSet"
                | "programDefaultAnimationSetFinished"
                | "requestDefaultAnimationSetColor"
                | "defaultAnimationSetColor"
                | "calibrate"
                | "calibrateFace"
                | "testHardware"
                | "storeValue"
                | "storeValueAck"
                | "setTopLevelState"
                | "setDesignAndColor"
                | "setDesignAndColorAck"
                | "setCurrentBehavior"
                | "setCurrentBehaviorAck"
                | "powerOperation"
                | "exitValidation"
                | "transferInstantAnimationSet"
                | "transferInstantAnimationSetAck"
                | "transferInstantAnimationSetFinished"
                | "playInstantAnimation"
                | "stopAllAnimations"
                | "setBatteryControllerMode"
                | "_unused"
                | "discharge"
                | "blinkId"
                | "blinkIdAck"
                | "transferTest"
                | "transferTestAck"
                | "transferTestFinished"
                | "clearSettings"
                | "clearSettingsAck"
                | "setAllLEDsToColor"
                | "printNormals"
                | "lightUpFace"
                | "setLEDToColor"
                | PixelMessage

          Returns void

    Returns void

  • Adds the given listener function for the specified property.

    Type Parameters

    • K extends
          | "systemId"
          | "name"
          | "rssi"
          | "pixelId"
          | "ledCount"
          | "colorway"
          | "dieType"
          | "firmwareDate"
          | "batteryLevel"
          | "isCharging"
          | "rollState"
          | "currentFace"
          | "currentFaceIndex"
          | "status"
          | "profileHash"
          | "isTransferring"

    Parameters

    Returns void

  • Requests the Pixel to blink and wait for a confirmation.

    Parameters

    • color: Color

      Blink color.

    • Optionalopt: {
          count?: number;
          duration?: number;
          faceMask?: number;
          fade?: number;
          loopCount?: number;
      }
      • Optionalcount?: number

        Number of blinks.

      • Optionalduration?: number

        Total duration of the animation in milliseconds.

      • OptionalfaceMask?: number

        Select which faces to light up.

      • Optionalfade?: number

        Amount of in and out fading, 0: sharp transition, 1: maximum fading.

      • OptionalloopCount?: number

        How many times to loop the animation.

    Returns Promise<void>

    A promise that resolves once the die has confirmed receiving the message.

  • Asynchronously tries to connect to the die. Throws on connection error.

    Parameters

    • OptionaltimeoutMs: number

      Delay before giving up (may be ignored when having concurrent calls to connect()). It may take longer than the given timeout for the function to return.

    Returns Promise<Pixel>

    A promise that resoles to this instance once the connection process has completed (whether successfully or not).

    Will throw a PixelConnectError if it fails to connect in time.

  • Immediately disconnects from the die.

    Returns Promise<Pixel>

    A promise that resolves once the disconnect request has been processed.

  • Emit a Pixel event for the specified property. This function should be called by the concrete type whenever the a property's value changes.

    Type Parameters

    • K extends
          | "systemId"
          | "name"
          | "rssi"
          | "pixelId"
          | "ledCount"
          | "colorway"
          | "dieType"
          | "firmwareDate"
          | "batteryLevel"
          | "isCharging"
          | "rollState"
          | "currentFace"
          | "currentFaceIndex"
          | "status"
          | "profileHash"
          | "isTransferring"

    Parameters

    • propertyName: K

      Event name.

    Returns void

  • Plays the instant animation at the given index. See

    Parameters

    • animIndex: number

      The index of the instant animation to play.

    Returns Promise<void>

    A promise that resolves once the message has been send.

    transferInstantAnimations().

  • Plays the (single) LEDs animation included in the given data set.

    Parameters

    • dataSet: Readonly<DataSet>

      The data set containing just one animation to play.

    Returns Promise<void>

    A promise that resolves once the transfer has completed.

  • Asynchronously gets the Pixel RSSI value.

    Returns Promise<number>

    A promise revolving to a negative number representing the RSSI value.

  • Unregisters a listener from receiving events identified by the given event name. See PixelEventMap for the list of events and their associated data.

    Type Parameters

    • K extends
          | "rollState"
          | "remoteAction"
          | "battery"
          | "statusChanged"
          | "messageReceived"
          | "messageSend"
          | "roll"
          | "userMessage"
          | "dataTransfer"

    Parameters

    • type: K

      A case-sensitive string representing the event type.

    • listener: EventReceiver<Readonly<{
          battery: Readonly<{
              isCharging: boolean;
              level: number;
          }>;
          dataTransfer: Readonly<{
              totalBytes: number;
              type: "starting" | "preparing" | "completed";
          } | {
              error:
                  | "unknown"
                  | "disconnected"
                  | "timeout"
                  | "outOfMemory";
              type: "failed";
          } | {
              type: "progress";
          } & Readonly<{
              progressPercent: number;
              totalBytes: number;
              transferredBytes: number;
          }>>;
          messageReceived: MessageOrType;
          messageSend: MessageOrType;
          remoteAction: number;
          roll: number;
          rollState: Readonly<{
              face: number;
              faceIndex: number;
              state:
                  | "unknown"
                  | "rolled"
                  | "handling"
                  | "rolling"
                  | "crooked"
                  | "onFace";
          }>;
          statusChanged: Readonly<{
              lastStatus: PixelStatus;
              reason?:
                  | "unknown"
                  | "peripheral"
                  | "success"
                  | "canceled"
                  | "notSupported"
                  | "timeout"
                  | "linkLoss"
                  | "bluetoothOff"
                  | "host";
              status: PixelStatus;
          }>;
          userMessage: Readonly<{
              message: string;
              response: ((okCancel: boolean) => Promise<void>);
              withCancel: boolean;
          }>;
      }>[K]>

      The callback function to unregister.

    Returns void

  • Unregisters a listener from receiving raw messages of a given type.

    Parameters

    • msgType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"

      The type of message to watch for.

    • listener: ((this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>, msg:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"
          | PixelMessage) => void)

      The callback function to unregister.

        • (this, msg): void
        • Parameters

          • this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>
          • msg:
                | "rssi"
                | "batteryLevel"
                | "rollState"
                | "blink"
                | "none"
                | "whoAreYou"
                | "bulkSetup"
                | "bulkSetupAck"
                | "bulkData"
                | "bulkDataAck"
                | "transferSettings"
                | "transferSettingsAck"
                | "transferSettingsFinished"
                | "debugLog"
                | "requestSettings"
                | "blinkAck"
                | "requestBatteryLevel"
                | "requestRssi"
                | "notifyUser"
                | "notifyUserAck"
                | "programDefaultParameters"
                | "programDefaultParametersFinished"
                | "setName"
                | "setNameAck"
                | "requestTemperature"
                | "temperature"
                | "testBulkSend"
                | "testBulkReceive"
                | "attractMode"
                | "printA2DReadings"
                | "printAnimationControllerState"
                | "iAmADie"
                | "telemetry"
                | "transferAnimationSet"
                | "transferAnimationSetAck"
                | "transferAnimationSetFinished"
                | "transferTestAnimationSet"
                | "transferTestAnimationSetAck"
                | "transferTestAnimationSetFinished"
                | "playAnimation"
                | "playAnimationEvent"
                | "stopAnimation"
                | "remoteAction"
                | "requestRollState"
                | "requestAnimationSet"
                | "requestTelemetry"
                | "programDefaultAnimationSet"
                | "programDefaultAnimationSetFinished"
                | "requestDefaultAnimationSetColor"
                | "defaultAnimationSetColor"
                | "calibrate"
                | "calibrateFace"
                | "testHardware"
                | "storeValue"
                | "storeValueAck"
                | "setTopLevelState"
                | "setDesignAndColor"
                | "setDesignAndColorAck"
                | "setCurrentBehavior"
                | "setCurrentBehaviorAck"
                | "powerOperation"
                | "exitValidation"
                | "transferInstantAnimationSet"
                | "transferInstantAnimationSetAck"
                | "transferInstantAnimationSetFinished"
                | "playInstantAnimation"
                | "stopAllAnimations"
                | "setBatteryControllerMode"
                | "_unused"
                | "discharge"
                | "blinkId"
                | "blinkIdAck"
                | "transferTest"
                | "transferTestAck"
                | "transferTestFinished"
                | "clearSettings"
                | "clearSettingsAck"
                | "setAllLEDsToColor"
                | "printNormals"
                | "lightUpFace"
                | "setLEDToColor"
                | PixelMessage

          Returns void

    Returns void

  • Removes the given listener function for the specified property.

    Type Parameters

    • K extends
          | "systemId"
          | "name"
          | "rssi"
          | "pixelId"
          | "ledCount"
          | "colorway"
          | "dieType"
          | "firmwareDate"
          | "batteryLevel"
          | "isCharging"
          | "rollState"
          | "currentFace"
          | "currentFaceIndex"
          | "status"
          | "profileHash"
          | "isTransferring"

    Parameters

    Returns void

  • Requests the Pixel to change its name.

    Parameters

    • name: string

      New name to assign to the Pixel. Must have at least one character.

    Returns Promise<void>

    A promise that resolves once the die has confirmed being renamed.

  • Requests the Pixel to regularly send its measured RSSI value.

    Parameters

    • activate: boolean

      Whether to turn or turn off this feature.

    • OptionalminInterval: number

      The minimum time interval in milliseconds between two RSSI updates.

    Returns Promise<void>

    A promise that resolves once the message has been send.

  • Sends a message to the Pixel and wait for a specific response.

    Parameters

    • msgOrTypeToSend: MessageOrType

      Message with the data to send or just a message type.

    • responseType:
          | "rssi"
          | "batteryLevel"
          | "rollState"
          | "blink"
          | "none"
          | "whoAreYou"
          | "bulkSetup"
          | "bulkSetupAck"
          | "bulkData"
          | "bulkDataAck"
          | "transferSettings"
          | "transferSettingsAck"
          | "transferSettingsFinished"
          | "debugLog"
          | "requestSettings"
          | "blinkAck"
          | "requestBatteryLevel"
          | "requestRssi"
          | "notifyUser"
          | "notifyUserAck"
          | "programDefaultParameters"
          | "programDefaultParametersFinished"
          | "setName"
          | "setNameAck"
          | "requestTemperature"
          | "temperature"
          | "testBulkSend"
          | "testBulkReceive"
          | "attractMode"
          | "printA2DReadings"
          | "printAnimationControllerState"
          | "iAmADie"
          | "telemetry"
          | "transferAnimationSet"
          | "transferAnimationSetAck"
          | "transferAnimationSetFinished"
          | "transferTestAnimationSet"
          | "transferTestAnimationSetAck"
          | "transferTestAnimationSetFinished"
          | "playAnimation"
          | "playAnimationEvent"
          | "stopAnimation"
          | "remoteAction"
          | "requestRollState"
          | "requestAnimationSet"
          | "requestTelemetry"
          | "programDefaultAnimationSet"
          | "programDefaultAnimationSetFinished"
          | "requestDefaultAnimationSetColor"
          | "defaultAnimationSetColor"
          | "calibrate"
          | "calibrateFace"
          | "testHardware"
          | "storeValue"
          | "storeValueAck"
          | "setTopLevelState"
          | "setDesignAndColor"
          | "setDesignAndColorAck"
          | "setCurrentBehavior"
          | "setCurrentBehaviorAck"
          | "powerOperation"
          | "exitValidation"
          | "transferInstantAnimationSet"
          | "transferInstantAnimationSetAck"
          | "transferInstantAnimationSetFinished"
          | "playInstantAnimation"
          | "stopAllAnimations"
          | "setBatteryControllerMode"
          | "_unused"
          | "discharge"
          | "blinkId"
          | "blinkIdAck"
          | "transferTest"
          | "transferTestAck"
          | "transferTestFinished"
          | "clearSettings"
          | "clearSettingsAck"
          | "setAllLEDsToColor"
          | "printNormals"
          | "lightUpFace"
          | "setLEDToColor"

      Expected response type.

    • OptionaltimeoutMs: number

      Timeout in mill-seconds before aborting waiting for the response.

    Returns Promise<MessageOrType>

    A promise resolving to the response in the form of a message type or a message object.

  • Sends a message to the Pixel and wait for a specific response which is returned casted to the expected type.

    Type Parameters

    • T extends PixelMessage

    Parameters

    • msgOrTypeToSend: MessageOrType

      Message with the data to send or just a message type.

    • responseType: (new () => T)

      Expected response class type.

        • new (): T
        • Returns T

    • OptionaltimeoutMs: number

    Returns Promise<T>

    A promise resolving to a message object of the expected type.

  • Sends a message to the Pixel.

    Parameters

    • msgOrType: MessageOrType

      Message with the data to send or just a message type.

    • OptionalwithoutAck: boolean

      Whether to request a confirmation that the message was received.

    Returns Promise<void>

    A promise that resolves once the message has been send.

  • Requests the Pixel to start faces calibration sequence.

    Returns Promise<void>

    A promise that resolves once the message has been send.

  • Requests the Pixel to stop all currently playing animations.

    Returns Promise<void>

    A promise.

  • Uploads the given data set of animations to the Pixel flash memory.

    Parameters

    • dataSet: Readonly<DataSet>

      The data set to upload.

    Returns Promise<void>

    A promise that resolves once the transfer has completed.

  • Uploads the given data set of animations to the Pixel RAM memory. Those animations are lost when the Pixel goes to sleep, is turned off or is restarted.

    Parameters

    • dataSet: Readonly<DataSet>

      The data set to upload.

    Returns Promise<void>

    A promise that resolves once the transfer has completed.

  • Requests the Pixel to completely turn off.

    Returns Promise<void>

    A promise that resolves once the message has been send.

  • Update Pixel info from an external source such as scanning data.

    Parameters

    • info: Partial<Omit<Readonly<{
          batteryLevel: number;
          colorway:
              | "custom"
              | "unknown"
              | "onyxBlack"
              | "hematiteGrey"
              | "midnightGalaxy"
              | "auroraSky"
              | "clear"
              | "whiteAurora";
          currentFace: number;
          currentFaceIndex: number;
          dieType:
              | "unknown"
              | "d4"
              | "d6"
              | "d8"
              | "d10"
              | "d00"
              | "d12"
              | "d20"
              | "d6pipped"
              | "d6fudge";
          firmwareDate: Date;
          isCharging: boolean;
          ledCount: number;
          name: string;
          pixelId: number;
          rollState:
              | "unknown"
              | "rolled"
              | "handling"
              | "rolling"
              | "crooked"
              | "onFace";
          rssi: number;
          systemId: string;
      }>, "systemId" | "currentFace">>

      The updated info.

    Returns void

    The info will be updated only if the die is disconnected. Roll state and face index are updated only if both are provided.