Represents a Pixels charger. Most of its methods require the instance to be connected to the charger. 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 Charger.

    Parameters

    • session: PixelSession

      The session used to communicate with the Charger.

    • 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" | "firmwareDate">>

    Returns Charger

Properties

_msgEvEmitter: EventEmitter<DefaultEventMap>
_serializer: MessageSerializer<
    | "rssi"
    | "batteryLevel"
    | "blink"
    | "none"
    | "whoAreYou"
    | "iAmALCC"
    | "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">
isNotifier = true
type = "charger"

Device type is Pixels charger.

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

Accessors

  • get batteryLevel(): number
  • Gets the Charger 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"
  • Always return "unknown".

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

  • get currentFace(): number
  • Always return "0".

    Returns number

  • get currentFaceIndex(): number
  • Always return "0".

    Returns number

  • get dieType():
        | "unknown"
        | "d4"
        | "d6"
        | "d8"
        | "d10"
        | "d00"
        | "d12"
        | "d20"
        | "d6pipped"
        | "d6fudge"
  • Always return "unknown".

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

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

    Returns Date

  • get isCharging(): boolean
  • Gets whether the Charger 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 ledCount(): number
  • Gets the number of LEDs for the Charger, 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 Charger name, may be empty until connected to device.

    Returns string

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

    Returns number

  • get rollState():
        | "unknown"
        | "rolled"
        | "handling"
        | "rolling"
        | "crooked"
        | "onFace"
  • Always return "unknown".

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

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

    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 Charger 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.

  • Returns void

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

    Parameters

    • msgOrTypeToSend:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"
          | PixelMessage

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

    • responseType:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"

      Expected response type.

    • OptionaltimeoutMs: number

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

    Returns Promise<
        | "rssi"
        | "batteryLevel"
        | "blink"
        | "none"
        | "whoAreYou"
        | "iAmALCC"
        | "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"
        | 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"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"
          | 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"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"
          | 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"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"

      Type of the message to expect.

    • OptionaltimeoutMs: number

      Timeout before aborting the wait.

    Returns Promise<
        | "rssi"
        | "batteryLevel"
        | "blink"
        | "none"
        | "whoAreYou"
        | "iAmALCC"
        | "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"
        | 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 ChargerEventMap for the list of events and their associated data.

    Type Parameters

    • K extends
          | "battery"
          | "statusChanged"
          | "messageReceived"
          | "messageSend"

    Parameters

    • type: K

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

    • listener: EventReceiver<Readonly<{
          battery: Readonly<{
              isCharging: boolean;
              level: number;
          }>;
          messageReceived: ChargerMessages.ChargerMessageOrType;
          messageSend: ChargerMessages.ChargerMessageOrType;
          statusChanged: Readonly<{
              lastStatus: PixelStatus;
              reason?:
                  | "unknown"
                  | "peripheral"
                  | "success"
                  | "canceled"
                  | "notSupported"
                  | "timeout"
                  | "linkLoss"
                  | "bluetoothOff"
                  | "host";
              status: PixelStatus;
          }>;
      }>[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"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"

      The type of message to watch for.

    • listener: ((this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>, message:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"
          | PixelMessage) => void)

      The callback function.

        • (this, message): void
        • Parameters

          • this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>
          • message:
                | "rssi"
                | "batteryLevel"
                | "blink"
                | "none"
                | "whoAreYou"
                | "iAmALCC"
                | "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"
                | 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"

    Parameters

    Returns void

  • Requests the Charger 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<Charger>

    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<Charger>

    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"

    Parameters

    • propertyName: K

      Event name.

    Returns void

  • Asynchronously gets the Charger 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 ChargerEventMap for the list of events and their associated data.

    Type Parameters

    • K extends
          | "battery"
          | "statusChanged"
          | "messageReceived"
          | "messageSend"

    Parameters

    • type: K

      A case-sensitive string representing the event type.

    • listener: EventReceiver<Readonly<{
          battery: Readonly<{
              isCharging: boolean;
              level: number;
          }>;
          messageReceived: ChargerMessages.ChargerMessageOrType;
          messageSend: ChargerMessages.ChargerMessageOrType;
          statusChanged: Readonly<{
              lastStatus: PixelStatus;
              reason?:
                  | "unknown"
                  | "peripheral"
                  | "success"
                  | "canceled"
                  | "notSupported"
                  | "timeout"
                  | "linkLoss"
                  | "bluetoothOff"
                  | "host";
              status: PixelStatus;
          }>;
      }>[K]>

      The callback function to unregister.

    Returns void

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

    Parameters

    • msgType:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"

      The type of message to watch for.

    • listener: ((this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>, msg:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"
          | PixelMessage) => void)

      The callback function to unregister.

        • (this, msg): void
        • Parameters

          • this: PixelConnect<PixelConnectMutableProps, PixelInfoWithStatus, string>
          • msg:
                | "rssi"
                | "batteryLevel"
                | "blink"
                | "none"
                | "whoAreYou"
                | "iAmALCC"
                | "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"
                | 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"

    Parameters

    Returns void

  • Requests the Charger to change its name.

    Parameters

    • name: string

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

    Returns Promise<void>

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

  • Requests the Charger 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 Charger and wait for a specific response.

    Parameters

    • msgOrTypeToSend: ChargerMessages.ChargerMessageOrType

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

    • responseType:
          | "rssi"
          | "batteryLevel"
          | "blink"
          | "none"
          | "whoAreYou"
          | "iAmALCC"
          | "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"

      Expected response type.

    • OptionaltimeoutMs: number

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

    Returns Promise<ChargerMessages.ChargerMessageOrType>

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

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

    Type Parameters

    • T extends PixelMessage

    Parameters

    • msgOrTypeToSend: ChargerMessages.ChargerMessageOrType

      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 Charger.

    Parameters

    • msgOrType: ChargerMessages.ChargerMessageOrType

      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.

  • Update Charger 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"
          | "colorway"
          | "dieType"
          | "rollState"
          | "currentFace"
          | "currentFaceIndex">>

      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.