Skip to content

Commit

Permalink
AP_OSD: add two osd resolution concurrently support
Browse files Browse the repository at this point in the history
  • Loading branch information
lida2003 committed Jan 27, 2025
1 parent 8e4179c commit 9ca74b5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
48 changes: 35 additions & 13 deletions libraries/AP_OSD/AP_OSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,41 @@ void AP_OSD::osd_thread()

void AP_OSD::update_osd()
{
for (uint8_t instance = 0; instance < _backend_count; instance++) {
_backends[instance]->clear();

if (!_disable) {
get_screen(current_screen).set_backend(_backends[instance]);
// skip drawing for MSP OSD backends to save some resources
if (_backends[instance]->get_backend_type() != OSD_MSP) {
get_screen(current_screen).draw();
}
}

_backends[instance]->flush();
}
#if AP_OSD_SCREEN_CONCURRENTLY_ENABLED
if (rc_channel == 0
&& get_screen(0).enabled && get_screen(1).enabled
&& osd_type.get()!=OSD_NONE && osd_type2.get()!=OSD_NONE) {
for (uint8_t instance = 0; instance < _backend_count; instance++) {
_backends[instance]->clear();

if (!_disable) {
get_screen(current_screen+instance).set_backend(_backends[instance]);
// skip drawing for MSP OSD backends to save some resources
if (_backends[instance]->get_backend_type() != OSD_MSP) {
get_screen(current_screen+instance).draw();
}
}

_backends[instance]->flush();
}
} else {
#endif /* AP_OSD_SCREEN_CONCURRENTLY_ENABLED */
for (uint8_t instance = 0; instance < _backend_count; instance++) {
_backends[instance]->clear();

if (!_disable) {
get_screen(current_screen).set_backend(_backends[instance]);
// skip drawing for MSP OSD backends to save some resources
if (_backends[instance]->get_backend_type() != OSD_MSP) {
get_screen(current_screen).draw();
}
}

_backends[instance]->flush();
}
#if AP_OSD_SCREEN_CONCURRENTLY_ENABLED
}
#endif /* AP_OSD_SCREEN_CONCURRENTLY_ENABLED */
}

//update maximums and totals
Expand Down
5 changes: 5 additions & 0 deletions libraries/AP_OSD/AP_OSD_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
#ifndef AP_OSD_LINK_STATS_EXTENSIONS_ENABLED
#define AP_OSD_LINK_STATS_EXTENSIONS_ENABLED 0 // Disabled by default to save flash, enable via custom build server
#endif

#ifndef AP_OSD_SCREEN_CONCURRENTLY_ENABLED
#define AP_OSD_SCREEN_CONCURRENTLY_ENABLED 0 // Disabled by default to save flash, enable via custom build server
#endif

0 comments on commit 9ca74b5

Please sign in to comment.