-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Conversation
Do you want to test this code? You can flash it directly from Betaflight Configurator:
WARNING: It may be unstable. Use only for testing! |
Fixing the unit test now... |
578ec0b
to
769ef4a
Compare
There was a problem hiding this 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.
startTime = simulationTime + 0.25e6; | ||
for (int i = 0; i < 15; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ?
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;
There was a problem hiding this comment.
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.
What's the best way to test this PR, Steve? |
@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. |
for reviewers, general test results in this comment: #13802 (comment) |
This comment was marked as off-topic.
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
e8c2650
to
e0aa3cd
Compare
…er is reset if it exceeds it
@SteveCEvans |
Possibly fixed by #13879? |
@SteveCEvans Double checked to be sure. It did not. Even tried with a short fixed string instead of using pilotConfig parameter. |
@haslinghuis Please see #13897 |
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.