/// <summary> /// Sends blink LED animation request /// </summary> /// <param name='ledMask'> /// which LEDs to run animation on /// </param> /// <param name='priority'> /// animation with lower value overrides other, values: 0 - 255 /// </param> /// <param name='color'> /// color to be blinked /// </param> /// <param name='ledOnPeriod'> /// time in ms LED is ON, values: 0 - 65535 /// </param> /// <param name='ledCyclePeriod'> /// time in ms one blink cycle lasts, values: 0 - 65535 /// </param> /// <param name='blinkNumber'> /// number of blinks, values: 0 - 255 /// </param> public void runBlinkAnimation(DicePlusConnector.LedFace ledMask, int priority, Color color, int ledOnPeriod, int ledCyclePeriod, int blinkNumber) { dpc.runBlinkAnimation(this, ledMask, priority, color, ledOnPeriod, ledCyclePeriod, blinkNumber); }
public DicePlus(DicePlusConnector dpc, string address) { this.dpc = dpc; this.address = address; }
public void onSubscriptionChangeStatus(DicePlusConnector.DataSource dataSource, string message) { foreach (IDicePlusListener listener in listeners) { listener.onSubscriptionChangeStatus(this, dataSource, message); } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } if (persistSceneTransitions) { DontDestroyOnLoad(transform.gameObject); } if (create() == false) { Debug.LogError("DICE+ wrapper initialization failed"); initialized = true; } }
public void onBluetoothStateChanged(DicePlusConnector.BluetoothState btstate) { if (btstate != DicePlusConnector.BluetoothState.READY) { //TODO remove jak sdk beda zminione DicePlusConnector.Instance.disconnectAll(); } if (state != State.ROLLER) { if (btstate == DicePlusConnector.BluetoothState.READY) { DicePlusAnimator.Instance.runSearchingAnimation(true); setState(State.DISCONNECTED); } else { DicePlusAnimator.Instance.runBluetoothDisabled(); setState(State.NO_BLUETOOTH); } } }
/// <summary> /// Sends setMode packet to the given die /// </summary> /// <param name='mode'> /// mode to set /// </param> public void setMode(DicePlusConnector.DieMode mode) { dpc.setMode(this, mode); }
/// <summary> /// Subscribes to magnetometer readouts and configures sensor. /// </summary> /// <param name='freq'> /// readout frequency (in Hz), values: 1 - 30 /// </param> /// <param name='type'> /// a readout type /// </param> public void subscribeMagnetometerReadouts(int freq, DicePlusConnector.MagnetometerReadoutType type) { dpc.subscribeMagnetometerReadouts(this, freq, type); }
public void onBatteryState(DicePlus dicePlus, DicePlusConnector.BatteryState state, int percentage, bool low, string errorMsg) { }
public void onLedState(DicePlus dicePlus, long time, DicePlusConnector.LedFace ledMask, long animationId, int type, string errorMsg) { }
public void onSubscriptionChangeStatus(DicePlus dicePlus, DicePlusConnector.DataSource dataSource, string errorMsg) { }
void IDicePlusConnectorListener.onBluetoothStateChanged(DicePlusConnector.BluetoothState state) { }
public void onPowerMode(DicePlus dicePlus, long time, DicePlusConnector.PowerMode mode, string errorMsg) { }
public void onBluetoothStateChanged(DicePlusConnector.BluetoothState state) { // throw new System.NotImplementedException (); }
/// <summary> /// Sends fade LED animation request /// </summary> /// <param name='ledMask'> /// which LEDs to run animation on /// </param> /// <param name='priority'> /// animation with lower value overrides other, values: 0 - 255 /// </param> /// <param name='color'> /// color to be faded /// </param> /// <param name='fadeInOutTime'> /// time in ms LED is fading in/out, values: 0 - 65535 /// </param> /// <param name='pauseTime'> /// time in ms LED stays at full bright before fading out, values: 0 - 65535 /// </param> public void runFadeAnimation(DicePlusConnector.LedFace ledMask, int priority, Color color, int fadeInOutTime, int pauseTime) { dpc.runFadeAnimation(this, ledMask, priority, color, fadeInOutTime, pauseTime); }
public virtual void onBluetoothStateChanged(DicePlusConnector.BluetoothState state) { }
/// <summary> /// Sends standard LED animation request /// </summary> /// <param name='ledMask'> /// which LEDs to run animation on /// </param> /// <param name='priority'> /// animation with lower value overrides other, values: 0 - 255 /// </param> /// <param name='animation'> /// standard animation type /// </param> public void runStandardAnimation(DicePlusConnector.LedFace ledMask, int priority, DicePlusConnector.AnimationType animation) { dpc.runStandardAnimation(this, ledMask, priority, animation); }
public void onBatteryState(DicePlusConnector.BatteryState status, int percentage, bool low, string errorMsg) { foreach (IDicePlusListener listener in listeners) { listener.onBatteryState(this, status, percentage, low, errorMsg); } }
/// <summary> /// Subscribes to accelerometer readouts and configure sensor /// </summary> /// <param name='readFrequency'> /// readout frequency (in Hz), values: 1 - 60 /// </param> /// <param name='readoutType'> /// a readout filter type /// </param> public void subscribeAccelerometerReadouts(int readFrequency, DicePlusConnector.AccelerometerReadoutType readoutType) { dpc.subscribeAccelerometerReadouts(this, readFrequency, readoutType); }
public void onLedState(long time, DicePlusConnector.LedFace ledMask, long animationId, int type, string errorMsg) { foreach (IDicePlusListener listener in listeners) { listener.onLedState(this, time, ledMask, animationId, type, errorMsg); } }
/// <summary> /// Sends standard LED animation request /// </summary> /// <param name='dicePlus'> /// the die to which to send command/request /// </param> /// <param name='ledMask'> /// which LEDs to run animation on /// </param> /// <param name='priority'> /// animation with lower value overrides other, values: 0 - 255 /// </param> /// <param name='animation'> /// standard animation type /// </param> public void runStandardAnimation(DicePlus dicePlus, LedFace ledMask, int priority, DicePlusConnector.AnimationType animation) { #if UNITY_EDITOR #elif UNITY_IPHONE ios_runStandardAnimation(dicePlus.address, (int)ledMask, priority, (int)animation); #elif UNITY_ANDROID if (dmo != null) { dmo.Call("runStandardAnimation", new object [] {dicePlus.address, (int)ledMask, priority, (int)animation}); } #endif }
public void onPowerMode(long time, DicePlusConnector.PowerMode mode, string errorMsg) { foreach (IDicePlusListener listener in listeners) { listener.onPowerMode(this, time, mode, errorMsg); } }
void OnDestroy() { if (this == instance) { disconnectAll(); instance = null; } }
public override void onBatteryState(DicePlus dicePlus, DicePlusConnector.BatteryState batteryState, int percentage, bool low, string errorMsg) { if (percentage < battery && low) { if (state != State.CONNECTED) { DicePlusAnimator.Instance.runLowBatteryAnimation(); } else { StartCoroutine(DicePlusAnimator.Instance.lowBatteryCorutine()); } battery = percentage; } }