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
+1
View File
@@ -95,6 +95,7 @@ if(PCB STREQUAL HORUS)
menu_model_inputs.cpp
menu_model_mixes.cpp
view_channels.cpp
view_logic_switches.cpp
view_about.cpp
view_text.cpp
screens_setup.cpp
+18 -6
View File
@@ -98,6 +98,10 @@ enum MenuIcons {
ICON_MONITOR,
ICON_MONITOR_OUTPUTS1,
ICON_MONITOR_OUTPUTS2,
ICON_MONITOR_MIXERS1,
ICON_MONITOR_MIXERS2,
/* ICON_MONITOR_LOGIC_SWITCHES1,
ICON_MONITOR_LOGIC_SWITCHES2,*/
MENUS_ICONS_COUNT
};
@@ -160,7 +164,11 @@ const uint8_t STATS_ICONS[] = {
const uint8_t MONITOR_ICONS[] = {
ICON_MONITOR,
ICON_MONITOR_OUTPUTS1,
ICON_MONITOR_OUTPUTS2
ICON_MONITOR_OUTPUTS2,
ICON_MONITOR_MIXERS1,
ICON_MONITOR_MIXERS2,
/* ICON_MONITOR_LOGIC_SWITCHES1,
ICON_MONITOR_LOGIC_SWITCHES2*/
};
bool menuModelSetup(evt_t event);
@@ -224,15 +232,19 @@ static const MenuHandlerFunc menuTabStats[] PROGMEM = {
#endif
};
enum EnumTabChannels
enum EnumTabMonitors
{
e_Channels1,
e_Channels2,
e_Outputs1,
e_Outputs2,
e_Mixers1,
e_Mixers2,
/* e_LogicSwitches1,
e_LogicSwitches2,*/
e_TabChannelsPagesCount
};
extern const MenuHandlerFunc menuTabChannels[e_TabChannelsPagesCount];
extern uint8_t lastChannelsPage;
extern const MenuHandlerFunc menuTabMonitors[e_TabChannelsPagesCount];
extern uint8_t lastMonitorPage;
extern const MenuHandlerFunc menuTabScreensSetup[1+MAX_CUSTOM_SCREENS] PROGMEM;
+1 -1
View File
@@ -377,7 +377,7 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u
if (menuTab == menuTabModel && event == EVT_KEY_FIRST(KEY_MODEL)) {
killEvents(event);
pushMenu(menuTabChannels[lastChannelsPage]);
pushMenu(menuTabMonitors[lastMonitorPage]);
return false;
}
+4
View File
@@ -109,6 +109,10 @@ class DarkblueTheme: public Theme
loadMenuIcon(ICON_MONITOR, "mask_monitor.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS2, "mask_monitor_outputs2.png");
loadMenuIcon(ICON_MONITOR_MIXERS1, "mask_monitor_mixes1.png");
loadMenuIcon(ICON_MONITOR_MIXERS2, "mask_monitor_mixes2.png");
/* loadMenuIcon(ICON_MONITOR_LOGIC_SWITCHES1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_LOGIC_SWITCHES2, "mask_monitor_outputs1.png");*/
}
virtual void load() const
+4
View File
@@ -125,6 +125,10 @@ class DefaultTheme: public Theme
loadMenuIcon(ICON_MONITOR, "mask_monitor.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS2, "mask_monitor_outputs2.png");
loadMenuIcon(ICON_MONITOR_MIXERS1, "mask_monitor_mixes1.png");
loadMenuIcon(ICON_MONITOR_MIXERS2, "mask_monitor_mixes2.png");
/* loadMenuIcon(ICON_MONITOR_LOGIC_SWITCHES1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_LOGIC_SWITCHES2, "mask_monitor_outputs1.png");*/
BitmapBuffer * background = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_bg.png"));
BitmapBuffer * shadow = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_shadow.png"));
+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);
}
@@ -0,0 +1,42 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
/*
extern bool menuChannelsMonitor(evt_t, uint8_t);
uint8_t drawLS_Table(uint16_t x, uint16_t y){
}
bool menuLogicSwitches1(evt_t event)
{
MENU("Logic Switches monitor 1-32", MONITOR_ICONS, menuTabMonitors, e_LogicSwitches1, 0, { 0 });
lastMonitorPage = e_LogicSwitches1;
return menuChannelsMonitor(event, 4);
}
bool menuLogicSwitches2(evt_t event)
{
MENU("Logic Switches 33-64",MONITOR_ICONS, menuTabMonitors, e_LogicSwitches2, 0, { 0 });
lastMonitorPage = e_LogicSwitches2;
return menuChannelsMonitor(event, 5);
}*/