Commit balls

This commit is contained in:
Luca Warmenhoven
2024-05-28 13:50:35 +02:00
parent eb6ffcf4c8
commit 8c1e4332aa
2 changed files with 15 additions and 3 deletions

View File

@@ -89,7 +89,7 @@ public class PersonalMotionPreviewElement extends View {
this.exercise = exercise;
this.path = exercise.getPath();
this.motionProcessor = new MotionProcessor();
this.motionProcessor = new MotionProcessor(qiContext);
this.motionProcessor.startListening();
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> {
// TODO: Implement the calculation of the `performingPath` based on the motion data

View File

@@ -2,6 +2,8 @@ package com.example.fitbot.util.processing;
import android.util.Log;
import com.aldebaran.qi.sdk.QiContext;
import com.example.fitbot.util.FitnessCycle;
import com.example.fitbot.util.path.GesturePath;
import com.example.fitbot.util.server.IWebServerHandler;
import com.example.fitbot.util.server.WebServer;
@@ -26,7 +28,11 @@ public class MotionProcessor {
private GesturePath path;
private WebServer server;
public MotionProcessor() {}
private QiContext context;
private long lastMessage = System.nanoTime();
public MotionProcessor(QiContext context) {}
/**
@@ -64,6 +70,12 @@ public class MotionProcessor {
* @param data The data to parse.
*/
public void parsePacket(@NotNull String data) {
if ( System.nanoTime() - lastMessage < 2 * 1E9)
return;
lastMessage = System.nanoTime();
FitnessCycle.say("Informatie ontvangen", context);
/*
// If the message starts with 'data', it's a data packet.
if ( data.startsWith("data")) {
Log.i("MotionProcessor", "Received data packet: " + data.split(" ")[1]);
@@ -82,7 +94,7 @@ public class MotionProcessor {
Log.i("MotionProcessor", "Device calibrated at " + ZERO.toString());
} else if ( data.startsWith("sampleRate")) {
this.sampleRate = Float.parseFloat(data.split(" ")[1]);
}
}*/
}
/**