Skip to content

Set next state expected time on per element basis #13706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

SteveCEvans
Copy link
Member

@SteveCEvans SteveCEvans commented Jun 18, 2024

May fix: #13656

The ability to schedule the OSD task is based on knowledge of the likely time for each state to execute.

This is OK typically, but when in the OSD_STATE_UPDATE_ELEMENTS state there is some variation in the required time to render elements. This PR therefore sets the expected next state duration for this state based on the element to be rendered. It also removes any attempt to render elements in groups. As a result, rather than always having to find a time slot big enough for the most complex element, smaller time slots can be utilised.

Note that previously the OSD state machine would render as many elements as possible in a target 20us, however on a heavily loaded F7 this has proven too great, so rather than attempt to render many items at once this PR instead renders them one at a time, which makes the OSD much more schedulable, at the cost of some efficiency in scheduling overhead.

Tested on ZEEZF7V3 and MATEKF405TE with Walksnail.

I'd be grateful if somebody could test on analog as my video capture card is playing up.

@SteveCEvans SteveCEvans self-assigned this Jun 18, 2024
Copy link

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13706 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

@McGiverGim
Copy link
Member

I can confirm that the OSD is smoother than before this PR. Before this PR, with my config, the OSD was unusable (one refresh each 4 seconds). Now it refreshes without problem.
After arming isn't as smooth as before arming, but it works.
I think this commit must go to maintenance branch too.

uint8_t osdCurrentElement = osdGetActiveElement();

timeUs_t startElementTime = micros();
uint8_t osdNextElement = osdGetActiveElement();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'next' od slightly confusing, it is mostly used for element that is already rendered. maybe just 'osdElement'?

@haslinghuis haslinghuis merged commit cff4c9c into betaflight:master Jun 21, 2024
haslinghuis pushed a commit to haslinghuis/betaflight that referenced this pull request Jun 21, 2024
* Set next state expected time on per element basis

* Rename osdNextElement to be clearer
blckmn pushed a commit that referenced this pull request Jun 24, 2024
…13713)

Set next state expected time on per element basis (#13706)

* Set next state expected time on per element basis

* Rename osdNextElement to be clearer

Co-authored-by: Steve Evans <SteveCEvans@users.noreply.github.com>
limonspb pushed a commit to limonspb/betaflight that referenced this pull request Jul 14, 2024
…#13706) (betaflight#13713)

Set next state expected time on per element basis (betaflight#13706)

* Set next state expected time on per element basis

* Rename osdNextElement to be clearer

Co-authored-by: Steve Evans <SteveCEvans@users.noreply.github.com>
@JobeDevian
Copy link

I flew this PR on 4.6 yesterday (about 40 packs). The First 10 were with 8k Loop, the rest I switched back to 4k. On 8k the refresh is definitely smoother than without this PR, as sometimes the whole OSD would remain at its last update for many seconds. But it still had a worrying tendency to miss the battery/cell voltage from the screen when it begins flashing for low battery. Sometimes the word "armed" is still on the screen for a few seconds after takeoff as well.
On 4k everything refreshes super smooth and crisp.
Short version: Better but I would still use 4k PID loop over the laggy OSD on 8k
See attached DVR:
https://youtu.be/zrKEmYWEKTY
PS. not sure if placebo, but seems worse when BB logging as well

@JobeDevian
Copy link

To add to the above. I have black box currently set to always logging (for some other testing) under the assumption that when full, the logging process would stop. Is my assumption wrong on that? Am I still choking up the already limited resources with blackbox when the memory is full?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Sporadic flickering OSD since BF 4.5 with DJI O3 and Integra
5 participants