@Override public void onPose(Myo myo, long timestamp, Pose pose) { currentPose = pose; if (currentPose.getType() == PoseType.FIST) { myo.vibrate(VibrationType.VIBRATION_MEDIUM); } invoke("publishPose", pose); }
public String toString() { String string = signal; if (customPose != null && !customPose.isEmpty()) { string += " " + customPose; } else { string += " " + setPose.name(); } string += " " + name; return string; }
public static Control getControl(String input) { Control newControl = new Control(); StringTokenizer st = new StringTokenizer(input); newControl.signal = st.nextToken(); String pose = st.nextToken(); for (String defPose : customPoses) { if (pose.equals(defPose)) { newControl.customPose = pose; newControl.name = st.nextToken(); return newControl; } } newControl.customPose = ""; newControl.setPose = Pose.valueOf(pose); newControl.name = st.nextToken(); return newControl; }
@Override public String toString() { StringBuilder builder = new StringBuilder("\r"); String xDisplay = String.format( "[%s%s]", repeatCharacter('*', (int) rollW), repeatCharacter(' ', (int) (SCALE - rollW))); String yDisplay = String.format( "[%s%s]", repeatCharacter('*', (int) pitchW), repeatCharacter(' ', (int) (SCALE - pitchW))); String zDisplay = String.format( "[%s%s]", repeatCharacter('*', (int) yawW), repeatCharacter(' ', (int) (SCALE - yawW))); String armString = null; if (whichArm != null) { armString = String.format("[%s]", whichArm == Arm.ARM_LEFT ? "L" : "R"); } else { armString = String.format("[?]"); } String poseString = null; if (currentPose != null) { String poseTypeString = currentPose.getType().toString(); poseString = String.format("[%s%" + (SCALE - poseTypeString.length()) + "s]", poseTypeString, " "); } else { poseString = String.format("[%14s]", " "); } builder.append(xDisplay); builder.append(yDisplay); builder.append(zDisplay); builder.append(armString); builder.append(poseString); return builder.toString(); }
// onPose() is called whenever the Myo detects that the person wearing it has changed their // pose, for example, // making a fist, or not making a fist anymore. @Override public void onPose(Myo myo, long timestamp, Pose pose) { // Show the name of the pose in a toast. showToast(getString(R.string.pose, pose.toString())); }