Merge pull request #110 from deiteris/fix-flip-gesture

Use gravity for "flip to calibrate" gesture
This commit is contained in:
Eiren Rain
2022-02-27 16:47:20 +02:00
committed by GitHub
2 changed files with 8 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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_))