// Draw some basic instructions. void OnGUI() { GUI.skin.label.fontSize = 20; ThalmicHub hub = ThalmicHub.instance; // Access the ThalmicMyo script attached to the Myo object. ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> (); if (!hub.hubInitialized) { GUI.Label(new Rect(12, 8, Screen.width, Screen.height), "Cannot contact Myo Connect. Is Myo Connect running?\n" + "Press Q to try again." ); } else if (!thalmicMyo.isPaired) { GUI.Label(new Rect(12, 8, Screen.width, Screen.height), "No Myo currently paired." ); } else if (!thalmicMyo.armSynced) { GUI.Label(new Rect(12, 8, Screen.width, Screen.height), "Perform the Sync Gesture." ); } else { // GUI.Label (new Rect (12, 8, Screen.width, Screen.height), // "Fist: Vibrate Myo armband\n" + // "Wave in: Set box material to blue\n" + // "Wave out: Set box material to green\n" + // "Double tap: Reset box material\n" + // "Fingers spread: Set forward direction" // ); GUI.Label(new Rect(12, 8, Screen.width, Screen.height), "playing ..." ); } }
private void Update() { ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> (); if (thalmicMyo.pose == Pose.Fist) { Debug.Log("Double contraction"); ExtendUnlockAndNotifyUserAction(thalmicMyo); } else if (thalmicMyo.pose == Pose.WaveIn) { Debug.Log("Biceps"); ExtendUnlockAndNotifyUserAction(thalmicMyo); } else if (thalmicMyo.pose == Pose.WaveOut) { Debug.Log("Triceps"); ExtendUnlockAndNotifyUserAction(thalmicMyo); } else if (thalmicMyo.pose == Pose.DoubleTap) { Debug.Log("Double tap"); ExtendUnlockAndNotifyUserAction(thalmicMyo); } // Extend the unlock if ThalmcHub's locking policy is standard, and notifies the given myo that a user action was // recognized. void ExtendUnlockAndNotifyUserAction(ThalmicMyo myo) { ThalmicHub hub = ThalmicHub.instance; if (hub.lockingPolicy == LockingPolicy.Standard) { myo.Unlock(UnlockType.Timed); } myo.NotifyUserAction(); } }