From 283baa7c0a28685ec184dd1f57a822009c46480b Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 15 May 2024 20:01:08 +0100 Subject: [PATCH 1/2] Initial changes --- src/main/CMakeLists.txt | 4 +- src/main/drivers/osd.h | 4 +- src/main/drivers/osd_symbols.h | 6 +- src/main/io/bf_osd_symbols.h | 163 ---- src/main/io/displayport_msp_bf_compat.c | 748 ------------------ src/main/io/displayport_msp_dji_compat.c | 713 +++++++++++++++++ ..._compat.h => displayport_msp_dji_compat.h} | 12 +- src/main/io/displayport_msp_osd.c | 18 +- src/main/io/dji_osd_symbols.h | 164 ++++ src/main/io/osd.c | 127 +-- src/main/io/osd_grid.c | 8 +- src/main/io/osd_hud.c | 4 +- src/main/io/osd_utils.c | 4 +- 13 files changed, 948 insertions(+), 1027 deletions(-) delete mode 100644 src/main/io/bf_osd_symbols.h delete mode 100644 src/main/io/displayport_msp_bf_compat.c create mode 100644 src/main/io/displayport_msp_dji_compat.c rename src/main/io/{displayport_msp_bf_compat.h => displayport_msp_dji_compat.h} (69%) create mode 100644 src/main/io/dji_osd_symbols.h diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 28c068966f8..c87abc1782d 100755 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -500,8 +500,8 @@ main_sources(COMMON_SRC io/displayport_max7456.h io/displayport_msp.c io/displayport_msp.h - io/displayport_msp_bf_compat.c - io/displayport_msp_bf_compat.h + io/displayport_msp_dji_compat.c + io/displayport_msp_dji_compat.h io/displayport_oled.c io/displayport_oled.h io/displayport_msp_osd.c diff --git a/src/main/drivers/osd.h b/src/main/drivers/osd.h index e9ae4d5ef3f..a8b0bbc8e42 100644 --- a/src/main/drivers/osd.h +++ b/src/main/drivers/osd.h @@ -49,8 +49,8 @@ typedef enum { VIDEO_SYSTEM_HDZERO, VIDEO_SYSTEM_DJIWTF, VIDEO_SYSTEM_AVATAR, - VIDEO_SYSTEM_BFCOMPAT, - VIDEO_SYSTEM_BFCOMPAT_HD + VIDEO_SYSTEM_DJICOMPAT, + VIDEO_SYSTEM_DJICOMPAT_HD } videoSystem_e; typedef enum { diff --git a/src/main/drivers/osd_symbols.h b/src/main/drivers/osd_symbols.h index 91cdcbb5f6b..90c0bc97131 100644 --- a/src/main/drivers/osd_symbols.h +++ b/src/main/drivers/osd_symbols.h @@ -44,9 +44,9 @@ #define SYM_DBM 0x13 // 019 dBm #define SYM_SNR 0x14 // 020 SNR -#define SYM_AH_DIRECTION_UP 0x15 // 021 Arrow up AHI -#define SYM_AH_DIRECTION_DOWN 0x16 // 022 Arrow down AHI -#define SYM_DIRECTION 0x17 // 023 to 030, directional little arrows +#define SYM_AH_DECORATION_UP 0x15 // 021 Arrow up AHI +#define SYM_AH_DECORATION_DOWN 0x16 // 022 Arrow down AHI +#define SYM_DECORATION 0x17 // 023 to 030, directional little arrows #define SYM_VOLT 0x1F // 031 VOLTS #define SYM_MAH 0x99 // 153 mAh diff --git a/src/main/io/bf_osd_symbols.h b/src/main/io/bf_osd_symbols.h deleted file mode 100644 index a63b9470fb3..00000000000 --- a/src/main/io/bf_osd_symbols.h +++ /dev/null @@ -1,163 +0,0 @@ -/* @file max7456_symbols.h - * @brief max7456 symbols for the mwosd font set - * - * @author Nathan Tsoi nathan@vertile.com - * - * Copyright (C) 2016 Nathan Tsoi - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -#pragma once - -//Misc -#define BF_SYM_NONE 0x00 -#define BF_SYM_END_OF_FONT 0xFF -#define BF_SYM_BLANK 0x20 -#define BF_SYM_HYPHEN 0x2D -#define BF_SYM_BBLOG 0x10 -#define BF_SYM_HOMEFLAG 0x11 -#define BF_SYM_RPM 0x12 -#define BF_SYM_ROLL 0x14 -#define BF_SYM_PITCH 0x15 -#define BF_SYM_TEMPERATURE 0x7A - -// GPS and navigation -#define BF_SYM_LAT 0x89 -#define BF_SYM_LON 0x98 -#define BF_SYM_ALTITUDE 0x7F -#define BF_SYM_TOTAL_DISTANCE 0x71 -#define BF_SYM_OVER_HOME 0x05 - -// RSSI -#define BF_SYM_RSSI 0x01 -#define BF_SYM_LINK_QUALITY 0x7B - -// Throttle Position (%) -#define BF_SYM_THR 0x04 - -// Unit Icons (Metric) -#define BF_SYM_M 0x0C -#define BF_SYM_KM 0x7D -#define BF_SYM_C 0x0E - -// Unit Icons (Imperial) -#define BF_SYM_FT 0x0F -#define BF_SYM_MILES 0x7E -#define BF_SYM_F 0x0D - -// Heading Graphics -#define BF_SYM_HEADING_N 0x18 -#define BF_SYM_HEADING_S 0x19 -#define BF_SYM_HEADING_E 0x1A -#define BF_SYM_HEADING_W 0x1B -#define BF_SYM_HEADING_DIVIDED_LINE 0x1C -#define BF_SYM_HEADING_LINE 0x1D - -// AH Center screen Graphics -#define BF_SYM_AH_CENTER_LINE 0x72 -#define BF_SYM_AH_CENTER 0x73 -#define BF_SYM_AH_CENTER_LINE_RIGHT 0x74 -#define BF_SYM_AH_RIGHT 0x02 -#define BF_SYM_AH_LEFT 0x03 -#define BF_SYM_AH_DECORATION 0x13 - -// Satellite Graphics -#define BF_SYM_SAT_L 0x1E -#define BF_SYM_SAT_R 0x1F - -// Direction arrows -#define BF_SYM_ARROW_SOUTH 0x60 -#define BF_SYM_ARROW_2 0x61 -#define BF_SYM_ARROW_3 0x62 -#define BF_SYM_ARROW_4 0x63 -#define BF_SYM_ARROW_EAST 0x64 -#define BF_SYM_ARROW_6 0x65 -#define BF_SYM_ARROW_7 0x66 -#define BF_SYM_ARROW_8 0x67 -#define BF_SYM_ARROW_NORTH 0x68 -#define BF_SYM_ARROW_10 0x69 -#define BF_SYM_ARROW_11 0x6A -#define BF_SYM_ARROW_12 0x6B -#define BF_SYM_ARROW_WEST 0x6C -#define BF_SYM_ARROW_14 0x6D -#define BF_SYM_ARROW_15 0x6E -#define BF_SYM_ARROW_16 0x6F - -#define BF_SYM_ARROW_SMALL_UP 0x75 -#define BF_SYM_ARROW_SMALL_DOWN 0x76 - -// AH Bars -#define BF_SYM_AH_BAR9_0 0x80 -#define BF_SYM_AH_BAR9_1 0x81 -#define BF_SYM_AH_BAR9_2 0x82 -#define BF_SYM_AH_BAR9_3 0x83 -#define BF_SYM_AH_BAR9_4 0x84 -#define BF_SYM_AH_BAR9_5 0x85 -#define BF_SYM_AH_BAR9_6 0x86 -#define BF_SYM_AH_BAR9_7 0x87 -#define BF_SYM_AH_BAR9_8 0x88 - -// Progress bar -#define BF_SYM_PB_START 0x8A -#define BF_SYM_PB_FULL 0x8B -#define BF_SYM_PB_HALF 0x8C -#define BF_SYM_PB_EMPTY 0x8D -#define BF_SYM_PB_END 0x8E -#define BF_SYM_PB_CLOSE 0x8F - -// Batt evolution -#define BF_SYM_BATT_FULL 0x90 -#define BF_SYM_BATT_5 0x91 -#define BF_SYM_BATT_4 0x92 -#define BF_SYM_BATT_3 0x93 -#define BF_SYM_BATT_2 0x94 -#define BF_SYM_BATT_1 0x95 -#define BF_SYM_BATT_EMPTY 0x96 - -// Batt Icons -#define BF_SYM_MAIN_BATT 0x97 - -// Voltage and amperage -#define BF_SYM_VOLT 0x06 -#define BF_SYM_AMP 0x9A -#define BF_SYM_MAH 0x07 -#define BF_SYM_WATT 0x57 // 0x57 is 'W' - -// Time -#define BF_SYM_ON_M 0x9B -#define BF_SYM_FLY_M 0x9C - -// Speed -#define BF_SYM_SPEED 0x70 -#define BF_SYM_KPH 0x9E -#define BF_SYM_MPH 0x9D -#define BF_SYM_MPS 0x9F -#define BF_SYM_FTPS 0x99 - -// Menu cursor -#define BF_SYM_CURSOR BF_SYM_AH_LEFT - -// Stick overlays -#define BF_SYM_STICK_OVERLAY_SPRITE_HIGH 0x08 -#define BF_SYM_STICK_OVERLAY_SPRITE_MID 0x09 -#define BF_SYM_STICK_OVERLAY_SPRITE_LOW 0x0A -#define BF_SYM_STICK_OVERLAY_CENTER 0x0B -#define BF_SYM_STICK_OVERLAY_VERTICAL 0x16 -#define BF_SYM_STICK_OVERLAY_HORIZONTAL 0x17 - -// GPS degree/minute/second symbols -#define BF_SYM_GPS_DEGREE BF_SYM_STICK_OVERLAY_SPRITE_HIGH // kind of looks like the degree symbol -#define BF_SYM_GPS_MINUTE 0x27 // ' -#define BF_SYM_GPS_SECOND 0x22 // " diff --git a/src/main/io/displayport_msp_bf_compat.c b/src/main/io/displayport_msp_bf_compat.c deleted file mode 100644 index e7f75ec2fa5..00000000000 --- a/src/main/io/displayport_msp_bf_compat.c +++ /dev/null @@ -1,748 +0,0 @@ -/* - * This file is part of INAV Project. - * - * INAV is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Cleanflight is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Cleanflight. If not, see . - */ - -#include "platform.h" - -#if defined(USE_OSD) && defined(USE_MSP_DISPLAYPORT) - -#ifndef DISABLE_MSP_BF_COMPAT - -#include "io/displayport_msp_bf_compat.h" -#include "io/bf_osd_symbols.h" -#include "drivers/osd_symbols.h" - -uint8_t getBfCharacter(uint8_t ch, uint8_t page) -{ - uint16_t ech = ch | ((page & 0x3)<< 8) ; - - if (ech >= 0x20 && ech <= 0x5F) { // ASCII range - return ch; - } - - if (ech >= SYM_AH_DECORATION_MIN && ech <= SYM_AH_DECORATION_MAX) { - return BF_SYM_AH_DECORATION; - } - - switch (ech) { - case SYM_RSSI: - return BF_SYM_RSSI; - - case SYM_LQ: - return BF_SYM_LINK_QUALITY; - - case SYM_LAT: - return BF_SYM_LAT; - - case SYM_LON: - return BF_SYM_LON; - - case SYM_SAT_L: - return BF_SYM_SAT_L; - - case SYM_SAT_R: - return BF_SYM_SAT_R; - - case SYM_HOME_NEAR: - return BF_SYM_HOMEFLAG; - - case SYM_DEGREES: - return BF_SYM_GPS_DEGREE; - -/* - case SYM_HEADING: - return BF_SYM_HEADING; - - case SYM_SCALE: - return BF_SYM_SCALE; - - case SYM_HDP_L: - return BF_SYM_HDP_L; - - case SYM_HDP_R: - return BF_SYM_HDP_R; -*/ - case SYM_HOME: - return BF_SYM_HOMEFLAG; - - case SYM_2RSS: - return BF_SYM_RSSI; - -/* - case SYM_DB: - return BF_SYM_DB - - case SYM_DBM: - return BF_SYM_DBM; - - case SYM_SNR: - return BF_SYM_SNR; - - case SYM_AH_DECORATION_UP: - return BF_SYM_AH_DECORATION_UP; - - case SYM_AH_DECORATION_DOWN: - return BF_SYM_AH_DECORATION_DOWN; -*/ - case SYM_DIRECTION: - return BF_SYM_ARROW_NORTH; - - case SYM_DIRECTION + 1: // NE pointing arrow - return BF_SYM_ARROW_7; - - case SYM_DIRECTION + 2: // E pointing arrow - return BF_SYM_ARROW_EAST; - - case SYM_DIRECTION + 3: // SE pointing arrow - return BF_SYM_ARROW_3; - - case SYM_DIRECTION + 4: // S pointing arrow - return BF_SYM_ARROW_SOUTH; - - case SYM_DIRECTION + 5: // SW pointing arrow - return BF_SYM_ARROW_15; - - case SYM_DIRECTION + 6: // W pointing arrow - return BF_SYM_ARROW_WEST; - - case SYM_DIRECTION + 7: // NW pointing arrow - return BF_SYM_ARROW_11; - - case SYM_VOLT: - return BF_SYM_VOLT; - - case SYM_MAH: - return BF_SYM_MAH; - - case SYM_AH_KM: - return BF_SYM_KM; - - case SYM_AH_MI: - return BF_SYM_MILES; -/* - case SYM_VTX_POWER: - return BF_SYM_VTX_POWER; - - case SYM_AH_NM: - return BF_SYM_AH_NM; - - case SYM_MAH_NM_0: - return BF_SYM_MAH_NM_0; - - case SYM_MAH_NM_1: - return BF_SYM_MAH_NM_1; - - case SYM_MAH_KM_0: - return BF_SYM_MAH_KM_0; - - case SYM_MAH_KM_1: - return BF_SYM_MAH_KM_1; - - case SYM_MILLIOHM: - return BF_SYM_MILLIOHM; -*/ - case SYM_BATT_FULL: - return BF_SYM_BATT_FULL; - - case SYM_BATT_5: - return BF_SYM_BATT_5; - - case SYM_BATT_4: - return BF_SYM_BATT_4; - - case SYM_BATT_3: - return BF_SYM_BATT_3; - - case SYM_BATT_2: - return BF_SYM_BATT_2; - - case SYM_BATT_1: - return BF_SYM_BATT_1; - - case SYM_BATT_EMPTY: - return BF_SYM_BATT_EMPTY; - - case SYM_AMP: - return BF_SYM_AMP; -/* - case SYM_WH: - return BF_SYM_WH; - - case SYM_WH_KM: - return BF_SYM_WH_KM; - - case SYM_WH_MI: - return BF_SYM_WH_MI; - - case SYM_WH_NM: - return BF_SYM_WH_NM; -*/ - case SYM_WATT: - return BF_SYM_WATT; -/* - case SYM_MW: - return BF_SYM_MW; - - case SYM_KILOWATT: - return BF_SYM_KILOWATT; -*/ - case SYM_FT: - return BF_SYM_FT; - - case SYM_ALT_FT: - return BF_SYM_FT; - - case SYM_ALT_M: - return BF_SYM_M; - - case SYM_TOTAL: - return BF_SYM_TOTAL_DISTANCE; -/* - case SYM_ALT_KM: - return BF_SYM_ALT_KM; - - case SYM_ALT_KFT: - return BF_SYM_ALT_KFT; - - case SYM_DIST_M: - return BF_SYM_DIST_M; - - case SYM_DIST_KM: - return BF_SYM_DIST_KM; - - case SYM_DIST_FT: - return BF_SYM_DIST_FT; - - case SYM_DIST_MI: - return BF_SYM_DIST_MI; - - case SYM_DIST_NM: - return BF_SYM_DIST_NM; -*/ - case SYM_M: - return BF_SYM_M; - - case SYM_KM: - return BF_SYM_KM; - - case SYM_MI: - return BF_SYM_MILES; -/* - case SYM_NM: - return BF_SYM_NM; -*/ - case SYM_WIND_HORIZONTAL: - return 'W'; // W for wind - -/* - case SYM_WIND_VERTICAL: - return BF_SYM_WIND_VERTICAL; - - case SYM_3D_KT: - return BF_SYM_3D_KT; -*/ - case SYM_AIR: - return 'A'; // A for airspeed - - case SYM_3D_KMH: - return BF_SYM_KPH; - - case SYM_3D_MPH: - return BF_SYM_MPH; - - case SYM_RPM: - return BF_SYM_RPM; - - case SYM_FTS: - return BF_SYM_FTPS; -/* - case SYM_100FTM: - return BF_SYM_100FTM; -*/ - case SYM_MS: - return BF_SYM_MPS; - - case SYM_KMH: - return BF_SYM_KPH; - - case SYM_MPH: - return BF_SYM_MPH; -/* - case SYM_KT: - return BF_SYM_KT - - case SYM_MAH_MI_0: - return BF_SYM_MAH_MI_0; - - case SYM_MAH_MI_1: - return BF_SYM_MAH_MI_1; -*/ - case SYM_THR: - return BF_SYM_THR; - - case SYM_TEMP_F: - return BF_SYM_F; - - case SYM_TEMP_C: - return BF_SYM_C; - - case SYM_BLANK: - return BF_SYM_BLANK; -/* - case SYM_ON_H: - return BF_SYM_ON_H; - - case SYM_FLY_H: - return BF_SYM_FLY_H; -*/ - case SYM_ON_M: - return BF_SYM_ON_M; - - case SYM_FLY_M: - return BF_SYM_FLY_M; -/* - case SYM_GLIDESLOPE: - return BF_SYM_GLIDESLOPE; - - case SYM_WAYPOINT: - return BF_SYM_WAYPOINT; - - case SYM_CLOCK: - return BF_SYM_CLOCK; - - case SYM_ZERO_HALF_TRAILING_DOT: - return BF_SYM_ZERO_HALF_TRAILING_DOT; - - case SYM_ZERO_HALF_LEADING_DOT: - return BF_SYM_ZERO_HALF_LEADING_DOT; -*/ - - case SYM_AUTO_THR0: - return 'A'; - - case SYM_AUTO_THR1: - return BF_SYM_THR; - - case SYM_ROLL_LEFT: - return BF_SYM_ROLL; - - case SYM_ROLL_LEVEL: - return BF_SYM_ROLL; - - case SYM_ROLL_RIGHT: - return BF_SYM_ROLL; - - case SYM_PITCH_UP: - return BF_SYM_PITCH; - - case SYM_PITCH_DOWN: - return BF_SYM_PITCH; - - case SYM_GFORCE: - return 'G'; - -/* - case SYM_GFORCE_X: - return BF_SYM_GFORCE_X; - - case SYM_GFORCE_Y: - return BF_SYM_GFORCE_Y; - - case SYM_GFORCE_Z: - return BF_SYM_GFORCE_Z; - - case SYM_BARO_TEMP: - return BF_SYM_BARO_TEMP; - - case SYM_IMU_TEMP: - return BF_SYM_IMU_TEMP; - - case SYM_TEMP: - return BF_SYM_TEMP; - - case SYM_TEMP_SENSOR_FIRST: - return BF_SYM_TEMP_SENSOR_FIRST; - - case SYM_ESC_TEMP: - return BF_SYM_ESC_TEMP; - - case SYM_TEMP_SENSOR_LAST: - return BF_SYM_TEMP_SENSOR_LAST; - - case TEMP_SENSOR_SYM_COUNT: - return BF_TEMP_SENSOR_SYM_COUNT; -*/ - case SYM_HEADING_N: - return BF_SYM_HEADING_N; - - case SYM_HEADING_S: - return BF_SYM_HEADING_S; - - case SYM_HEADING_E: - return BF_SYM_HEADING_E; - - case SYM_HEADING_W: - return BF_SYM_HEADING_W; - - case SYM_HEADING_DIVIDED_LINE: - return BF_SYM_HEADING_DIVIDED_LINE; - - case SYM_HEADING_LINE: - return BF_SYM_HEADING_LINE; -/* - case SYM_MAX: - return BF_SYM_MAX; - - case SYM_PROFILE: - return BF_SYM_PROFILE; - - case SYM_SWITCH_INDICATOR_LOW: - return BF_SYM_SWITCH_INDICATOR_LOW; - - case SYM_SWITCH_INDICATOR_MID: - return BF_SYM_SWITCH_INDICATOR_MID; - - case SYM_SWITCH_INDICATOR_HIGH: - return BF_SYM_SWITCH_INDICATOR_HIGH; - - case SYM_AH: - return BF_SYM_AH; - - case SYM_GLIDE_DIST: - return BF_SYM_GLIDE_DIST; - - case SYM_GLIDE_MINS: - return BF_SYM_GLIDE_MINS; - - case SYM_AH_V_FT_0: - return BF_SYM_AH_V_FT_0; - - case SYM_AH_V_FT_1: - return BF_SYM_AH_V_FT_1; - - case SYM_AH_V_M_0: - return BF_SYM_AH_V_M_0; - - case SYM_AH_V_M_1: - return BF_SYM_AH_V_M_1; - - case SYM_FLIGHT_MINS_REMAINING: - return BF_SYM_FLIGHT_MINS_REMAINING; - - case SYM_FLIGHT_HOURS_REMAINING: - return BF_SYM_FLIGHT_HOURS_REMAINING; - - case SYM_GROUND_COURSE: - return BF_SYM_GROUND_COURSE; - - case SYM_CROSS_TRACK_ERROR: - return BF_SYM_CROSS_TRACK_ERROR; - - case SYM_LOGO_START: - return BF_SYM_LOGO_START; - - case SYM_LOGO_WIDTH: - return BF_SYM_LOGO_WIDTH; - - case SYM_LOGO_HEIGHT: - return BF_SYM_LOGO_HEIGHT; -*/ - case SYM_AH_LEFT: - return BF_SYM_AH_LEFT; - - case SYM_AH_RIGHT: - return BF_SYM_AH_RIGHT; - -/* - case SYM_AH_DECORATION_COUNT: - return BF_SYM_AH_DECORATION_COUNT; -*/ - case SYM_AH_CH_LEFT: - case SYM_AH_CH_TYPE3: - case SYM_AH_CH_TYPE4: - case SYM_AH_CH_TYPE5: - case SYM_AH_CH_TYPE6: - case SYM_AH_CH_TYPE7: - case SYM_AH_CH_TYPE8: - case SYM_AH_CH_AIRCRAFT1: - return BF_SYM_AH_CENTER_LINE; - - case SYM_AH_CH_RIGHT: - case (SYM_AH_CH_TYPE3+2): - case (SYM_AH_CH_TYPE4+2): - case (SYM_AH_CH_TYPE5+2): - case (SYM_AH_CH_TYPE6+2): - case (SYM_AH_CH_TYPE7+2): - case (SYM_AH_CH_TYPE8+2): - case SYM_AH_CH_AIRCRAFT3: - return BF_SYM_AH_CENTER_LINE_RIGHT; - - case SYM_AH_CH_AIRCRAFT0: - case SYM_AH_CH_AIRCRAFT4: - return ' '; - - case SYM_ARROW_UP: - return BF_SYM_ARROW_NORTH; - - case SYM_ARROW_2: - return BF_SYM_ARROW_8; - - case SYM_ARROW_3: - return BF_SYM_ARROW_7; - - case SYM_ARROW_4: - return BF_SYM_ARROW_6; - - case SYM_ARROW_RIGHT: - return BF_SYM_ARROW_EAST; - - case SYM_ARROW_6: - return BF_SYM_ARROW_4; - - case SYM_ARROW_7: - return BF_SYM_ARROW_3; - - case SYM_ARROW_8: - return BF_SYM_ARROW_2; - - case SYM_ARROW_DOWN: - return BF_SYM_ARROW_SOUTH; - - case SYM_ARROW_10: - return BF_SYM_ARROW_16; - - case SYM_ARROW_11: - return BF_SYM_ARROW_15; - - case SYM_ARROW_12: - return BF_SYM_ARROW_14; - - case SYM_ARROW_LEFT: - return BF_SYM_ARROW_WEST; - - case SYM_ARROW_14: - return BF_SYM_ARROW_12; - - case SYM_ARROW_15: - return BF_SYM_ARROW_11; - - case SYM_ARROW_16: - return BF_SYM_ARROW_10; - - case SYM_AH_H_START: - return BF_SYM_AH_BAR9_0; - - case (SYM_AH_H_START+1): - return BF_SYM_AH_BAR9_1; - - case (SYM_AH_H_START+2): - return BF_SYM_AH_BAR9_2; - - case (SYM_AH_H_START+3): - return BF_SYM_AH_BAR9_3; - - case (SYM_AH_H_START+4): - return BF_SYM_AH_BAR9_4; - - case (SYM_AH_H_START+5): - return BF_SYM_AH_BAR9_5; - - case (SYM_AH_H_START+6): - return BF_SYM_AH_BAR9_6; - - case (SYM_AH_H_START+7): - return BF_SYM_AH_BAR9_7; - - case (SYM_AH_H_START+8): - return BF_SYM_AH_BAR9_8; - - // BF does not have vertical artificial horizon. replace with middle horizontal one - case SYM_AH_V_START: - case (SYM_AH_V_START+1): - case (SYM_AH_V_START+2): - case (SYM_AH_V_START+3): - case (SYM_AH_V_START+4): - case (SYM_AH_V_START+5): - return BF_SYM_AH_BAR9_4; - - // BF for ESP_RADAR Symbols - case SYM_HUD_CARDINAL: - return BF_SYM_ARROW_SOUTH; - case SYM_HUD_CARDINAL + 1: - return BF_SYM_ARROW_16; - case SYM_HUD_CARDINAL + 2: - return BF_SYM_ARROW_15; - case SYM_HUD_CARDINAL + 3: - return BF_SYM_ARROW_WEST; - case SYM_HUD_CARDINAL + 4: - return BF_SYM_ARROW_12; - case SYM_HUD_CARDINAL + 5: - return BF_SYM_ARROW_11; - case SYM_HUD_CARDINAL + 6: - return BF_SYM_ARROW_NORTH; - case SYM_HUD_CARDINAL + 7: - return BF_SYM_ARROW_7; - case SYM_HUD_CARDINAL + 8: - return BF_SYM_ARROW_6; - case SYM_HUD_CARDINAL + 9: - return BF_SYM_ARROW_EAST; - case SYM_HUD_CARDINAL + 10: - return BF_SYM_ARROW_3; - case SYM_HUD_CARDINAL + 11: - return BF_SYM_ARROW_2; - - case SYM_HUD_ARROWS_R3: - return BF_SYM_AH_RIGHT; - case SYM_HUD_ARROWS_L3: - return BF_SYM_AH_LEFT; - - case SYM_HUD_SIGNAL_0: - return BF_SYM_AH_BAR9_1; - case SYM_HUD_SIGNAL_1: - return BF_SYM_AH_BAR9_3; - case SYM_HUD_SIGNAL_2: - return BF_SYM_AH_BAR9_4; - case SYM_HUD_SIGNAL_3: - return BF_SYM_AH_BAR9_5; - case SYM_HUD_SIGNAL_4: - return BF_SYM_AH_BAR9_7; -/* - case SYM_VARIO_UP_2A: - return BF_SYM_VARIO_UP_2A; - - case SYM_VARIO_UP_1A: - return BF_SYM_VARIO_UP_1A; - - case SYM_VARIO_DOWN_1A: - return BF_SYM_VARIO_DOWN_1A; - - case SYM_VARIO_DOWN_2A: - return BF_SYM_VARIO_DOWN_2A; -*/ - case SYM_ALT: - return BF_SYM_ALTITUDE; -/* - case SYM_HUD_SIGNAL_0: - return BF_SYM_HUD_SIGNAL_0; - - case SYM_HUD_SIGNAL_1: - return BF_SYM_HUD_SIGNAL_1; - - case SYM_HUD_SIGNAL_2: - return BF_SYM_HUD_SIGNAL_2; - - case SYM_HUD_SIGNAL_3: - return BF_SYM_HUD_SIGNAL_3; - - case SYM_HUD_SIGNAL_4: - return BF_SYM_HUD_SIGNAL_4; - - case SYM_HOME_DIST: - return BF_SYM_HOME_DIST; -*/ - - case SYM_AH_CH_CENTER: - case (SYM_AH_CH_TYPE3+1): - case (SYM_AH_CH_TYPE4+1): - case (SYM_AH_CH_TYPE5+1): - case (SYM_AH_CH_TYPE6+1): - case (SYM_AH_CH_TYPE7+1): - case (SYM_AH_CH_TYPE8+1): - case SYM_AH_CH_AIRCRAFT2: - return BF_SYM_AH_CENTER; -/* - case SYM_FLIGHT_DIST_REMAINING: - return BF_SYM_FLIGHT_DIST_REMAINING; - - case SYM_AH_CH_TYPE3: - return BF_SYM_AH_CH_TYPE3; - - case SYM_AH_CH_TYPE4: - return BF_SYM_AH_CH_TYPE4; - - case SYM_AH_CH_TYPE5: - return BF_SYM_AH_CH_TYPE5; - - case SYM_AH_CH_TYPE6: - return BF_SYM_AH_CH_TYPE6; - - case SYM_AH_CH_TYPE7: - return BF_SYM_AH_CH_TYPE7; - - case SYM_AH_CH_TYPE8: - return BF_SYM_AH_CH_TYPE8; - - case SYM_AH_CH_AIRCRAFT0: - return BF_SYM_AH_CH_AIRCRAFT0; - - case SYM_AH_CH_AIRCRAFT1: - return BF_SYM_AH_CH_AIRCRAFT1; - - case SYM_AH_CH_AIRCRAFT2: - return BF_SYM_AH_CH_AIRCRAFT2; - - case SYM_AH_CH_AIRCRAFT3: - return BF_SYM_AH_CH_AIRCRAFT3; - - case SYM_AH_CH_AIRCRAFT4: - return BF_SYM_AH_CH_AIRCRAFT4; - - case SYM_HUD_ARROWS_L1: - return BF_SYM_HUD_ARROWS_L1; - - case SYM_HUD_ARROWS_L2: - return BF_SYM_HUD_ARROWS_L2; - - case SYM_HUD_ARROWS_L3: - return BF_SYM_HUD_ARROWS_L3; - - case SYM_HUD_ARROWS_R1: - return BF_SYM_HUD_ARROWS_R1; - - case SYM_HUD_ARROWS_R2: - return BF_SYM_HUD_ARROWS_R2; - - case SYM_HUD_ARROWS_R3: - return BF_SYM_HUD_ARROWS_R3; - - case SYM_HUD_ARROWS_U1: - return BF_SYM_HUD_ARROWS_U1; - - case SYM_HUD_ARROWS_U2: - return BF_SYM_HUD_ARROWS_U2; - - case SYM_HUD_ARROWS_U3: - return BF_SYM_HUD_ARROWS_U3; - - case SYM_HUD_ARROWS_D1: - return BF_SYM_HUD_ARROWS_D1; - - case SYM_HUD_ARROWS_D2: - return BF_SYM_HUD_ARROWS_D2; - - case SYM_HUD_ARROWS_D3: - return BF_SYM_HUD_ARROWS_D3; -*/ - default: - break; - } - - return '?'; // Missing/not mapped character -} - -#endif - -#endif diff --git a/src/main/io/displayport_msp_dji_compat.c b/src/main/io/displayport_msp_dji_compat.c new file mode 100644 index 00000000000..de4fa8656fa --- /dev/null +++ b/src/main/io/displayport_msp_dji_compat.c @@ -0,0 +1,713 @@ +/* + * This file is part of INAV Project. + * + * INAV is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Cleanflight is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cleanflight. If not, see . + */ + +#include "platform.h" + +#if defined(USE_OSD) && defined(USE_MSP_DISPLAYPORT) + +#ifndef DISABLE_MSP_DJI_COMPAT + +#include "io/displayport_msp_dji_compat.h" +#include "io/dji_osd_symbols.h" +#include "drivers/osd_symbols.h" + +uint8_t getDJICharacter(uint8_t ch, uint8_t page) +{ + uint16_t ech = ch | ((page & 0x3)<< 8) ; + + if (ech >= 0x20 && ech <= 0x5F) { // ASCII range + return ch; + } + + if (ech >= SYM_AH_DECORATION_MIN && ech <= SYM_AH_DECORATION_MAX) { + return DJI_SYM_AH_DECORATION; + } + + switch (ech) { + case SYM_RSSI: + return DJI_SYM_RSSI; + +/* + case SYM_LQ: + return DJI_SYM_LINK_QUALITY; +*/ + + case SYM_LAT: + return DJI_SYM_LAT; + + case SYM_LON: + return DJI_SYM_LON; + + case SYM_SAT_L: + return DJI_SYM_SAT_L; + + case SYM_SAT_R: + return DJI_SYM_SAT_R; + + case SYM_HOME_NEAR: + return DJI_SYM_HOMEFLAG; + + case SYM_DEGREES: + return DJI_SYM_GPS_DEGREE; + +/* + case SYM_HEADING: + return DJI_SYM_HEADING; + + case SYM_SCALE: + return DJI_SYM_SCALE; + + case SYM_HDP_L: + return DJI_SYM_HDP_L; + + case SYM_HDP_R: + return DJI_SYM_HDP_R; +*/ + case SYM_HOME: + return DJI_SYM_HOMEFLAG; + + case SYM_2RSS: + return DJI_SYM_RSSI; + +/* + case SYM_DB: + return DJI_SYM_DB + + case SYM_DBM: + return DJI_SYM_DBM; + + case SYM_SNR: + return DJI_SYM_SNR; +*/ + + case SYM_AH_DECORATION_UP: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_AH_DECORATION_DOWN: + return DJI_SYM_ARROW_SMALL_DOWN; + + case SYM_DECORATION: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_DECORATION + 1: // NE pointing arrow + return DJI_SYM_ARROW_7; + + case SYM_DECORATION + 2: // E pointing arrow + return DJI_SYM_ARROW_EAST; + + case SYM_DECORATION + 3: // SE pointing arrow + return DJI_SYM_ARROW_3; + + case SYM_DECORATION + 4: // S pointing arrow + return DJI_SYM_ARROW_SOUTH; + + case SYM_DECORATION + 5: // SW pointing arrow + return DJI_SYM_ARROW_15; + + case SYM_DECORATION + 6: // W pointing arrow + return DJI_SYM_ARROW_WEST; + + case SYM_DECORATION + 7: // NW pointing arrow + return DJI_SYM_ARROW_11; + + case SYM_VOLT: + return DJI_SYM_VOLT; + + case SYM_MAH: + return DJI_SYM_MAH; + + case SYM_AH_KM: + return 'K'; + + case SYM_AH_MI: + return 'M'; +/* + case SYM_VTX_POWER: + return DJI_SYM_VTX_POWER; + + case SYM_AH_NM: + return DJI_SYM_AH_NM; + + case SYM_MAH_NM_0: + return DJI_SYM_MAH_NM_0; + + case SYM_MAH_NM_1: + return DJI_SYM_MAH_NM_1; + + case SYM_MAH_KM_0: + return DJI_SYM_MAH_KM_0; + + case SYM_MAH_KM_1: + return DJI_SYM_MAH_KM_1; + + case SYM_MILLIOHM: + return DJI_SYM_MILLIOHM; +*/ + case SYM_BATT_FULL: + return DJI_SYM_BATT_FULL; + + case SYM_BATT_5: + return DJI_SYM_BATT_5; + + case SYM_BATT_4: + return DJI_SYM_BATT_4; + + case SYM_BATT_3: + return DJI_SYM_BATT_3; + + case SYM_BATT_2: + return DJI_SYM_BATT_2; + + case SYM_BATT_1: + return DJI_SYM_BATT_1; + + case SYM_BATT_EMPTY: + return DJI_SYM_BATT_EMPTY; + + case SYM_AMP: + return DJI_SYM_AMP; +/* + case SYM_WH: + return DJI_SYM_WH; + + case SYM_WH_KM: + return DJI_SYM_WH_KM; + + case SYM_WH_MI: + return DJI_SYM_WH_MI; + + case SYM_WH_NM: + return DJI_SYM_WH_NM; +*/ + case SYM_WATT: + return DJI_SYM_WATT; +/* + case SYM_MW: + return DJI_SYM_MW; + + case SYM_KILOWATT: + return DJI_SYM_KILOWATT; +*/ + case SYM_FT: + return DJI_SYM_FT; + + case SYM_ALT_FT: + return DJI_SYM_FT; + + case SYM_ALT_M: + return DJI_SYM_M; + + case SYM_TOTAL: + return DJI_SYM_FLY_H; +/* + + case SYM_ALT_KM: + return DJI_SYM_ALT_KM; + + case SYM_ALT_KFT: + return DJI_SYM_ALT_KFT; + + case SYM_DIST_M: + return DJI_SYM_DIST_M; + + case SYM_DIST_KM: + return DJI_SYM_DIST_KM; + + case SYM_DIST_FT: + return DJI_SYM_DIST_FT; + + case SYM_DIST_MI: + return DJI_SYM_DIST_MI; + + case SYM_DIST_NM: + return DJI_SYM_DIST_NM; +*/ + case SYM_M: + return DJI_SYM_M; + + case SYM_KM: + return 'K'; + + case SYM_MI: + return 'M'; +/* + case SYM_NM: + return DJI_SYM_NM; +*/ + case SYM_WIND_HORIZONTAL: + return 'W'; // W for wind + +/* + case SYM_WIND_VERTICAL: + return DJI_SYM_WIND_VERTICAL; + + case SYM_3D_KT: + return DJI_SYM_3D_KT; +*/ + case SYM_AIR: + return 'A'; // A for airspeed + + case SYM_3D_KMH: + return DJI_SYM_KPH; + + case SYM_3D_MPH: + return DJI_SYM_MPH; + + case SYM_RPM: + return DJI_SYM_RPM; + + case SYM_FTS: + return DJI_SYM_FTPS; +/* + case SYM_100FTM: + return DJI_SYM_100FTM; +*/ + case SYM_MS: + return DJI_SYM_MPS; + + case SYM_KMH: + return DJI_SYM_KPH; + + case SYM_MPH: + return DJI_SYM_MPH; +/* + case SYM_KT: + return DJI_SYM_KT + + case SYM_MAH_MI_0: + return DJI_SYM_MAH_MI_0; + + case SYM_MAH_MI_1: + return DJI_SYM_MAH_MI_1; +*/ + case SYM_THR: + return DJI_SYM_THR; + + case SYM_TEMP_F: + return DJI_SYM_F; + + case SYM_TEMP_C: + return DJI_SYM_C; + + case SYM_BLANK: + return DJI_SYM_BLANK; + + case SYM_ON_H: + return DJI_SYM_ON_H; + + case SYM_FLY_H: + return DJI_SYM_FLY_H; + + case SYM_ON_M: + return DJI_SYM_ON_M; + + case SYM_FLY_M: + return DJI_SYM_FLY_M; +/* + case SYM_GLIDESLOPE: + return DJI_SYM_GLIDESLOPE; + + case SYM_WAYPOINT: + return DJI_SYM_WAYPOINT; + + case SYM_CLOCK: + return DJI_SYM_CLOCK; + + case SYM_ZERO_HALF_TRAILING_DOT: + return DJI_SYM_ZERO_HALF_TRAILING_DOT; + + case SYM_ZERO_HALF_LEADING_DOT: + return DJI_SYM_ZERO_HALF_LEADING_DOT; +*/ + + case SYM_AUTO_THR0: + return 'A'; + + case SYM_AUTO_THR1: + return DJI_SYM_THR; + + case SYM_ROLL_LEFT: + return DJI_SYM_ROLL; + + case SYM_ROLL_LEVEL: + return DJI_SYM_ROLL; + + case SYM_ROLL_RIGHT: + return DJI_SYM_ROLL; + + case SYM_PITCH_UP: + return DJI_SYM_PITCH; + + case SYM_PITCH_DOWN: + return DJI_SYM_PITCH; + + case SYM_GFORCE: + return 'G'; + +/* + case SYM_GFORCE_X: + return DJI_SYM_GFORCE_X; + + case SYM_GFORCE_Y: + return DJI_SYM_GFORCE_Y; + + case SYM_GFORCE_Z: + return DJI_SYM_GFORCE_Z; +*/ + case SYM_BARO_TEMP: + return DJI_SYM_TEMPERATURE; + + case SYM_IMU_TEMP: + return DJI_SYM_TEMPERATURE; + + case SYM_TEMP: + return DJI_SYM_TEMPERATURE; + + case SYM_ESC_TEMP: + return DJI_SYM_TEMPERATURE; +/* + case SYM_TEMP_SENSOR_FIRST: + return DJI_SYM_TEMP_SENSOR_FIRST; + + case SYM_TEMP_SENSOR_LAST: + return DJI_SYM_TEMP_SENSOR_LAST; + + case TEMP_SENSOR_SYM_COUNT: + return DJI_TEMP_SENSOR_SYM_COUNT; +*/ + case SYM_HEADING_N: + return DJI_SYM_HEADING_N; + + case SYM_HEADING_S: + return DJI_SYM_HEADING_S; + + case SYM_HEADING_E: + return DJI_SYM_HEADING_E; + + case SYM_HEADING_W: + return DJI_SYM_HEADING_W; + + case SYM_HEADING_DIVIDED_LINE: + return DJI_SYM_HEADING_DIVIDED_LINE; + + case SYM_HEADING_LINE: + return DJI_SYM_HEADING_LINE; + + case SYM_MAX: + return DJI_SYM_MAX; +/* + case SYM_PROFILE: + return DJI_SYM_PROFILE; +*/ + case SYM_SWITCH_INDICATOR_LOW: + return DJI_SYM_STICK_OVERLAY_SPRITE_LOW; + + case SYM_SWITCH_INDICATOR_MID: + return DJI_SYM_STICK_OVERLAY_SPRITE_MID; + + case SYM_SWITCH_INDICATOR_HIGH: + return DJI_SYM_STICK_OVERLAY_SPRITE_HIGH; +/* + case SYM_AH: + return DJI_SYM_AH; + + case SYM_GLIDE_DIST: + return DJI_SYM_GLIDE_DIST; + + case SYM_GLIDE_MINS: + return DJI_SYM_GLIDE_MINS; + + case SYM_AH_V_FT_0: + return DJI_SYM_AH_V_FT_0; + + case SYM_AH_V_FT_1: + return DJI_SYM_AH_V_FT_1; + + case SYM_AH_V_M_0: + return DJI_SYM_AH_V_M_0; + + case SYM_AH_V_M_1: + return DJI_SYM_AH_V_M_1; + + case SYM_FLIGHT_MINS_REMAINING: + return DJI_SYM_FLIGHT_MINS_REMAINING; + + case SYM_FLIGHT_HOURS_REMAINING: + return DJI_SYM_FLIGHT_HOURS_REMAINING; + + case SYM_GROUND_COURSE: + return DJI_SYM_GROUND_COURSE; + + case SYM_CROSS_TRACK_ERROR: + return DJI_SYM_CROSS_TRACK_ERROR; + + case SYM_LOGO_START: + return DJI_SYM_LOGO_START; + + case SYM_LOGO_WIDTH: + return DJI_SYM_LOGO_WIDTH; + + case SYM_LOGO_HEIGHT: + return DJI_SYM_LOGO_HEIGHT; +*/ + case SYM_AH_LEFT: + return DJI_SYM_AH_LEFT; + + case SYM_AH_RIGHT: + return DJI_SYM_AH_RIGHT; + +/* + case SYM_AH_DECORATION_COUNT: + return DJI_SYM_AH_DECORATION_COUNT; +*/ + case SYM_AH_CH_LEFT: + case SYM_AH_CH_TYPE3: + case SYM_AH_CH_TYPE4: + case SYM_AH_CH_TYPE5: + case SYM_AH_CH_TYPE6: + case SYM_AH_CH_TYPE7: + case SYM_AH_CH_TYPE8: + case SYM_AH_CH_AIRCRAFT1: + return DJI_SYM_CROSSHAIR_LEFT; + + case SYM_AH_CH_CENTER: + case (SYM_AH_CH_TYPE3+1): + case (SYM_AH_CH_TYPE4+1): + case (SYM_AH_CH_TYPE5+1): + case (SYM_AH_CH_TYPE6+1): + case (SYM_AH_CH_TYPE7+1): + case (SYM_AH_CH_TYPE8+1): + case SYM_AH_CH_AIRCRAFT2: + return DJI_SYM_CROSSHAIR_CENTRE; + + case SYM_AH_CH_RIGHT: + case (SYM_AH_CH_TYPE3+2): + case (SYM_AH_CH_TYPE4+2): + case (SYM_AH_CH_TYPE5+2): + case (SYM_AH_CH_TYPE6+2): + case (SYM_AH_CH_TYPE7+2): + case (SYM_AH_CH_TYPE8+2): + case SYM_AH_CH_AIRCRAFT3: + return DJI_SYM_CROSSHAIR_RIGHT; + + case SYM_AH_CH_AIRCRAFT0: + case SYM_AH_CH_AIRCRAFT4: + return DJI_SYM_BLANK; + + case SYM_ARROW_UP: + return DJI_SYM_ARROW_NORTH; + + case SYM_ARROW_2: + return DJI_SYM_ARROW_8; + + case SYM_ARROW_3: + return DJI_SYM_ARROW_7; + + case SYM_ARROW_4: + return DJI_SYM_ARROW_6; + + case SYM_ARROW_RIGHT: + return DJI_SYM_ARROW_EAST; + + case SYM_ARROW_6: + return DJI_SYM_ARROW_4; + + case SYM_ARROW_7: + return DJI_SYM_ARROW_3; + + case SYM_ARROW_8: + return DJI_SYM_ARROW_2; + + case SYM_ARROW_DOWN: + return DJI_SYM_ARROW_SOUTH; + + case SYM_ARROW_10: + return DJI_SYM_ARROW_16; + + case SYM_ARROW_11: + return DJI_SYM_ARROW_15; + + case SYM_ARROW_12: + return DJI_SYM_ARROW_14; + + case SYM_ARROW_LEFT: + return DJI_SYM_ARROW_WEST; + + case SYM_ARROW_14: + return DJI_SYM_ARROW_12; + + case SYM_ARROW_15: + return DJI_SYM_ARROW_11; + + case SYM_ARROW_16: + return DJI_SYM_ARROW_10; + + case SYM_AH_H_START: + return DJI_SYM_AH_BAR9_0; + + case (SYM_AH_H_START+1): + return DJI_SYM_AH_BAR9_1; + + case (SYM_AH_H_START+2): + return DJI_SYM_AH_BAR9_2; + + case (SYM_AH_H_START+3): + return DJI_SYM_AH_BAR9_3; + + case (SYM_AH_H_START+4): + return DJI_SYM_AH_BAR9_4; + + case (SYM_AH_H_START+5): + return DJI_SYM_AH_BAR9_5; + + case (SYM_AH_H_START+6): + return DJI_SYM_AH_BAR9_6; + + case (SYM_AH_H_START+7): + return DJI_SYM_AH_BAR9_7; + + case (SYM_AH_H_START+8): + return DJI_SYM_AH_BAR9_8; + + // DJI does not have vertical artificial horizon. replace with middle horizontal one + case SYM_AH_V_START: + case (SYM_AH_V_START+1): + case (SYM_AH_V_START+2): + case (SYM_AH_V_START+3): + case (SYM_AH_V_START+4): + case (SYM_AH_V_START+5): + return DJI_SYM_AH_BAR9_4; + + // DJI for ESP_RADAR Symbols + case SYM_HUD_CARDINAL: + return DJI_SYM_ARROW_SOUTH; + case SYM_HUD_CARDINAL + 1: + return DJI_SYM_ARROW_16; + case SYM_HUD_CARDINAL + 2: + return DJI_SYM_ARROW_15; + case SYM_HUD_CARDINAL + 3: + return DJI_SYM_ARROW_WEST; + case SYM_HUD_CARDINAL + 4: + return DJI_SYM_ARROW_12; + case SYM_HUD_CARDINAL + 5: + return DJI_SYM_ARROW_11; + case SYM_HUD_CARDINAL + 6: + return DJI_SYM_ARROW_NORTH; + case SYM_HUD_CARDINAL + 7: + return DJI_SYM_ARROW_7; + case SYM_HUD_CARDINAL + 8: + return DJI_SYM_ARROW_6; + case SYM_HUD_CARDINAL + 9: + return DJI_SYM_ARROW_EAST; + case SYM_HUD_CARDINAL + 10: + return DJI_SYM_ARROW_3; + case SYM_HUD_CARDINAL + 11: + return DJI_SYM_ARROW_2; + + case SYM_HUD_SIGNAL_0: + return DJI_SYM_AH_BAR9_1; + case SYM_HUD_SIGNAL_1: + return DJI_SYM_AH_BAR9_3; + case SYM_HUD_SIGNAL_2: + return DJI_SYM_AH_BAR9_4; + case SYM_HUD_SIGNAL_3: + return DJI_SYM_AH_BAR9_5; + case SYM_HUD_SIGNAL_4: + return DJI_SYM_AH_BAR9_7; + + case SYM_VARIO_UP_2A: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_VARIO_UP_1A: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_VARIO_DOWN_1A: + return DJI_SYM_ARROW_SMALL_DOWN; + + case SYM_VARIO_DOWN_2A: + return DJI_SYM_ARROW_SMALL_DOWN; + + case SYM_ALT: + return DJI_SYM_ALTITUDE; +/* + case SYM_HUD_SIGNAL_0: + return DJI_SYM_HUD_SIGNAL_0; + + case SYM_HUD_SIGNAL_1: + return DJI_SYM_HUD_SIGNAL_1; + + case SYM_HUD_SIGNAL_2: + return DJI_SYM_HUD_SIGNAL_2; + + case SYM_HUD_SIGNAL_3: + return DJI_SYM_HUD_SIGNAL_3; + + case SYM_HUD_SIGNAL_4: + return DJI_SYM_HUD_SIGNAL_4; + + case SYM_HOME_DIST: + return DJI_SYM_HOME_DIST; + + case SYM_FLIGHT_DIST_REMAINING: + return DJI_SYM_FLIGHT_DIST_REMAINING; +*/ + case SYM_HUD_ARROWS_L1: + return DJI_SYM_ARROW_SMALL_LEFT; + + case SYM_HUD_ARROWS_L2: + return DJI_SYM_ARROW_SMALL_LEFT; + + case SYM_HUD_ARROWS_L3: + return DJI_SYM_ARROW_SMALL_LEFT; + + case SYM_HUD_ARROWS_R1: + return DJI_SYM_ARROW_SMALL_RIGHT; + + case SYM_HUD_ARROWS_R2: + return DJI_SYM_ARROW_SMALL_RIGHT; + + case SYM_HUD_ARROWS_R3: + return DJI_SYM_ARROW_SMALL_RIGHT; + + case SYM_HUD_ARROWS_U1: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_HUD_ARROWS_U2: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_HUD_ARROWS_U3: + return DJI_SYM_ARROW_SMALL_UP; + + case SYM_HUD_ARROWS_D1: + return DJI_SYM_ARROW_SMALL_DOWN; + + case SYM_HUD_ARROWS_D2: + return DJI_SYM_ARROW_SMALL_DOWN; + + case SYM_HUD_ARROWS_D3: + return DJI_SYM_ARROW_SMALL_DOWN; + + default: + break; + } + + return '?'; // Missing/not mapped character +} + +#endif + +#endif diff --git a/src/main/io/displayport_msp_bf_compat.h b/src/main/io/displayport_msp_dji_compat.h similarity index 69% rename from src/main/io/displayport_msp_bf_compat.h rename to src/main/io/displayport_msp_dji_compat.h index 95dab7b518d..6380770aa00 100644 --- a/src/main/io/displayport_msp_bf_compat.h +++ b/src/main/io/displayport_msp_dji_compat.h @@ -22,15 +22,15 @@ #include "platform.h" -#if defined(USE_OSD) && defined(USE_MSP_DISPLAYPORT) && !defined(DISABLE_MSP_BF_COMPAT) +#if defined(USE_OSD) && defined(USE_MSP_DISPLAYPORT) && !defined(DISABLE_MSP_DJI_COMPAT) #include "osd.h" -uint8_t getBfCharacter(uint8_t ch, uint8_t page); -#define isBfCompatibleVideoSystem(osdConfigPtr) (osdConfigPtr->video_system == VIDEO_SYSTEM_BFCOMPAT || osdConfigPtr->video_system == VIDEO_SYSTEM_BFCOMPAT_HD) +uint8_t getDJICharacter(uint8_t ch, uint8_t page); +#define isDJICompatibleVideoSystem(osdConfigPtr) (osdConfigPtr->video_system == VIDEO_SYSTEM_DJICOMPAT || osdConfigPtr->video_system == VIDEO_SYSTEM_DJICOMPAT_HD) #else -#define getBfCharacter(x, page) (x) +#define getDJICharacter(x, page) (x) #ifdef OSD_UNIT_TEST -#define isBfCompatibleVideoSystem(osdConfigPtr) (true) +#define isDJICompatibleVideoSystem(osdConfigPtr) (true) #else -#define isBfCompatibleVideoSystem(osdConfigPtr) (false) +#define isDJICompatibleVideoSystem(osdConfigPtr) (false) #endif #endif \ No newline at end of file diff --git a/src/main/io/displayport_msp_osd.c b/src/main/io/displayport_msp_osd.c index d587104e9b9..2e425e6aecb 100644 --- a/src/main/io/displayport_msp_osd.c +++ b/src/main/io/displayport_msp_osd.c @@ -51,7 +51,7 @@ #include "msp/msp_serial.h" #include "displayport_msp_osd.h" -#include "displayport_msp_bf_compat.h" +#include "displayport_msp_dji_compat.h" #define FONT_VERSION 3 @@ -307,7 +307,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz uint8_t len = 4; do { bitArrayClr(dirty, pos); - subcmd[len] = isBfCompatibleVideoSystem(osdConfig()) ? getBfCharacter(screen[pos++], page): screen[pos++]; + subcmd[len] = isDJICompatibleVideoSystem(osdConfig()) ? getDJICharacter(screen[pos++], page): screen[pos++]; len++; if (bitArrayGet(dirty, pos)) { @@ -315,7 +315,7 @@ static int drawScreen(displayPort_t *displayPort) // 250Hz } } while (next == pos && next < endOfLine && getAttrPage(attrs[next]) == page && getAttrBlink(attrs[next]) == blink); - if (!isBfCompatibleVideoSystem(osdConfig())) { + if (!isDJICompatibleVideoSystem(osdConfig())) { attributes |= (page << DISPLAYPORT_MSP_ATTR_FONTPAGE); } @@ -465,7 +465,7 @@ displayPort_t* mspOsdDisplayPortInit(const videoSystem_e videoSystem) if (mspOsdSerialInit()) { switch(videoSystem) { case VIDEO_SYSTEM_AUTO: - case VIDEO_SYSTEM_BFCOMPAT: + case VIDEO_SYSTEM_DJICOMPAT: case VIDEO_SYSTEM_PAL: currentOsdMode = SD_3016; screenRows = PAL_ROWS; @@ -486,7 +486,7 @@ displayPort_t* mspOsdDisplayPortInit(const videoSystem_e videoSystem) screenRows = DJI_ROWS; screenCols = DJI_COLS; break; - case VIDEO_SYSTEM_BFCOMPAT_HD: + case VIDEO_SYSTEM_DJICOMPAT_HD: case VIDEO_SYSTEM_AVATAR: currentOsdMode = HD_5320; screenRows = AVATAR_ROWS; @@ -500,10 +500,10 @@ displayPort_t* mspOsdDisplayPortInit(const videoSystem_e videoSystem) init(); displayInit(&mspOsdDisplayPort, &mspOsdVTable); - if (osdVideoSystem == VIDEO_SYSTEM_BFCOMPAT) { - mspOsdDisplayPort.displayPortType = "MSP DisplayPort: BetaFlight Compatability mode"; - } else if (osdVideoSystem == VIDEO_SYSTEM_BFCOMPAT_HD) { - mspOsdDisplayPort.displayPortType = "MSP DisplayPort: BetaFlight Compatability mode (HD)"; + if (osdVideoSystem == VIDEO_SYSTEM_DJICOMPAT) { + mspOsdDisplayPort.displayPortType = "MSP DisplayPort: DJI Compatability mode"; + } else if (osdVideoSystem == VIDEO_SYSTEM_DJICOMPAT_HD) { + mspOsdDisplayPort.displayPortType = "MSP DisplayPort: DJI Compatability mode (HD)"; } else { mspOsdDisplayPort.displayPortType = "MSP DisplayPort"; } diff --git a/src/main/io/dji_osd_symbols.h b/src/main/io/dji_osd_symbols.h new file mode 100644 index 00000000000..66972a810e7 --- /dev/null +++ b/src/main/io/dji_osd_symbols.h @@ -0,0 +1,164 @@ +/* @file max7456_symbols.h + * @brief max7456 symbols for the mwosd font set + * + * @author Nathan Tsoi nathan@vertile.com + * + * Copyright (C) 2016 Nathan Tsoi + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +#pragma once + +//Misc +#define DJI_SYM_NONE 0x00 +#define DJI_SYM_END_OF_FONT 0xFF +#define DJI_SYM_BLANK 0x20 +#define DJI_SYM_HYPHEN 0x2D +#define DJI_SYM_BBLOG 0x10 +#define DJI_SYM_HOMEFLAG 0x11 +#define DJI_SYM_RPM 0x12 +#define DJI_SYM_ROLL 0x14 +#define DJI_SYM_PITCH 0x15 +#define DJI_SYM_TEMPERATURE 0x7A +#define DJI_SYM_MAX 0x24 + +// GPS and navigation +#define DJI_SYM_LAT 0x89 +#define DJI_SYM_LON 0x98 +#define DJI_SYM_ALTITUDE 0x7F +#define DJI_SYM_OVER_HOME 0x05 + +// RSSI +#define DJI_SYM_RSSI 0x01 + +// Throttle Position (%) +#define DJI_SYM_THR 0x04 + +// Unit Icons (Metric) +#define DJI_SYM_M 0x0C +#define DJI_SYM_C 0x0E + +// Unit Icons (Imperial) +#define DJI_SYM_F 0x0D +#define DJI_SYM_FT 0x0F + +// Heading Graphics +#define DJI_SYM_HEADING_N 0x18 +#define DJI_SYM_HEADING_S 0x19 +#define DJI_SYM_HEADING_E 0x1A +#define DJI_SYM_HEADING_W 0x1B +#define DJI_SYM_HEADING_DIVIDED_LINE 0x1C +#define DJI_SYM_HEADING_LINE 0x1D + +// AH Center screen Graphics +#define DJI_SYM_CROSSHAIR_LEFT 0x72 +#define DJI_SYM_CROSSHAIR_CENTRE 0x73 +#define DJI_SYM_CROSSHAIR_RIGHT 0x74 +#define DJI_SYM_AH_RIGHT 0x02 +#define DJI_SYM_AH_LEFT 0x03 +#define DJI_SYM_AH_DECORATION 0x13 +#define DJI_SYM_SMALL_CROSSHAIR 0x7E + +// Satellite Graphics +#define DJI_SYM_SAT_L 0x1E +#define DJI_SYM_SAT_R 0x1F + +// Direction arrows +#define DJI_SYM_ARROW_SOUTH 0x60 +#define DJI_SYM_ARROW_2 0x61 +#define DJI_SYM_ARROW_3 0x62 +#define DJI_SYM_ARROW_4 0x63 +#define DJI_SYM_ARROW_EAST 0x64 +#define DJI_SYM_ARROW_6 0x65 +#define DJI_SYM_ARROW_7 0x66 +#define DJI_SYM_ARROW_8 0x67 +#define DJI_SYM_ARROW_NORTH 0x68 +#define DJI_SYM_ARROW_10 0x69 +#define DJI_SYM_ARROW_11 0x6A +#define DJI_SYM_ARROW_12 0x6B +#define DJI_SYM_ARROW_WEST 0x6C +#define DJI_SYM_ARROW_14 0x6D +#define DJI_SYM_ARROW_15 0x6E +#define DJI_SYM_ARROW_16 0x6F + +#define DJI_SYM_ARROW_SMALL_UP 0x75 +#define DJI_SYM_ARROW_SMALL_DOWN 0x76 +#define DJI_SYM_ARROW_SMALL_RIGHT 0x77 +#define DJI_SYM_ARROW_SMALL_LEFT 0x78 + +// AH Bars +#define DJI_SYM_AH_BAR9_0 0x80 +#define DJI_SYM_AH_BAR9_1 0x81 +#define DJI_SYM_AH_BAR9_2 0x82 +#define DJI_SYM_AH_BAR9_3 0x83 +#define DJI_SYM_AH_BAR9_4 0x84 +#define DJI_SYM_AH_BAR9_5 0x85 +#define DJI_SYM_AH_BAR9_6 0x86 +#define DJI_SYM_AH_BAR9_7 0x87 +#define DJI_SYM_AH_BAR9_8 0x88 + +// Progress bar +#define DJI_SYM_PB_START 0x8A +#define DJI_SYM_PB_FULL 0x8B +#define DJI_SYM_PB_HALF 0x8C +#define DJI_SYM_PB_EMPTY 0x8D +#define DJI_SYM_PB_END 0x8E +#define DJI_SYM_PB_CLOSE 0x8F + +// Batt evolution +#define DJI_SYM_BATT_FULL 0x90 +#define DJI_SYM_BATT_5 0x91 +#define DJI_SYM_BATT_4 0x92 +#define DJI_SYM_BATT_3 0x93 +#define DJI_SYM_BATT_2 0x94 +#define DJI_SYM_BATT_1 0x95 +#define DJI_SYM_BATT_EMPTY 0x96 + +// Batt Icons +#define DJI_SYM_MAIN_BATT 0x97 + +// Voltage and amperage +#define DJI_SYM_VOLT 0x06 +#define DJI_SYM_AMP 0x9A +#define DJI_SYM_MAH 0x07 +#define DJI_SYM_WATT 0x57 // 0x57 is 'W' + +// Time +#define DJI_SYM_ON_H 0x70 +#define DJI_SYM_FLY_H 0x71 +#define DJI_SYM_ON_M 0x9B +#define DJI_SYM_FLY_M 0x9C + +// Speed +#define DJI_SYM_KPH 0x9E +#define DJI_SYM_MPH 0x9D +#define DJI_SYM_MPS 0x9F +#define DJI_SYM_FTPS 0x99 + +// Menu cursor +#define DJI_SYM_CURSOR DJI_SYM_AH_LEFT + +// Stick overlays +#define DJI_SYM_STICK_OVERLAY_SPRITE_HIGH 0x08 +#define DJI_SYM_STICK_OVERLAY_SPRITE_MID 0x09 +#define DJI_SYM_STICK_OVERLAY_SPRITE_LOW 0x0A +#define DJI_SYM_STICK_OVERLAY_CENTER 0x0B +#define DJI_SYM_STICK_OVERLAY_VERTICAL 0x16 +#define DJI_SYM_STICK_OVERLAY_HORIZONTAL 0x17 + +// GPS degree/minute/second symbols +#define DJI_SYM_GPS_DEGREE DJI_SYM_STICK_OVERLAY_SPRITE_HIGH // kind of looks like the degree symbol +#define DJI_SYM_GPS_MINUTE 0x27 // ' +#define DJI_SYM_GPS_SECOND 0x22 // " diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 56245ea04af..f3f00ae7bdb 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -70,7 +70,7 @@ #include "io/osd_common.h" #include "io/osd_hud.h" #include "io/osd_utils.h" -#include "io/displayport_msp_bf_compat.h" +#include "io/displayport_msp_dji_compat.h" #include "io/vtx.h" #include "io/vtx_string.h" @@ -253,51 +253,6 @@ bool osdIsNotMetric(void) { return !(osdConfig()->units == OSD_UNIT_METRIC || osdConfig()->units == OSD_UNIT_METRIC_MPH); } -/* - * Aligns text to the left side. Adds spaces at the end to keep string length unchanged. - */ -/* -- Currently unused -- -static void osdLeftAlignString(char *buff) -{ - uint8_t sp = 0, ch = 0; - uint8_t len = strlen(buff); - while (buff[sp] == ' ') sp++; - for (ch = 0; ch < (len - sp); ch++) buff[ch] = buff[ch + sp]; - for (sp = ch; sp < len; sp++) buff[sp] = ' '; -}*/ - -/* - * This is a simplified distance conversion code that does not use any scaling - * but is fully compatible with the DJI G2 MSP Displayport OSD implementation. - * (Based on osdSimpleAltitudeSymbol() implementation) - */ -/* void osdSimpleDistanceSymbol(char *buff, int32_t dist) { - - int32_t convertedDistance; - char suffix; - - switch ((osd_unit_e)osdConfig()->units) { - case OSD_UNIT_UK: - FALLTHROUGH; - case OSD_UNIT_GA: - FALLTHROUGH; - case OSD_UNIT_IMPERIAL: - convertedDistance = CENTIMETERS_TO_FEET(dist); - suffix = SYM_ALT_FT; - break; - case OSD_UNIT_METRIC_MPH: - FALLTHROUGH; - case OSD_UNIT_METRIC: - convertedDistance = CENTIMETERS_TO_METERS(dist); - suffix = SYM_ALT_M; // Intentionally use the altitude symbol, as the distance symbol is not defined in BFCOMPAT mode - break; - } - - tfp_sprintf(buff, "%5d", (int) convertedDistance); // 5 digits, allowing up to 99999 meters/feet, which should be plenty for 99.9% of use cases - buff[5] = suffix; - buff[6] = '\0'; -} */ - /** * Converts distance into a string based on the current unit system * prefixed by a a symbol to indicate the unit used. @@ -313,12 +268,12 @@ static void osdFormatDistanceSymbol(char *buff, int32_t dist, uint8_t decimals) uint8_t symbol_mi = SYM_DIST_MI; uint8_t symbol_nm = SYM_DIST_NM; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it and change the values + if (isDJICompatibleVideoSystem(osdConfig())) { // Add one digit so up no switch to scaled decimal occurs above 99 digits = 4U; sym_index = 4U; - // Use altitude symbols on purpose, as it seems distance symbols are not defined in BFCOMPAT mode + // Use altitude symbols on purpose, as it seems distance symbols are not defined in DJICOMPAT mode symbol_m = SYM_ALT_M; symbol_km = SYM_ALT_KM; symbol_ft = SYM_ALT_FT; @@ -570,8 +525,8 @@ void osdFormatAltitudeSymbol(char *buff, int32_t alt) buff[0] = ' '; } -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it and change the values + if (isDJICompatibleVideoSystem(osdConfig())) { totalDigits++; digits++; symbolIndex++; @@ -792,21 +747,21 @@ static void osdFormatCoordinate(char *buff, char sym, int32_t val) int32_t decimalPart = abs(val % (int)GPS_DEGREES_DIVIDER); STATIC_ASSERT(GPS_DEGREES_DIVIDER == 1e7, adjust_max_decimal_digits); int decimalDigits; - bool bfcompat = false; // Assume BFCOMPAT mode is no enabled + bool djiCompat = false; // Assume DJICOMPAT mode is no enabled -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if(isBfCompatibleVideoSystem(osdConfig())) { - bfcompat = true; +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if(isDJICompatibleVideoSystem(osdConfig())) { + djiCompat = true; } #endif - if (!bfcompat) { + if (!djiCompat) { decimalDigits = tfp_sprintf(buff + 1 + integerDigits, "%07d", (int)decimalPart); // Embbed the decimal separator buff[1 + integerDigits - 1] += SYM_ZERO_HALF_TRAILING_DOT - '0'; buff[1 + integerDigits] += SYM_ZERO_HALF_LEADING_DOT - '0'; } else { - // BFCOMPAT mode enabled + // DJICOMPAT mode enabled decimalDigits = tfp_sprintf(buff + 1 + integerDigits, ".%06d", (int)decimalPart); } // Fill up to coordinateLength with zeros @@ -1752,8 +1707,8 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_MAIN_BATT_VOLTAGE: { uint8_t base_digits = 2U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if(isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if(isDJICompatibleVideoSystem(osdConfig())) { base_digits = 3U; // Add extra digit to account for decimal point taking an extra character space } #endif @@ -1763,8 +1718,8 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_SAG_COMPENSATED_MAIN_BATT_VOLTAGE: { uint8_t base_digits = 2U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if(isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if(isDJICompatibleVideoSystem(osdConfig())) { base_digits = 3U; // Add extra digit to account for decimal point taking an extra character space } #endif @@ -1787,9 +1742,9 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_MAH_DRAWN: { uint8_t mah_digits = osdConfig()->mAh_precision; // Initialize to config value -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if (isBfCompatibleVideoSystem(osdConfig())) { - //BFcompat is unable to work with scaled values and it only has mAh symbol to work with +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if (isDJICompatibleVideoSystem(osdConfig())) { + //DJIcompat is unable to work with scaled values and it only has mAh symbol to work with tfp_sprintf(buff, "%5d", (int)getMAhDrawn()); // Use 5 digits to allow packs below 100Ah buff[5] = SYM_MAH; buff[6] = '\0'; @@ -1828,9 +1783,9 @@ static bool osdDrawSingleElement(uint8_t item) else if (currentBatteryProfile->capacity.unit == BAT_CAPACITY_UNIT_MAH) { uint8_t mah_digits = osdConfig()->mAh_precision; // Initialize to config value -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if (isBfCompatibleVideoSystem(osdConfig())) { - //BFcompat is unable to work with scaled values and it only has mAh symbol to work with +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if (isDJICompatibleVideoSystem(osdConfig())) { + //DJIcompat is unable to work with scaled values and it only has mAh symbol to work with tfp_sprintf(buff, "%5d", (int)getBatteryRemainingCapacity()); // Use 5 digits to allow packs below 100Ah buff[5] = SYM_MAH; buff[6] = '\0'; @@ -2139,8 +2094,8 @@ static bool osdDrawSingleElement(uint8_t item) buff[1] = SYM_HDP_R; int32_t centiHDOP = 100 * gpsSol.hdop / HDOP_SCALE; uint8_t digits = 2U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it and change the values + if (isDJICompatibleVideoSystem(osdConfig())) { digits = 3U; } #endif @@ -2799,8 +2754,8 @@ static bool osdDrawSingleElement(uint8_t item) // time will be longer than 99 minutes. If it is, it will show 99:^^ if (glideTime > (99 * 60) + 59) { tfp_sprintf(buff + 1, "%02d:", (int)(glideTime / 60)); - buff[4] = SYM_DIRECTION; - buff[5] = SYM_DIRECTION; + buff[4] = SYM_DECORATION; + buff[5] = SYM_DECORATION; } else { tfp_sprintf(buff + 1, "%02d:%02d", (int)(glideTime / 60), (int)(glideTime % 60)); } @@ -3147,8 +3102,8 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_MAIN_BATT_CELL_VOLTAGE: { uint8_t base_digits = 3U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if(isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if(isDJICompatibleVideoSystem(osdConfig())) { base_digits = 4U; // Add extra digit to account for decimal point taking an extra character space } #endif @@ -3159,8 +3114,8 @@ static bool osdDrawSingleElement(uint8_t item) case OSD_MAIN_BATT_SAG_COMPENSATED_CELL_VOLTAGE: { uint8_t base_digits = 3U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it - if(isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it + if(isDJICompatibleVideoSystem(osdConfig())) { base_digits = 4U; // Add extra digit to account for decimal point taking an extra character space } #endif @@ -3215,8 +3170,8 @@ static bool osdDrawSingleElement(uint8_t item) timeUs_t currentTimeUs = micros(); timeDelta_t efficiencyTimeDelta = cmpTimeUs(currentTimeUs, efficiencyUpdated); uint8_t digits = 3U; -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it and change the values + if (isDJICompatibleVideoSystem(osdConfig())) { // Increase number of digits so values above 99 don't get scaled by osdFormatCentiNumber digits = 4U; } @@ -3248,7 +3203,7 @@ static bool osdDrawSingleElement(uint8_t item) } if (!efficiencyValid) { buff[0] = buff[1] = buff[2] = buff[3] = '-'; - buff[digits] = SYM_MAH_MI_0; // This will overwrite the "-" at buff[3] if not in BFCOMPAT mode + buff[digits] = SYM_MAH_MI_0; // This will overwrite the "-" at buff[3] if not in DJICOMPAT mode buff[digits + 1] = SYM_MAH_MI_1; buff[digits + 2] = '\0'; } @@ -3418,7 +3373,7 @@ static bool osdDrawSingleElement(uint8_t item) horizontalWindSpeed = getEstimatedHorizontalWindSpeed(&angle); int16_t windDirection = osdGetHeadingAngle( CENTIDEGREES_TO_DEGREES((int)angle) - DECIDEGREES_TO_DEGREES(attitude.values.yaw) + 22); buff[0] = SYM_WIND_HORIZONTAL; - buff[1] = SYM_DIRECTION + (windDirection*2 / 90); + buff[1] = SYM_DECORATION + (windDirection*2 / 90); osdFormatWindSpeedStr(buff + 2, horizontalWindSpeed, valid); break; } @@ -3435,10 +3390,10 @@ static bool osdDrawSingleElement(uint8_t item) float verticalWindSpeed; verticalWindSpeed = -getEstimatedWindSpeed(Z); //from NED to NEU if (verticalWindSpeed < 0) { - buff[1] = SYM_AH_DIRECTION_DOWN; + buff[1] = SYM_AH_DECORATION_DOWN; verticalWindSpeed = -verticalWindSpeed; } else { - buff[1] = SYM_AH_DIRECTION_UP; + buff[1] = SYM_AH_DECORATION_UP; } osdFormatWindSpeedStr(buff + 2, verticalWindSpeed, valid); break; @@ -3552,7 +3507,7 @@ static bool osdDrawSingleElement(uint8_t item) } else { referenceSymbol = '-'; } - displayWriteChar(osdDisplayPort, elemPosX, elemPosY, SYM_DIRECTION); + displayWriteChar(osdDisplayPort, elemPosX, elemPosY, SYM_DECORATION); displayWriteChar(osdDisplayPort, elemPosX, elemPosY + 1, referenceSymbol); return true; } @@ -4186,8 +4141,8 @@ uint8_t drawLogos(bool singular, uint8_t row) { uint8_t logoColOffset = 0; bool usePilotLogo = (osdConfig()->use_pilot_logo && osdDisplayIsHD()); -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is in use, the pilot logo cannot be used, due to font issues. - if (isBfCompatibleVideoSystem(osdConfig())) +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is in use, the pilot logo cannot be used, due to font issues. + if (isDJICompatibleVideoSystem(osdConfig())) usePilotLogo = false; #endif @@ -4727,8 +4682,8 @@ uint8_t drawStat_AverageEfficiency(uint8_t col, uint8_t row, uint8_t statValX, b tfp_sprintf(outBuff, ": "); uint8_t digits = 3U; // Total number of digits (including decimal point) -#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values - if (isBfCompatibleVideoSystem(osdConfig())) { +#ifndef DISABLE_MSP_DJI_COMPAT // IF DJICOMPAT is not supported, there's no need to check for it and change the values + if (isDJICompatibleVideoSystem(osdConfig())) { // Add one digit so no switch to scaled decimal occurs above 99 digits = 4U; } diff --git a/src/main/io/osd_grid.c b/src/main/io/osd_grid.c index 5d7e8736d91..9e79194498d 100644 --- a/src/main/io/osd_grid.c +++ b/src/main/io/osd_grid.c @@ -315,16 +315,16 @@ void osdGridDrawSidebars(displayPort_t *display) // Arrows if (osdConfig()->sidebar_scroll_arrows) { displayWriteChar(display, elemPosX - hudwidth, elemPosY - hudheight - 1, - left.arrow == OSD_SIDEBAR_ARROW_UP ? SYM_AH_DIRECTION_UP : SYM_BLANK); + left.arrow == OSD_SIDEBAR_ARROW_UP ? SYM_AH_DECORATION_UP : SYM_BLANK); displayWriteChar(display, elemPosX + hudwidth, elemPosY - hudheight - 1, - right.arrow == OSD_SIDEBAR_ARROW_UP ? SYM_AH_DIRECTION_UP : SYM_BLANK); + right.arrow == OSD_SIDEBAR_ARROW_UP ? SYM_AH_DECORATION_UP : SYM_BLANK); displayWriteChar(display, elemPosX - hudwidth, elemPosY + hudheight + 1, - left.arrow == OSD_SIDEBAR_ARROW_DOWN ? SYM_AH_DIRECTION_DOWN : SYM_BLANK); + left.arrow == OSD_SIDEBAR_ARROW_DOWN ? SYM_AH_DECORATION_DOWN : SYM_BLANK); displayWriteChar(display, elemPosX + hudwidth, elemPosY + hudheight + 1, - right.arrow == OSD_SIDEBAR_ARROW_DOWN ? SYM_AH_DIRECTION_DOWN : SYM_BLANK); + right.arrow == OSD_SIDEBAR_ARROW_DOWN ? SYM_AH_DECORATION_DOWN : SYM_BLANK); } // Draw AH sides diff --git a/src/main/io/osd_hud.c b/src/main/io/osd_hud.c index 07bc181d1c1..8a6a68f467a 100644 --- a/src/main/io/osd_hud.c +++ b/src/main/io/osd_hud.c @@ -207,7 +207,7 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu if (poiType == 1) { // POI from the ESP radar error_x = hudWrap360(poiP1 - DECIDEGREES_TO_DEGREES(osdGetHeading())); - osdHudWrite(poi_x - 1, poi_y, SYM_DIRECTION + ((error_x + 22) / 45) % 8, 1); + osdHudWrite(poi_x - 1, poi_y, SYM_DECORATION + ((error_x + 22) / 45) % 8, 1); osdHudWrite(poi_x + 1, poi_y, SYM_HUD_SIGNAL_0 + poiP2, 1); } else if (poiType == 2) { // Waypoint, @@ -248,7 +248,7 @@ void osdHudDrawPoi(uint32_t poiDistance, int16_t poiDirection, int32_t poiAltitu tfp_sprintf(buff, "%3d", altc); } - buff[0] = (poiAltitude >= 0) ? SYM_AH_DIRECTION_UP : SYM_AH_DIRECTION_DOWN; + buff[0] = (poiAltitude >= 0) ? SYM_AH_DECORATION_UP : SYM_AH_DECORATION_DOWN; } else { // Display the distance by default switch ((osd_unit_e)osdConfig()->units) { case OSD_UNIT_UK: diff --git a/src/main/io/osd_utils.c b/src/main/io/osd_utils.c index 6675be8783b..9c9fb0608a0 100644 --- a/src/main/io/osd_utils.c +++ b/src/main/io/osd_utils.c @@ -20,7 +20,7 @@ #include "common/maths.h" #include "common/typeconversion.h" #include "drivers/osd_symbols.h" -#include "io/displayport_msp_bf_compat.h" +#include "io/displayport_msp_dji_compat.h" #if defined(USE_OSD) || defined(OSD_UNIT_TEST) @@ -45,7 +45,7 @@ bool osdFormatCentiNumber(char *buff, int32_t centivalue, uint32_t scale, int ma int decimals = maxDecimals; bool negative = false; bool scaled = false; - bool explicitDecimal = isBfCompatibleVideoSystem(osdConfig()); + bool explicitDecimal = isDJICompatibleVideoSystem(osdConfig()); buff[length] = '\0'; From 3d9d1f3b91aa255c80919d90d89dbfa755894a64 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Thu, 16 May 2024 07:43:56 +0100 Subject: [PATCH 2/2] Update docs --- docs/Betaflight 4.3 compatible OSD.md | 50 --------------------------- docs/DJI compatible OSD.md | 50 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 docs/Betaflight 4.3 compatible OSD.md create mode 100644 docs/DJI compatible OSD.md diff --git a/docs/Betaflight 4.3 compatible OSD.md b/docs/Betaflight 4.3 compatible OSD.md deleted file mode 100644 index 0e9644dae24..00000000000 --- a/docs/Betaflight 4.3 compatible OSD.md +++ /dev/null @@ -1,50 +0,0 @@ -# Betaflight 4.3 compatible MSP DisplayPort OSD (DJI O3 "Canvas Mode") - -INAV 6.0 includes a special mode for MSP DisplayPort that supports incomplete implementations of MSP DisplayPort that only support BetaFlight, like the DJI O3 Air Unit. INAV 6.1 expands this to include HD canvas sizes from BetaFlight 4.4. - -Different flight controllers have different OSD symbols and elements and require different fonts. BetaFlight's font is a single page and supports a maximum of 256 glyphs, INAV's font is currently 2 pages and supports up to 512 different glyphs. - -While there is some overlap between the glyphs in BetaFlight and INAV, it is not possible to perform a 1 to 1 mapping for all the them. In cases where there is no suitable glyph in the BetaFlight font, a question mark `?` will be displayed. - -This mode can be enabled by selecting BF43COMPAT or BFHDCOMPAT as video format in the OSD tab of the configurator or by typing the following command on the CLI: - -`set osd_video_system = BF43COMPAT` - -or - -`set osd_video_system = BFHDCOMPAT` - -## Limitations - -* Canvas size needs to be manually changed to HD on the Display menu in DJI's goggles (you may need a firmware update) and set as BFHDCOMPAT in the OSD tab of the configurator. -* Unsupported Glyphs show up as `?` - -## FAQ - -### I see a lot of `?` on my OSD. - -That is expected, when your INAV OSD widgets use glyphs that don't have a suitable mapping in BetaFlight's font. - -### Does it work with the G2 and Original Air Unit/Vista? - -Yes. - -### Is this a replacement for WTFOS? - -Not exactly. WTFOS is a full implementation of MSP-Displayport for rooted Air Unit/Vista/Googles V2 and actually works much better than BetaFlight compatibility mode, being able to display all INAV's glyphs. - -### Can INAV fix DJI's product? - -No. OSD renderinng happens on the googles/air unit side of things. Please ask DJI to fix their incomplete MSP DisplayPort implemenation. You can probably request it in [DJI's forum](https://forum.dji.com/forum.php?mod=forumdisplay&fid=129&filter=typeid&typeid=767). - -### BetaFlight X.Y now has more symbols, can you update INAV? - -Maybe. If a future version of BetaFlight includes more Glyphs that can be mapped into INAV it is fairly simple to add the mapping, but the problem with DJI's implemenation persists. Even if we update the mapping, if DJI does not update the fonts on their side the problem will persist. - -### Can you replace glyph `X` with text `x description`? - -While it might technically be possible to replace some glyphs with text in multiple cells, it will introduce a lot of complexity in the OSD rendering and configuration for something we hope is a temporary workaround. - -### Does DJI support Canvas Mode? - -Actually, no. What DJI calls Canvas Mode is actually MSP DisplayPort and is a character based OSD. diff --git a/docs/DJI compatible OSD.md b/docs/DJI compatible OSD.md new file mode 100644 index 00000000000..6af25670306 --- /dev/null +++ b/docs/DJI compatible OSD.md @@ -0,0 +1,50 @@ +# DJI compatible MSP DisplayPort OSD (DJI O3 "Canvas Mode") + +INAV 6.0 includes a special mode for MSP DisplayPort that supports DJI's incomplete implementations of MSP DisplayPort. This can be found on products like the DJI O3 Air Unit. INAV 6.1 expands this to include HD canvas sizes from BetaFlight 4.4. + +Different flight controller firmware have different OSD symbols and elements and require different fonts. BetaFlight's font is a single page and supports a maximum of 256 glyphs, INAV's font is currently 2 pages and supports up to 512 different glyphs. DJI's font is single page and based, but not the same as, BetaFlight's font. + +While there is some overlap between the glyphs in DJI and INAV, it is not possible to perform a 1 to 1 mapping for all the them. In cases where there is no suitable glyph in the DJI font, a question mark `?` will be displayed. + +This mode can be enabled by selecting DJI43COMPAT or DJIHDCOMPAT as video format in the OSD tab of the configurator or by typing the following command on the CLI: + +`set osd_video_system = DJI43COMPAT` + +or + +`set osd_video_system = DJIHDCOMPAT` + +## Limitations + +* Canvas size needs to be manually changed to HD on the Display menu in DJI's goggles (you may need a firmware update) and set as DJIHDCOMPAT in the OSD tab of the configurator. +* Unsupported Glyphs show up as `?` + +## FAQ + +### I see a lot of `?` on my OSD. + +That is expected. When your INAV OSD widgets use glyphs that don't have a suitable mapping in DJI's font. + +### Does it work with the G2 and Original Air Unit/Vista? + +Yes. + +### Is this a replacement for WTFOS? + +Not exactly. WTFOS is a full implementation of MSP-Displayport for rooted Air Unit/Vista/Googles V2 and actually works much better than DJI compatibility mode. It can use all of INAV's OSD elements as intended. If you have the option of WTFOS or DJI compatability mode. WTFOS is the best option. + +### Can INAV fix DJI's product? + +No. OSD renderinng happens on the googles/air unit side of things. Please ask DJI to fix their incomplete MSP DisplayPort implemenation. You can probably request it in [DJI's forum](https://forum.dji.com/forum.php?mod=forumdisplay&fid=129&filter=typeid&typeid=767). To see what you're missing out on with O3. Check out what WTFOS did with the original system. Not only could the pilots upload the fonts of their choosing (who doesn't want a cool SneakyFPV font on their OSD). But there were no problems supporting and firmware. Plus, there was even an option to save the OSD to a file and overlay that over your DVR video. If you're reading this far. Please recommend to DJI that they fix their product, to at least what was possible with WTFOS. + +### DJI's font now has more symbols, can you update INAV? + +Maybe. If a future version of DJI's font includes more Glyphs that can be mapped into INAV. It is fairly simple to add the mapping. However, the best solution would be full support of MSP DisplayPort by DJI. Then there will never be an issue with missing icons. As the latest INAV font would be able to be uploaded on to the goggles. + +### Can you replace glyph `X` with text `x description`? + +While it might technically be possible to replace some glyphs with text in multiple cells, it will introduce a lot of complexity in the OSD rendering and configuration for something we hope is a temporary workaround. + +### Does DJI support Canvas Mode? + +Actually, no. What DJI calls Canvas Mode is actually MSP DisplayPort and is a character based OSD. Currently, the only true implementaion of Canvas Mode is with FrSKY PixelOSD. This was found on some F722 flight controllers from Matek.