mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
Make MPU-6050 send data only when it has new data
This commit is contained in:
@@ -57,7 +57,6 @@ bool blinking = false;
|
||||
unsigned long blinkStart = 0;
|
||||
unsigned long now_ms, last_ms = 0; //millis() timers
|
||||
unsigned long last_battery_sample = 0;
|
||||
unsigned long const start = millis();
|
||||
bool secondImuActive = false;
|
||||
|
||||
void setConfig(DeviceConfig newConfig)
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
bool hasNewData = false;
|
||||
|
||||
void gatherCalibrationData(MPU9250 &imu);
|
||||
|
||||
void MPU6050Sensor::motionSetup(DeviceConfig * config) {
|
||||
@@ -122,11 +124,15 @@ void MPU6050Sensor::motionLoop() {
|
||||
q[3] = rawQuat.w;
|
||||
quaternion.set(-q[1], q[0], q[2], q[3]);
|
||||
quaternion *= sensorOffset;
|
||||
hasNewData = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MPU6050Sensor::sendData() {
|
||||
sendQuat(&quaternion, PACKET_ROTATION);
|
||||
if(hasNewData) {
|
||||
sendQuat(&quaternion, PACKET_ROTATION);
|
||||
hasNewData = false;
|
||||
}
|
||||
}
|
||||
|
||||
void MPU6050Sensor::startCalibration(int calibrationType) {
|
||||
|
||||
Reference in New Issue
Block a user