Documentation
    Preparing search index...

    Class PixelInfoNotifier<MutableProps, Type>Abstract

    Abstract implementation of PixelInfo type with the addition of events that are emitted when mutable properties change. The concrete implementation is responsible of calling the () function when a property is mutated.

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Type Parameters

      • MutableProps extends PixelInfoNotifierMutableProps = PixelInfoNotifierMutableProps
      • Type extends Readonly<
            {
                batteryLevel: number;
                colorway: | "unknown"
                | "onyxBlack"
                | "hematiteGrey"
                | "midnightGalaxy"
                | "auroraSky"
                | "clear"
                | "whiteAurora"
                | "electricGalaxy"
                | "custom";
                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;
            },
        > = Readonly<
            {
                batteryLevel: number;
                colorway: | "unknown"
                | "onyxBlack"
                | "hematiteGrey"
                | "midnightGalaxy"
                | "auroraSky"
                | "clear"
                | "whiteAurora"
                | "electricGalaxy"
                | "custom";
                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;
            },
        >

      Returns PixelInfoNotifier<MutableProps, Type>

    Properties

    isNotifier: true
    type: "die" | "charger" | "mpc" | "bootloader"
    MutablePropsList: readonly (
        | "name"
        | "systemId"
        | "pixelId"
        | "ledCount"
        | "colorway"
        | "dieType"
        | "firmwareDate"
        | "rssi"
        | "batteryLevel"
        | "isCharging"
        | "rollState"
        | "currentFace"
        | "currentFaceIndex"
    )[]

    Accessors

    • get batteryLevel(): number

      The Pixel battery level (percentage).

      Returns number

    • get colorway(): | "unknown"
      | "onyxBlack"
      | "hematiteGrey"
      | "midnightGalaxy"
      | "auroraSky"
      | "clear"
      | "whiteAurora"
      | "electricGalaxy"
      | "custom"

      The Pixel color.

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

    • get currentFace(): number

      The value of the die face that is currently facing up.

      Returns number

      • This value is always an integer number.
      • D10 returns values ranging from 0 to 9 included.
      • D00 returns 0, 10, 20, ..., 90.
      • Fudge die returns +1, 0 and -1.
    • get currentFaceIndex(): number

      The 0-based index of the die face that is currently facing up.

      Returns number

      Indices are continuous and follow the numerical order of the die faces values.

      A D20 die will have face indices ranging from 0 to 19.
      Index 0 corresponds to face 1 and index 19 to face 20.

      D10 and D00 share the same face indices but have different face values.
      Index 0 corresponds to face 0 of both dice types.
      Index 9 corresponds to face 9 for a D10 and to face 90 for a D00.

      The fudge die returns the following indices:
      - O and 5 for the "+" face .
      - 1 and 4 for the "-" face.
      - 2 and 3 for the "blank" face.
    • get dieType(): | "unknown"
      | "d4"
      | "d6"
      | "d8"
      | "d10"
      | "d00"
      | "d12"
      | "d20"
      | "d6pipped"
      | "d6fudge"

      The Pixel die type.

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

    • get firmwareDate(): Date

      The Pixel firmware build date.

      Returns Date

    • get isCharging(): boolean

      Whether the Pixel battery is charging or not. Set to 'true' if fully charged but still on charger.

      Returns boolean

    • get ledCount(): number

      The number of LEDs of the Pixel.

      Returns number

    • get name(): string

      The Pixels die name.

      Returns string

    • get pixelId(): number

      The unique Pixel id of the device.

      Returns number

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

      The Pixel roll state.

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

    • get rssi(): number

      The last RSSI value measured by the Pixel.

      Returns number

    • get systemId(): string

      The unique id assigned by the system to the Pixel Bluetooth peripheral.

      Returns string

    Methods

    • Adds the given listener function for the specified property.

      Type Parameters

      • K extends string

      Parameters

      • propertyName: K

        The name of the property.

      • listener: EventReceiver<Type>

        The callback function.

      Returns void

    • 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 string

      Parameters

      • propertyName: K

        Event name.

      Returns void

    • Removes the given listener function for the specified property.

      Type Parameters

      • K extends string

      Parameters

      • propertyName: K

        The name of the property.

      • listener: EventReceiver<Type>

        The callback function to unregister.

      Returns void