private static void Myo_PoseChanged(object sender, PoseEventArgs e) { Console.SetCursorPosition(0, 11); ClearCurrentConsoleLine(); Console.Write("Myo del brazo {0} detecto la pose {1}!", e.Myo.Arm, e.Myo.Pose); if (e.Myo.Pose.Equals(Pose.DoubleTap) || e.Myo.Pose.Equals(Pose.FingersSpread)) { Console.SetCursorPosition(0, 12); ClearCurrentConsoleLine(); bool togglePlay = Player.TogglePlay(); Console.WriteLine("Musica on/off: " + togglePlay); e.Myo.Vibrate(VibrationType.Long); } if (e.Myo.Pose.Equals(Pose.WaveOut)) { Player.Stop(); Console.SetCursorPosition(0, 12); ClearCurrentConsoleLine(); Console.WriteLine("Musica parada"); } if(e.Myo.Pose.Equals(Pose.WaveIn)) { Player.Init(); Console.SetCursorPosition(0, 2); ClearCurrentConsoleLine(); Console.WriteLine("El repoductor ha sido reinicializado"); } }
private void Myo_PoseChanged(object sender, PoseEventArgs e) { if (PoseChanged != null) { PoseChanged.Invoke(this, e); } }
/// <summary> /// Called when the Myo has detected a change in the user's pose. /// </summary> /// <param name="evt">The pointer to the event.</param> /// <param name="timestamp">The timestamp of the event.</param> protected virtual void OnPoseChanged(IntPtr evt, DateTime timestamp) { var pose = _myoDeviceDriver.GetEventPose(evt); this.Pose = pose; var handler = PoseChanged; if (handler != null) { var args = new PoseEventArgs(this, timestamp, pose); handler.Invoke(this, args); } }
public void GetPose_ValidState_EqualsConstructorParameter() { // Setup var pose = Pose.Fist; var args = new PoseEventArgs( new Mock<IMyo>().Object, DateTime.UtcNow, pose); // Execute var result = args.Pose; // Assert Assert.Equal(pose, result); }
/// <summary> /// Called when the Myo has detected a change in the user's pose. /// </summary> /// <param name="evt">The pointer to the event.</param> /// <param name="timestamp">The timestamp of the event.</param> protected virtual void OnPoseChanged(IntPtr evt, DateTime timestamp) { // Contract.Requires<ArgumentException>(evt != IntPtr.Zero, "The event handle must be set."); var pose = _myoDeviceDriver.GetEventPose(evt); this.Pose = pose; var handler = PoseChanged; if (handler != null) { var args = new PoseEventArgs(this, timestamp, pose); handler.Invoke(this, args); } }
public void GetMyo_ValidState_EqualsConstructorParameter() { // Setup var myo = new Mock<IMyo>(); var args = new PoseEventArgs( myo.Object, DateTime.UtcNow, Pose.Unknown); // Execute var result = args.Myo; // Assert Assert.Equal(myo.Object, result); }
private static void Myo_PoseChanged(object sender, PoseEventArgs e) { Console.WriteLine("{0} arm Myo detected {1} pose!", e.Myo.Arm, e.Myo.Pose); string requestUri = _destinationUrl; switch (e.Myo.Pose) { case Poses.Pose.WaveIn: Console.WriteLine("Previous Track"); requestUri += "previous_track"; break; case Poses.Pose.WaveOut: Console.WriteLine("Next Track"); requestUri += "next_track"; break; case Poses.Pose.FingersSpread: Console.WriteLine("Volume Up"); requestUri += "volume_up"; break; case Poses.Pose.Fist: Console.WriteLine("Volume Down"); requestUri += "volume_down"; break; case Poses.Pose.Rest: break; case Poses.Pose.DoubleTap: Console.WriteLine("start_stop"); requestUri += "start_stop"; break; default: break; } if (_enableWebTransmission) { try { _webRequest = WebRequest.Create(requestUri); _webRequest.Method = "POST"; WebResponse response = _webRequest.GetResponse(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
//Called when a pose is detected and outputs the pose to console, //also sets the start sequence private static void Myo_PoseChanged(object sender, PoseEventArgs e) { Console.WriteLine("{0} arm Myo detected {1} pose!", e.Myo.Arm, e.Myo.Pose); Console.WriteLine ("Pose = " + e.Myo.Pose); //Start sequence is wave out if (e.Myo.Pose == Pose.WaveOut) startSequence = true; if (e.Myo.Pose == Pose.WaveIn) startSequence = false; }
private void Myo_PoseChanged(object sender, PoseEventArgs e) { if (_currentSequence.Count == _sequence.Count) { for (int i = 0; i < _currentSequence.Count; i++) { if (_currentSequence[i] != _sequence[i]) { var lastItem = _currentSequence[_currentSequence.Count - 1]; _currentSequence.Clear(); _currentSequence.Add(lastItem); return; } } // got a match OnPoseSequenceCompleted(e.Myo, e.Timestamp, _currentSequence); _currentSequence.Clear(); } else { switch (e.Pose) { case Pose.WaveOut: case Pose.WaveIn: case Pose.FingersSpread: case Pose.Fist: case Pose.DoubleTap: _currentSequence.Add(e.Pose); break; } } }
private static void Myo_PoseChanged(object sender, PoseEventArgs e) { Console.WriteLine("{0} arm Myo detected {1} pose!", e.Myo.Arm, e.Myo.Pose); }
public void GetTimestamp_ValidState_EqualsConstructorParameter() { // Setup var timestamp = DateTime.UtcNow; var args = new PoseEventArgs( new Mock<IMyo>().Object, timestamp, Pose.Unknown); // Execute var result = args.Timestamp; // Assert Assert.Equal(timestamp, result); }
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(); } } }
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); } }
private static void Pose_Triggered(object sender, PoseEventArgs e) { Console.WriteLine("{0} arm Myo is holding pose {1}!", e.Myo.Arm, e.Pose); }
private void Myo_PoseChanged(object sender, PoseEventArgs e) { if (PoseToSound.ContainsKey(e.Pose)) PoseToSound[e.Pose].Play(); }
public void Pose(object o, PoseEventArgs e) { var myo = (Myo)o; if (myo.Pose == MyoSharp.Poses.Pose.DoubleTap) { if (!absoluteTL.ContainsKey(myo)) { absoluteTL.Add(myo, Math3D.FromQuaternion(myo.Orientation)); Console.WriteLine("Calibrated Top Left!"); UpdateBlob(myo, new Point(clientRes.Width, clientRes.Height)); } else { absoluteTL.Remove(myo); UpdateBlob(myo, new Point(0, 0)); } } else if (myo.Pose == MyoSharp.Poses.Pose.Fist) { if (absoluteTL.ContainsKey(myo)) { var position = GetPixelPosition(myo); var api = new WindowApi(); var window = api.WindowFromPoint(position); if (window != null) { if (!SelectedWindow.ContainsKey(myo)) { SelectedWindow.Add(myo, api.GetRoot(window)); if (SelectedWindow.ContainsKey(myo)) { if (!DragOffset.ContainsKey(myo)) { DragOffset.Add(myo, new Point(position.X - SelectedWindow[myo].Area.Location.X, position.Y - SelectedWindow[myo].Area.Location.Y)); } } } } } } else { if (absoluteTL != null) { if (SelectedWindow.ContainsKey(myo)) { var position = GetPixelPosition(myo); var api = new WindowApi(); var newWindow = new Window(SelectedWindow[myo].Ptr, new Rectangle(position.X - DragOffset[myo].Value.X, position.Y - DragOffset[myo].Value.Y, SelectedWindow[myo].Area.Width, SelectedWindow[myo].Area.Height)); SelectedWindow.Remove(myo); api.SetWindow(newWindow); api.BringToFront(newWindow); blobs.Add(myo, position); } if (rectangles.ContainsKey(myo)) { DeleteRect(myo); } DragOffset.Remove(myo); } } }
private void OnPose(object sender, PoseEventArgs e) { if (e.Myo.Pose == Pose.DoubleTap) { // use doubletap trigger myo lock if (_isLock) e.Myo.Unlock(UnlockType.Hold); else e.Myo.Lock(); } else if (e.Myo.Pose == Pose.Rest) { ReceiveOver(); } else { if (!_onReceive) { ReceiveStart(); } _currentPose = e.Pose.ToString(); ReceivePose(_currentPose); } }