Instantiates a Pixel.
The session used to communicate with the Pixel.
Optional
info: Partial<Pick<PixelInfo, "pixelId" | "dieType" | "ledCount" | "colorway" | "firmwareDate">>Private
_disposePrivate
Readonly
_evPrivate
Readonly
_infoPrivate
_logPrivate
_logPrivate
_logPrivate
Readonly
_msgPrivate
Readonly
_sessionPrivate
_statusPrivate
Readonly
_versionsStatic
MutableGet the Pixel battery level (percentage).
This value is automatically updated when the die is connected.
Gets the color of the Pixel.
Get the die face value that is currently facing up.
Fudge die returns +1, 0 and -1. This value is automatically updated when the die is connected.
Get the 0-based index of the die face that is currently facing up.
This value is automatically updated when the die is connected.
PixelInfo.currentFaceIndex for more details.
Gets the number of faces of the Pixel.
Gets the die type of the Pixel.
Get the Pixel firmware build date.
Gets whether the Pixel battery is charging or not. Returns 'true' if fully charged but still on charger.
This value is automatically updated when the die is connected.
Shorthand property that indicates if the Pixel status is "ready".
Gets the number of LEDs for the Pixel, may be 0 until connected to device.
Toggle logging information about each send and received message.
Toggle logging the serialized (binary) data for each send and received message.
Set logger to use by this instance.
Get the Pixel name, may be empty until connected to device.
Gets the unique Pixel id of the device, may be 0 until connected.
Get the Pixel roll state.
This value is automatically updated when the die is connected.
Gets the last RSSI value notified by the Pixel.
Call () to automatically update the RSSI value.
Get the Pixel last known connection status.
Gets the unique id assigned by the system to the Pixel Bluetooth peripheral.
Private
_createPrivate
_deserializePrivate
_disposePrivate
_internalPrivate
_logPrivate
_logPrivate
_onPrivate
_tagPrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_updatePrivate
_uploadPrivate
_warnRegisters a listener function that will be called when the specified event is raised. See PixelEventMap for the list of events and their associated data.
A case-sensitive string representing the event type to listen for.
The callback function.
Registers a listener function that will be called on receiving raw messages of a given type from the Pixel.
The type of message to watch for.
The callback function.
Adds the given listener function for the specified property.
The name of the property.
The callback function.
Requests the Pixel to blink and wait for a confirmation.
Blink color.
Optional
opt: { Optional
count?: numberNumber of blinks.
Optional
duration?: numberTotal duration of the animation in milliseconds.
Optional
faceSelect which faces to light up.
Optional
fade?: numberAmount of in and out fading, 0: sharp transition, 1: maximum fading.
Optional
loopHow many times to loop the animation.
A promise that resolves once the die has confirmed receiving the message.
Asynchronously tries to connect to the die. Throws on connection error.
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.
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.
Protected
emitPlays the (single) LEDs animation included in the given data set.
The data set containing just one animation to play.
Optional
progressCallback: ((progress) => void)An optional callback that is called as the operation progresses with the progress in percent..
A promise that resolves once the transfer has completed.
Unregisters a listener from receiving events identified by the given event name. See PixelEventMap for the list of events and their associated data.
A case-sensitive string representing the event type.
The callback function to unregister.
Unregisters a listener from receiving raw messages of a given type.
The type of message to watch for.
The callback function to unregister.
Removes the given listener function for the specified property.
The name of the property.
The callback function to unregister.
Requests the Pixel to regularly send its measured RSSI value.
Whether to turn or turn off this feature.
The minimum time interval in milliseconds between two RSSI updates.
A promise that resolves once the message has been send.
Sends a message to the Pixel and wait for a specific response.
Message with the data to send or just a message type.
Expected response type.
Timeout in mill-seconds before aborting waiting for the response.
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.
Message with the data to send or just a message type.
Expected response class type.
A promise resolving to a message object of the expected type.
Sends a message to the Pixel.
Message with the data to send or just a message type.
Whether to request a confirmation that the message was received.
A promise that resolves once the message has been send.
Uploads the given data set of animations to the Pixel flash memory.
The data set to upload.
Optional
progressCallback: ((progress) => void)An optional callback that is called as the operation progresses with the progress in percent..
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.
The data set to upload.
Optional
progressCallback: ((progress) => void)An optional callback that is called as the operation progresses with the progress in percent..
A promise that resolves once the transfer has completed.
Update Pixel info from an external source such as scanning data.
The updated info.
The info will be updated only if the die is disconnected. Roll state and face index are updated only if both are provided.
Upload the given data to the Pixel.
The expected confirmation message type.
The data to send.
Optional
progressCallback: ((progress) => void)An optional callback that is called as the operation progresses with the progress in percent..
Whether to notify progress in percent or bytes.
A promise that resolves once the transfer has completed.
Private
waitWaits for a message from the Pixel.
Type of the message to expect.
Timeout before aborting the wait.
A promise with the received message of the expected type.
Generated using TypeDoc
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.