Skip to content

Split OSD element rendering into draw and display states #13813

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
Aug 22, 2024

Conversation

SteveCEvans
Copy link
Member

@SteveCEvans SteveCEvans commented Aug 11, 2024

Fixes: #13802

With 4.5 the realtime tasks; gyro/filter/PID take longer and consequently the scheduler struggled to find time slots big enough for the OSD task. Also the HDZero system appears to struggle to keep up with the data stream demonstrated by hot swapping to a Walksnail system which doesn't exhibit this issue.

Disabling some filters also fixed the issue, which showed the system to be sensitive to the amount of time spent in the filter task.

This PR therefore splits display of OSD elements into two phases, drawing the element in the display buffer and then sending to the display device. Each phase is then scheduled consecutively.

Also, in the first time slot after the real-time tasks have run, the scheduler no longer refuses to run the highest priority task on the grounds that it is predicted to take too long as there will never be a longer time slot available, so there's no point waiting for one.

Tested with both HDZero and MAX7456.

Note that it is still possible to make the HDZero system laggy by enabling a lot of elements, the most problematic being the artificial horizon and sidebars, but with the config provided in #13802 the issue appears resolved.

@JDRotor @limonspb Please test.

@SteveCEvans SteveCEvans requested a review from limonspb August 11, 2024 17:51
@SteveCEvans SteveCEvans self-assigned this Aug 11, 2024
Copy link

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

  • Simply put #13813 (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!

@haslinghuis haslinghuis modified the milestones: 4.5.1, 4.6 Aug 11, 2024
@SteveCEvans
Copy link
Member Author

Fixing the unit test now...

Copy link
Contributor

@ledvinap ledvinap left a comment

Choose a reason for hiding this comment

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

OSD code is getting more complicated with each iteration. You are trying to implement multitasking from scratch - it is possible, but it takes years to fix all bugs.

Comment on lines +429 to 430
startTime = simulationTime + 0.25e6;
for (int i = 0; i < 15; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe ?

Suggested change
startTime = simulationTime + 0.25e6;
for (int i = 0; i < 15; i++) {
startTime = simulationTime;
for (int i = 1; i <= 15; i++) {

or simulationTime = startTime + (i + 1) * 0.25e6;

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just aiming for a minimal change.

@ctzsnooze
Copy link
Member

What's the best way to test this PR, Steve?

@SteveCEvans
Copy link
Member Author

@ctzsnooze the easiest way to to load up an OSD config and check that it updates at a good rate. Flashing items are a good test. If you overdo the number of elements it may still struggle, but we don’t use overly busy OSD displays.

@nerdCopter
Copy link
Member

for reviewers, general test results in this comment: #13802 (comment)

YLAD-nobody

This comment was marked as off-topic.

@nerdCopter

This comment was marked as off-topic.

Always execute task on first scheduling opportunity after realtime tasks as there will never be a better time

Use time specific comparision function
@blckmn blckmn merged commit 16827f0 into betaflight:master Aug 22, 2024
26 checks passed
haslinghuis pushed a commit to haslinghuis/betaflight that referenced this pull request Aug 22, 2024
haslinghuis added a commit that referenced this pull request Aug 30, 2024
) (#13839)

Split OSD element rendering into draw and display states (#13813)

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

haslinghuis commented Sep 11, 2024

@SteveCEvans
Reverting the change resolves the issue found with not displaying craft name and pilot name on SPBE F7V3 with TBS Unify Pro32 5V V3. Please have a look. All other background elements display without issues.

@SteveCEvans
Copy link
Member Author

SteveCEvans commented Sep 11, 2024

Possibly fixed by #13879?

@haslinghuis
Copy link
Member

haslinghuis commented Sep 11, 2024

@SteveCEvans Double checked to be sure. It did not. Even tried with a short fixed string instead of using pilotConfig parameter.

@SteveCEvans
Copy link
Member Author

@haslinghuis Please see #13897

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.

HDZero OSD renders very slowly in Releases 4.5.0 and later
8 participants