mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Make OSD items configurable
This commit is contained in:
parent
98bd0f18b3
commit
e2ec4ce2be
13 changed files with 124 additions and 28 deletions
|
@ -60,6 +60,7 @@
|
|||
#include "io/serial_cli.h"
|
||||
#include "io/serial_msp.h"
|
||||
#include "io/statusindicator.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/msp.h"
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "io/escservo.h"
|
||||
#include "rx/rx.h"
|
||||
#include "io/rc_controls.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "io/gimbal.h"
|
||||
#include "io/gps.h"
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "io/rc_curves.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/gps.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
||||
|
@ -402,7 +403,20 @@ static void resetConf(void)
|
|||
//masterConfig.batteryConfig.vbatscale = 20;
|
||||
masterConfig.mag_hardware = MAG_NONE; // disabled by default
|
||||
masterConfig.rxConfig.serialrx_provider = SERIALRX_SBUS;
|
||||
#endif
|
||||
|
||||
#ifdef OSD
|
||||
masterConfig.vtx_channel = 0;
|
||||
masterConfig.osdProfile.system = 0;
|
||||
masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE] = -29;
|
||||
masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE] = -59;
|
||||
masterConfig.osdProfile.item_pos[OSD_TIMER] = -39;
|
||||
masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS] = -9;
|
||||
masterConfig.osdProfile.item_pos[OSD_CPU_LOAD] = 26;
|
||||
masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL] = 1;
|
||||
masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING] = -80;
|
||||
masterConfig.osdProfile.item_pos[OSD_ARMED] = -107;
|
||||
masterConfig.osdProfile.item_pos[OSD_DISARMED] = -109;
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_HAS_VOLTAGE_DIVIDER
|
||||
|
|
|
@ -127,6 +127,7 @@ typedef struct master_t {
|
|||
|
||||
#ifdef OSD
|
||||
uint8_t vtx_channel;
|
||||
osd_profile osdProfile;
|
||||
#endif
|
||||
|
||||
profile_t profile[MAX_PROFILE_COUNT];
|
||||
|
|
|
@ -46,7 +46,7 @@ uint8_t max7456_send(uint8_t add, uint8_t data) {
|
|||
|
||||
// ============================================================ WRITE TO SCREEN
|
||||
|
||||
void max7456_init(void) {
|
||||
void max7456_init(uint8_t system) {
|
||||
uint8_t max7456_reset=0x02;
|
||||
uint8_t max_screen_rows;
|
||||
uint8_t srdata = 0;
|
||||
|
@ -68,6 +68,16 @@ void max7456_init(void) {
|
|||
video_signal_type = VIDEO_MODE_NTSC;
|
||||
}
|
||||
|
||||
// Override detected type: 0-AUTO, 1-PAL, 2-NTSC
|
||||
switch(system) {
|
||||
case 1:
|
||||
video_signal_type = VIDEO_MODE_PAL;
|
||||
break;
|
||||
case 2:
|
||||
video_signal_type = VIDEO_MODE_NTSC;
|
||||
break;
|
||||
}
|
||||
|
||||
max7456_reset |= video_signal_type;
|
||||
|
||||
if (video_signal_type) { //PAL
|
||||
|
@ -94,8 +104,13 @@ void max7456_init(void) {
|
|||
}
|
||||
|
||||
// Copy string from ram into screen buffer
|
||||
void max7456_write_string(const char *string, int address) {
|
||||
char *dest = screen + address;
|
||||
void max7456_write_string(const char *string, int16_t address) {
|
||||
char *dest;
|
||||
|
||||
if (address >= 0)
|
||||
dest = screen + address;
|
||||
else
|
||||
dest = screen + (max_screen_size + address);
|
||||
|
||||
while(*string)
|
||||
*dest++ = *string++;
|
||||
|
|
|
@ -119,12 +119,13 @@
|
|||
//uint8_t ENABLE_display;
|
||||
//uint8_t ENABLE_display_vert;
|
||||
//uint8_t DISABLE_display;
|
||||
uint16_t MAX_screen_size;
|
||||
|
||||
extern uint16_t max_screen_size;
|
||||
char screen[480];
|
||||
|
||||
|
||||
void max7456_init(void);
|
||||
void max7456_init(uint8_t system);
|
||||
void max7456_draw_screen(void);
|
||||
void max7456_draw_screen_fast(void);
|
||||
void max7456_write_string(const char *string, int address);
|
||||
void max7456_write_string(const char *string, int16_t address);
|
||||
void max7456_write_nvm(uint8_t char_address, uint8_t *font_data);
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#include "io/display.h"
|
||||
#include "io/asyncfatfs/asyncfatfs.h"
|
||||
#include "io/transponder_ir.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/sonar.h"
|
||||
|
@ -104,7 +105,6 @@
|
|||
|
||||
#ifdef OSD
|
||||
|
||||
#include "io/osd.h"
|
||||
#include "drivers/max7456.h"
|
||||
#include "drivers/rtc6705.h"
|
||||
#include "scheduler.h"
|
||||
|
@ -485,10 +485,10 @@ void show_menu(void) {
|
|||
uint16_t pos;
|
||||
col_t *col;
|
||||
row_t *row;
|
||||
uint16_t cursor_x, cursor_y;
|
||||
int16_t cursor_x, cursor_y;
|
||||
|
||||
sprintf(string_buffer, "EXIT SAVE+EXIT PAGE");
|
||||
max7456_write_string(string_buffer, 12 * OSD_LINE_LENGTH + 1);
|
||||
max7456_write_string(string_buffer, -29);
|
||||
|
||||
pos = (OSD_LINE_LENGTH - strlen(menu_pages[current_page].title)) / 2 + line * OSD_LINE_LENGTH;
|
||||
sprintf(string_buffer, "%s", menu_pages[current_page].title);
|
||||
|
@ -591,7 +591,7 @@ void show_menu(void) {
|
|||
|
||||
if (cursor_row > MAX_MENU_ROWS) {
|
||||
cursor_row = 255;
|
||||
cursor_y = 12;
|
||||
cursor_y = -1;
|
||||
switch(cursor_col) {
|
||||
case 0:
|
||||
cursor_x = 0;
|
||||
|
@ -651,27 +651,37 @@ void updateOsd(void)
|
|||
if (in_menu) {
|
||||
show_menu();
|
||||
} else {
|
||||
if (batteryWarningVoltage > vbat && blink) {
|
||||
max7456_write_string("LOW VOLTAGE", 310);
|
||||
if (batteryWarningVoltage > vbat && blink && masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING] != -1) {
|
||||
max7456_write_string("LOW VOLTAGE", masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING]);
|
||||
}
|
||||
if (arming && blink) {
|
||||
max7456_write_string("ARMED", 283);
|
||||
if (arming && blink && masterConfig.osdProfile.item_pos[OSD_ARMED] != -1) {
|
||||
max7456_write_string("ARMED", masterConfig.osdProfile.item_pos[OSD_ARMED]);
|
||||
arming--;
|
||||
}
|
||||
if (!armed) {
|
||||
max7456_write_string("DISARMED", 281);
|
||||
if (!armed && masterConfig.osdProfile.item_pos[OSD_DISARMED] != -1) {
|
||||
max7456_write_string("DISARMED", masterConfig.osdProfile.item_pos[OSD_DISARMED]);
|
||||
}
|
||||
|
||||
sprintf(line, "\x97%d.%1d", vbat / 10, vbat % 10);
|
||||
max7456_write_string(line, 361);
|
||||
sprintf(line, "\xba%d", rssi / 10);
|
||||
max7456_write_string(line, 331);
|
||||
sprintf(line, "\x7e%3d", (constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX) - PWM_RANGE_MIN) * 100 / (PWM_RANGE_MAX - PWM_RANGE_MIN));
|
||||
max7456_write_string(line, 381);
|
||||
seconds = (now - armed_at) / 1000000 + armed_seconds;
|
||||
sprintf(line, "\x9C %02d:%02d", seconds / 60, seconds % 60);
|
||||
max7456_write_string(line, 351);
|
||||
print_average_system_load(26, 0);
|
||||
if (masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE] != -1) {
|
||||
sprintf(line, "\x97%d.%1d", vbat / 10, vbat % 10);
|
||||
max7456_write_string(line, masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE]);
|
||||
}
|
||||
if (masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE] != -1) {
|
||||
sprintf(line, "\xba%d", rssi / 10);
|
||||
max7456_write_string(line, masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE]);
|
||||
}
|
||||
if (masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS] != -1) {
|
||||
sprintf(line, "\x7e%3d", (constrain(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX) - PWM_RANGE_MIN) * 100 / (PWM_RANGE_MAX - PWM_RANGE_MIN));
|
||||
max7456_write_string(line, masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS]);
|
||||
}
|
||||
if (masterConfig.osdProfile.item_pos[OSD_TIMER] != -1) {
|
||||
seconds = (now - armed_at) / 1000000 + armed_seconds;
|
||||
sprintf(line, "\x9C %02d:%02d", seconds / 60, seconds % 60);
|
||||
max7456_write_string(line, masterConfig.osdProfile.item_pos[OSD_TIMER]);
|
||||
}
|
||||
if (masterConfig.osdProfile.item_pos[OSD_CPU_LOAD] != -1) {
|
||||
print_average_system_load(masterConfig.osdProfile.item_pos[OSD_CPU_LOAD], 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
max7456_draw_screen_fast();
|
||||
|
@ -686,7 +696,7 @@ void osdInit(void)
|
|||
current_vtx_channel = masterConfig.vtx_channel;
|
||||
rtc6705_set_channel(vtx_freq[current_vtx_channel]);
|
||||
#endif
|
||||
max7456_init();
|
||||
max7456_init(masterConfig.osdProfile.system);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,5 +38,25 @@ typedef struct {
|
|||
row_t rows[MAX_MENU_ROWS];
|
||||
} page_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
OSD_MAIN_BATT_VOLTAGE,
|
||||
OSD_RSSI_VALUE,
|
||||
OSD_TIMER,
|
||||
OSD_THROTTLE_POS,
|
||||
OSD_CPU_LOAD,
|
||||
OSD_VTX_CHANNEL,
|
||||
OSD_VOLTAGE_WARNING,
|
||||
OSD_ARMED,
|
||||
OSD_DISARMED,
|
||||
OSD_MAX_ITEMS, // MUST BE LAST
|
||||
} osd_items;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t system;
|
||||
int16_t item_pos[OSD_MAX_ITEMS];
|
||||
} osd_profile;
|
||||
|
||||
void updateOsd(void);
|
||||
void osdInit(void);
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "io/flashfs.h"
|
||||
#include "io/beeper.h"
|
||||
#include "io/asyncfatfs/asyncfatfs.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
#include "rx/spektrum.h"
|
||||
|
@ -437,6 +438,13 @@ static const char * const lookupTableDebug[] = {
|
|||
"MIXER",
|
||||
"AIRMODE"
|
||||
};
|
||||
#ifdef OSD
|
||||
static const char * const lookupTableOsdType[] = {
|
||||
"AUTO",
|
||||
"PAL",
|
||||
"NTSC"
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct lookupTableEntry_s {
|
||||
const char * const *values;
|
||||
|
@ -464,6 +472,9 @@ typedef enum {
|
|||
TABLE_MAG_HARDWARE,
|
||||
TABLE_DELTA_METHOD,
|
||||
TABLE_DEBUG,
|
||||
#ifdef OSD
|
||||
TABLE_OSD,
|
||||
#endif
|
||||
} lookupTableIndex_e;
|
||||
|
||||
static const lookupTableEntry_t lookupTables[] = {
|
||||
|
@ -486,7 +497,10 @@ static const lookupTableEntry_t lookupTables[] = {
|
|||
{ lookupTableBaroHardware, sizeof(lookupTableBaroHardware) / sizeof(char *) },
|
||||
{ lookupTableMagHardware, sizeof(lookupTableMagHardware) / sizeof(char *) },
|
||||
{ lookupDeltaMethod, sizeof(lookupDeltaMethod) / sizeof(char *) },
|
||||
{ lookupTableDebug, sizeof(lookupTableDebug) / sizeof(char *) }
|
||||
{ lookupTableDebug, sizeof(lookupTableDebug) / sizeof(char *) },
|
||||
#ifdef OSD
|
||||
{ lookupTableOsdType, sizeof(lookupTableOsdType) / sizeof(char *) },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define VALUE_TYPE_OFFSET 0
|
||||
|
@ -771,6 +785,18 @@ const clivalue_t valueTable[] = {
|
|||
#ifdef USE_RTC6705
|
||||
{ "vtx_channel", VAR_INT16 | MASTER_VALUE, &masterConfig.vtx_channel, .config.minmax = { 0, 39 } },
|
||||
#endif
|
||||
#ifdef OSD
|
||||
{ "osd_system", VAR_UINT8 | MASTER_VALUE, &masterConfig.osdProfile.system, .config.lookup = { TABLE_OSD } },
|
||||
{ "osd_main_voltage_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_MAIN_BATT_VOLTAGE], .config.minmax = { -480, 480 } },
|
||||
{ "osd_rssi_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_RSSI_VALUE], .config.minmax = { -480, 480 } },
|
||||
{ "osd_timer_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_TIMER], .config.minmax = { -480, 480 } },
|
||||
{ "osd_throttle_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_THROTTLE_POS], .config.minmax = { -480, 480 } },
|
||||
{ "osd_cpu_load_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_CPU_LOAD], .config.minmax = { -480, 480 } },
|
||||
{ "osd_vtx_channel_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VTX_CHANNEL], .config.minmax = { -480, 480 } },
|
||||
{ "osd_voltage_warning_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_VOLTAGE_WARNING], .config.minmax = { -480, 480 } },
|
||||
{ "osd_armed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_ARMED], .config.minmax = { -480, 480 } },
|
||||
{ "osd_disarmed_pos", VAR_INT16 | MASTER_VALUE, &masterConfig.osdProfile.item_pos[OSD_DISARMED], .config.minmax = { -480, 480 } },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define VALUE_COUNT (sizeof(valueTable) / sizeof(clivalue_t))
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "io/flashfs.h"
|
||||
#include "io/transponder_ir.h"
|
||||
#include "io/asyncfatfs/asyncfatfs.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
|
@ -1569,6 +1570,9 @@ static bool processInCommand(void)
|
|||
#endif
|
||||
#ifdef OSD
|
||||
case MSP_SET_OSD_CONFIG:
|
||||
masterConfig.osdProfile.system = read8();
|
||||
for (i = 0; i < OSD_MAX_ITEMS; i++)
|
||||
masterConfig.osdProfile.item_pos[i] = read16();
|
||||
break;
|
||||
case MSP_OSD_CHAR_WRITE:
|
||||
addr = read8();
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "io/display.h"
|
||||
#include "io/asyncfatfs/asyncfatfs.h"
|
||||
#include "io/transponder_ir.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/sonar.h"
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "io/gps.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/beeper.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "rx/rx.h"
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "io/gimbal.h"
|
||||
#include "io/serial.h"
|
||||
#include "io/ledstrip.h"
|
||||
#include "io/osd.h"
|
||||
|
||||
#include "sensors/boardalignment.h"
|
||||
#include "sensors/sensors.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue