1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 23:35:34 +03:00

Minimize latency in Acro modes with acc enabled

This commit is contained in:
borisbstyle 2015-09-25 15:23:04 +02:00
parent 9277f64d85
commit f39ca7add6
3 changed files with 86 additions and 51 deletions

View file

@ -727,6 +727,14 @@ void filterRc(void){
}
}
bool imuUpdateAccDelayed(void) {
if (flightModeFlags) {
return false;
} else {
return true;
}
}
void loop(void)
{
static uint32_t loopTime;
@ -777,7 +785,13 @@ void loop(void)
if (gyroSyncCheckUpdate() || (int32_t)(currentTime - (loopTime + GYRO_WATCHDOG_DELAY)) >= 0) {
loopTime = currentTime + targetLooptime;
imuUpdate(&currentProfile->accelerometerTrims);
// Determine current flight mode. When no acc needed in pid calculations we should only read gyro to reduce latency
if (imuUpdateAccDelayed()) {
imuUpdate(&currentProfile->accelerometerTrims, ONLY_GYRO); // When no level modes active read only gyro
} else {
imuUpdate(&currentProfile->accelerometerTrims, ACC_AND_GYRO); // When level modes active read gyro and acc
}
// Measure loop rate just after reading the sensors
currentTime = micros();
@ -872,6 +886,11 @@ void loop(void)
writeMotors();
}
// When no level modes active read acc after motor update
if (imuUpdateAccDelayed()) {
imuUpdate(&currentProfile->accelerometerTrims, ONLY_ACC);
}
#ifdef BLACKBOX
if (!cliMode && feature(FEATURE_BLACKBOX)) {
handleBlackbox();