Skip to content

Commit 55649b4

Browse files
committed
OSD: add VTX power indicator
Complement to #4717. It is now possible to change the VTX power setting in flight. This allows to see what power the VTX is set at and also when the VTX power RC adjustment is active.
1 parent f37f228 commit 55649b4

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

src/main/cms/cms_menu_osd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ static const OSD_Entry menuOsdElemsEntries[] =
258258
OSD_ELEMENT_ENTRY("BARO TEMP", OSD_BARO_TEMPERATURE),
259259
#endif
260260

261+
OSD_ELEMENT_ENTRY("VTX POWER", OSD_VTX_POWER),
262+
261263
#ifdef USE_TEMPERATURE_SENSOR
262264
OSD_ELEMENT_ENTRY("SENSOR 0 TEMP", OSD_TEMP_SENSOR_0_TEMPERATURE),
263265
OSD_ELEMENT_ENTRY("SENSOR 1 TEMP", OSD_TEMP_SENSOR_1_TEMPERATURE),

src/main/io/osd.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "io/gps.h"
6464
#include "io/osd.h"
6565
#include "io/osd_hud.h"
66+
#include "io/vtx.h"
6667
#include "io/vtx_string.h"
6768

6869
#include "fc/config.h"
@@ -510,6 +511,14 @@ static uint16_t osdConvertRSSI(void)
510511
return constrain(getRSSI() * 100 / RSSI_MAX_VALUE, 0, 99);
511512
}
512513

514+
static void osdGetVTXPowerChar(char *buff)
515+
{
516+
buff[0] = '-';
517+
buff[1] = '\0';
518+
uint8_t powerIndex = 0;
519+
if (vtxCommonGetPowerIndex(vtxCommonDevice(), &powerIndex)) buff[0] = '0' + powerIndex;
520+
}
521+
513522
/**
514523
* Displays a temperature postfixed with a symbol depending on the current unit system
515524
* @param label to display
@@ -1638,25 +1647,31 @@ static bool osdDrawSingleElement(uint8_t item)
16381647
{
16391648
uint8_t band = 0;
16401649
uint8_t channel = 0;
1641-
uint8_t powerIndex = 0;
16421650
char bandChr = '-';
16431651
const char *channelStr = "-";
1644-
char powerChr = '-';
1645-
vtxDevice_t *vtxDevice = vtxCommonDevice();
1646-
if (vtxDevice) {
1647-
if (vtxCommonGetBandAndChannel(vtxDevice, &band, &channel)) {
1648-
bandChr = vtx58BandLetter[band];
1649-
channelStr = vtx58ChannelNames[channel];
1650-
}
1651-
if (vtxCommonGetPowerIndex(vtxDevice, &powerIndex)) {
1652-
powerChr = '0' + powerIndex;
1653-
}
1652+
if (vtxCommonGetBandAndChannel(vtxCommonDevice(), &band, &channel)) {
1653+
bandChr = vtx58BandLetter[band];
1654+
channelStr = vtx58ChannelNames[channel];
16541655
}
1655-
tfp_sprintf(buff, "CH:%c%s:%c", bandChr, channelStr, powerChr);
1656+
tfp_sprintf(buff, "CH:%c%s:", bandChr, channelStr);
1657+
displayWrite(osdDisplayPort, elemPosX, elemPosY, buff);
1658+
1659+
osdGetVTXPowerChar(buff);
1660+
if (isAdjustmentFunctionSelected(ADJUSTMENT_VTX_POWER_LEVEL)) TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
1661+
displayWriteWithAttr(osdDisplayPort, elemPosX + 6, elemPosY, buff, elemAttr);
1662+
return true;
16561663
}
16571664
#endif
16581665
break;
16591666

1667+
case OSD_VTX_POWER:
1668+
{
1669+
osdGetVTXPowerChar(buff);
1670+
if (isAdjustmentFunctionSelected(ADJUSTMENT_VTX_POWER_LEVEL)) TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
1671+
displayWriteWithAttr(osdDisplayPort, elemPosX, elemPosY, buff, elemAttr);
1672+
return true;
1673+
}
1674+
16601675
case OSD_CROSSHAIRS: // Hud is a sub-element of the crosshair
16611676

16621677
osdCrosshairPosition(&elemPosX, &elemPosY);
@@ -2718,6 +2733,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
27182733
osdConfig->item_pos[0][OSD_GFORCE_Y] = OSD_POS(12, 6);
27192734
osdConfig->item_pos[0][OSD_GFORCE_Z] = OSD_POS(12, 7);
27202735

2736+
osdConfig->item_pos[0][OSD_VTX_POWER] = OSD_POS(3, 5);
2737+
27212738
#if defined(USE_RX_MSP) && defined(USE_MSP_RC_OVERRIDE)
27222739
osdConfig->item_pos[0][OSD_RC_SOURCE] = OSD_POS(3, 4);
27232740
#endif

src/main/io/osd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ typedef enum {
149149
OSD_GFORCE_Y,
150150
OSD_GFORCE_Z,
151151
OSD_RC_SOURCE,
152+
OSD_VTX_POWER,
152153
OSD_ITEM_COUNT // MUST BE LAST
153154
} osd_items_e;
154155

0 commit comments

Comments
 (0)