Example #1
0
 @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);
 }
Example #2
0
  @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();
  }