mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Merge pull request #7614 from etracer65/optimize_osd_elements_display
Refactor OSD element display code
This commit is contained in:
commit
bd40489492
31 changed files with 2435 additions and 2133 deletions
|
@ -166,7 +166,8 @@ maths_unittest_SRC := \
|
|||
|
||||
|
||||
osd_unittest_SRC := \
|
||||
$(USER_DIR)/io/osd.c \
|
||||
$(USER_DIR)/osd/osd.c \
|
||||
$(USER_DIR)/osd/osd_elements.c \
|
||||
$(USER_DIR)/common/typeconversion.c \
|
||||
$(USER_DIR)/drivers/display.c \
|
||||
$(USER_DIR)/common/maths.c \
|
||||
|
|
|
@ -40,11 +40,11 @@ extern "C" {
|
|||
#include "flight/servos.h"
|
||||
#include "io/beeper.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/vtx.h"
|
||||
#include "msp/msp.h"
|
||||
#include "msp/msp_box.h"
|
||||
#include "osd/osd.h"
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/beeper.h"
|
||||
|
|
|
@ -52,7 +52,9 @@ extern "C" {
|
|||
|
||||
#include "io/beeper.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "osd/osd.h"
|
||||
#include "osd/osd_elements.h"
|
||||
|
||||
#include "sensors/acceleration.h"
|
||||
#include "sensors/battery.h"
|
||||
|
@ -62,7 +64,6 @@ extern "C" {
|
|||
|
||||
void osdRefresh(timeUs_t currentTimeUs);
|
||||
void osdFormatTime(char * buff, osd_timer_precision_e precision, timeUs_t time);
|
||||
void osdFormatTimer(char *buff, bool showSymbol, int timerIndex);
|
||||
int osdConvertTemperatureToSelectedUnit(int tempInDegreesCelcius);
|
||||
|
||||
uint16_t rssi;
|
||||
|
@ -481,6 +482,8 @@ TEST(OsdTest, TestAlarms)
|
|||
osdConfigMutable()->cap_alarm = 2200;
|
||||
osdConfigMutable()->alt_alarm = 100; // meters
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// and
|
||||
// this timer 1 configuration
|
||||
osdConfigMutable()->timers[OSD_TIMER_1] = OSD_TIMER(OSD_TIMER_SRC_ON, OSD_TIMER_PREC_HUNDREDTHS, 2);
|
||||
|
@ -562,6 +565,8 @@ TEST(OsdTest, TestElementRssi)
|
|||
osdConfigMutable()->item_pos[OSD_RSSI_VALUE] = OSD_POS(8, 1) | OSD_PROFILE_1_FLAG;
|
||||
osdConfigMutable()->rssi_alarm = 0;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// when
|
||||
rssi = 1024;
|
||||
displayClearScreen(&testDisplayPort);
|
||||
|
@ -595,6 +600,8 @@ TEST(OsdTest, TestElementAmperage)
|
|||
// given
|
||||
osdConfigMutable()->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 12) | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// when
|
||||
simulationBatteryAmperage = 0;
|
||||
displayClearScreen(&testDisplayPort);
|
||||
|
@ -628,6 +635,8 @@ TEST(OsdTest, TestElementMahDrawn)
|
|||
// given
|
||||
osdConfigMutable()->item_pos[OSD_MAH_DRAWN] = OSD_POS(1, 11) | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// when
|
||||
simulationMahDrawn = 0;
|
||||
displayClearScreen(&testDisplayPort);
|
||||
|
@ -677,6 +686,8 @@ TEST(OsdTest, TestElementPower)
|
|||
// given
|
||||
osdConfigMutable()->item_pos[OSD_POWER] = OSD_POS(1, 10) | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// and
|
||||
simulationBatteryVoltage = 1000; // 10V
|
||||
|
||||
|
@ -739,6 +750,8 @@ TEST(OsdTest, TestElementAltitude)
|
|||
// given
|
||||
osdConfigMutable()->item_pos[OSD_ALTITUDE] = OSD_POS(23, 7) | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// and
|
||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||
sensorsClear(SENSOR_GPS);
|
||||
|
@ -800,6 +813,8 @@ TEST(OsdTest, TestElementCoreTemperature)
|
|||
// given
|
||||
osdConfigMutable()->item_pos[OSD_CORE_TEMPERATURE] = OSD_POS(1, 8) | OSD_PROFILE_1_FLAG;
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// and
|
||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||
|
||||
|
@ -846,6 +861,8 @@ TEST(OsdTest, TestElementWarningsBattery)
|
|||
osdWarnSetState(OSD_WARNING_BATTERY_CRITICAL, true);
|
||||
osdWarnSetState(OSD_WARNING_BATTERY_NOT_FULL, true);
|
||||
|
||||
osdAnalyzeActiveElements();
|
||||
|
||||
// and
|
||||
batteryConfigMutable()->vbatfullcellvoltage = 410;
|
||||
|
||||
|
|
|
@ -40,9 +40,10 @@ extern "C" {
|
|||
|
||||
#include "scheduler/scheduler.h"
|
||||
#include "io/rcdevice_cam.h"
|
||||
#include "io/osd.h"
|
||||
#include "io/rcdevice.h"
|
||||
|
||||
#include "osd/osd.h"
|
||||
|
||||
#include "pg/pg.h"
|
||||
#include "pg/pg_ids.h"
|
||||
#include "pg/vcd.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue