static void Main(string[] args) { try { using (var hub = new Hub()) { Console.WriteLine("Attempting to find a Myo..."); IMyo myo = hub.WaitForMyo(TimeSpan.FromSeconds(10)); if (myo == null) throw new TimeoutException("Unable to find a Myo!"); Console.WriteLine("Connected to a Myo armband!\n"); hub.MyoUnpaired += OnUnpair; hub.RecognizedArm += OnRecognizedArm; hub.LostArm += OnLostArm; myo.PoseChanged += OnPoseChanged; myo.OrientationDataAcquired += OnOrientationData; while (true) { hub.Run(TimeSpan.FromMilliseconds(1000 / 20)); PrintDisplay(); } } } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); Console.WriteLine("Press any key to continue."); Console.ReadKey(); } }
void Create() { _myoState = new MyoState(); MyoFound = false; for (int i = 0; i < 30 && _myo == null; i++) { Console.Write("\r"); Console.Write("Attempting to find a myo, attempt {0}", i); _myo = Context.Instance.Hub.GetMyo(); } if (_myo == null) { return; } MyoFound = true; //we will vibrate whenever a new MyomiMyo is created _myo.AccelerometerDataAcquired += OnAccelerometerData; _myo.GyroscopeDataAquired += OnGyroscopeData; _myo.OrientationDataAcquired += OnOrientationData; _myo.PoseChanged += OnPoseChanged; _myo.RecognizedArm += OnRecognizedArm; _myo.LostArm += OnLostArm; if (_isOnArm) { InstanceCollectionEnabled = true; } }
private void Myo_PoseChanged(object sender, PoseEventArgs e) { var samePose = _lastPose == e.Pose; _lastPose = e.Pose; _triggeringMyo = e.Myo; lock (_timer) { if (_timerAlive) { return; } if (samePose && _targetPoses.Contains(e.Pose)) { if (_timerPaused) { _timerPaused = false; _timer.Start(); } } else { _timerPaused = true; _timer.Stop(); } } }
/// <summary> /// Initializes a new instance of the <see cref="RssiEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="rssi">The received signal strength indicator (RSSI).</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi) : base(myo, timestamp) { Contract.Requires <ArgumentNullException>(myo != null, "myo"); this.Rssi = rssi; }
/// <summary> /// Initialize the Myo input module. Will throw an exception if no Myo is available /// </summary> public MyoInput() { Active = true; hub = new Hub("de.dhbw.MyoPilot"); myo = hub.WaitForMyo(TimeSpan.FromSeconds(5)); if (myo == null) { throw new TimeoutException("Unable to find a Myo!"); } hub.MyoUnpaired += OnUnpair; myo.PoseChanged += OnPoseChanged; myo.OrientationDataAcquired += OnOrientationData; myo.RecognizedArm += OnRecognizedArm; myo.LostArm += OnLostArm; myo.Unlock(UnlockType.Hold); // hub.Run() needs to run permanently in order to receive events from the Myo Thread worker = new Thread(hub.Run) { IsBackground = true, Name = "MyoBackgroundWorker" }; worker.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="MyoEventArgs" /> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>. /// </exception> public MyoEventArgs(IMyo myo, DateTime timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); _myo = myo; _timestamp = timestamp; }
/// <summary> /// Initializes a new instance of the <see cref="PoseEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="pose">The pose that the Myo detected.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); this.Pose = pose; }
/// <summary> /// Initializes a new instance of the <see cref="PoseEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="pose">The pose that the Myo detected.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose) : base(myo, timestamp) { // Contract.Requires<ArgumentNullException>(myo != null, "myo"); this.Pose = pose; }
/// <summary> /// Initializes a new instance of the <see cref="MyoEventArgs" /> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>. /// </exception> public MyoEventArgs(IMyo myo, DateTime timestamp) { Contract.Requires <ArgumentNullException>(myo != null, "myo"); _myo = myo; _timestamp = timestamp; }
/// <summary> /// Initializes a new instance of the <see cref="RssiEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="rssi">The received signal strength indicator (RSSI).</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); this.Rssi = rssi; }
/// <summary> /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null. /// </exception> public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData) : base(myo, timestamp) { Contract.Requires <ArgumentNullException>(myo != null, "myo"); Contract.Requires <ArgumentNullException>(accelerometerData != null, "accelerometerData"); this.Accelerometer = accelerometerData; }
/// <summary> /// Initializes a new instance of the <see cref="EmgDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised this event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="emgData">The EMG data that corresponds to this event. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="emgData"/> is null. /// </exception> public EmgDataEventArgs(IMyo myo, DateTime timestamp, IEmgData emgData) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(emgData != null, "emgData"); this.EmgData = emgData; }
/// <summary> /// Initializes a new instance of the <see cref="EmgDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised this event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="emgData">The EMG data that corresponds to this event. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="emgData"/> is null. /// </exception> public EmgDataEventArgs(IMyo myo, DateTime timestamp, IEmgData emgData) : base(myo, timestamp) { //Contract.Requires<ArgumentNullException>(myo != null, "myo"); //Contract.Requires<ArgumentNullException>(emgData != null, "emgData"); this.EmgData = emgData; }
/// <summary> /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null. /// </exception> public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(accelerometerData != null, "accelerometerData"); this.Accelerometer = accelerometerData; }
/// <summary> /// Initializes a new instance of the <see cref="ArmRecognizedEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="arm">The arm.</param> /// <param name="directionX">The direction x.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public ArmRecognizedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection directionX) : base(myo, timestamp) { // Contract.Requires<ArgumentNullException>(myo != null, "myo"); this.Arm = arm; this.XDirection = directionX; }
// OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user. protected void OnUnpair(object sender, MyoEventArgs e) { lock (myLock) { myo = null; onArm = false; } }
/// <summary> /// Initializes a new instance of the <see cref="ArmRecognizedEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="arm">The arm.</param> /// <param name="directionX">The direction x.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is null. /// </exception> public ArmRecognizedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection directionX) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); this.Arm = arm; this.XDirection = directionX; }
/// <summary> /// Initializes a new instance of the <see cref="GyroscopeDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="gyroscopeData">The gyroscope data. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="gyroscopeData"/> is null. /// </exception> public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3F gyroscopeData) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(gyroscopeData != null, "gyroscopeData"); this.Gyroscope = gyroscopeData; }
/// <summary> /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="orientationData">The orientation.</param> /// <param name="roll">The roll.</param> /// <param name="pitch">The pitch.</param> /// <param name="yaw">The yaw.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>. /// </exception> public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw) : base(myo, timestamp) { this.Orientation = orientationData; this.Roll = roll; this.Pitch = pitch; this.Yaw = yaw; }
/// <summary> /// Initializes a new instance of the <see cref="GyroscopeDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="gyroscopeData">The gyroscope data. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="gyroscopeData"/> is null. /// </exception> public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3F gyroscopeData) : base(myo, timestamp) { //Contract.Requires<ArgumentNullException>(myo != null, "myo"); //Contract.Requires<ArgumentNullException>(gyroscopeData != null, "gyroscopeData"); this.Gyroscope = gyroscopeData; }
public void RemoveHeldPose(IMyo myo, params Pose[] poses) { if (!heldPoses.ContainsKey(myo)) { return; } heldPoses[myo].Stop(); heldPoses[myo].RemovePoses(poses); heldPoses[myo].Start(); }
public PoseSequenceEventArgs(IMyo myo, DateTime timestamp, IList<Pose> poses) : base(myo, timestamp, poses[poses.Count - 1]) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(poses != null, "poses"); Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose."); // copy this list so we don't have any unexpected reference sharing _poses = new List<Pose>(poses).AsReadOnly(); }
public PoseSequenceEventArgs(IMyo myo, DateTime timestamp, IList <Pose> poses) : base(myo, timestamp, poses[poses.Count - 1]) { // Contract.Requires<ArgumentNullException>(myo != null, "myo"); // Contract.Requires<ArgumentNullException>(poses != null, "poses"); // Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose."); // copy this list so we don't have any unexpected reference sharing _poses = new List <Pose>(poses).AsReadOnly(); }
public void RemovePoseSequence(IMyo myo, params Pose[] poses) { var sequence = PoseSequence.Create(myo, poses); if (!poseSequences.Contains(sequence)) { return; } sequence.PoseSequenceCompleted -= Sequence_PoseSequenceCompleted; poseSequences.Remove(sequence); }
/// <summary> /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="orientationData">The orientation.</param> /// <param name="roll">The roll.</param> /// <param name="pitch">The pitch.</param> /// <param name="yaw">The yaw.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>. /// </exception> public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw) : base(myo, timestamp) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(orientationData != null, "orientationData"); this.Orientation = orientationData; this.Roll = roll; this.Pitch = pitch; this.Yaw = yaw; }
/// <summary> /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="orientationData">The orientation.</param> /// <param name="roll">The roll.</param> /// <param name="pitch">The pitch.</param> /// <param name="yaw">The yaw.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>. /// </exception> public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw) : base(myo, timestamp) { //Contract.Requires<ArgumentNullException>(myo != null, "myo"); //Contract.Requires<ArgumentNullException>(orientationData != null, "orientationData"); this.Orientation = orientationData; this.Roll = roll; this.Pitch = pitch; this.Yaw = yaw; }
public void AddPoseSequence(IMyo myo, params Pose[] poses) { var sequence = PoseSequence.Create(myo, poses); if (poseSequences.Contains(sequence)) { return; } poseSequences.Add(sequence); sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted; }
internal IMyo GetMyo() { if (_myo == null) { _myo = _hub.WaitForMyo(TimeSpan.FromMilliseconds(1500)); return(_myo); } else { return(_myo); } }
protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose) { var handler = Triggered; if (handler != null) { var args = new PoseEventArgs( myo, timestamp, pose); handler.Invoke(this, args); } }
protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList <Pose> poses) { var handler = PoseSequenceCompleted; if (handler != null) { var args = new PoseSequenceEventArgs( myo, timestamp, poses); handler.Invoke(this, args); } }
protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose) { //Contract.Requires<ArgumentNullException>(myo != null, "myo"); var handler = Triggered; if (handler != null) { var args = new PoseEventArgs( myo, timestamp, pose); handler.Invoke(this, args); } }
public void AddHeldPose(IMyo myo, TimeSpan interval, params Pose[] poses) { if (!heldPoses.ContainsKey(myo)) { var pose = HeldPose.Create(myo, interval, poses); pose.Triggered += Pose_Triggered; heldPoses.Add(myo, pose); pose.Start(); return; } heldPoses[myo].Stop(); heldPoses[myo].AddPoses(poses); heldPoses[myo].Start(); }
private void _myoHub_MyoConnected(object sender, MyoEventArgs e) { _MyMyo = e.Myo; e.Myo.Vibrate(VibrationType.Long); // Add the pose changed event here e.Myo.PoseChanged += Myo_PoseChanged; // Unlock the Myo so that it doesn't keep locking between our poses e.Myo.Unlock(UnlockType.Hold); UpdateUi("Myo Connected: " + e.Myo.Handle); //Find The Bricks Ip Address FindHostIP(); }
protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList <Pose> poses) { // Contract.Requires<ArgumentNullException>(myo != null, "myo"); // Contract.Requires<ArgumentNullException>(poses != null, "poses"); // Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose."); var handler = PoseSequenceCompleted; if (handler != null) { var args = new PoseSequenceEventArgs( myo, timestamp, poses); handler.Invoke(this, args); } }
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; }; }
MainWindow Window; //Forms #endregion Fields #region Constructors 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; }; }
/// <summary> /// Initialize the Myo input module. Will throw an exception if no Myo is available /// </summary> public MyoInput() { hub = new Hub("de.dhbw.MyoPilot"); myo = hub.WaitForMyo(TimeSpan.FromSeconds(5)); if (myo == null) throw new TimeoutException("Unable to find a Myo!"); hub.MyoUnpaired += OnUnpair; myo.PoseChanged += OnPoseChanged; myo.OrientationDataAcquired += OnOrientationData; myo.RecognizedArm += OnRecognizedArm; myo.LostArm += OnLostArm; myo.Unlock(UnlockType.Hold); // hub.Run() needs to run permanently in order to receive events from the Myo Thread worker = new Thread(hub.Run) { IsBackground = true, Name = "MyoBackgroundWorker" }; worker.Start(); }
static void Main(string[] args) { using (var hub = new Hub()) { Console.WriteLine("Attempting to find a Myo..."); IMyo myo = hub.WaitForMyo(TimeSpan.FromSeconds(10)); if (myo == null) { throw new TimeoutException("Unable to find a Myo!"); } Console.WriteLine("Connected to a Myo armband!\n"); hub.MyoUnpaired += OnUnpair; hub.RecognizedArm += OnRecognizedArm; hub.LostArm += OnLostArm; myo.PoseChanged += OnPoseChanged; myo.OrientationDataAcquired += OnOrientationData; } }
protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); var handler = Triggered; if (handler != null) { var args = new PoseEventArgs( myo, timestamp, pose); handler.Invoke(this, args); } }
public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi) : base(myo, timestamp) { this.Rssi = rssi; }
public void AddBlob(IMyo myo, Point pos) { blobs.Add(myo, pos); Invalidate(); }
public AccelerationChangedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp, Vector3 acceleration) : base(routedEvent, source, myo, timeStamp) { Acceleration = acceleration; }
public MyoRoutedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp) : base(routedEvent, source) { Myo = myo; TimeStamp = timeStamp; }
public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3 accelerometer) : base(myo, timestamp) { this.Accelerometer = accelerometer; }
public OrientationChangedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp, Quaternion orientation) : base(routedEvent, source, myo, timeStamp) { Orientation = orientation; }
public void DeleteRect(IMyo myo) { rectangles.Remove(myo); Invalidate(); }
public EmgDataEventArgs(IMyo myo, DateTime timestamp, Int32[] emg) : base(myo, timestamp) { this.EMG = emg; }
public void AddRect(IMyo myo, Rectangle rect) { rectangles.Add(myo, rect); Invalidate(); }
public ArmSyncedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection xDirection) : base(myo, timestamp) { this.Arm = arm; this.XDirection = xDirection; }
public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose) : base(myo, timestamp) { this.Pose = pose; }
public OrientationDataEventArgs(IMyo myo, DateTime timestamp, Quaternion orientation) : base(myo, timestamp) { this.Orientation = orientation; }
public void DeleteBlob(IMyo myo) { blobs.Remove(myo); Invalidate(); }
protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList<Pose> poses) { Contract.Requires<ArgumentNullException>(myo != null, "myo"); Contract.Requires<ArgumentNullException>(poses != null, "poses"); Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose."); var handler = PoseSequenceCompleted; if (handler != null) { var args = new PoseSequenceEventArgs( myo, timestamp, poses); handler.Invoke(this, args); } }
public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3 gyroscope) : base(myo, timestamp) { this.Gyroscope = gyroscope; }
/// <summary> /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class. /// </summary> /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param> /// <param name="timestamp">The timestamp of the event.</param> /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param> /// <exception cref="System.ArgumentNullException"> /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null. /// </exception> public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData) : base(myo, timestamp) { this.Accelerometer = accelerometerData; }
public MyoEventArgs(IMyo myo, DateTime timestamp) { this.Myo = myo; this.Timestamp = timestamp; }
public void UpdateRect(IMyo myo, Rectangle rect) { rectangles[myo] = rect; Invalidate(); }