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:
parent
9277f64d85
commit
f39ca7add6
3 changed files with 86 additions and 51 deletions
|
@ -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(¤tProfile->accelerometerTrims);
|
||||
|
||||
// Determine current flight mode. When no acc needed in pid calculations we should only read gyro to reduce latency
|
||||
if (imuUpdateAccDelayed()) {
|
||||
imuUpdate(¤tProfile->accelerometerTrims, ONLY_GYRO); // When no level modes active read only gyro
|
||||
} else {
|
||||
imuUpdate(¤tProfile->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(¤tProfile->accelerometerTrims, ONLY_ACC);
|
||||
}
|
||||
|
||||
#ifdef BLACKBOX
|
||||
if (!cliMode && feature(FEATURE_BLACKBOX)) {
|
||||
handleBlackbox();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue