Cosmetics again ...
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
enum MenuModelHeliItems {
|
||||
ITEM_HELI_SWASHTYPE,
|
||||
ITEM_HELI_SWASHRING,
|
||||
ITEM_HELI_ELE,
|
||||
ITEM_HELI_ELE_WEIGHT,
|
||||
ITEM_HELI_AIL,
|
||||
ITEM_HELI_AIL_WEIGHT,
|
||||
ITEM_HELI_COL,
|
||||
ITEM_HELI_COL_WEIGHT,
|
||||
ITEM_HELI_MAX
|
||||
};
|
||||
|
||||
#define MODEL_HELI_2ND_COLUMN (230)
|
||||
|
||||
bool menuModelHeli(event_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUHELISETUP, MODEL_ICONS, menuTabModel, MENU_MODEL_HELI, ITEM_HELI_MAX);
|
||||
|
||||
uint8_t sub = menuVerticalPosition;
|
||||
|
||||
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
|
||||
coord_t y = MENU_CONTENT_TOP + i*FH;
|
||||
int k = i+menuVerticalOffset;
|
||||
LcdFlags blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
|
||||
LcdFlags attr = (sub == k ? blink : 0);
|
||||
|
||||
switch (k) {
|
||||
case ITEM_HELI_SWASHTYPE:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHTYPE);
|
||||
g_model.swashR.type = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_SWASHRING:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHRING);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.value, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_ELE:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ELEVATOR);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorSource, attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.elevatorSource, 0, MIXSRC_LAST_CH);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_ELE_WEIGHT:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.elevatorWeight, -100, 100);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_AIL:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_AILERON);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronSource, attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.aileronSource, 0, MIXSRC_LAST_CH);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_AIL_WEIGHT:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.aileronWeight, -100, 100);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_COL:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_COLLECTIVE);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveSource, attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_COL_WEIGHT:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
|
||||
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
|
||||
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -23,6 +23,44 @@
|
||||
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix)
|
||||
{
|
||||
char s[64];
|
||||
strAppendUnsigned(strAppend(strAppend(s, prefix), str), abs(idx));
|
||||
char * tmp = (prefix ? strAppend(s, prefix) : s);
|
||||
tmp = strAppend(tmp, str);
|
||||
tmp = strAppendUnsigned(tmp, abs(idx));
|
||||
lcdDrawText(x, y, s, flags);
|
||||
}
|
||||
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
|
||||
char unitStr[8];
|
||||
strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]);
|
||||
lcdDrawNumber(x, y, val, att, 0, NULL, unitStr);
|
||||
}
|
||||
else {
|
||||
lcdDrawNumber(x, y, val, att);
|
||||
}
|
||||
}
|
||||
|
||||
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event)
|
||||
{
|
||||
if (attr & INVERS) value = checkIncDec(event, value, min, max, (menuVerticalPositions[0] == 0) ? EE_MODEL : EE_GENERAL);
|
||||
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
|
||||
return value;
|
||||
}
|
||||
|
||||
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event )
|
||||
{
|
||||
value = editChoice(x, y, NULL, value, 0, 1, attr, event);
|
||||
drawCheckBox(x, y, value, attr);
|
||||
return value;
|
||||
}
|
||||
|
||||
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)
|
||||
{
|
||||
if (attr & INVERS) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
|
||||
drawSwitch(x, y, value, attr);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ void menuModelHeli(uint8_t event)
|
||||
|
||||
switch (k) {
|
||||
case ITEM_HELI_SWASHTYPE:
|
||||
g_model.swashR.type = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_SWASHTYPE, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event);
|
||||
g_model.swashR.type = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_SWASHTYPE, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_SWASHRING:
|
||||
@@ -111,20 +111,20 @@ void menuModelHeli(uint8_t event)
|
||||
break;
|
||||
#else
|
||||
case ITEM_HELI_COLLECTIVE:
|
||||
g_model.swashR.collectiveSource = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_COLLECTIVE, NULL, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH, attr, event);
|
||||
g_model.swashR.collectiveSource = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_COLLECTIVE, NULL, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH, attr, event);
|
||||
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveSource, attr);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_ELEDIRECTION:
|
||||
g_model.swashR.invertELE = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_ELEDIRECTION, STR_MMMINV, g_model.swashR.invertELE, 0, 1, attr, event);
|
||||
g_model.swashR.invertELE = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_ELEDIRECTION, STR_MMMINV, g_model.swashR.invertELE, 0, 1, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_AILDIRECTION:
|
||||
g_model.swashR.invertAIL = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_AILDIRECTION, STR_MMMINV, g_model.swashR.invertAIL, 0, 1, attr, event);
|
||||
g_model.swashR.invertAIL = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_AILDIRECTION, STR_MMMINV, g_model.swashR.invertAIL, 0, 1, attr, event);
|
||||
break;
|
||||
|
||||
case ITEM_HELI_COLDIRECTION:
|
||||
g_model.swashR.invertCOL = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_COLDIRECTION, STR_MMMINV, g_model.swashR.invertCOL, 0, 1, attr, event);
|
||||
g_model.swashR.invertCOL = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_COLDIRECTION, STR_MMMINV, g_model.swashR.invertCOL, 0, 1, attr, event);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user