128 chan monitor (#7418)

Introduce 128x64 channels monitor
This commit is contained in:
3djc
2020-03-10 17:17:59 +01:00
committed by GitHub
parent ad188aa916
commit cf5e2b3fd5
17 changed files with 338 additions and 276 deletions
+94 -67
View File
@@ -20,7 +20,30 @@
#include "opentx.h"
void menuChannelsView(event_t event)
constexpr coord_t CHANNEL_NAME_OFFSET = 1;
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;
constexpr coord_t CHANNEL_PROPERTIES_OFFSET = CHANNEL_GAUGE_OFFSET + CHANNEL_BAR_WIDTH + 2;
#if defined(NAVIGATION_X7)
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_LONG(KEY_PAGE)
#define EVT_KEY_NEXT_VIEW EVT_KEY_BREAK(KEY_PAGE)
#define EVT_KEY_NEXT_PAGE EVT_ROTARY_RIGHT
#define EVT_KEY_PREVIOUS_PAGE EVT_ROTARY_LEFT
#elif defined(NAVIGATION_XLITE)
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_UP)
#define EVT_KEY_NEXT_VIEW EVT_KEY_BREAK(KEY_DOWN)
#define EVT_KEY_NEXT_PAGE EVT_KEY_BREAK(KEY_RIGHT)
#define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT)
#else
#define EVT_KEY_PREVIOUS_VIEW EVT_KEY_BREAK(KEY_UP)
#define EVT_KEY_NEXT_VIEW EVT_KEY_BREAK(KEY_DOWN)
#define EVT_KEY_NEXT_PAGE EVT_KEY_BREAK(KEY_RIGHT)
#define EVT_KEY_PREVIOUS_PAGE EVT_KEY_BREAK(KEY_LEFT)
#endif
void menuChannelsViewCommon(event_t event)
{
bool newLongNames = false;
@@ -31,13 +54,79 @@ void menuChannelsView(event_t event)
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
break;
case EVT_KEY_FIRST(KEY_ENTER):
reusableBuffer.viewChannels.mixersView = !reusableBuffer.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);
lcdInvertLine(0);
int16_t limits = 512 * 2;
// Channels
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 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;
lcdDrawSizedText(CHANNEL_NAME_OFFSET, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
}
else {
putsChn(CHANNEL_NAME_OFFSET, y, ch + 1, SMLSIZE);
}
// Value
#if defined(PPM_UNIT_US)
lcdDrawNumber(CHANNEL_VALUE_OFFSET, y + 1, PPM_CH_CENTER(ch) + val / 2, TINSIZE | RIGHT);
#elif defined(PPM_UNIT_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);
#endif
// Gauge
drawGauge(CHANNEL_GAUGE_OFFSET, y, CHANNEL_BAR_WIDTH, 6, val, limits);
if (!reusableBuffer.viewChannels.mixersView) {
// Properties
#if defined(OVERRIDE_CHANNEL_FUNCTION)
if (safetyCh[ch] != OVERRIDE_CHANNEL_UNDEFINED)
lcdDrawText(CHANNEL_PROPERTIES_OFFSET, y, "OVR", TINSIZE);
else
#endif
if (ld && ld->revert) {
lcdDrawText(CHANNEL_PROPERTIES_OFFSET, y, "INV", TINSIZE);
}
}
++ch;
}
reusableBuffer.viewChannels.longNames = newLongNames;
}
void menuChannelsView(event_t event)
{
switch (event) {
case EVT_KEY_BREAK(KEY_EXIT):
popMenu();
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
case EVT_KEY_NEXT_PAGE:
g_eeGeneral.view = (g_eeGeneral.view + (4 * ALTERNATE_VIEW) + ALTERNATE_VIEW) % (4 * ALTERNATE_VIEW);
break;
case EVT_KEY_PREVIOUS_PAGE:
g_eeGeneral.view = (g_eeGeneral.view + (4 * ALTERNATE_VIEW) - ALTERNATE_VIEW) % (4 * ALTERNATE_VIEW);
break;
case EVT_KEY_FIRST(KEY_ENTER):
@@ -45,67 +134,5 @@ void menuChannelsView(event_t event)
break;
}
if (reusableBuffer.viewChannels.secondPage)
ch = 16;
else
ch = 0;
if (reusableBuffer.viewChannels.mixersView) {
lcdDrawTextAlignedCenter(0, TR_MIXERS_MONITOR);
}
else {
lcdDrawTextAlignedCenter(0, TR_CHANNELS_MONITOR);
}
lcdInvertLine(0);
// Column separator
lcdDrawSolidVerticalLine(LCD_W/2, FH, LCD_H-FH);
for (uint8_t col=0; col<2; col++) {
uint8_t x = col*LCD_W/2+1;
// Channels
for (uint8_t line=0; line<8; line++) {
uint8_t y = 9+line*7;
int32_t val = (reusableBuffer.viewChannels.mixersView) ? ex_chans[ch] : channelOutputs[ch];
uint8_t ofs = (col ? 0 : 1);
// Channel name if present, number if not
uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
if (lenLabel > 4) {
newLongNames = reusableBuffer.viewChannels.longNames = true;
}
if (lenLabel > 0)
lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
else
putsChn(x+1-ofs, y, ch+1, SMLSIZE);
// Value
#if defined(PPM_UNIT_US)
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE|RIGHT);
#elif defined(PPM_UNIT_PERCENT_PREC1)
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 48 : 58);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE|RIGHT);
#else
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE|RIGHT);
#endif
// Gauge
// uint16_t lim = (g_model.extendedLimits ? (512 * (long)LIMIT_EXT_PERCENT / 100) : 512) * 2;
//#ifdef MIXERS_MONITOR
// if (mixersView)
// lim = 512 * 2 * 2;
//#endif
// TODO ? drawGauge(x+LCD_W/2-3-wbar-ofs, y, wbar, 6, val, lim);
ch++;
}
}
reusableBuffer.viewChannels.longNames = newLongNames;
menuChannelsViewCommon(event);
}