From f509582e6d91bf3d16f9cad2ea4aaff244e74704 Mon Sep 17 00:00:00 2001 From: Hydra Date: Tue, 7 Mar 2017 22:48:01 +0000 Subject: [PATCH 1/9] CF/BF - OSD - Cleanup the splash screen. --- src/main/io/osd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d0629aad3b..c1bed129a3 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -537,12 +537,12 @@ void osdInit(displayPort_t *osdDisplayPortToUse) } char string_buffer[30]; - sprintf(string_buffer, "BF VERSION: %s", FC_VERSION_STRING); - displayWrite(osdDisplayPort, 5, 6, string_buffer); + sprintf(string_buffer, "V%s", FC_VERSION_STRING); + displayWrite(osdDisplayPort, 20, 6, string_buffer); #ifdef CMS - displayWrite(osdDisplayPort, 7, 7, CMS_STARTUP_HELP_TEXT1); - displayWrite(osdDisplayPort, 11, 8, CMS_STARTUP_HELP_TEXT2); - displayWrite(osdDisplayPort, 11, 9, CMS_STARTUP_HELP_TEXT3); + displayWrite(osdDisplayPort, 7, 8, CMS_STARTUP_HELP_TEXT1); + displayWrite(osdDisplayPort, 11, 9, CMS_STARTUP_HELP_TEXT2); + displayWrite(osdDisplayPort, 11, 10, CMS_STARTUP_HELP_TEXT3); #endif displayResync(osdDisplayPort); From 45252b5f8489267855ee5c8fb9db0ee13dd4d5d0 Mon Sep 17 00:00:00 2001 From: Hydra Date: Tue, 7 Mar 2017 23:10:24 +0000 Subject: [PATCH 2/9] CF/BF - OSD - Extract logo drawing code into static method. --- src/main/io/osd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index c1bed129a3..f82804d684 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -512,6 +512,18 @@ void pgResetFn_osdConfig(osdConfig_t *osdProfile) osdProfile->alt_alarm = 100; // meters or feet depend on configuration } +static void osdDrawLogo(int x, int y) +{ + // display logo and help + char fontOffset = 160; + for (int row = 0; row < 4; row++) { + for (int column = 0; column < 24; column++) { + if (fontOffset != 255) // FIXME magic number + displayWriteChar(osdDisplayPort, x + column, y + row, fontOffset++); + } + } +} + void osdInit(displayPort_t *osdDisplayPortToUse) { BUILD_BUG_ON(OSD_POS_MAX != OSD_POS(31,31)); @@ -527,14 +539,7 @@ void osdInit(displayPort_t *osdDisplayPortToUse) displayClearScreen(osdDisplayPort); - // display logo and help - char x = 160; - for (int i = 1; i < 5; i++) { - for (int j = 3; j < 27; j++) { - if (x != 255) - displayWriteChar(osdDisplayPort, j, i, x++); - } - } + osdDrawLogo(3, 1); char string_buffer[30]; sprintf(string_buffer, "V%s", FC_VERSION_STRING); From d91987c2870f558cd844c2f3af480ad715152db6 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 19:41:38 +0000 Subject: [PATCH 3/9] CF/BF - OSD - Use a default OSD layout that has no overlapping elements. Note: We give the users all the information, and let them turn off what they don't need. In testing it was found that if we hide the information some users will never know it's there. --- src/main/io/osd.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index f82804d684..d44591f76b 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -483,28 +483,28 @@ void osdDrawElements(void) void pgResetFn_osdConfig(osdConfig_t *osdProfile) { - osdProfile->item_pos[OSD_RSSI_VALUE] = OSD_POS(22, 0); - osdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 0) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_RSSI_VALUE] = OSD_POS(8, 1) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_MAIN_BATT_VOLTAGE] = OSD_POS(12, 1) | VISIBLE_FLAG; osdProfile->item_pos[OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6) | VISIBLE_FLAG; osdProfile->item_pos[OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_ONTIME] = OSD_POS(22, 11) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_FLYTIME] = OSD_POS(22, 12) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_FLYMODE] = OSD_POS(12, 11) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_CRAFT_NAME] = OSD_POS(12, 12); - osdProfile->item_pos[OSD_THROTTLE_POS] = OSD_POS(1, 4); - osdProfile->item_pos[OSD_VTX_CHANNEL] = OSD_POS(8, 6); - osdProfile->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 3); - osdProfile->item_pos[OSD_MAH_DRAWN] = OSD_POS(15, 3); - osdProfile->item_pos[OSD_GPS_SPEED] = OSD_POS(2, 2); - osdProfile->item_pos[OSD_GPS_SATS] = OSD_POS(2, 12); - osdProfile->item_pos[OSD_ALTITUDE] = OSD_POS(1, 5); - osdProfile->item_pos[OSD_ROLL_PIDS] = OSD_POS(2, 10); - osdProfile->item_pos[OSD_PITCH_PIDS] = OSD_POS(2, 11); - osdProfile->item_pos[OSD_YAW_PIDS] = OSD_POS(2, 12); - osdProfile->item_pos[OSD_POWER] = OSD_POS(15, 1); - osdProfile->item_pos[OSD_PIDRATE_PROFILE] = OSD_POS(2, 13); - osdProfile->item_pos[OSD_MAIN_BATT_WARNING] = OSD_POS(8, 6); - osdProfile->item_pos[OSD_AVG_CELL_VOLTAGE] = OSD_POS(12, 0); + osdProfile->item_pos[OSD_ONTIME] = OSD_POS(22, 1) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_FLYTIME] = OSD_POS(1, 1) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_FLYMODE] = OSD_POS(13, 11) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_CRAFT_NAME] = OSD_POS(9, 12) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_THROTTLE_POS] = OSD_POS(1, 7) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_VTX_CHANNEL] = OSD_POS(25, 11) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 12) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_MAH_DRAWN] = OSD_POS(1, 11) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_GPS_SPEED] = OSD_POS(27, 6) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_GPS_SATS] = OSD_POS(19, 1) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_ALTITUDE] = OSD_POS(23, 7) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_ROLL_PIDS] = OSD_POS(7, 13) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_PITCH_PIDS] = OSD_POS(7, 14) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_YAW_PIDS] = OSD_POS(7, 15) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_POWER] = OSD_POS(1, 10) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_PIDRATE_PROFILE] = OSD_POS(25, 10) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_MAIN_BATT_WARNING] = OSD_POS(9, 10) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_AVG_CELL_VOLTAGE] = OSD_POS(12, 2) | VISIBLE_FLAG; osdProfile->rssi_alarm = 20; osdProfile->cap_alarm = 2200; From e1ac5b82df522bed19a9358979e8d9f5912352fc Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 19:58:04 +0000 Subject: [PATCH 4/9] CF/BF - OSD - use a strict mask to prevent invalid OSD positions values from being created. --- src/main/io/osd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d44591f76b..ca994b6d21 100755 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -86,9 +86,10 @@ // Character coordinate -#define OSD_POS(x,y) (x | (y << 5)) +#define OSD_POSITION_BITS 5 // 5 bits gives a range 0-31 +#define OSD_POS(x,y) ((x & 0x001F) | ((y & 0x001F) << OSD_POSITION_BITS)) #define OSD_X(x) (x & 0x001F) -#define OSD_Y(x) ((x >> 5) & 0x001F) +#define OSD_Y(x) ((x >> OSD_POSITION_BITS) & 0x001F) // Blink control From c8888ad6bdffc65d01cc6ba3d631aee32c950d81 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 20:42:35 +0000 Subject: [PATCH 5/9] CF/BF - OSD - Show VTX channel/band hardware RTC6705 users (e.g. SPRacingF3NEO/SINGULARITY) --- src/main/io/osd.c | 13 ++++++++++++- src/main/target/common_post.h | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/main/io/osd.c diff --git a/src/main/io/osd.c b/src/main/io/osd.c old mode 100755 new mode 100644 index ca994b6d21..bc319b6fa9 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -54,6 +54,9 @@ #include "drivers/system.h" #ifdef USE_RTC6705 #include "drivers/vtx_soft_spi_rtc6705.h" +#include "drivers/vtx_soft_spi_rtc6705.h" +#elif defined(VTX) +#include "drivers/vtx_rtc6705.h" #endif #include "cms/cms.h" @@ -65,6 +68,7 @@ #include "io/gps.h" #include "io/osd.h" #include "io/vtx.h" +#include "io/vtx_string.h" #include "fc/config.h" #include "fc/rc_controls.h" @@ -284,10 +288,17 @@ static void osdDrawSingleElement(uint8_t item) break; } -#ifdef USE_RTC6705 +#if defined(VTX) || defined(USE_RTC6705) case OSD_VTX_CHANNEL: { + // FIXME cleanup this when the VTX API is aligned for software vs hardware support of the RTC6705 - See SPRACINGF3NEO/SINGULARITY/SIRINFPV targets. +#if defined(VTX) + const char vtxBandLetter = vtx58BandLetter[vtxConfig()->vtx_band + 1]; + const char *vtxChannelName = vtx58ChannelNames[vtxConfig()->vtx_channel + 1]; + sprintf(buff, "%c:%s", vtxBandLetter, vtxChannelName); +#elif defined(USE_RTC6705) sprintf(buff, "CH:%d", current_vtx_channel % CHANNELS_PER_BAND + 1); +#endif break; } #endif // VTX diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index 7a089ebff7..9575e252aa 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -22,7 +22,6 @@ // Targets with built-in vtx do not need external vtx #if defined(VTX) || defined(USE_RTC6705) # undef VTX_CONTROL -# undef VTX_COMMON # undef VTX_SMARTAUDIO # undef VTX_TRAMP #endif From c40c507f1b0ee9459dff336899ea72ebe57bcaf0 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 21:11:48 +0000 Subject: [PATCH 6/9] CF/BF - OSD - Use m/s as the GPS speed unit, there is currently no imperial conversion. --- src/main/io/osd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index bc319b6fa9..4825bab577 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -220,7 +220,7 @@ static void osdDrawSingleElement(uint8_t item) case OSD_GPS_SPEED: { - sprintf(buff, "%d", GPS_speed * 36 / 1000); + sprintf(buff, "%d%c", GPS_speed * 36 / 1000, SYM_MS); break; } #endif // GPS @@ -507,7 +507,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdProfile) osdProfile->item_pos[OSD_VTX_CHANNEL] = OSD_POS(25, 11) | VISIBLE_FLAG; osdProfile->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 12) | VISIBLE_FLAG; osdProfile->item_pos[OSD_MAH_DRAWN] = OSD_POS(1, 11) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_GPS_SPEED] = OSD_POS(27, 6) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_GPS_SPEED] = OSD_POS(26, 6) | VISIBLE_FLAG; osdProfile->item_pos[OSD_GPS_SATS] = OSD_POS(19, 1) | VISIBLE_FLAG; osdProfile->item_pos[OSD_ALTITUDE] = OSD_POS(23, 7) | VISIBLE_FLAG; osdProfile->item_pos[OSD_ROLL_PIDS] = OSD_POS(7, 13) | VISIBLE_FLAG; From 636c194aea5aa10778c29689d3ca828c8d883661 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 21:31:58 +0000 Subject: [PATCH 7/9] CF/BF - OSD - Show symbol for GPS speed to better align with altitude display on OSD. Name and extract the duplicated GPS_speed equation - in CM/S to KM/H. --- src/main/common/maths.h | 2 ++ src/main/io/osd.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/common/maths.h b/src/main/common/maths.h index e21dfb0426..807be800b8 100644 --- a/src/main/common/maths.h +++ b/src/main/common/maths.h @@ -35,6 +35,8 @@ #define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f) #define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f) +#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000) + #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define ABS(x) ((x) > 0 ? (x) : -(x)) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 4825bab577..79e4b415b6 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -220,7 +220,8 @@ static void osdDrawSingleElement(uint8_t item) case OSD_GPS_SPEED: { - sprintf(buff, "%d%c", GPS_speed * 36 / 1000, SYM_MS); + // FIXME ideally we want to use SYM_KMH symbol but it's not in the font any more, so we use K. + sprintf(buff, "%dK", CM_S_TO_KM_H(GPS_speed) * 10); break; } #endif // GPS @@ -637,7 +638,7 @@ static void osdUpdateStats(void) { int16_t value = 0; #ifdef GPS - value = GPS_speed * 36 / 1000; + value = CM_S_TO_KM_H(GPS_speed); #endif if (stats.max_speed < value) stats.max_speed = value; From 4c517a56eac2ef5de4aa6c0142133803f5531782 Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 21:35:24 +0000 Subject: [PATCH 8/9] CF/BF - OSD - Change the default OSD unit to metric since there are missing calculations for GPS_speed, better to have everything in the same units than a mix. --- src/main/io/osd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 79e4b415b6..8129452508 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -519,6 +519,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdProfile) osdProfile->item_pos[OSD_MAIN_BATT_WARNING] = OSD_POS(9, 10) | VISIBLE_FLAG; osdProfile->item_pos[OSD_AVG_CELL_VOLTAGE] = OSD_POS(12, 2) | VISIBLE_FLAG; + osdProfile->units = OSD_UNIT_METRIC; osdProfile->rssi_alarm = 20; osdProfile->cap_alarm = 2200; osdProfile->time_alarm = 10; // in minutes From e37944ba7bf66acdc7a6529be7fad01c920c3cae Mon Sep 17 00:00:00 2001 From: Hydra Date: Wed, 8 Mar 2017 21:49:10 +0000 Subject: [PATCH 9/9] CF/BF - OSD - Nudge craft name over by one character to align with flight mode. --- src/main/io/osd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 8129452508..00797ab1f6 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -503,7 +503,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdProfile) osdProfile->item_pos[OSD_ONTIME] = OSD_POS(22, 1) | VISIBLE_FLAG; osdProfile->item_pos[OSD_FLYTIME] = OSD_POS(1, 1) | VISIBLE_FLAG; osdProfile->item_pos[OSD_FLYMODE] = OSD_POS(13, 11) | VISIBLE_FLAG; - osdProfile->item_pos[OSD_CRAFT_NAME] = OSD_POS(9, 12) | VISIBLE_FLAG; + osdProfile->item_pos[OSD_CRAFT_NAME] = OSD_POS(10, 12) | VISIBLE_FLAG; osdProfile->item_pos[OSD_THROTTLE_POS] = OSD_POS(1, 7) | VISIBLE_FLAG; osdProfile->item_pos[OSD_VTX_CHANNEL] = OSD_POS(25, 11) | VISIBLE_FLAG; osdProfile->item_pos[OSD_CURRENT_DRAW] = OSD_POS(1, 12) | VISIBLE_FLAG;