mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
Minor cleanup, added tap packet
This commit is contained in:
@@ -214,10 +214,10 @@ uint16_t BNO080::getReadings(void)
|
||||
{
|
||||
return parseCommandReport(); //This will update responses to commands, calibrationStatus, etc.
|
||||
}
|
||||
else if(shtpHeader[2] == CHANNEL_GYRO)
|
||||
{
|
||||
return parseInputReport(); //This will update the rawAccelX, etc variables depending on which feature report is found
|
||||
}
|
||||
else if(shtpHeader[2] == CHANNEL_GYRO)
|
||||
{
|
||||
return parseInputReport(); //This will update the rawAccelX, etc variables depending on which feature report is found
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void BNO080Sensor::motionSetup(DeviceConfig * config)
|
||||
void BNO080Sensor::motionLoop()
|
||||
{
|
||||
//Look for reports from the IMU
|
||||
if (imu.dataAvailable() == true)
|
||||
if (imu.dataAvailable())
|
||||
{
|
||||
quaternion.x = imu.getQuatI();
|
||||
quaternion.y = imu.getQuatJ();
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#define IMU_BNO085 4
|
||||
#define IMU_BNO055 5
|
||||
|
||||
#define IMU IMU_BNO080
|
||||
#define IMU IMU_BNO085
|
||||
|
||||
#if IMU == IMU_BNO085
|
||||
#define IMU_NAME "BNO085"
|
||||
|
||||
@@ -84,7 +84,7 @@ void setup()
|
||||
// join I2C bus
|
||||
Wire.flush();
|
||||
Wire.begin(D2, D1);
|
||||
Wire.setClockStretchLimit(4000);
|
||||
Wire.setClockStretchLimit(1000);
|
||||
Serial.begin(serialBaudRate);
|
||||
while (!Serial)
|
||||
; // wait for connection
|
||||
|
||||
@@ -56,6 +56,7 @@ class BNO080Sensor : public Sensor {
|
||||
BNO080 imu {};
|
||||
bool newData {false};
|
||||
Quat sensorOffset {Quat(Vector3(0, 0, 1), PI / 2.0)};
|
||||
uint8_t tap;
|
||||
};
|
||||
|
||||
class BNO055Sensor : public Sensor {
|
||||
|
||||
@@ -146,6 +146,26 @@ void sendFloat(float const value, int type)
|
||||
}
|
||||
}
|
||||
|
||||
void sendByte(char const value, int type)
|
||||
{
|
||||
if (Udp.beginPacket(host, port) > 0)
|
||||
{
|
||||
sendType(type);
|
||||
sendPacketNumber();
|
||||
Udp.write(&value, 1);
|
||||
if (Udp.endPacket() == 0)
|
||||
{
|
||||
//Serial.print("Write error: ");
|
||||
//Serial.println(Udp.getWriteError());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.print("Write error: ");
|
||||
//Serial.println(Udp.getWriteError());
|
||||
}
|
||||
}
|
||||
|
||||
void sendQuat(Quat *const quaternion, int type)
|
||||
{
|
||||
if (Udp.beginPacket(host, port) > 0)
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#define PACKET_PING_PONG 10
|
||||
#define PACKET_SERIAL 11
|
||||
#define PACKET_BATTERY_LEVEL 12
|
||||
#define PACKET_TAP 13
|
||||
|
||||
#define PACKET_RECIEVE_HEARTBEAT 1
|
||||
#define PACKET_RECIEVE_VIBRATE 2
|
||||
@@ -62,6 +63,7 @@ void sendQuat(Quat * const quaternion, int type);
|
||||
void sendVector(float * const result, int type);
|
||||
void sendConfig(DeviceConfig * const config, int type);
|
||||
void sendFloat(float const value, int type);
|
||||
void sendByte(char const value, int type);
|
||||
void sendRawCalibrationData(int * const data, int type);
|
||||
void setConfigRecievedCallback(configRecievedCallback);
|
||||
void setCommandRecievedCallback(commandRecievedCallback);
|
||||
|
||||
Reference in New Issue
Block a user