3djc/test combined mixer output mon (#3622)

* Merge outputs and mixers in a single 'bar'
View 8 per page

* Cosmetics

* Add proper icons for channels3 and 4

* Bars colors now fixed by overwhelmingly popular demand

* Fix outL outR display

* Add bottom line description to avoid confusion between outputs and mixers

* Cosmetics

* Typo
This commit is contained in:
3djc
2016-06-22 22:51:11 +02:00
committed by Bertrand Songis
parent 38fdae6f1f
commit 3ee9f56423
21 changed files with 158 additions and 157 deletions
+73 -84
View File
@@ -21,23 +21,25 @@
#include "opentx.h"
#define RECT_OFFSET 80
#define ROW_HEIGHT 21
#define BAR_HEIGHT 10
#define COLUMN_SIZE 180
#define X_OFFSET 30
#define ROW_HEIGHT 42
#define BAR_HEIGHT 14
#define COLUMN_SIZE 200
#define X_OFFSET 25
#define Y_OFFSET 75
#define Y_OUTBAR 15
#define Y_MIXBAR 28
bool menuOutputs1(evt_t);
bool menuOutputs2(evt_t);
bool menuMixers1(evt_t);
bool menuMixers2(evt_t);
bool menuChannels1(evt_t);
bool menuChannels2(evt_t);
bool menuChannels3(evt_t);
bool menuChannels4(evt_t);
bool menuLogicalSwitches(evt_t);
const MenuHandlerFunc menuTabMonitors[] PROGMEM = {
menuOutputs1,
menuOutputs2,
menuMixers1,
menuMixers2,
menuChannels1,
menuChannels2,
menuChannels3,
menuChannels4,
menuLogicalSwitches
};
@@ -51,38 +53,29 @@ uint16_t posOnBar(int16_t value_to100)
void drawSingleMixerBar(coord_t x, coord_t y, uint8_t chan)
{
char chanString[] = "Ch 32";
int16_t chanVal = calcRESXto100(ex_chans[chan]);
strAppendSigned(&chanString[3], chan + 1, 2);
lcdDrawText(x + X_OFFSET, y + 1, chanString, TINSIZE | TEXT_COLOR | LEFT);
lcdDrawSizedText(x + X_OFFSET + 50, y + 1, g_model.limitData[chan].name, sizeof(g_model.limitData[chan].name), TINSIZE | TEXT_COLOR | LEFT | ZCHAR);
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x, y, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT, HEADER_BGCOLOR);
strAppendSigned(chanString, chanVal);
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
lcd->drawSolidVerticalLine(x + posOnBar(chanVal), y, BAR_HEIGHT, HEADER_BGCOLOR);
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(25, 150, 50);
if (chanVal > 0) {
lcdDrawSolidFilledRect(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, divRoundClosest(chanVal * COLUMN_SIZE, 200), BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x + COLUMN_SIZE / 2, y, divRoundClosest(chanVal * COLUMN_SIZE, 200), BAR_HEIGHT, CUSTOM_COLOR);
}
else if (chanVal < 0) {
uint16_t endpoint = x + X_OFFSET + COLUMN_SIZE / 2;
uint16_t endpoint = x + COLUMN_SIZE / 2;
uint16_t size = divRoundClosest(-chanVal * COLUMN_SIZE, 200);
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(endpoint - size, y, size, BAR_HEIGHT, CUSTOM_COLOR);
}
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT, TEXT_COLOR);
lcd->drawSolidVerticalLine(x + COLUMN_SIZE / 2, y, BAR_HEIGHT, TEXT_COLOR);
}
void drawSingleOutputBar(coord_t x, coord_t y, uint8_t channel)
{
char chanString[] = "Ch 32";
char chanString[] = "Ch32 ";
uint16_t limits = (g_model.extendedLimits ? 300 : 200);
int16_t chanVal = calcRESXto100(channelOutputs[channel]);
LimitData * ld = limitAddress(channel);
@@ -92,103 +85,99 @@ void drawSingleOutputBar(coord_t x, coord_t y, uint8_t channel)
static const BitmapBuffer * outL_bmp = BitmapBuffer::load(getThemePath("mask_monitor_outL.png"));
static const BitmapBuffer * outR_bmp = BitmapBuffer::load(getThemePath("mask_monitor_outR.png"));
strAppendSigned(&chanString[3], channel + 1, 2);
lcdDrawText(x + X_OFFSET, y + 1, chanString, TINSIZE | TEXT_COLOR | LEFT);
strAppendSigned(&chanString[2], channel + 1, 2);
lcdDrawText(x, y, chanString, SMLSIZE | TEXT_COLOR | LEFT);
lcdDrawSizedText(x + X_OFFSET + 50, y + 1, g_model.limitData[channel].name, sizeof(g_model.limitData[channel].name), TINSIZE | TEXT_COLOR | LEFT | ZCHAR);
lcdDrawSizedText(x + 45, y, g_model.limitData[channel].name, sizeof(g_model.limitData[channel].name), SMLSIZE | TEXT_COLOR | LEFT | ZCHAR);
int usValue = PPM_CH_CENTER(channel) + channelOutputs[channel] / 2;
strAppendSigned(chanString, usValue);
if (usValue < 1000) strAppend(&chanString[3], STR_US);
else strAppend(&chanString[4], STR_US);
lcdDrawText(x + 155, y, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x, y + Y_OUTBAR, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawText(x + X_OFFSET + posOnBar(-100 + ld->min / 10) + 2, y + 10, "]", TINSIZE | TEXT_COLOR | RIGHT);
lcdDrawText(x + X_OFFSET + posOnBar(100 + ld->max / 10), y + 10, "[", TINSIZE | TEXT_COLOR);
lcdDrawText(x + posOnBar(-100 + ld->min / 10) + 2, y + Y_OUTBAR, "]", TINSIZE | TEXT_COLOR | RIGHT);
lcdDrawText(x + posOnBar(100 + ld->max / 10), y + Y_OUTBAR, "[", TINSIZE | TEXT_COLOR);
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT, HEADER_BGCOLOR);
lcd->drawSolidVerticalLine(x + posOnBar(calcRESXto100(ld->offset)), y + Y_OUTBAR, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
lcd->drawSolidVerticalLine(x + posOnBar(chanVal), y + Y_OUTBAR, BAR_HEIGHT, HEADER_BGCOLOR);
strAppendSigned(chanString, chanVal);
if (chanVal < -limits / 2) {
lcd->drawBitmap(x + X_OFFSET + COLUMN_SIZE / 2 - 55, y + 8, outL_bmp);
chanVal = -limits / 2;
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
lcdDrawText(x + COLUMN_SIZE - 2, y + 1, chanString, SMLSIZE | TEXT_COLOR | RIGHT | INVERS);
lcd->drawBitmap(x + COLUMN_SIZE / 2 + 5, y + 16, outL_bmp);
}
else if (chanVal > limits / 2) {
lcd->drawBitmap(x + X_OFFSET + COLUMN_SIZE / 2 + 55, y + 8, outR_bmp);
chanVal = limits / 2;
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
lcdDrawText(x + COLUMN_SIZE - 2, y + 1, chanString, SMLSIZE | TEXT_COLOR | RIGHT | INVERS);
lcd->drawBitmap(x + COLUMN_SIZE / 2 - 5, y + 16, outR_bmp);
}
else {
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
lcdDrawText(x + COLUMN_SIZE - 2, y + 1, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
}
lcdColorTable[CUSTOM_COLOR_INDEX] = RED;
if (posOnBar(chanVal) > posOnBar(calcRESXto100(ld->offset))) {
lcdDrawSolidFilledRect(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
lcdDrawSolidFilledRect(x + posOnBar(calcRESXto100(ld->offset)), y + Y_OUTBAR, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, CUSTOM_COLOR);
}
else if (posOnBar(chanVal) < posOnBar(calcRESXto100(ld->offset))) {
uint16_t endpoint = x + X_OFFSET + posOnBar(calcRESXto100(ld->offset));
uint16_t endpoint = x + posOnBar(calcRESXto100(ld->offset));
uint16_t size = posOnBar(calcRESXto100(ld->offset)) - posOnBar(chanVal);
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
lcdDrawSolidFilledRect(endpoint - size, y + Y_OUTBAR, size, BAR_HEIGHT, CUSTOM_COLOR);
}
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) lcd->drawBitmap(x + 3, y + 5, locked_bmp);
if (ld->revert) lcd->drawBitmap(x + 16, y + 5, inver_bmp);
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT, TEXT_COLOR);
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) lcd->drawBitmap(x -X_OFFSET + 7, y + 7, locked_bmp);
if (ld->revert) lcd->drawBitmap(x -X_OFFSET + 7, y + 25, inver_bmp);
lcd->drawSolidVerticalLine(x + COLUMN_SIZE / 2, y + Y_OUTBAR, BAR_HEIGHT, TEXT_COLOR);
}
bool menuOutputsMonitor(evt_t event, uint8_t page)
bool menuChannelsMonitor(evt_t event, uint8_t page)
{
uint8_t channel = 16 * page;
uint16_t x = 1, y = Y_OFFSET;
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
uint8_t channel = 8 * page;
coord_t x = X_OFFSET, y = Y_OFFSET;
drawStatusText(STR_MONITOR_CHANNELS_DESC);
for (uint8_t i = 0; i < 4; i++, channel++, y += ROW_HEIGHT) {
drawSingleOutputBar(x, y, channel);
drawSingleMixerBar(x, y + Y_MIXBAR, channel);
}
x = 1 + LCD_W / 2;
x = 1 + LCD_W / 2 + X_OFFSET;
y = Y_OFFSET;
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
for (uint8_t i = 0; i < 4; i++, channel++, y += ROW_HEIGHT) {
drawSingleOutputBar(x, y, channel);
drawSingleMixerBar(x, y + Y_MIXBAR, channel);
}
return true;
}
bool menuOutputs1(evt_t event)
bool menuChannels1(evt_t event)
{
MENU(STR_MONITOR_OUTPUTS1, MONITOR_ICONS, menuTabMonitors, e_MonOutputs1, 0, { 0 });
lastMonitorPage = e_MonOutputs1;
return menuOutputsMonitor(event, 0);
MENU(STR_MONITOR_CHANNELS1, MONITOR_ICONS, menuTabMonitors, e_MonChannels1, 0, { 0 });
lastMonitorPage = e_MonChannels1;
return menuChannelsMonitor(event, 0);
}
bool menuOutputs2(evt_t event)
bool menuChannels2(evt_t event)
{
MENU(STR_MONITOR_OUTPUTS2, MONITOR_ICONS, menuTabMonitors, e_MonOutputs2, 0, { 0 });
lastMonitorPage = e_MonOutputs2;
return menuOutputsMonitor(event, 1);
MENU(STR_MONITOR_CHANNELS2, MONITOR_ICONS, menuTabMonitors, e_MonChannels2, 0, { 0 });
lastMonitorPage = e_MonChannels2;
return menuChannelsMonitor(event, 1);
}
bool menuMixersMonitor(evt_t event, uint8_t page)
bool menuChannels3(evt_t event)
{
uint8_t channel = 16 * page;
uint16_t x = 1, y = Y_OFFSET;
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
drawSingleMixerBar(x, y, channel);
}
x = 1 + LCD_W / 2;
y = Y_OFFSET;
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
drawSingleMixerBar(x, y, channel);
}
return true;
MENU(STR_MONITOR_CHANNELS3, MONITOR_ICONS, menuTabMonitors, e_MonChannels3, 0, { 0 });
lastMonitorPage = e_MonChannels3;
return menuChannelsMonitor(event, 2);
}
bool menuMixers1(evt_t event)
bool menuChannels4(evt_t event)
{
MENU(STR_MONITOR_MIXERS1, MONITOR_ICONS, menuTabMonitors, e_MonMixers1, 0, { 0 });
lastMonitorPage = e_MonMixers1;
return menuMixersMonitor(event, 0);
}
bool menuMixers2(evt_t event)
{
MENU(STR_MONITOR_MIXERS2, MONITOR_ICONS, menuTabMonitors, e_MonMixers2, 0, { 0 });
lastMonitorPage = e_MonMixers2;
return menuMixersMonitor(event, 1);
MENU(STR_MONITOR_CHANNELS4, MONITOR_ICONS, menuTabMonitors, e_MonChannels4, 0, { 0 });
lastMonitorPage = e_MonChannels4;
return menuChannelsMonitor(event, 3);
}