Pixels Plugin for Unity
Enable communications with Pixels dice using Bluetooth Low Energy.
Loading...
Searching...
No Matches
Systemic.Unity.Pixels Namespace Reference

A collection of C# classes for the Unity game engine that enables communications with Pixels dice. The Pixel class represents a die peripheral and the DiceBag static class implements methods for scanning for and connecting to Pixels. More...

Namespaces

namespace  Animations
 Set of types for manipulating Pixel LEDs animations data.
 
namespace  Messages
 Set of classes to represent all supported Pixel messages as well as en enum MessageType with all the message types and a marshaling helper PixelMessageMarshaling.
 
namespace  Profiles
 Set of types for manipulating Pixel animation profiles data.
 

Classes

class  ColorUIntUtils
 Helper static class that implements various color operations with the color information being stored as an unsigned 32 bits value. In related methods, the intensity is a byte value between 0 (black) and 255 (white). More...
 
class  DiceBag
 Static class that scan for and connect to Pixel dice. Scan and connection requests are counted, meaning that the same number of respectively scan cancellation and disconnection requests must be made for them to effectively happen. More...
 
class  DiceUtils
 Helper static class that implements various gamma operations on colors. More...
 
class  GammaUtils
 Helper static class that implements various gamma operations on colors. More...
 
class  Pixel
 Represents a Pixel die. More...
 
class  PixelBleUuids
 Pixel dice Bluetooth Low Energy UUIDs. More...
 

Enumerations

enum  PixelDieType : byte {
  Unknown = 0 , D4 , D6 , D8 ,
  D10 , D00 , D12 , D20 ,
  D6Pipped , D6Fudge
}
 The different types of dice.
 
enum  PixelColorway : byte {
  Unknown = 0 , OnyxBlack , HematiteGrey , MidnightGalaxy ,
  AuroraSky , Clear , WhiteAurora , Custom = 0xFF
}
 Available Pixels dice colorways.
 
enum  PixelRollState : byte {
  Unknown = 0 , Rolled , Handling , Rolling ,
  Crooked , OnFace
}
 Pixels dice roll states.
 
enum  PixelBatteryState : byte {
  Ok = 0 , Low , Charging , Done ,
  BadCharging , Error
}
 Pixel battery states. More...
 
enum  PixelConnectionState {
  Invalid = -1 , Available , Connecting , Identifying ,
  Ready , Disconnecting
}
 Pixel connection states. More...
 
enum  PixelError { None = 0 , ConnectionError , Disconnected }
 Identify an error encountered while communicating with a PixeL. More...
 

Functions

delegate void ConnectionResultCallback (Pixel pixel, bool ready, string error)
 Delegate for Pixel connection request result.
 
delegate void OperationResultCallback (bool success, string error)
 Delegate for Pixel operations result.
 
delegate void DataOperationResultCallback (byte[] data, string error)
 Delegate for Pixel operations returning some data.
 
delegate void OperationProgressCallback (Pixel pixel, float progress)
 Delegate for Pixel operations progress reporting.
 
delegate void ConnectionStateChangedEventHandler (Pixel pixel, PixelConnectionState state)
 Delegate for Pixel connection state events.
 
delegate void ErrorRaisedEventHandler (Pixel pixel, PixelError error)
 Delegate for Pixel communication error events.
 
delegate void AppearanceChangedEventHandler (Pixel pixel, int ledCount, PixelDieType dieType, PixelColorway colorway)
 Delegate for Pixel appearance setting changes.
 
delegate void RollStateChangedEventHandler (Pixel pixel, PixelRollState rollState, int face, int faceIndex)
 Delegate for Pixel roll events.
 
delegate void BatteryLevelChangedEventHandler (Pixel pixel, int batteryLevel, bool isCharging)
 Delegate for Pixel battery level changes.
 
delegate void RssiChangedEventHandler (Pixel pixel, int rssi)
 Delegate for Pixel RSSI changes.
 
delegate void TemperatureChangedEventHandler (Pixel pixel, float mcuTemperature, float batteryTemperature)
 Delegate for Pixel temperature changes.
 
delegate void TelemetryEventHandler (Pixel pixel, AccelerationFrame frame)
 Delegate for Pixel telemetry events.
 
delegate void NotifyUserCallback (Pixel pixel, string text, bool canCancel, System.Action< bool > userActionCallback)
 Delegate for Pixel requests to notify user of some message, with the option to cancel the operation.
 
delegate void PlayAudioClipCallback (Pixel pixel, uint clipId)
 Delegate for Pixel requests to play an audio clip.
 

Detailed Description

A collection of C# classes for the Unity game engine that enables communications with Pixels dice. The Pixel class represents a die peripheral and the DiceBag static class implements methods for scanning for and connecting to Pixels.

Enumeration Type Documentation

◆ PixelBatteryState

Pixel battery states.

Enumerator
Ok 

Battery looks fine, nothing is happening.

Low 

Battery level is low, notify user they should recharge.

Charging 

Battery is currently recharging.

Done 

Battery is full and finished charging.

BadCharging 

Coil voltage is bad, die is probably positioned incorrectly. Note that currently this state is triggered during transition between charging and not charging...

Error 

Charge state doesn't make sense (charging but no coil voltage detected for instance).

◆ PixelConnectionState

Pixel connection states.

Enumerator
Invalid 

