|
63 | 63 | #include "io/gps.h" |
64 | 64 | #include "io/osd.h" |
65 | 65 | #include "io/osd_hud.h" |
| 66 | +#include "io/vtx.h" |
66 | 67 | #include "io/vtx_string.h" |
67 | 68 |
|
68 | 69 | #include "fc/config.h" |
@@ -510,6 +511,14 @@ static uint16_t osdConvertRSSI(void) |
510 | 511 | return constrain(getRSSI() * 100 / RSSI_MAX_VALUE, 0, 99); |
511 | 512 | } |
512 | 513 |
|
| 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 | + |
513 | 522 | /** |
514 | 523 | * Displays a temperature postfixed with a symbol depending on the current unit system |
515 | 524 | * @param label to display |
@@ -1638,25 +1647,31 @@ static bool osdDrawSingleElement(uint8_t item) |
1638 | 1647 | { |
1639 | 1648 | uint8_t band = 0; |
1640 | 1649 | uint8_t channel = 0; |
1641 | | - uint8_t powerIndex = 0; |
1642 | 1650 | char bandChr = '-'; |
1643 | 1651 | 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]; |
1654 | 1655 | } |
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; |
1656 | 1663 | } |
1657 | 1664 | #endif |
1658 | 1665 | break; |
1659 | 1666 |
|
| 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 | + |
1660 | 1675 | case OSD_CROSSHAIRS: // Hud is a sub-element of the crosshair |
1661 | 1676 |
|
1662 | 1677 | osdCrosshairPosition(&elemPosX, &elemPosY); |
@@ -2718,6 +2733,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig) |
2718 | 2733 | osdConfig->item_pos[0][OSD_GFORCE_Y] = OSD_POS(12, 6); |
2719 | 2734 | osdConfig->item_pos[0][OSD_GFORCE_Z] = OSD_POS(12, 7); |
2720 | 2735 |
|
| 2736 | + osdConfig->item_pos[0][OSD_VTX_POWER] = OSD_POS(3, 5); |
| 2737 | + |
2721 | 2738 | #if defined(USE_RX_MSP) && defined(USE_MSP_RC_OVERRIDE) |
2722 | 2739 | osdConfig->item_pos[0][OSD_RC_SOURCE] = OSD_POS(3, 4); |
2723 | 2740 | #endif |
|
0 commit comments