private void initMyo() { IsEnabledMyo = true; try { var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); var hub = MyoSharp.Device.Hub.Create(channel); // listen for when the Myo connects hub.MyoConnected += (sender, e1) => { Debug.WriteLine("Myo {0} has connected!", e1.Myo.Handle); e1.Myo.Vibrate(VibrationType.Short); e1.Myo.Unlock(UnlockType.Hold); e1.Myo.PoseChanged += Myo_PoseChanged; }; // listen for when the Myo disconnects hub.MyoDisconnected += (sender, e1) => { Debug.WriteLine("It looks like {0} arm Myo has disconnected!", e1.Myo.Arm); e1.Myo.PoseChanged -= Myo_PoseChanged; }; channel.StartListening(); } catch (Exception ex) { Debug.Write($"Myo Error : {ex}"); } }
public void btnCheckConnection_Click(object sender, RoutedEventArgs e) { // communication, device, exceptions, poses // create the channel _myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); // create the hub with the channel _myoHub = MyoSharp.Device.Hub.Create(_myoChannel); // create the event handlers for connect and disconnect _myoHub.MyoConnected += _myoHub_MyoConnected; _myoHub.MyoDisconnected += _myoHub_MyoDisconnected; // start listening _myoChannel.StartListening(); // create the channel _myoChannel1 = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); // create the hub with the channel _myoHub1 = MyoSharp.Device.Hub.Create(_myoChannel1); // create the event handlers for connect and disconnect _myoHub1.MyoConnected += _myoHub_MyoConnected; _myoHub1.MyoDisconnected += _myoHub_MyoDisconnected; // start listening _myoChannel1.StartListening(); }
private void frmMain_Load(object sender, EventArgs e) { Ojw.CMessage.Init(txtMessage); // Graph Init m_CGrap = new Ojw.CGraph(lbGraph, lbGraph.Width, Color.White, null, Color.Red, Color.Blue, Color.Green, Color.Cyan, Color.Violet, Color.Purple, Color.Magenta, Color.Orange ); #region Myo m_myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); m_myoHub = Hub.Create(m_myoChannel); // 이벤트 등록 m_myoHub.MyoConnected += new EventHandler <MyoEventArgs>(myoHub_MyoConnected); m_myoHub.MyoDisconnected += new EventHandler <MyoEventArgs>(myoHub_MyoDisconnected); // start listening for Myo data m_myoChannel.StartListening(); #endregion Myo }
public AdductionAbductionFlexionView() { InitializeComponent(); // create a hub that will manage Myo devices for us channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create())); hub = Hub.Create(channel); { //set a bpoint here, gets triggered // listen for when the Myo connects hub.MyoConnected += (sender, e) => { //set a bpoint here, doesn't get triggered this.Dispatcher.Invoke((Action)(() => { statusTbx.Text = "Myo has connected! " + e.Myo.Handle; //Console.WriteLine("Myo {0} has connected!", e.Myo.Handle); e.Myo.Vibrate(VibrationType.Short); })); }; // listen for when the Myo disconnects hub.MyoDisconnected += (sender, e) => { this.Dispatcher.Invoke((Action)(() => { statusTbx.Text = "Myo has disconnected!"; //Console.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm); e.Myo.Vibrate(VibrationType.Medium); })); }; // start listening for Myo data channel.StartListening(); } }
private static void Main() { // create a hub that will manage Myo devices for us using (var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (var hub = Hub.Create(channel)) { // listen for when the Myo connects hub.MyoConnected += (sender, e) => { Console.WriteLine("Myo {0} has connected!", e.Myo.Handle); e.Myo.Vibrate(VibrationType.Short); e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.Locked += Myo_Locked; e.Myo.Unlocked += Myo_Unlocked; }; // listen for when the Myo disconnects hub.MyoDisconnected += (sender, e) => { Console.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm); e.Myo.PoseChanged -= Myo_PoseChanged; e.Myo.Locked -= Myo_Locked; e.Myo.Unlocked -= Myo_Unlocked; }; // start listening for Myo data channel.StartListening(); // wait on user input ConsoleHelper.UserInputLoop(hub); } }
public void InitMyoManagerHub(MainWindow m) { this.mWindow = m; channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); hub = Hub.Create(channel); // listen for when the Myo connects hub.MyoConnected += (sender, e) => { Debug.WriteLine("Myo {0} has connected!", e.Myo.Handle); e.Myo.Vibrate(VibrationType.Short); e.Myo.EmgDataAcquired += Myo_EmgDataAcquired; e.Myo.OrientationDataAcquired += Myo_OrientationAcquired; e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.SetEmgStreaming(true); }; // listen for when the Myo disconnects hub.MyoDisconnected += (sender, e) => { Debug.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm); e.Myo.SetEmgStreaming(false); e.Myo.EmgDataAcquired -= Myo_EmgDataAcquired; }; // start listening for Myo data channel.StartListening(); }
public void ShutdownMyoHub_ValidParameters_ExpectedBridgeCalls() { // Setup IntPtr errorHandle; IntPtr myoHandle = new IntPtr(123); var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); bridge .Setup(x => x.ShutdownHub32(myoHandle, out errorHandle)) .Returns(MyoResult.Success); bridge .Setup(x => x.ShutdownHub64(myoHandle, out errorHandle)) .Returns(MyoResult.Success); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); errorHandlerDriver .Setup(x => x.FreeMyoError(IntPtr.Zero)); var driver = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); // Execute driver.ShutdownMyoHub(myoHandle); // Assert bridge.Verify(x => x.ShutdownHub32(myoHandle, out errorHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never()); bridge.Verify(x => x.ShutdownHub64(myoHandle, out errorHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once()); errorHandlerDriver.Verify(x => x.FreeMyoError(IntPtr.Zero), Times.Once()); }
public void GetEventType_ValidParameters_ExpectedBridgeCalls() { // Setup var eventHandle = new IntPtr(123); var eventType = MyoEventType.Paired; var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); bridge .Setup(x => x.EventGetType32(eventHandle)) .Returns(eventType); bridge .Setup(x => x.EventGetType64(eventHandle)) .Returns(eventType); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); var driver = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); // Execute var result = driver.GetEventType(eventHandle); // Assert Assert.Equal(eventType, result); bridge.Verify(x => x.EventGetType32(eventHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never()); bridge.Verify(x => x.EventGetType64(eventHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once()); }
public void GetEventTimestamp_ValidParameters_ExpectedBridgeCalls() { // Setup var eventHandle = new IntPtr(123); var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); bridge .Setup(x => x.EventGetTimestamp32(eventHandle)) .Returns(10000); bridge .Setup(x => x.EventGetTimestamp64(eventHandle)) .Returns(10000); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); var driver = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); // Execute var result = driver.GetEventTimestamp(eventHandle); // Assert Assert.Equal(new DateTime(1970, 1, 1).Add(TimeSpan.FromMilliseconds(10000 / 1000)), result); bridge.Verify(x => x.EventGetTimestamp32(eventHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never()); bridge.Verify(x => x.EventGetTimestamp64(eventHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once()); }
public void InitializeMyoHub_ValidParameters_ExpectedBridgeCalls() { // Setup IntPtr errorHandle = IntPtr.Zero; IntPtr myoHandle = new IntPtr(123); var applicationIdentifier = "com.myosharp.tests"; var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); bridge .Setup(x => x.InitHub32(out myoHandle, applicationIdentifier, out errorHandle)) .Returns(MyoResult.Success); bridge .Setup(x => x.InitHub64(out myoHandle, applicationIdentifier, out errorHandle)) .Returns(MyoResult.Success); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); errorHandlerDriver .Setup(x => x.FreeMyoError(errorHandle)); var driver = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); // Execute var result = driver.InitializeMyoHub(applicationIdentifier); // Assert Assert.Equal(new IntPtr(123), result); bridge.Verify(x => x.InitHub32(out myoHandle, applicationIdentifier, out errorHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never()); bridge.Verify(x => x.InitHub64(out myoHandle, applicationIdentifier, out errorHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once()); errorHandlerDriver.Verify(x => x.GetErrorString(errorHandle), Times.Never()); errorHandlerDriver.Verify(x => x.FreeMyoError(errorHandle), Times.Once()); }
public void Run_ValidParameters_ExpectedBridgeCalls() { // Setup var myoHandle = new IntPtr(123); var userData = new IntPtr(789); var bridge = new Mock <IChannelBridge>(); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); errorHandlerDriver .Setup(x => x.FreeMyoError(IntPtr.Zero)); var driver = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); MyoRunHandler handler = (_, __) => MyoRunHandlerResult.Continue; // Execute driver.Run(myoHandle, handler, userData); // Assert IntPtr errorHandle; bridge.Verify(x => x.Run32(myoHandle, 50, handler, userData, out errorHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never()); bridge.Verify(x => x.Run64(myoHandle, 50, handler, userData, out errorHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once()); errorHandlerDriver.Verify(x => x.FreeMyoError(IntPtr.Zero), Times.Once()); }
//Button Event that calls all necessary methods to connect to everything private void btnConnect_Click(object sender, RoutedEventArgs e) { // communication, device, exceptions, poses Disconnect.Visibility = Visibility.Visible; btnConnect.Visibility = Visibility.Collapsed; // Create the channel try { _MyoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); } catch (Exception) { UpdateUi("Myo Connect Must Be Turned On"); } // Create the hub with the channel _MyoHub = MyoSharp.Device.Hub.Create(_MyoChannel); // Create the event handlers for connect and disconnect _MyoHub.MyoConnected += _myoHub_MyoConnected; _MyoHub.MyoDisconnected += _myoHub_MyoDisconnected; // Start listening _MyoChannel.StartListening(); }
private static void Main() { // create a hub to manage Myos using (var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (var hub = Hub.Create(channel)) { // listen for when a Myo connects hub.MyoConnected += (sender, e) => { Console.WriteLine("Myo {0} has connected!", e.Myo.Handle); // for every Myo that connects, listen for special sequences var sequence = PoseSequence.Create( e.Myo, Pose.WaveOut, Pose.WaveIn); sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted; }; // start listening for Myo data channel.StartListening(); ConsoleHelper.UserInputLoop(hub); } }
public void InitMyoManagerHub() { LastExecution = DateTime.Now; channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); hub = Hub.Create(channel); // listen for when the Myo connects hub.MyoConnected += (sender, e) => { Debug.WriteLine("Myo {0} has connected!", e.Myo.Handle); e.Myo.Vibrate(VibrationType.Short); e.Myo.EmgDataAcquired += Myo_EmgDataAcquired; e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired; e.Myo.GyroscopeDataAcquired += Myo_GyroscopeDataAcquired; e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; e.Myo.SetEmgStreaming(true); }; // listen for when the Myo disconnects hub.MyoDisconnected += (sender, e) => { Debug.WriteLine("Oh no! It looks like {0} arm Myo has disconnected!", e.Myo.Arm); e.Myo.SetEmgStreaming(false); e.Myo.EmgDataAcquired -= Myo_EmgDataAcquired; e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired; e.Myo.GyroscopeDataAcquired -= Myo_GyroscopeDataAcquired; e.Myo.OrientationDataAcquired -= Myo_OrientationDataAcquired; }; // start listening for Myo data channel.StartListening(); }
private static void Main() { // create a hub to manage Myos using (var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (var hub = Hub.Create(channel)) { // listen for when a Myo connects hub.MyoConnected += (sender, e) => { Console.WriteLine("Myo {0} has connected!", e.Myo.Handle); // unlock the Myo so that it doesn't keep locking between our poses e.Myo.Unlock(UnlockType.Hold); // setup for the pose we want to watch for var pose = HeldPose.Create(e.Myo, Pose.Fist, Pose.FingersSpread); // set the interval for the event to be fired as long as // the pose is held by the user pose.Interval = TimeSpan.FromSeconds(0.5); pose.Start(); pose.Triggered += Pose_Triggered; }; // start listening for Myo data channel.StartListening(); ConsoleHelper.UserInputLoop(hub); } }
public void StartMyo() { this._myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); this._myoHub = Hub.Create((IChannelListener)this._myoChannel); this._myoHub.MyoConnected += new EventHandler <MyoEventArgs>(this._myoHub_MyoConnected); this._myoHub.MyoDisconnected += new EventHandler <MyoEventArgs>(this._myoHub_MyoDisconnected); this._myoChannel.StartListening(); }
public void Init() { HeldPoseInterval = TimeSpan.FromMilliseconds(500); _Channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); _Hub = Hub.Create(_Channel); }
public MyoManager() { Type = "Myo"; myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create())); myoHub = Hub.Create(myoChannel); myoHub.MyoConnected += MyoConnected; myoHub.MyoDisconnected += MyoDisconnected; }
public void InitializeMyo() { myoChannel = Channel.Create(ChannelDriver.Create (ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())) ); myoHub = Hub.Create(myoChannel); myoHub.MyoConnected += myoHub_MyoConnected; myoHub.MyoDisconnected += myoHub_MyoDisconnected; }
/// <summary> /// Creates the Myo channel. /// </summary> /// <returns>The Myo channel.</returns> private static IChannelListener CreateChannel() { var bridge = MyoErrorHandlerBridge.Create(); var errorHandlerDriver = MyoErrorHandlerDriver.Create(bridge); var channelBridge = ChannelBridge.Create(); var channelDriver = ChannelDriver.Create(channelBridge, errorHandlerDriver); return(Channel.Create(channelDriver)); }
// Creates a channel and hub for the MYO to connect to private void InitializeMyo() { myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); myoHub = Hub.Create(myoChannel); myoHub.MyoConnected += myoHub_MyoConnected; // runs method when MYO connects myoHub.MyoDisconnected -= myoHub_MyoDisconnected; // runs method when MYO disconnects myoChannel.StartListening(); }
// Creates a channel and hub for the second MYO to connect to private void InitializeMyo2() { myoChannel2 = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); myoHub2 = Hub.Create(myoChannel2); myoHub2.MyoConnected += myoHub2_MyoConnected; myoHub2.MyoDisconnected -= myoHub2_MyoDisconnected; myoChannel2.StartListening(); }
public void Create_ValidParameters_NewInstance() { // Setup var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict); // Execute var result = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object); // Assert Assert.NotNull(result); }
public void Create_NullMyoErrorHandlerDriver_ThrowsNullArgumentException() { // Setup var bridge = new Mock <IChannelBridge>(MockBehavior.Strict); // Execute Assert.ThrowsDelegate method = () => ChannelDriver.Create(bridge.Object, null); // Assert var exception = Assert.Throws <ArgumentNullException>(method); Assert.Equal("myoErrorHandlerDriver", exception.ParamName); }
public Form1() { InitializeComponent(); // we'll calculate all of our incoming data relative to this point in time _startTime = DateTime.UtcNow; // construct our graph _graphControl = new ZedGraphControl() { Dock = DockStyle.Fill }; _graphControl.MouseClick += GraphControl_MouseClick; _graphControl.GraphPane.Title.Text = "Myo EMG Data vs Time"; MasterPane Main_Pane = _graphControl.MasterPane; Main_Pane.PaneList.Clear(); _pointPairs = new PointPairList[NUMBER_OF_SENSORS]; _sortOrderZ = new List <LineItem>(); Panes = new PaneList(); for (int i = 0; i < 8; i++) { Panes.Add(new GraphPane()); Main_Pane.Add(Panes[i]); Panes[i].XAxis.Scale.MajorStep = 100; Panes[i].YAxis.Scale.Max = 200; Panes[i].YAxis.Scale.Min = -200; _pointPairs[i] = new PointPairList(); var dataPointLine = Panes[i].AddCurve("Sensor " + i, _pointPairs[i], DATA_SERIES_COLORS[i]); dataPointLine.Line.IsVisible = true; _sortOrderZ.Add(dataPointLine); } Controls.Add(_graphControl); // get set up to listen for Myo events _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); _hub = Hub.Create(_channel); _hub.MyoConnected += Hub_MyoConnected; _hub.MyoDisconnected += Hub_MyoDisconnected; }
private static void Main() { //list initialisation for (int i = 0; i < 8; i++) { emgList.Add(new List <int>()); } for (int i = 0; i < 3; i++) { deltaList.Add(new List <double>()); } //M2X initialisation M2XDevice device = m2x.Device("7787671fb86b9e2bc3ccaa23ad934bf6"); movement = device.Stream("patientMove"); streamFall = device.Stream("hasFallen"); patientState = device.Stream("patientState"); // Myo initialisation from SDK using (var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (var hub = Hub.Create(channel)) { // listenin and register event handlers hub.MyoConnected += (sender, e) => { //e.Myo.Lock(); Console.WriteLine("Myo has been connected!", e.Myo.Handle); //e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; e.Myo.AccelerometerDataAcquired += Myo_Accelerometer; e.Myo.EmgDataAcquired += MyoEmgDataHandler; e.Myo.SetEmgStreaming(true); e.Myo.Lock(); }; // disabling myo listening and handlers hub.MyoDisconnected += (sender, e) => { Console.WriteLine("Myo was disconnected, data logging wont work.", e.Myo.Arm); e.Myo.AccelerometerDataAcquired -= Myo_Accelerometer; e.Myo.EmgDataAcquired -= MyoEmgDataHandler; }; // start listening for Myo data channel.StartListening(); // wait on user input ConsoleHelper.UserInputLoop(hub); } }
static void Main(string[] args) { Console.WriteLine("Make sure that Myo is worn, warmed up, and synced..."); Console.WriteLine("Connecting to Myo and starting stream..."); // Create a hub to manage Myo devices using (IChannel channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (IHub myoHub = Hub.Create(channel)) { // Listen for when Myo connects myoHub.MyoConnected += (sender, e) => { Console.WriteLine("Connected to Myo {0}.", e.Myo.Handle); // Unlock Myo so it doesn't keep locking between poses e.Myo.Unlock(UnlockType.Hold); // Say hello to Myo e.Myo.Vibrate(VibrationType.Long); // Listen for pose changes e.Myo.PoseChanged += Myo_PoseChanged; // Listen for lock/unlock e.Myo.Locked += Myo_Locked; e.Myo.Unlocked += Myo_Unlocked; }; // Listen for when Myo disconnects myoHub.MyoDisconnected += (sender, e) => { Console.WriteLine("Disconnected from Myo {0}.", e.Myo.Handle); e.Myo.PoseChanged -= Myo_PoseChanged; e.Myo.Locked -= Myo_Locked; e.Myo.Unlocked -= Myo_Unlocked; }; channel.StartListening(); // Keep running Console.WriteLine("Press ESC to quit."); if (Console.ReadKey(true).Key == ConsoleKey.Escape) { myoHub.Dispose(); return; } } }
private void InitMyo() { CheckForIllegalCrossThreadCalls = false; m_myoChannel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); m_myoHub = Hub.Create(m_myoChannel); // 이벤트 등록 m_myoHub.MyoConnected += new EventHandler <MyoEventArgs>(myoHub_MyoConnected); // 접속했을 때 myoHub_MyoConnected() 함수가 동작하도록 등록 m_myoHub.MyoDisconnected += new EventHandler <MyoEventArgs>(myoHub_MyoDisconnected); // 접속했을 때 myoHub_MyoDisconnected() 함수가 동작하도록 등록 // start listening for Myo data m_myoChannel.StartListening(); }
private int btam = 10;//tamanho borracha #endregion public Pyo() { InitializeComponent(); //Criação do canal de comunicação com o Myo _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); //Hub que irá utilizar o canal _hub = Hub.Create(_channel); //Envento de conexão quando o Myo é conectado _hub.MyoConnected += (sender, e) => { MethodInvoker inv2 = delegate { this.buttonState.Image = Image.FromFile("C:\\Users\\Leandro\\OneDrive\\Documentos\\7 Periodo\\CG\\MyoSharp\\icon\\check-mark-8-16.png"); this.btnTam.Text = $"{this.tam}"; }; this.Invoke(inv2); e.Myo.Unlock(UnlockType.Hold); e.Myo.Vibrate(VibrationType.Short); e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.Locked += Myo_Locked; e.Myo.Unlocked += Myo_Unlocked; e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired; e.Myo.GyroscopeDataAcquired += Myo_GyroscopeDataAcquired; e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; InicializaListaOrientacao(e.Myo.Orientation); }; //Envento de conexão quando o Myo é conectado _hub.MyoDisconnected += (sender, e) => { MethodInvoker inv2 = delegate { this.buttonState.Image = Image.FromFile("C:\\Users\\Leandro\\OneDrive\\Documentos\\7 Periodo\\CG\\MyoSharp\\icon\\cross - 25x25.png"); this.btnTam.Text = $"{this.tam}"; }; this.Invoke(inv2); e.Myo.PoseChanged -= Myo_PoseChanged; e.Myo.Locked -= Myo_Locked; e.Myo.Unlocked -= Myo_Unlocked; e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired; e.Myo.GyroscopeDataAcquired -= Myo_GyroscopeDataAcquired; e.Myo.OrientationDataAcquired -= Myo_OrientationDataAcquired; }; }
public Form1() { InitializeComponent(); // get set up to listen for Myo events _channel = Channel.Create(ChannelDriver.Create(ChannelBridge.Create())); _hub = Hub.Create(_channel); _hub.MyoConnected += _hub_MyoConnected; _hub.MyoDisconnected += _hub_MyoDisconnected; //Starting the timer when the game starts //and setting the time internal to 2 sec ticks. timer.Interval = 2000; timer.Tick += timer_Tick; timer.Start(); }