feat(bw128): display PPM value in channel monitor (#5781)

This commit is contained in:
philmoz
2025-01-19 11:23:12 +10:00
committed by GitHub
parent df9e313b84
commit e41680bf87
+41 -34
View File
@@ -21,11 +21,9 @@
#include "edgetx.h" #include "edgetx.h"
constexpr coord_t CHANNEL_NAME_OFFSET = 1; constexpr coord_t CHANNEL_NAME_OFFSET = 0;
constexpr coord_t CHANNEL_VALUE_OFFSET = CHANNEL_NAME_OFFSET + 42; constexpr coord_t CHANNEL_VALUE_OFFSET = CHANNEL_NAME_OFFSET + 41;
constexpr coord_t CHANNEL_GAUGE_OFFSET = CHANNEL_VALUE_OFFSET;
constexpr coord_t CHANNEL_BAR_WIDTH = 70; constexpr coord_t CHANNEL_BAR_WIDTH = 70;
constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR_WIDTH + 2;
#if defined(RADIO_T8) || defined(RADIO_COMMANDO8) #if defined(RADIO_T8) || defined(RADIO_COMMANDO8)
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_PAGEUP) #define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_PAGEUP)
@@ -54,78 +52,87 @@ constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR
#define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT) #define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT)
#endif #endif
struct ViewChannelsState { static bool mixersView = false;
bool longNames;
bool mixersView;
};
static ViewChannelsState viewChannels = { false, false };
void menuChannelsViewCommon(event_t event) void menuChannelsViewCommon(event_t event)
{ {
bool newLongNames = false;
uint8_t ch; uint8_t ch;
switch (event) { switch (event) {
case EVT_KEY_BREAK(KEY_ENTER): case EVT_KEY_BREAK(KEY_ENTER):
viewChannels.mixersView = !viewChannels.mixersView; mixersView = !mixersView;
break; break;
} }
ch = 8 * (g_eeGeneral.view / ALTERNATE_VIEW); ch = 8 * (g_eeGeneral.view / ALTERNATE_VIEW);
// Screen title coord_t vx = CHANNEL_VALUE_OFFSET;
lcdDrawText(LCD_W / 2, 0, viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED); coord_t bw = CHANNEL_BAR_WIDTH;
lcdInvertLine(0); if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) {
vx += 8;
bw -= 8;
}
int16_t limits = 512 * 2; // Screen title
lcdDrawText(LCD_W / 2, 0, mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
lcdInvertLine(0);
// Channels // Channels
for (uint8_t line = 0; line < 8; line++) { for (uint8_t line = 0; line < 8; line++) {
LimitData * ld = limitAddress(ch); LimitData * ld = limitAddress(ch);
const uint8_t y = 9 + line * 7; const uint8_t y = 9 + line * 7;
const int32_t val = viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch]; const int32_t val = mixersView ? ex_chans[ch] : channelOutputs[ch];
const uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); const uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
// Channel name if present, number if not // Channel name if present, number if not
if (lenLabel > 0) { if (lenLabel > 0) {
if (lenLabel > 4)
viewChannels.longNames = true;
lcdDrawSizedText(CHANNEL_NAME_OFFSET, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), SMLSIZE); lcdDrawSizedText(CHANNEL_NAME_OFFSET, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), SMLSIZE);
} } else {
else {
putsChn(CHANNEL_NAME_OFFSET, y, ch + 1, SMLSIZE); putsChn(CHANNEL_NAME_OFFSET, y, ch + 1, SMLSIZE);
} }
// Value // Value
if (g_eeGeneral.ppmunit == PPM_US) { if (g_eeGeneral.ppmunit == PPM_US) {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT); lcdDrawNumber(vx, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT);
} else if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) { } else if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val), PREC1 | TINSIZE | RIGHT); lcdDrawNumber(vx, y + 1, calcRESXto1000(val), PREC1 | TINSIZE | RIGHT);
} else { } else {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val) / 10, TINSIZE | RIGHT); lcdDrawNumber(vx, y + 1, calcRESXto1000(val) / 10, TINSIZE | RIGHT);
} }
// Gauge // Gauge
drawGauge(CHANNEL_GAUGE_OFFSET, y, CHANNEL_BAR_WIDTH, 6, val, limits); drawGauge(vx, y, bw, 6, val, RESX);
if (!mixersView) {
int phase = (g_blinkTmr10ms >> 6) & 3;
if (phase == 3) phase = 0;
if (!viewChannels.mixersView) {
// Properties // Properties
#if defined(OVERRIDE_CHANNEL_FUNCTION) #if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED) if (phase == 1) {
lcdDrawText(CHANNEL_PROPERTIES_OFFSET, y, "OVR", TINSIZE); if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED)
else lcdDrawText(LCD_W + 1, y + 1, "OVR", TINSIZE | RIGHT);
else
phase = 0;
}
#endif #endif
if (ld && ld->revert) { if (phase == 2) {
lcdDrawText(CHANNEL_PROPERTIES_OFFSET, y, "INV", TINSIZE); if (ld && ld->revert)
lcdDrawText(LCD_W + 1, y + 1, "INV", TINSIZE | RIGHT);
else
phase = 0;
}
if (phase == 0) {
if (g_eeGeneral.ppmunit == PPM_US)
lcdDrawNumber(LCD_W + 1, y + 1, calcRESXto1000(val) / 10, TINSIZE | RIGHT);
else
lcdDrawNumber(LCD_W + 1, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT);
} }
} }
++ch; ++ch;
} }
viewChannels.longNames = newLongNames;
} }
void menuChannelsView(event_t event) void menuChannelsView(event_t event)