mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Refactor OSD element display code
Remove the giant `select` block that contained all the code to generate the elements and transition them to individual functions called only when the element is active. Simplifies the code and results in a performance improvement as it's not necessary to fall through the large `select` statement for every element that will be drawn. The individual functions and the element to function mapping are moved to a new `osd_elements.c` file. Moved the OSD related code files to a new `osd/` directory. Also pre-analyze the active elements and only process those that are active. This also saves processing as it's not necessary to loop through all 50 or so elements when only a couple are active. Various other cleanup and removal of stale or unnecessary code. In the default configuration the element drawing phase of the OSD task is reduced from ~51us to ~35us - resulting in about a 30% decrease in processing time.
This commit is contained in:
parent
e053965489
commit
30672a37c5
31 changed files with 2435 additions and 2133 deletions
|
@ -85,7 +85,6 @@
|
|||
#include "io/gps.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/motors.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/serial_4way.h"
|
||||
#include "io/servos.h"
|
||||
|
@ -99,6 +98,9 @@
|
|||
#include "msp/msp_protocol.h"
|
||||
#include "msp/msp_serial.h"
|
||||
|
||||
#include "osd/osd.h"
|
||||
#include "osd/osd_elements.h"
|
||||
|
||||
#include "pg/beeper.h"
|
||||
#include "pg/board.h"
|
||||
#include "pg/gyrodev.h"
|
||||
|
@ -2672,8 +2674,7 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src, mspPos
|
|||
// API >= 1.41
|
||||
// selected OSD profile
|
||||
#ifdef USE_OSD_PROFILES
|
||||
osdConfigMutable()->osdProfileIndex = sbufReadU8(src);
|
||||
setOsdProfile(osdConfig()->osdProfileIndex);
|
||||
changeOsdProfileIndex(sbufReadU8(src));
|
||||
#else
|
||||
sbufReadU8(src);
|
||||
#endif // USE_OSD_PROFILES
|
||||
|
@ -2714,6 +2715,7 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src, mspPos
|
|||
} else if (addr < OSD_ITEM_COUNT) {
|
||||
/* Set element positions */
|
||||
osdConfigMutable()->item_pos[addr] = value;
|
||||
osdAnalyzeActiveElements();
|
||||
} else {
|
||||
return MSP_RESULT_ERROR;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue