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 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(); }
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); } }
protected virtual IMyoDeviceDriver CreateMyoDeviceDriver(IntPtr myoHandle, IMyoDeviceBridge myoDeviceBridge) { return(CreateMyoDeviceDriver( myoHandle, myoDeviceBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
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 static IChannelDriver Create(IChannelBridge channelBridge) { // Contract.Requires<ArgumentNullException>(channelBridge != null, "channelBridge"); Contract.Ensures(Contract.Result <IChannelDriver>() != null); return(Create(channelBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
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 Init() { HeldPoseInterval = TimeSpan.FromMilliseconds(500); _Channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); _Hub = Hub.Create(_Channel); }
public static IMyoDeviceDriver Create(IntPtr handle, IMyoDeviceBridge myoDeviceBridge) { //Contract.Requires<ArgumentException>(handle != IntPtr.Zero, "handle"); //Contract.Requires<ArgumentNullException>(myoDeviceBridge != null, "myoDeviceBridge"); Contract.Ensures(Contract.Result <IMyoDeviceDriver>() != null); return(Create(handle, myoDeviceBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
/// <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)); }
protected virtual IMyoDeviceDriver CreateMyoDeviceDriver(IntPtr myoHandle, IMyoDeviceBridge myoDeviceBridge) { Contract.Requires <ArgumentException>(myoHandle != IntPtr.Zero, "The handle to the Myo must be set."); Contract.Requires <ArgumentNullException>(myoDeviceBridge != null, "myoDeviceBridge"); Contract.Ensures(Contract.Result <IMyoDeviceDriver>() != null); return(CreateMyoDeviceDriver( myoHandle, myoDeviceBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
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; } } }
public MyoSoundControl(MainWindow Gui) { this.Window = Gui; //Channel und Hub (Schnittstelle) erzeugen this.Channel = MyoSharp.Communication.Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); this.Hub = MyoSharp.Device.Hub.Create(Channel); Hub.MyoConnected += (sender, e) => { this.myo = e.Myo; e.Myo.Vibrate(VibrationType.Long); e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.Locked += Myo_Locked; e.Myo.Unlocked += Myo_Unlocked; this.myo.Unlock(UnlockType.Hold); //Pose in Dictionary mit Sound verbinden (Soundplayerklasse extra) this.PoseToSound[Pose.Fist] = new SoundPlayer("./Sound/Mario.wav"); this.PoseToSound[Pose.WaveIn] = new SoundPlayer("./Sound/Glass.wav"); this.PoseToSound[Pose.WaveOut] = new SoundPlayer("./Sound/Slap.wav"); //Sequence //IPoseSequence sequence0 = PoseSequence.Create(e.Myo, Pose.Fist, Pose.FingersSpread); //sequence0.PoseSequenceCompleted += PoseSequenceCompleted; //this.PoseSequenceToSound[sequence0] = new SoundPlayer("./Sound/Mario.wav"); //IPoseSequence sequence1 = PoseSequence.Create(e.Myo, Pose.WaveIn, Pose.WaveOut); //sequence1.PoseSequenceCompleted += PoseSequenceCompleted; //this.PoseSequenceToSound[sequence1] = new SoundPlayer("./Sound/Slap.wav"); //IPoseSequence sequence2 = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn); //sequence2.PoseSequenceCompleted += PoseSequenceCompleted; //this.PoseSequenceToSound[sequence2] = new SoundPlayer("./Sound/Glass.wav"); }; Hub.MyoDisconnected += (sender, e) => { e.Myo.PoseChanged -= Myo_PoseChanged; e.Myo.Locked -= Myo_Locked; e.Myo.Unlocked -= Myo_Unlocked; }; }
private static void Main() { Console.SetCursorPosition(0, 0); Console.WriteLine("--- Estado ---"); Player.Init(); Console.SetCursorPosition(0, 2); Console.WriteLine("El reproductor ha sido inicializado"); Console.SetCursorPosition(0, 3); Console.WriteLine("--- Controles ---"); Console.SetCursorPosition(0, 6); Console.WriteLine("--- Posicionamiento ---"); Console.SetCursorPosition(0, 10); Console.WriteLine("--- Gestos ---"); Console.SetCursorPosition(0, 12); Console.WriteLine("Musica parada"); Console.SetCursorPosition(0, 13); Console.WriteLine("--- Bloqueo ---"); Console.SetCursorPosition(0, 1); using (var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())))) using (var hub = Hub.Create(channel)) { hub.MyoConnected += (sender, e) => { Console.WriteLine("Myo {0} está conectado!", e.Myo.Handle); e.Myo.Vibrate(VibrationType.Short); e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.Locked += Myo_Locked; e.Myo.Unlocked += Myo_Unlocked; }; hub.MyoDisconnected += (sender, e) => { Console.WriteLine("Oh no!, parece que el Myo del brazo {0} se ha desconectado!", e.Myo.Arm); e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; e.Myo.PoseChanged += Myo_PoseChanged; e.Myo.Locked -= Myo_Locked; e.Myo.Unlocked -= Myo_Unlocked; }; channel.StartListening(); ConsoleHelper.UserInputLoop(hub); } }
//Modified code from the Myo Sharp tutorial on GitHub //Available at: https://github.com/tayfuzun/MyoSharp public static void Myo_Start() { //Create a hub that will manage Myo devices for us var channel = Channel.Create( ChannelDriver.Create(ChannelBridge.Create(), MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); IHub 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.OrientationDataAcquired += Myo_OrientationDataAcquired; var pose = HeldPose.Create(e.Myo, Pose.Fist); pose.Interval = TimeSpan.FromSeconds(0.5); //For every Myo that connects, listen for special sequences var sequence = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn); sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted; }; //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.OrientationDataAcquired -= Myo_OrientationDataAcquired; }; //Start listening for Myo data channel.StartListening(); Console.WriteLine("Listening to channel..."); //Wait on user input ConsoleHelper.UserInputLoop(hub); }
private void StartMyo2() { Console.WriteLine("1111111111111111111111111111111111111111111111111111111111111"); bool MyoConnected = false; // 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); _waitHandle.Set(); e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired; }; // 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.OrientationDataAcquired -= Myo_OrientationDataAcquired; }; Console.WriteLine("2222222222222222222222222222222222222222222222222222222222222"); // start listening for Myo data channel.StartListening(); ConsoleRunner.UserInputHub(hub); _waitHandle.WaitOne(); abbSensor.Start(); } }
public MyoController(PoseManager poseManager) { _poseManager = poseManager; _timer.Interval = 100; _timer.Elapsed += OnTimedEvent; try { _myoChannel = Channel.Create( ChannelDriver.Create( ChannelBridge.Create(), MyoErrorHandlerDriver.Create( MyoErrorHandlerBridge.Create() ) )); _myoHub = Hub.Create(_myoChannel); _myoHub.MyoConnected += new EventHandler <MyoEventArgs>(MyoConnected); _myoHub.MyoDisconnected += new EventHandler <MyoEventArgs>(MyoDisconnected); _myoChannel.StartListening(); } catch (Exception) { throw new Exception("Unable to find a Myo!"); } }
private 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; myoChannel.StartListening(); }
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(); }
//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 void MyoSetup() { // 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.MyoDisconnected -= _myoHub_MyoDisconnected; _myoHub.MyoConnected += _myoHub_MyoConnected; // start listening _myoChannel.StartListening(); }
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; }
public static IChannelDriver Create(IChannelBridge channelBridge) { return(Create(channelBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
public static IMyoDeviceDriver Create(IntPtr handle, IMyoDeviceBridge myoDeviceBridge) { return(Create(handle, myoDeviceBridge, MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create()))); }
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 Form1() { InitializeComponent(); //comentário // 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 += (sender, e) => { MethodInvoker inv = delegate { this.label1.Text = $"Myo {e.Myo.Handle} conectado"; }; this.Invoke(inv); 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); }; // listen for when the Myo disconnects _hub.MyoDisconnected += (sender, e) => { var braco = e.Myo.Arm == Arm.Right ? "Direito" : e.Myo.Arm == Arm.Left ? "Esquerdo" : "Desconhecido"; MethodInvoker inv = delegate { this.label2.Text = $"Parece que o braco {braco} desconectou"; }; this.Invoke(inv); 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 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 void InitMyo() { #region Step1 // For Message Ojw.CMessage.Init(txtMessage); 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() 함수가 동작하도록 등록 #endregion Step1 // start listening for Myo data m_myoChannel.StartListening(); Ojw.CMessage.Write("Form Loaded..."); }
public void InitMyoManagerHub(MainWindow m) { lastExecutionEmg = DateTime.Now; lastExecutionVibrate = DateTime.Now; 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.AccelerometerDataAcquired += Myo_AccelerometerAcquired; e.Myo.GyroscopeDataAcquired += Myo_GyroscopeAcquired; 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; }; try { setValueNames(); myFeedback.feedbackReceivedEvent += MyFeedback_feedbackReceivedEvent; } catch (Exception e) { Debug.WriteLine("MyoManager error at connecting the hub"); } // start listening for Myo data channel.StartListening(); }