1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Still update duration of next anticipated state even is current execution time is ignored

This commit is contained in:
Steve Evans 2022-01-14 03:22:52 +00:00
parent 4e47a792d8
commit e7b61a928f
2 changed files with 27 additions and 25 deletions

View file

@ -225,23 +225,21 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
break;
}
if (schedulerGetIgnoreTaskExecTime()) {
return;
}
if (!schedulerGetIgnoreTaskExecTime()) {
executeTimeUs = micros() - currentTimeUs + RX_TASK_MARGIN;
executeTimeUs = micros() - currentTimeUs + RX_TASK_MARGIN;
// If the scheduler has reduced the anticipatedExecutionTime due to task aging, pick that up
anticipatedExecutionTime = schedulerGetNextStateTime();
if (anticipatedExecutionTime != (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
rxStateDurationFracUs[oldRxState] = anticipatedExecutionTime << RX_TASK_DECAY_SHIFT;
}
// If the scheduler has reduced the anticipatedExecutionTime due to task aging, pick that up
anticipatedExecutionTime = schedulerGetNextStateTime();
if (anticipatedExecutionTime != (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
rxStateDurationFracUs[oldRxState] = anticipatedExecutionTime << RX_TASK_DECAY_SHIFT;
}
if (executeTimeUs > (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
rxStateDurationFracUs[oldRxState] = executeTimeUs << RX_TASK_DECAY_SHIFT;
} else {
// Slowly decay the max time
rxStateDurationFracUs[oldRxState]--;
if (executeTimeUs > (rxStateDurationFracUs[oldRxState] >> RX_TASK_DECAY_SHIFT)) {
rxStateDurationFracUs[oldRxState] = executeTimeUs << RX_TASK_DECAY_SHIFT;
} else {
// Slowly decay the max time
rxStateDurationFracUs[oldRxState]--;
}
}
if (debugMode == DEBUG_RX_STATE_TIME) {

View file

@ -1006,6 +1006,8 @@ void osdDrawStats2(timeUs_t currentTimeUs)
osdStatsEnabled = false;
stats.armed_time = 0;
}
schedulerIgnoreTaskExecTime();
}
#ifdef USE_ESC_SENSOR
if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
@ -1305,20 +1307,22 @@ void osdUpdate(timeUs_t currentTimeUs)
break;
}
executeTimeUs = micros() - currentTimeUs;
if (!schedulerGetIgnoreTaskExecTime()) {
executeTimeUs = micros() - currentTimeUs;
// On the first pass no element groups will have been formed, so all elements will have been
// rendered which is unrepresentative, so ignore
if (!firstPass) {
if (osdCurState == OSD_STATE_UPDATE_ELEMENTS) {
if (executeTimeUs > osdElementGroupDurationUs[osdCurElementGroup]) {
osdElementGroupDurationUs[osdCurElementGroup] = executeTimeUs;
// On the first pass no element groups will have been formed, so all elements will have been
// rendered which is unrepresentative, so ignore
if (!firstPass) {
if (osdCurState == OSD_STATE_UPDATE_ELEMENTS) {
if (executeTimeUs > osdElementGroupDurationUs[osdCurElementGroup]) {
osdElementGroupDurationUs[osdCurElementGroup] = executeTimeUs;
}
}
}
if (executeTimeUs > osdStateDurationUs[osdCurState]) {
osdStateDurationUs[osdCurState] = executeTimeUs;
if (executeTimeUs > osdStateDurationUs[osdCurState]) {
osdStateDurationUs[osdCurState] = executeTimeUs;
}
}
}