Skip to content

Commit

Permalink
Display PPM value in channel monitor on 128x64 B&W radios.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Jan 17, 2025
1 parent 5a15ffb commit 8f486d8
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions radio/src/gui/128x64/view_channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#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_GAUGE_OFFSET = CHANNEL_VALUE_OFFSET;
constexpr coord_t CHANNEL_BAR_WIDTH = 70;
Expand Down Expand Up @@ -54,29 +54,22 @@ constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR
#define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT)
#endif

struct ViewChannelsState {
bool longNames;
bool mixersView;
};

static ViewChannelsState viewChannels = { false, false };
static bool mixersView = false;

void menuChannelsViewCommon(event_t event)
{
bool newLongNames = false;

uint8_t ch;

switch (event) {
case EVT_KEY_BREAK(KEY_ENTER):
viewChannels.mixersView = !viewChannels.mixersView;
mixersView = !mixersView;
break;
}

ch = 8 * (g_eeGeneral.view / ALTERNATE_VIEW);

// Screen title
lcdDrawText(LCD_W / 2, 0, viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
lcdDrawText(LCD_W / 2, 0, mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
lcdInvertLine(0);

int16_t limits = 512 * 2;
Expand All @@ -85,32 +78,29 @@ void menuChannelsViewCommon(event_t event)
for (uint8_t line = 0; line < 8; line++) {
LimitData * ld = limitAddress(ch);
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);

// Channel name if present, number if not
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);
}
else {
} else {
putsChn(CHANNEL_NAME_OFFSET, y, ch + 1, SMLSIZE);
}

// Value
if (g_eeGeneral.ppmunit == PPM_US) {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT);
} else if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) {
if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val), PREC1 | TINSIZE | RIGHT);
} else {
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, calcRESXto1000(val) / 10, TINSIZE | RIGHT);
}

lcdDrawNumber(LCD_W + 1, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT);

// Gauge
drawGauge(CHANNEL_GAUGE_OFFSET, y, CHANNEL_BAR_WIDTH, 6, val, limits);

if (!viewChannels.mixersView) {
if (!mixersView) {
// Properties
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED)
Expand All @@ -124,8 +114,6 @@ void menuChannelsViewCommon(event_t event)

++ch;
}

viewChannels.longNames = newLongNames;
}

void menuChannelsView(event_t event)
Expand Down

0 comments on commit 8f486d8

Please sign in to comment.