fix(bw): Channel Monitor view not working correctly on startup (#4490)
This commit is contained in:
@@ -54,6 +54,13 @@ 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 };
|
||||
|
||||
void menuChannelsViewCommon(event_t event)
|
||||
{
|
||||
bool newLongNames = false;
|
||||
@@ -61,19 +68,15 @@ void menuChannelsViewCommon(event_t event)
|
||||
uint8_t ch;
|
||||
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
|
||||
viewChannels.mixersView = !viewChannels.mixersView;
|
||||
break;
|
||||
}
|
||||
|
||||
ch = 8 * (g_eeGeneral.view / ALTERNATE_VIEW);
|
||||
|
||||
// Screen title
|
||||
lcdDrawText(LCD_W / 2, 0, reusableBuffer.viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
|
||||
lcdDrawText(LCD_W / 2, 0, viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
|
||||
lcdInvertLine(0);
|
||||
|
||||
int16_t limits = 512 * 2;
|
||||
@@ -82,13 +85,13 @@ 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 = reusableBuffer.viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch];
|
||||
const int32_t val = viewChannels.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)
|
||||
reusableBuffer.viewChannels.longNames = true;
|
||||
viewChannels.longNames = true;
|
||||
lcdDrawSizedText(CHANNEL_NAME_OFFSET, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), SMLSIZE);
|
||||
}
|
||||
else {
|
||||
@@ -107,7 +110,7 @@ void menuChannelsViewCommon(event_t event)
|
||||
// Gauge
|
||||
drawGauge(CHANNEL_GAUGE_OFFSET, y, CHANNEL_BAR_WIDTH, 6, val, limits);
|
||||
|
||||
if (!reusableBuffer.viewChannels.mixersView) {
|
||||
if (!viewChannels.mixersView) {
|
||||
// Properties
|
||||
#if defined(OVERRIDE_CHANNEL_FUNCTION)
|
||||
if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED)
|
||||
@@ -122,7 +125,7 @@ void menuChannelsViewCommon(event_t event)
|
||||
++ch;
|
||||
}
|
||||
|
||||
reusableBuffer.viewChannels.longNames = newLongNames;
|
||||
viewChannels.longNames = newLongNames;
|
||||
}
|
||||
|
||||
void menuChannelsView(event_t event)
|
||||
|
||||
@@ -21,10 +21,18 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
struct ViewChannelsState {
|
||||
bool longNames;
|
||||
bool secondPage;
|
||||
bool mixersView;
|
||||
};
|
||||
|
||||
static ViewChannelsState viewChannels = { false, false, false };
|
||||
|
||||
void menuChannelsView(event_t event)
|
||||
{
|
||||
uint8_t ch = 0;
|
||||
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
|
||||
uint8_t wbar = (viewChannels.longNames ? 54 : 64);
|
||||
int16_t limits = 512 * 2;
|
||||
|
||||
if (g_eeGeneral.ppmunit == PPM_PERCENT_PREC1) {
|
||||
@@ -32,10 +40,6 @@ void menuChannelsView(event_t event)
|
||||
}
|
||||
|
||||
switch(event) {
|
||||
case EVT_ENTRY:
|
||||
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
|
||||
break;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_EXIT):
|
||||
popMenu();
|
||||
break;
|
||||
@@ -44,23 +48,23 @@ void menuChannelsView(event_t event)
|
||||
case EVT_ROTARY_RIGHT:
|
||||
case EVT_KEY_FIRST(KEY_PLUS):
|
||||
case EVT_KEY_FIRST(KEY_MINUS):
|
||||
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
|
||||
viewChannels.secondPage = !viewChannels.secondPage;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
|
||||
viewChannels.mixersView = !viewChannels.mixersView;
|
||||
break;
|
||||
}
|
||||
|
||||
if (reusableBuffer.viewChannels.secondPage)
|
||||
if (viewChannels.secondPage)
|
||||
ch = 16;
|
||||
|
||||
if (reusableBuffer.viewChannels.mixersView)
|
||||
if (viewChannels.mixersView)
|
||||
limits *= 2; // this could be handled nicer, but slower, by checking actual range for this mixer
|
||||
else if (g_model.extendedLimits)
|
||||
limits *= LIMIT_EXT_PERCENT / 100;
|
||||
|
||||
lcdDrawText(LCD_W / 2, 0, reusableBuffer.viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
|
||||
lcdDrawText(LCD_W / 2, 0, viewChannels.mixersView ? STR_MIXERS_MONITOR : STR_CHANNELS_MONITOR, CENTERED);
|
||||
lcdInvertLine(0);
|
||||
|
||||
// Column separator
|
||||
@@ -73,13 +77,13 @@ void menuChannelsView(event_t event)
|
||||
// Channels
|
||||
for (uint8_t line=0; line < 8; line++) {
|
||||
const uint8_t y = 9 + line * 7;
|
||||
const int32_t val = reusableBuffer.viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch];
|
||||
const int32_t val = viewChannels.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)
|
||||
reusableBuffer.viewChannels.longNames = true;
|
||||
viewChannels.longNames = true;
|
||||
lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -805,12 +805,6 @@ union ReusableBuffer
|
||||
} viewText;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
bool longNames;
|
||||
bool secondPage;
|
||||
bool mixersView;
|
||||
} viewChannels;
|
||||
|
||||
struct {
|
||||
uint8_t maxNameLen;
|
||||
} modelFailsafe;
|
||||
|
||||
Reference in New Issue
Block a user