//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); } }
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 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(); }
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 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; }; }