public static IHaptic GetHaptic() { if (Haptic == null) { try { Init = true; if (Application.platform == RuntimePlatform.Android) { Haptic = new AndroidHaptic(); BhapticsLogger.LogInfo("Android initialized."); } else { Haptic = new BhapticsHaptic(); BhapticsLogger.LogInfo("Initialized."); } } catch (System.Exception e) { } } return(Haptic); }
public void StartMotorPattern(ulong pMacAdress, ushort pDurationMs, float pIntensity, ushort pSleepMs, int pPatternIterations) { // Cancel the Previous Task if Any. if (_motorPatternCancellationToken != null) { _motorPatternCancellationToken.Cancel(); } // Run the new Task. _motorPatternCancellationToken = new CancellationTokenSource(); Task.Run(() => { IMetaWearBoard board = _mwBoardsManager.GetBoard(pMacAdress); if (board != null) { IHaptic haptic = board.GetModule <IHaptic>(); if (haptic != null) { // Set 120ms as the minimal duration between Bluetooth' stream of successives commands. // Below this value, pattern can be broken by pushing too frequently on the BLE connection. // Better solution should be to implement the vibration pattern directly on the MetaWearBoard. int sleep = Math.Max((int)pSleepMs, 120) + pDurationMs; while (pPatternIterations-- > 0) { haptic.StartMotor(pDurationMs, pIntensity); Thread.Sleep(sleep); } } } }, _motorPatternCancellationToken.Token); }
public Proc_Haptics(IHaptic haptic, ConcurrentQueue <Joints> inStream, List <AmplitudeModulationControlPoint> ampPoints, List <int> times) { haptics = haptic; jointsStream = inStream; targets = ampPoints; remainingTimes = times; uh_time = GBL.UH_TIME; }
public static void Dispose() { if (Haptic != null) { Init = false; Haptic.TurnOff(); BhapticsLogger.LogInfo("Dispose() bHaptics plugin."); Haptic.Dispose(); Haptic = null; } }
public static void HapticSoft() { if (haptic == null) { haptic = CreateHaptics(); } if (haptic != null) { haptic.Soft(); } }
public static void HapticBounce() { if (haptic == null) { haptic = CreateHaptics(); } if (haptic != null) { haptic.Bounce(); } }
public static void HapticSoft(uint period) { if (haptic == null) { haptic = CreateHaptics(); } if (haptic != null) { haptic.Soft(period); } }
public void StartBuzzer(ulong pMacAdress, ushort pDurationMs) { IMetaWearBoard board = _mwBoardsManager.GetBoard(pMacAdress); if (board != null) { IHaptic haptic = board.GetModule <IHaptic>(); if (haptic != null) { haptic.StartBuzzer(pDurationMs); } } }
public static IHaptic GetHaptic() { if (Haptic == null) { Init = true; if (Application.platform == RuntimePlatform.Android) { BhapticsLogger.LogInfo("Android initialized."); Haptic = new AndroidHaptic(); } else { BhapticsLogger.LogInfo("Initialized."); Haptic = new BhapticsHaptic(); } } return(Haptic); }
public override void SetUp() { base.SetUp(); haptic = metawear.GetModule <IHaptic>(); }
public async override Task SetUp() { await base.SetUp(); haptic = metawear.GetModule <IHaptic>(); }