This is the value right after creation.

Available 

This is a Pixel we knew about and scanned.

Connecting 

We are currently connecting to this Pixel.

Identifying 

Getting info from the Pixel, making sure it is valid to be used (correct firmware version, etc.).

Ready 

Pixel is ready for communications.

Disconnecting 

We are currently disconnecting from this Pixel.

◆ PixelError

Identify an error encountered while communicating with a PixeL.

Enumerator
None 

No error.

ConnectionError 

An error occurred during the connection.

Disconnected 

The Pixel is disconnected.

Function Documentation

◆ AppearanceChangedEventHandler()

delegate void Systemic.Unity.Pixels.AppearanceChangedEventHandler ( Pixel  pixel,
int  ledCount,
PixelDieType  dieType,
PixelColorway  colorway 
)

Delegate for Pixel appearance setting changes.

Parameters
pixelThe source of the event.
ledCountNumber of LEDs on the die.
dieTypeType of the die.
colorwayThe coloring of the die.

◆ BatteryLevelChangedEventHandler()

delegate void Systemic.Unity.Pixels.BatteryLevelChangedEventHandler ( Pixel  pixel,
int  batteryLevel,
bool  isCharging 
)

Delegate for Pixel battery level changes.

Parameters
pixelThe source of the event.
batteryLevelThe latest battery level reported by the die, in percent.
isChargingWhether or not the battery is reported as charging.

◆ ConnectionResultCallback()

delegate void Systemic.Unity.Pixels.ConnectionResultCallback ( Pixel  pixel,
bool  ready,
string  error 
)

Delegate for Pixel connection request result.

Parameters
pixelThe source of the event.
readyWhether the Pixel is ready for communications.
errorThe error if it failed to connect.

◆ ConnectionStateChangedEventHandler()

delegate void Systemic.Unity.Pixels.ConnectionStateChangedEventHandler ( Pixel  pixel,
PixelConnectionState  state 
)

Delegate for Pixel connection state events.

Parameters
pixelThe source of the event.
stateThe current connection sate.

◆ DataOperationResultCallback()

delegate void Systemic.Unity.Pixels.DataOperationResultCallback ( byte[]  data,
string  error 
)

Delegate for Pixel operations returning some data.

Parameters
dataThe resulting data.
errorThe error if the operation failed.

◆ ErrorRaisedEventHandler()

delegate void Systemic.Unity.Pixels.ErrorRaisedEventHandler ( Pixel  pixel,
PixelError  error 
)

Delegate for Pixel communication error events.

Parameters
pixelThe source of the event.
errorThe type of error.

◆ NotifyUserCallback()

delegate void Systemic.Unity.Pixels.NotifyUserCallback ( Pixel  pixel,
string  text,
bool  canCancel,
System.Action< bool >  userActionCallback 
)

Delegate for Pixel requests to notify user of some message, with the option to cancel the operation.

Parameters
pixelThe source of the event.
textThe text to display to the user.
canCancelWhether the user may cancel the operation.
userActionCallbackThe callback to run once the user has acknowledged the message. False may be passed to cancel the operation when applicable.

◆ OperationProgressCallback()

delegate void Systemic.Unity.Pixels.OperationProgressCallback ( Pixel  pixel,
float  progress 
)

Delegate for Pixel operations progress reporting.

Parameters
pixelThe source of the event.
progressThe progress, between 0 and 1 included.

◆ OperationResultCallback()

delegate void Systemic.Unity.Pixels.OperationResultCallback ( bool  success,
string  error 
)

Delegate for Pixel operations result.

Parameters
successWhether the operation succeeded.
errorThe error if the operation failed.

◆ PlayAudioClipCallback()

delegate void Systemic.Unity.Pixels.PlayAudioClipCallback ( Pixel  pixel,
uint  clipId 
)

Delegate for Pixel requests to play an audio clip.

Parameters
pixelThe source of the event.
clipIdThe audio clip id to play.

◆ RollStateChangedEventHandler()

delegate void Systemic.Unity.Pixels.RollStateChangedEventHandler ( Pixel  pixel,
PixelRollState  rollState,
int  face,
int  faceIndex 
)

Delegate for Pixel roll events.

Parameters
pixelThe source of the event.
rollStateThe roll state.
faceThe face that is up (fudge die returns +1, 0 and -1).
faceIndexThe 0-based index of the die face that is up.

◆ RssiChangedEventHandler()

delegate void Systemic.Unity.Pixels.RssiChangedEventHandler ( Pixel  pixel,
int  rssi 
)

Delegate for Pixel RSSI changes.

Parameters
pixelThe source of the event.
rssiThe latest RSSI in dBm reported by the die.

◆ TelemetryEventHandler()

delegate void Systemic.Unity.Pixels.TelemetryEventHandler ( Pixel  pixel,
AccelerationFrame  frame 
)

Delegate for Pixel telemetry events.

Parameters
pixelThe source of the event.
frameThe latest acceleration data reported by the die.

◆ TemperatureChangedEventHandler()

delegate void Systemic.Unity.Pixels.TemperatureChangedEventHandler ( Pixel  pixel,
float  mcuTemperature,
float  batteryTemperature 
)

Delegate for Pixel temperature changes.

Parameters
pixelThe source of the event.
temperatureThe latest temperature for the micro-controller and the battery in Celsius degrees reported by the die.