3djc/horus chan mon fix mixers limits (#3626)

* Review Channel monitor to handle mixers outside -100/100
Percentage values are now displayed on bar, for both mix and out

* Cosmetics (uncrustify)

* Channels monitor bars color and background now theme driven

* Add TEXT_STATUSBAR_COLOR (was ToDo)
Rename for consistency

* Replace text by graphic caption

* Cosmetics

* Remove unwanted vertical line on chanVal

* Tidy up code a little

* Tidy up

* Change green bar to grey
Introduce a space between outputs and mixers bar

* Partial cosmetics

* Fix bad copy/paste
This commit is contained in:
3djc
2016-06-25 14:11:22 +02:00
committed by Bertrand Songis
parent 6861d6c8a4
commit 1a77d1ffda
20 changed files with 82 additions and 52 deletions
+38 -38
View File
@@ -22,12 +22,13 @@
#define RECT_OFFSET 80
#define ROW_HEIGHT 42
#define BAR_HEIGHT 14
#define BAR_HEIGHT 13
#define COLUMN_SIZE 200
#define X_OFFSET 25
#define Y_OFFSET 75
#define Y_OUTBAR 15
#define Y_MIXBAR 28
#define LEG_COLORBOX 15
bool menuChannelsMonitor(evt_t event, uint8_t page);
bool menuLogicalSwitches(evt_t);
@@ -58,21 +59,23 @@ uint16_t posOnBar(int16_t value_to100)
void drawSingleMixerBar(coord_t x, coord_t y, uint8_t chan)
{
char chanString[] = "-500%";
int16_t chanVal = calcRESXto100(ex_chans[chan]);
int16_t displayVal = chanVal;
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
lcdDrawSolidFilledRect(x, y, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
chanVal = limit<int16_t>(-100, chanVal, 100);
strAppend(strAppendSigned(chanString, displayVal), "%");
lcd->drawSolidVerticalLine(x + posOnBar(chanVal), y, BAR_HEIGHT, HEADER_BGCOLOR);
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(25, 150, 50);
lcdDrawSolidFilledRect(x, y, COLUMN_SIZE, BAR_HEIGHT, BARGRAPH_BGCOLOR);
if (chanVal > 0) {
lcdDrawSolidFilledRect(x + COLUMN_SIZE / 2, y, divRoundClosest(chanVal * COLUMN_SIZE, 200), BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x + COLUMN_SIZE / 2, y, divRoundClosest(chanVal * COLUMN_SIZE, 200), BAR_HEIGHT, BARGRAPH2_COLOR);
lcdDrawText(x - 10 + COLUMN_SIZE / 2, y, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
}
else if (chanVal < 0) {
uint16_t endpoint = x + COLUMN_SIZE / 2;
uint16_t size = divRoundClosest(-chanVal * COLUMN_SIZE, 200);
lcdDrawSolidFilledRect(endpoint - size, y, size, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(endpoint - size, y, size, BAR_HEIGHT, BARGRAPH2_COLOR);
lcdDrawText(x + 10 + COLUMN_SIZE / 2, y, chanString, SMLSIZE | TEXT_COLOR);
}
lcd->drawSolidVerticalLine(x + COLUMN_SIZE / 2, y, BAR_HEIGHT, TEXT_COLOR);
@@ -87,8 +90,6 @@ void drawSingleOutputBar(coord_t x, coord_t y, uint8_t channel)
static const BitmapBuffer * locked_bmp = BitmapBuffer::load(getThemePath("mask_monitor_lockch.png"));
static const BitmapBuffer * inver_bmp = BitmapBuffer::load(getThemePath("mask_monitor_inver.png"));
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[2], channel + 1, 2);
lcdDrawText(x, y, chanString, SMLSIZE | TEXT_COLOR | LEFT);
@@ -98,62 +99,61 @@ void drawSingleOutputBar(coord_t x, coord_t y, uint8_t channel)
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);
lcdDrawText(x + COLUMN_SIZE, y, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
lcdDrawSolidFilledRect(x, y + Y_OUTBAR, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x, y + Y_OUTBAR, COLUMN_SIZE, BAR_HEIGHT, BARGRAPH_BGCOLOR);
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 + 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) {
chanVal = -limits / 2;
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) {
chanVal = limits / 2;
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 + COLUMN_SIZE - 2, y + 1, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
}
strAppend(strAppendSigned(chanString, chanVal), "%");
if (chanVal > 0) lcdDrawText(x - 10 + COLUMN_SIZE / 2, y + BAR_HEIGHT, chanString, SMLSIZE | TEXT_COLOR | RIGHT);
else lcdDrawText(x + 10 + COLUMN_SIZE / 2, y + BAR_HEIGHT, chanString, SMLSIZE | TEXT_COLOR);
lcdColorTable[CUSTOM_COLOR_INDEX] = RED;
if (chanVal < -limits / 2) chanVal = -limits / 2;
else if (chanVal > limits / 2) chanVal = limits / 2;
if (posOnBar(chanVal) > posOnBar(calcRESXto100(ld->offset))) {
lcdDrawSolidFilledRect(x + posOnBar(calcRESXto100(ld->offset)), y + Y_OUTBAR, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x + posOnBar(calcRESXto100(ld->offset)), y + Y_OUTBAR, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, BARGRAPH1_COLOR);
}
else if (posOnBar(chanVal) < 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 + Y_OUTBAR, size, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(endpoint - size, y + Y_OUTBAR, size, BAR_HEIGHT, BARGRAPH1_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);
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);
}
coord_t drawChannelsMonitorLegend(coord_t x, const pm_char * s, int color)
{
lcdDrawSolidFilledRect(x, MENU_FOOTER_TOP + 2, LEG_COLORBOX + 2, LEG_COLORBOX + 2, BARGRAPH_BGCOLOR);
lcdDrawSolidFilledRect(x + 1, MENU_FOOTER_TOP + 3, LEG_COLORBOX, LEG_COLORBOX, color);
lcdDrawText(x + 20, MENU_FOOTER_TOP, s, TEXT_STATUSBAR_COLOR);
return x + 25 + getTextWidth(s);
}
bool menuChannelsMonitor(evt_t event, uint8_t page)
{
uint8_t channel = 8 * page;
coord_t x = X_OFFSET, y = Y_OFFSET;
drawStatusText(STR_MONITOR_CHANNELS_DESC);
coord_t x, y = Y_OFFSET;
x = drawChannelsMonitorLegend(MENUS_MARGIN_LEFT, STR_MONITOR_OUTPUT_DESC, BARGRAPH1_COLOR);
drawChannelsMonitorLegend(x, STR_MONITOR_MIXER_DESC, BARGRAPH2_COLOR);
x = X_OFFSET;
for (uint8_t i = 0; i < 4; i++, channel++, y += ROW_HEIGHT) {
drawSingleOutputBar(x, y, channel);
drawSingleMixerBar(x, y + Y_MIXBAR, channel);
drawSingleMixerBar(x, y + Y_MIXBAR + 1, channel);
}
x = 1 + LCD_W / 2 + X_OFFSET;
y = Y_OFFSET;
for (uint8_t i = 0; i < 4; i++, channel++, y += ROW_HEIGHT) {
drawSingleOutputBar(x, y, channel);
drawSingleMixerBar(x, y + Y_MIXBAR, channel);
drawSingleMixerBar(x, y + Y_MIXBAR + 1, channel);
}
return true;
}