/// <inheritdoc />
        public void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
        {
            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                           ? _channelBridge.Run32(
                    hubHandle,
                    1000 / 20,
                    handler,
                    userData,
                    out errorHandle)
                           : _channelBridge.Run64(
                    hubHandle,
                    1000 / 20,
                    handler,
                    userData,
                    out errorHandle);

                return(MyoCommandResult.Create(result, errorHandle));
            });

            command.Execute();
        }
Пример #2
0
        /// <inheritdoc />
        public void Vibrate(VibrationType type)
        {
            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                        ? _myoDeviceBridge.Vibrate32(_handle, type, out errorHandle)
                        : _myoDeviceBridge.Vibrate64(_handle, type, out errorHandle);

                return(MyoCommandResult.Create(
                           result,
                           errorHandle));
            });

            command.Execute();
        }
Пример #3
0
        /// <inheritdoc />
        public void RequestRssi()
        {
            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                        ? _myoDeviceBridge.RequestRssi32(_handle, out errorHandle)
                        : _myoDeviceBridge.RequestRssi64(_handle, out errorHandle);

                return(MyoCommandResult.Create(
                           result,
                           errorHandle));
            });

            command.Execute();
        }
        /// <inheritdoc />
        public IntPtr InitializeMyoHub(string applicationIdentifier)
        {
            var hubPointer = IntPtr.Zero;

            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                        ? _channelBridge.InitHub32(out hubPointer, applicationIdentifier, out errorHandle)
                        : _channelBridge.InitHub64(out hubPointer, applicationIdentifier, out errorHandle);

                return(MyoCommandResult.Create(result, errorHandle));
            });

            command.Execute();
            return(hubPointer);
        }
        /// <inheritdoc />
        public void ShutdownMyoHub(IntPtr hubPointer)
        {
            if (hubPointer == IntPtr.Zero)
            {
                return;
            }

            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                       ? _channelBridge.ShutdownHub32(hubPointer, out errorHandle)
                       : _channelBridge.ShutdownHub64(hubPointer, out errorHandle);

                return(MyoCommandResult.Create(result, errorHandle));
            });

            command.Execute();
        }
Пример #6
0
        /// <inheritdoc />
        public void SetEmgStreaming(bool enabled)
        {
            var streamEmgType = enabled
                ? StreamEmgType.Enabled
                : StreamEmgType.Disabled;

            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                         ? _myoDeviceBridge.StreamEmg32(_handle, streamEmgType, out errorHandle)
                         : _myoDeviceBridge.StreamEmg64(_handle, streamEmgType, out errorHandle);

                return(MyoCommandResult.Create(
                           result,
                           errorHandle));
            });

            command.Execute();
        }