comments and cleanup

This commit is contained in:
2024-06-05 13:56:23 +02:00
parent fbca5ce351
commit d0c74c4e25
4 changed files with 20 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
#ifndef Connectivity_h
#define Connectivity_h
#ifndef MOVEMENTSENSORCODE_CONNECTIVITY_h
#define MOVEMENTSENSORCODE_CONNECTIVITY_h
#include "Arduino.h"
#include <WebSocketsClient.h>
@@ -30,4 +30,4 @@ private:
};
#endif
#endif // MOVEMENTSENSORCODE_CONNECTIVITY_h

View File

@@ -9,9 +9,10 @@ void setup() {
}
void loop() {
SensorManager::RotationQuaternions Rotation = sensorManager.getQuaternions();
// SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
SensorManager::eulerAngles Rotation = sensorManager.getEulerAngles();
//static structure
// TODO: redo json for esp8266 and in android studio
struct acceleration {
float x = 9;
float y = 9;
@@ -19,22 +20,22 @@ struct acceleration {
} accelData;
if (!ipAquired) {
serverIp = connectivity.fetchIPAddress(); // Assign the value here
serverIp = connectivity.fetchIPAddress(); //Fetch pepper ip address
ipAquired = true;
}
unsigned long lastTime = 0; // will store the last time the code was run
unsigned long currentTime = millis();
if (currentTime - lastTime >= 100) { // 100 ms has passed
if (currentTime - lastTime >= 100) { // do everything inside every 100 ms
memset(buffer, 0, BUFFER_SIZE);
sprintf(
buffer,
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
DEVICE_ID,
Rotation.i,
Rotation.j,
Rotation.k,
Rotation.w,
Rotation.roll,
Rotation.pitch,
Rotation.yaw,
accelData.x,
accelData.y,
accelData.z,
"data");
@@ -45,6 +46,3 @@ struct acceleration {
lastTime = currentTime;
}
}
//acceleration.X
//acceleration.Y
//acceleration.Z

View File

@@ -1,5 +1,5 @@
#ifndef SensorManager_h
#define SensorManager_h
#ifndef MOVEMENTSENSORCODE_SENSORMANAGER_H
#define MOVEMENTSENSORCODE_SENSORMANAGER_H
#include "Arduino.h"
#include "SparkFun_BNO080_Arduino_Library.h"
@@ -23,6 +23,8 @@ public:
acceleration getAcelleration();
bool sensorTap();
private:
struct RotationQuaternions {
float i;
float j;
@@ -31,9 +33,7 @@ public:
};
RotationQuaternions getQuaternions();
private:
BNO080 myIMU;
};
#endif
#endif // MOVEMENTSENSORCODE_SENSORMANAGER_H

View File

@@ -8,11 +8,10 @@ Connectivity connectivity;
WebSocketsClient webSocket;
#define USE_SERIAL Serial
#define ssid "msi 5556"
#define pass "abc12345"
#define ssid "1235678i"
#define pass "12345678"
#define BUFFER_SIZE 1024
#define DEVICE_ID 1
#define IP_ADDRESS "192.168.137.12"
#define DEVICE_ID 0
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
const char* serverIp = NULL; // Declare serverIp here