3djc/Mixer monitor (#3606)

* Add menu mechanics for 2 Mixers screens and 2 logical switches screens

* Add two mixer pages. To prevent errors, the Mixer bar are green (as opposed to red for outputs).

Icons for those pages are not yet the right ones

* Ready for mixers monitor PR
This commit is contained in:
3djc
2016-06-17 23:54:35 +02:00
committed by Bertrand Songis
parent 4445f7cdec
commit 5ed74f1329
7 changed files with 171 additions and 28 deletions
+101 -21
View File
@@ -23,7 +23,7 @@
#define RECT_OFFSET 80
#define ROW_HEIGHT 21
#define BAR_HEIGHT 10
#define COLLUMN_SIZE 180
#define COLUMN_SIZE 180
#define X_OFFSET 30
#define Y_OFFSET 75
@@ -34,15 +34,61 @@ const BitmapBuffer *inver_bmp = NULL;
const BitmapBuffer *outL_bmp = NULL;
const BitmapBuffer *outR_bmp = NULL;
const MenuHandlerFunc menuTabChannels[] PROGMEM = {
menuChannels1,
menuChannels2,
bool menuOutputs1(evt_t);
bool menuOutputs2(evt_t);
extern bool menuLogicSwitches1(evt_t);
extern bool menuLogicSwitches2(evt_t);
extern bool menuMixers1(evt_t);
extern bool menuMixers2(evt_t);
const MenuHandlerFunc menuTabMonitors[] PROGMEM = {
menuOutputs1,
menuOutputs2,
menuMixers1,
menuMixers2,
/* menuLogicSwitches1,
menuLogicSwitches2*/
};
uint8_t lastChannelsPage = 0;
uint8_t lastMonitorPage = 0;
uint16_t posOnBar(int16_t value_to100){
return divRoundClosest((value_to100 + (g_model.extendedLimits ? 150 : 100)) * COLLUMN_SIZE, (g_model.extendedLimits ? 150 : 100)*2);
return divRoundClosest((value_to100 + (g_model.extendedLimits ? 150 : 100)) * COLUMN_SIZE, (g_model.extendedLimits ? 150 : 100)*2);
}
void drawSingleMixerBar(uint16_t x, uint16_t y, uint8_t Chan)
{
char chanString[] = "CH 32";
int16_t chanVal = calcRESXto100(ex_chans[Chan]);
strAppend(chanString, "Ch ");
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);
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);
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);
}
else if (chanVal < 0) {
uint16_t endpoint = x + X_OFFSET + COLUMN_SIZE / 2;
uint16_t size = divRoundClosest(-chanVal * COLUMN_SIZE, 200);
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, CUSTOM_COLOR);
}
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT , TEXT_COLOR);
}
void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t Chan)
@@ -64,9 +110,8 @@ void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t Chan)
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, COLLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
lcdColorTable[CUSTOM_COLOR_INDEX]= RGB(180, 180, 180);
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);
@@ -75,17 +120,17 @@ void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t Chan)
strAppendSigned(chanString, chanVal);
if (chanVal < -limits / 2) {
lcd->drawBitmap(x + X_OFFSET + COLLUMN_SIZE / 2 - 55, y + 8, outL_bmp);
lcd->drawBitmap(x + X_OFFSET + COLUMN_SIZE / 2 - 55, y + 8, outL_bmp);
chanVal = - limits / 2;
lcdDrawText(x + X_OFFSET + COLLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
} else if (chanVal > limits / 2){
lcd->drawBitmap(x + X_OFFSET + COLLUMN_SIZE / 2 + 55, y + 8, outR_bmp);
lcd->drawBitmap(x + X_OFFSET + COLUMN_SIZE / 2 + 55, y + 8, outR_bmp);
chanVal = limits / 2;
lcdDrawText(x + X_OFFSET + COLLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
} else {
lcdDrawText(x + X_OFFSET + COLLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
}
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);
}
@@ -97,7 +142,7 @@ void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t Chan)
if (safetyCh[Chan] != 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 + COLLUMN_SIZE / 2, y + 11, BAR_HEIGHT , TEXT_COLOR);
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT , TEXT_COLOR);
}
bool menuChannelsMonitor(evt_t event, uint8_t page)
@@ -105,10 +150,10 @@ bool menuChannelsMonitor(evt_t event, uint8_t page)
return true;
}
bool menuChannels1(evt_t event)
bool menuOutputs1(evt_t event)
{
MENU("Channels monitor 1-16", MONITOR_ICONS, menuTabChannels, e_Channels1, 0, { 0 });
lastChannelsPage = e_Channels1;
MENU("Output monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Outputs1, 0, { 0 });
lastMonitorPage = e_Outputs1;
int8_t Chan;
uint16_t x=0,y=0;
@@ -121,10 +166,10 @@ bool menuChannels1(evt_t event)
return menuChannelsMonitor(event, 0);
}
bool menuChannels2(evt_t event)
bool menuOutputs2(evt_t event)
{
MENU("Channels monitor 17-32", MONITOR_ICONS, menuTabChannels, e_Channels2, 0, { 0 });
lastChannelsPage = e_Channels2;
MENU("Output monitor 17-32", MONITOR_ICONS, menuTabMonitors, e_Outputs2, 0, { 0 });
lastMonitorPage = e_Outputs2;
int8_t Chan;
uint16_t x,y;
@@ -137,3 +182,38 @@ bool menuChannels2(evt_t event)
return menuChannelsMonitor(event, 1);
}
bool menuMixers1(evt_t event)
{
MENU("Mixer monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Mixers1, 0, { 0 });
lastMonitorPage = e_Mixers1;
int8_t Chan;
uint16_t x=0,y=0;
for(Chan=0, x=1, y=Y_OFFSET;Chan < 8; Chan++, y+=ROW_HEIGHT){
drawSingleMixerBar(x, y, Chan);
}
for(Chan=8, x=1 + LCD_W/2, y=Y_OFFSET; Chan < 16;Chan++, y+=ROW_HEIGHT){
drawSingleMixerBar(x, y, Chan);
}
return menuChannelsMonitor(event, 2);
}
bool menuMixers2(evt_t event)
{
MENU("Mixer monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Mixers2, 0, { 0 });
lastMonitorPage = e_Mixers2;
int8_t Chan;
uint16_t x,y;
for(Chan=16, x=1, y=Y_OFFSET; Chan < 24; Chan++, y+=ROW_HEIGHT){
drawSingleMixerBar(x, y, Chan);
}
for(Chan=24, x=1 + LCD_W/2, y=Y_OFFSET; Chan < 32; Chan++, y+=ROW_HEIGHT){
drawSingleMixerBar(x, y, Chan);
}
return menuChannelsMonitor(event, 2);
}