mirror of
https://github.com/SlimeVR/SlimeVR-Tracker-ESP.git
synced 2026-04-06 02:01:57 +02:00
Merge pull request #110 from deiteris/fix-flip-gesture
Use gravity for "flip to calibrate" gesture
This commit is contained in:
@@ -68,12 +68,14 @@ void BMI160Sensor::motionSetup() {
|
||||
|
||||
int16_t ax, ay, az;
|
||||
imu.getAcceleration(&ax, &ay, &az);
|
||||
if(az < 0 && 10 * (ax * ax + ay * ay) < az * az) {
|
||||
float g_az = (float)az / 8192; // For 4G sensitivity
|
||||
if(g_az < -0.75f) {
|
||||
LEDManager::off(CALIBRATING_LED);
|
||||
Serial.println("Calling Calibration... Flip front to confirm start calibration.");
|
||||
delay(5000);
|
||||
imu.getAcceleration(&ax, &ay, &az);
|
||||
if(az > 0 && 10 * (ax * ax + ay * ay) < az * az)
|
||||
g_az = (float)az / 8192;
|
||||
if(g_az > 0.75f)
|
||||
startCalibration(0);
|
||||
LEDManager::on(CALIBRATING_LED);
|
||||
}
|
||||
|
||||
@@ -56,13 +56,15 @@ void MPU9250Sensor::motionSetup() {
|
||||
// turn on while flip back to calibrate. then, flip again after 5 seconds.
|
||||
// TODO: Move calibration invoke after calibrate button on slimeVR server available
|
||||
imu.getAcceleration(&ax, &ay, &az);
|
||||
if(az<0 && 10.0*(ax*ax+ay*ay)<az*az) {
|
||||
float g_az = (float)az / 16384; // For 2G sensitivity
|
||||
if(g_az < -0.75f) {
|
||||
digitalWrite(CALIBRATING_LED, HIGH);
|
||||
Serial.println("Calling Calibration... Flip front to confirm start calibration.");
|
||||
delay(5000);
|
||||
digitalWrite(CALIBRATING_LED, LOW);
|
||||
imu.getAcceleration(&ax, &ay, &az);
|
||||
if(az>0 && 10.0*(ax*ax+ay*ay)<az*az)
|
||||
g_az = (float)az / 16384;
|
||||
if(g_az > 0.75f)
|
||||
startCalibration(0);
|
||||
}
|
||||
#if not (defined(_MAHONY_H_) || defined(_MADGWICK_H_))
|
||||
|
||||
Reference in New Issue
Block a user