3djc/chan mon improve (#3604)

* Prepare for more flexibility (and a much better look)

* [Horus] Preparation for a new Channels menu

* monitor bar icons added

* Add ICONS structure and populate for MONITOR pages

* Restore old widget (had used it for temp work), will likely update to the newer look later

Functionnal output monitor 1,2, still need extended and overrides

* extended limits

* Overrides are now managed

* Back to Red ;)
Add outL outR to hightlight out of limits values

* Rewrite of posOnBar, as it was getting overly complex
subtrin now fulland more logicaly managed

* Fix overrides

* Center bar drawn last to be always visible

* Limits need to go through extend limits display calculation as well

* remove debug printf

* Add inverted output icon

* Tidy up and cosmetics
This commit is contained in:
3djc
2016-06-16 10:14:53 +02:00
committed by Bertrand Songis
parent 9b5b9be50c
commit 98b1029bec
19 changed files with 197 additions and 134 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+9
View File
@@ -20,6 +20,15 @@
#include "opentx.h"
const MenuHandlerFunc menuTabGeneral[] = {
menuGeneralSetup,
menuGeneralSdManager,
menuGeneralCustomFunctions,
menuGeneralTrainer,
menuGeneralHardware,
menuGeneralVersion,
};
bool menuGeneralCustomFunctions(evt_t event)
{
MENU(STR_MENUGLOBALFUNCS, RADIO_ICONS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
+21
View File
@@ -20,6 +20,27 @@
#include "opentx.h"
const MenuHandlerFunc menuTabModel[] = {
menuModelSetup,
CASE_HELI(menuModelHeli)
CASE_FLIGHT_MODES(menuModelFlightModesAll)
menuModelExposAll,
menuModelMixAll,
menuModelLimits,
CASE_CURVES(menuModelCurvesAll)
#if defined(GVARS) && defined(FLIGHT_MODES)
CASE_GVARS(menuModelGVars)
#endif
menuModelLogicalSwitches,
menuModelCustomFunctions,
#if defined(LUA_MODEL_SCRIPTS)
menuModelCustomScripts,
#endif
CASE_FRSKY(menuModelTelemetry)
CASE_MAVLINK(menuTelemetryMavlinkSetup)
CASE_TEMPLATES(menuModelTemplates)
};
extern uint8_t s_curveChan;
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t attr);
+23 -31
View File
@@ -95,6 +95,9 @@ enum MenuIcons {
ICON_STATS_TIMERS,
ICON_STATS_ANALOGS,
ICON_STATS_DEBUG,
ICON_MONITOR,
ICON_MONITOR_OUTPUTS1,
ICON_MONITOR_OUTPUTS2,
MENUS_ICONS_COUNT
};
@@ -113,6 +116,7 @@ enum EnumTabModel {
e_CustomScripts,
#endif
CASE_FRSKY(e_Telemetry)
e_TabModelPagesCount
};
const uint8_t RADIO_ICONS[] = {
@@ -153,6 +157,12 @@ const uint8_t STATS_ICONS[] = {
#endif
};
const uint8_t MONITOR_ICONS[] = {
ICON_MONITOR,
ICON_MONITOR_OUTPUTS1,
ICON_MONITOR_OUTPUTS2
};
bool menuModelSetup(evt_t event);
bool menuModelHeli(evt_t event);
bool menuModelFlightModesAll(evt_t event);
@@ -168,27 +178,7 @@ bool menuModelCustomScripts(evt_t event);
bool menuModelTelemetry(evt_t event);
bool menuModelExpoOne(evt_t event);
const MenuHandlerFunc menuTabModel[] = {
// menuModelSelect,
menuModelSetup,
CASE_HELI(menuModelHeli)
CASE_FLIGHT_MODES(menuModelFlightModesAll)
menuModelExposAll,
menuModelMixAll,
menuModelLimits,
CASE_CURVES(menuModelCurvesAll)
#if defined(GVARS) && defined(FLIGHT_MODES)
CASE_GVARS(menuModelGVars)
#endif
menuModelLogicalSwitches,
menuModelCustomFunctions,
#if defined(LUA_MODEL_SCRIPTS)
menuModelCustomScripts,
#endif
CASE_FRSKY(menuModelTelemetry)
CASE_MAVLINK(menuTelemetryMavlinkSetup)
CASE_TEMPLATES(menuModelTemplates)
};
extern const MenuHandlerFunc menuTabModel[e_TabModelPagesCount];
enum EnumTabRadio {
e_Setup,
@@ -197,6 +187,7 @@ enum EnumTabRadio {
e_Trainer,
e_Hardware,
e_Vers,
e_TabRadioPagesCount
};
bool menuGeneralSetup(evt_t event);
@@ -207,14 +198,7 @@ bool menuGeneralVersion(evt_t event);
bool menuGeneralHardware(evt_t event);
bool menuGeneralCalib(evt_t event);
static const MenuHandlerFunc menuTabGeneral[] PROGMEM = {
menuGeneralSetup,
menuGeneralSdManager,
menuGeneralCustomFunctions,
menuGeneralTrainer,
menuGeneralHardware,
menuGeneralVersion,
};
extern const MenuHandlerFunc menuTabGeneral[e_TabRadioPagesCount];
enum EnumTabDiag
{
@@ -240,6 +224,16 @@ static const MenuHandlerFunc menuTabStats[] PROGMEM = {
#endif
};
enum EnumTabChannels
{
e_Channels1,
e_Channels2,
e_TabChannelsPagesCount
};
extern const MenuHandlerFunc menuTabChannels[e_TabChannelsPagesCount];
extern uint8_t lastChannelsPage;
extern const MenuHandlerFunc menuTabScreensSetup[1+MAX_CUSTOM_SCREENS] PROGMEM;
bool menuFirstCalib(evt_t event);
@@ -248,8 +242,6 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
bool menuModelSelect(evt_t event);
bool menuAboutView(evt_t event);
bool menuMainViewChannelsMonitor(evt_t event);
bool menuChannelsView(evt_t event);
bool menuChannelsView(evt_t event);
bool menuTextView(evt_t event);
bool menuScreensTheme(evt_t event);
+6 -1
View File
@@ -375,6 +375,12 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u
{
uint8_t maxcol = MAXCOL(menuVerticalPosition);
if (menuTab == menuTabModel && event == EVT_KEY_FIRST(KEY_MODEL)) {
killEvents(event);
pushMenu(menuTabChannels[lastChannelsPage]);
return false;
}
if (menuTab && !calibrationState) {
int cc = curr;
switch (event) {
@@ -383,7 +389,6 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u
cc = 0;
break;
case EVT_KEY_FIRST(KEY_PGUP):
if (cc-- == 0)
cc = menuTabSize-1;
+3
View File
@@ -106,6 +106,9 @@ class DarkblueTheme: public Theme
loadMenuIcon(ICON_THEME_VIEW4, "mask_theme_view4.png");
loadMenuIcon(ICON_THEME_VIEW5, "mask_theme_view5.png");
loadMenuIcon(ICON_THEME_ADD_VIEW, "mask_theme_add_view.png");
loadMenuIcon(ICON_MONITOR, "mask_monitor.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS2, "mask_monitor_outputs2.png");
}
virtual void load() const
+4 -1
View File
@@ -122,7 +122,10 @@ class DefaultTheme: public Theme
loadMenuIcon(ICON_THEME_VIEW5, "mask_theme_view5.png");
loadMenuIcon(ICON_THEME_ADD_VIEW, "mask_theme_add_view.png");
loadMenuIcon(ICON_LIBRARY, "mask_library.png");
loadMenuIcon(ICON_MONITOR, "mask_monitor.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS1, "mask_monitor_outputs1.png");
loadMenuIcon(ICON_MONITOR_OUTPUTS2, "mask_monitor_outputs2.png");
BitmapBuffer * background = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_bg.png"));
BitmapBuffer * shadow = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_shadow.png"));
BitmapBuffer * dot = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_dot.png"));
+131 -100
View File
@@ -1,108 +1,139 @@
/*
* 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"
/*
* 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.
*/
bool isChannelUsed(int channel);
int getChannelsUsed();
#include "opentx.h"
bool menuChannelsView(evt_t event)
#define RECT_OFFSET 80
#define ROW_HEIGHT 21
#define BAR_HEIGHT 10
#define COLLUMN_SIZE 180
#define X_OFFSET 30
#define Y_OFFSET 75
bool menuChannels1(evt_t event);
bool menuChannels2(evt_t event);
const BitmapBuffer *locked_bmp = NULL;
const BitmapBuffer *inver_bmp = NULL;
const BitmapBuffer *outL_bmp = NULL;
const BitmapBuffer *outR_bmp = NULL;
const MenuHandlerFunc menuTabChannels[] PROGMEM = {
menuChannels1,
menuChannels2,
};
uint8_t lastChannelsPage = 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);
}
void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t Chan)
{
const int CHANNEL_MARGIN = 16;
const int CHANNEL_HEIGHT = 25;
const int CHANNEL_WIDTH = (LCD_W - 3*CHANNEL_MARGIN) / 2;
const int CHANNEL_PADDING_HORZ = 4;
const int CHANNEL_PADDING_VERT = 2;
const int BAR_WIDTH = CHANNEL_WIDTH-2*CHANNEL_PADDING_HORZ;
static int view = 0;
int x=CHANNEL_MARGIN, y=CHANNEL_MARGIN;
int viewMax = (getChannelsUsed() - 1) / 8;
if (viewMax <= 0 || view > viewMax) {
view = 0;
}
else {
switch (event) {
case EVT_KEY_FIRST(KEY_RIGHT):
if (++view > viewMax)
view = 0;
break;
case EVT_KEY_FIRST(KEY_LEFT):
if (--view < 0)
view = viewMax;
break;
}
}
int skipCount = view*8;
for (int ch=0, index=0; index<skipCount+8 && ch<NUM_CHNOUT; ++ch) {
if (isChannelUsed(ch)) {
if (++index > skipCount) {
// The black background
lcdDrawSolidFilledRect(x, y, CHANNEL_WIDTH, CHANNEL_HEIGHT, TEXT_BGCOLOR);
// The label
unsigned int lenLabel = ZLEN(g_model.limitData[ch].name);
if (lenLabel > 0)
lcdDrawSizedText(x+CHANNEL_PADDING_HORZ, y+CHANNEL_PADDING_VERT, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR);
else
putsChn(x+CHANNEL_PADDING_HORZ, y+CHANNEL_PADDING_VERT, ch+1, 0);
int32_t val = channelOutputs[ch];
// The bar
lcdDrawSolidFilledRect(x+CHANNEL_PADDING_HORZ, y+15, BAR_WIDTH, 6, TEXT_INVERTED_BGCOLOR);
unsigned int lim = g_model.extendedLimits ? 640*2 : 512*2;
unsigned int len = limit<unsigned int>(1, (abs(val) * BAR_WIDTH/2 + lim/2) / lim, BAR_WIDTH/2);
unsigned int x0 = (val>0) ? x+CHANNEL_PADDING_HORZ-1+BAR_WIDTH/2 : x+CHANNEL_PADDING_HORZ+BAR_WIDTH/2+1-len;
lcdDrawSolidFilledRect(x0, y+16, len, 4, TEXT_BGCOLOR);
y += CHANNEL_HEIGHT + CHANNEL_MARGIN;
if (y >= 4*(CHANNEL_HEIGHT + CHANNEL_MARGIN)) {
x += CHANNEL_WIDTH + CHANNEL_MARGIN;
y = CHANNEL_MARGIN;
}
}
}
}
#if 0
char chanString[] = "CH 32";
uint16_t limits = (g_model.extendedLimits ? 300 : 200);
int16_t chanVal = calcRESXto100(channelOutputs[Chan]);
LimitData *ld = limitAddress(Chan);
#if defined(CHANNELS_MONITOR_INV_HIDE)
//if channel output is inverted, show it with oposite sign
if (g_model.limitData[ch].revert) val = -val;
#endif
if (!locked_bmp) locked_bmp = BitmapBuffer::load(getThemePath("mask_monitor_lockch.png"));
if (!inver_bmp) inver_bmp = BitmapBuffer::load(getThemePath("mask_monitor_inver.png"));
if (!outL_bmp) outL_bmp = BitmapBuffer::load(getThemePath("mask_monitor_outL.png"));
if (!outR_bmp) outR_bmp = BitmapBuffer::load(getThemePath("mask_monitor_outR.png"));
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);
// Value
#if defined(PPM_UNIT_US)
uint8_t wbar = (longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE);
#elif defined(PPM_UNIT_PERCENT_PREC1)
uint8_t wbar = (longNames ? 48 : 58);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE);
#else
uint8_t wbar = (longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE); // G: Don't like the decimal part*
#endif
#endif
lcdColorTable[CUSTOM_COLOR_INDEX]= RGB(222, 222, 222);
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLLUMN_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);
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);
strAppendSigned(chanString, chanVal);
if (chanVal < -limits / 2) {
lcd->drawBitmap(x + X_OFFSET + COLLUMN_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);
} else if (chanVal > limits / 2){
lcd->drawBitmap(x + X_OFFSET + COLLUMN_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);
} else {
lcdDrawText(x + X_OFFSET + COLLUMN_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);
}
else if (posOnBar(chanVal) < posOnBar(calcRESXto100(ld->offset))) {
uint16_t endpoint = x + X_OFFSET + posOnBar(calcRESXto100(ld->offset));
uint16_t size = posOnBar(calcRESXto100(ld->offset)) - posOnBar(chanVal);
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
}
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);
}
bool menuChannelsMonitor(evt_t event, uint8_t page)
{
return true;
}
bool menuChannels1(evt_t event)
{
MENU("Channels monitor 1-16", MONITOR_ICONS, menuTabChannels, e_Channels1, 0, { 0 });
lastChannelsPage = e_Channels1;
int8_t Chan;
uint16_t x=0,y=0;
for(Chan=0, x=1, y=Y_OFFSET;Chan < 8; Chan++, y+=ROW_HEIGHT){
drawSingleOutputBar(x, y, Chan);
}
for(Chan=8, x=1 + LCD_W/2, y=Y_OFFSET; Chan < 16;Chan++, y+=ROW_HEIGHT){
drawSingleOutputBar(x, y, Chan);
}
return menuChannelsMonitor(event, 0);
}
bool menuChannels2(evt_t event)
{
MENU("Channels monitor 17-32", MONITOR_ICONS, menuTabChannels, e_Channels2, 0, { 0 });
lastChannelsPage = e_Channels2;
int8_t Chan;
uint16_t x,y;
for(Chan=16, x=1, y=Y_OFFSET; Chan < 24; Chan++, y+=ROW_HEIGHT){
drawSingleOutputBar(x, y, Chan);
}
for(Chan=24, x=1 + LCD_W/2, y=Y_OFFSET; Chan < 32; Chan++, y+=ROW_HEIGHT){
drawSingleOutputBar(x, y, Chan);
}
return menuChannelsMonitor(event, 1);
}
-1
View File
@@ -25,7 +25,6 @@
#define MENU_STATS_COLUMN2 (LCD_W/2)
#define MENU_STATS_COLUMN3 (LCD_W/2 + 120)
bool menuStatsGraph(evt_t event)
{
switch(event) {