This commit is contained in:
Luca Warmenhoven
2024-06-05 13:31:21 +02:00
parent 7384f0e62b
commit 8c462e9f48
2 changed files with 13 additions and 12 deletions

View File

@@ -281,13 +281,10 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
private void triggerColorBurst(boolean isGoodRep) {
if (isGoodRep) {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_good));
new MediaPlayer().create(this, R.raw.good_sound).start();
} else {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_bad));
new MediaPlayer().create(this, R.raw.wrong_sound).start();
}
int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad;
int soundId = isGoodRep ? R.raw.good_sound : R.raw.wrong_sound;
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, circleId));
MediaPlayer.create(this, soundId).start();
ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f);
animator.setDuration(500); // Burst duration

View File

@@ -28,7 +28,7 @@ public class InputProcessor {
private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data
private final float sampleRate; // The sample rate of the motion sensor
private float exerciseDurationInSeconds;
private float exerciseRepetitionDurationInSeconds = 0.0f;
private int repetitionsRemaining = 0;
private int exercisesRemaining = 0;
private float exerciseScore = 0.0F;
@@ -120,7 +120,7 @@ public class InputProcessor {
this.targetRotationVectorPaths = new Vector3f[2][exercise.rightPath.getAngleVectors().length];
this.targetRotationVectorPaths[0] = exercise.leftPath.getAngleVectors();
this.targetRotationVectorPaths[1] = exercise.rightPath.getAngleVectors();
this.exerciseDurationInSeconds = exercise.exerciseTimeInSeconds;
this.exerciseRepetitionDurationInSeconds = exercise.exerciseTimeInSeconds;
this.secondsPassed = 0.0D;
this.lastTime = System.currentTimeMillis();
}
@@ -170,7 +170,7 @@ public class InputProcessor {
public boolean hasFinished() {
return this.recordingMovement ?
(this.secondsPassed >= this.recordingDurationInSeconds) :
(this.secondsPassed >= this.exerciseDurationInSeconds);
(this.secondsPassed >= this.exerciseRepetitionDurationInSeconds);
}
/**
@@ -356,6 +356,10 @@ public class InputProcessor {
// Ensure the sensor ID is within the bounds of the array
if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length)
return 0.0d;
// Calculate the index of the rotational vector where we're currently at
int targetRotationIdx =
/*
// Index of the current rotation vector
@@ -383,10 +387,10 @@ public class InputProcessor {
*/
public double getAverageError(int sensorId) {
double error = 0;
for (int i = 0; i < this.exerciseDurationInSeconds; i++) {
for (int i = 0; i < this.exerciseRepetitionDurationInSeconds; i++) {
error += getError(sensorId, i);
}
return error / this.exerciseDurationInSeconds;
return error / this.exerciseRepetitionDurationInSeconds;
}
public float secondsPassed() {