Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public static void Dispose()
 {
     if (Haptic != null)
     {
         Init = false;
         Haptic.TurnOff();
         BhapticsLogger.LogInfo("Dispose() bHaptics plugin.");
         Haptic.Dispose();
         Haptic = null;
     }
 }
Ejemplo n.º 5
0
 public static void HapticSoft()
 {
     if (haptic == null)
     {
         haptic = CreateHaptics();
     }
     if (haptic != null)
     {
         haptic.Soft();
     }
 }
Ejemplo n.º 6
0
 public static void HapticBounce()
 {
     if (haptic == null)
     {
         haptic = CreateHaptics();
     }
     if (haptic != null)
     {
         haptic.Bounce();
     }
 }
Ejemplo n.º 7
0
        public static void HapticSoft(uint period)
        {
            if (haptic == null)
            {
                haptic = CreateHaptics();
            }

            if (haptic != null)
            {
                haptic.Soft(period);
            }
        }
Ejemplo n.º 8
0
        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);
                }
            }
        }
Ejemplo n.º 9
0
    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>();
        }
Ejemplo n.º 11
0
        public async override Task SetUp()
        {
            await base.SetUp();

            haptic = metawear.GetModule <IHaptic>();
        }