[All] Code refactoring

- keys beep and haptic refactoring (not anymore audio events)
- trims move/mid/min/max refactoring (trim end splitted to trim min / trim max)
- S6R new alarms
- S6R servos/rx status displayed as a text (not an integer which has no sense)
- Timer countdown configuration
- The splash was not displayed (but the timeout was there) after the first calibration
This commit is contained in:
Bertrand Songis
2016-05-13 14:41:48 +02:00
parent 24abad55ca
commit 7908eaa406
82 changed files with 749 additions and 598 deletions
+52 -5
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -568,7 +568,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2
if (att & TIMEHOUR) {
div_t qr2 = div(qr.quot, 60);
lcdDrawNumber(x, y, qr2.quot, att|LEADING0|LEFT, 2);
lcdDrawChar(lcdLastPos, y, separator, att&att2);
lcdDrawChar(lcdLastPos, y, separator, att);
qr.quot = qr2.rem;
if (att & MIDSIZE)
x += 17;
@@ -646,7 +646,7 @@ void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
lcdDrawChar(x, y, '\307', att); //stick symbol
else if (idx < MIXSRC_FIRST_SLIDER-MIXSRC_Rud )
lcdDrawChar(x, y, '\310', att); //pot symbol
else
else
lcdDrawChar(x, y, '\311', att); //slider symbol
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, ZCHAR|att);
}
@@ -940,7 +940,9 @@ void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFl
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t value, LcdFlags att)
{
if (channel >= MAX_SENSORS) return; //Lua luaLcdDrawChannel() can call us with a bad value
if (channel >= MAX_SENSORS)
return; // Lua luaLcdDrawChannel() can call us with a bad value
TelemetryItem & telemetryItem = telemetryItems[channel];
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[channel];
if (telemetrySensor.unit == UNIT_DATETIME) {
@@ -949,6 +951,52 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t va
else if (telemetrySensor.unit == UNIT_GPS) {
displayGpsCoords(x, y, telemetryItem, att);
}
else if (telemetrySensor.unit == UNIT_BITFIELD) {
if (IS_FRSKY_SPORT_PROTOCOL()) {
if (telemetrySensor.id >= RBOX_STATE_FIRST_ID && telemetrySensor.id <= RBOX_STATE_LAST_ID) {
if (telemetrySensor.subId == 0) {
if (value == 0) {
lcdDrawText(att & LEFT ? x : x-15, att & DBLSIZE ? y+1 : y, "OK");
}
else {
for (uint8_t i=0; i<16; i++) {
if (value & (1 << i)) {
drawStringWithIndex(att & LEFT ? x : x-40, att & DBLSIZE ? y+1 : y, "CH", i+1);
lcdDrawText(lcdLastPos+3, att & DBLSIZE ? y+1 : y, "KO");
break;
}
}
}
}
else {
if (value == 0) {
lcdDrawText(x, att & DBLSIZE ? y+1 : y, "Rx OK");
}
else {
static const char * const RXS_STATUS[] = {
"Rx1 Ovl",
"Rx2 Ovl",
"SBUS Ovl",
"Rx1 FS",
"Rx1 LF",
"Rx2 FS",
"Rx2 LF",
"Rx1 Lost",
"Rx2 Lost",
"Rx1 NS",
"Rx2 NS",
};
for (uint8_t i=0; i<DIM(RXS_STATUS); i++) {
if (value & (1<<i)) {
lcdDrawText(att & LEFT ? x : x-40, att & DBLSIZE ? y+1 : y, RXS_STATUS[i]);
break;
}
}
}
}
}
}
}
else {
LcdFlags flags = att;
if (telemetrySensor.prec > 0) {
@@ -1139,4 +1187,3 @@ void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset, co
}
}
#endif
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -262,7 +262,7 @@ void menuGeneralSdManager(evt_t _event)
killEvents(_event);
POPUP_MENU_ADD_ITEM(STR_SD_INFO);
POPUP_MENU_ADD_ITEM(STR_SD_FORMAT);
popupMenuHandler = onSdManagerMenu;
POPUP_MENU_START(onSdManagerMenu);
}
break;
@@ -333,7 +333,7 @@ void menuGeneralSdManager(evt_t _event)
if (IS_FILE(line))
POPUP_MENU_ADD_ITEM(STR_DELETE_FILE);
}
popupMenuHandler = onSdManagerMenu;
POPUP_MENU_START(onSdManagerMenu);
}
break;
}
@@ -345,7 +345,7 @@ void menuGeneralSdManager(evt_t _event)
TCHAR lfn[_MAX_LFN + 1];
fno.lfname = lfn;
fno.lfsize = sizeof(lfn);
if (menuVerticalOffset == 0) {
reusableBuffer.sdmanager.offset = 0;
memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines));
+7 -1
View File
@@ -228,9 +228,11 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_BEEP_VOLUME:
SLIDER_5POS(y, g_eeGeneral.beepVolume, STR_BEEP_VOLUME, event, attr);
break;
case ITEM_SETUP_WAV_VOLUME:
SLIDER_5POS(y, g_eeGeneral.wavVolume, STR_WAV_VOLUME, event, attr);
break;
case ITEM_SETUP_BACKGROUND_VOLUME:
SLIDER_5POS(y, g_eeGeneral.backgroundVolume, STR_BG_VOLUME, event, attr);
break;
@@ -253,21 +255,25 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_VARIO_LABEL:
lcd_putsLeft(y, STR_VARIO);
break;
case ITEM_SETUP_VARIO_VOLUME:
SLIDER_5POS(y, g_eeGeneral.varioVolume, TR_SPEAKER_VOLUME, event, attr);
break;
case ITEM_SETUP_VARIO_PITCH:
lcd_putsLeft(y, STR_PITCH_AT_ZERO);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT);
lcdDrawText(lcdLastPos, y, "Hz", attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40);
break;
case ITEM_SETUP_VARIO_RANGE:
lcd_putsLeft(y, STR_PITCH_AT_MAX);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT);
lcdDrawText(lcdLastPos, y, "Hz", attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80);
break;
case ITEM_SETUP_VARIO_REPEAT:
lcd_putsLeft(y, STR_REPEAT_AT_ZERO);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT);
@@ -310,7 +316,7 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_BATTERY_WARNING:
lcd_putsLeft(y, STR_BATTERYWARNING);
putsVolts(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.vBatWarn, attr|LEFT);
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatWarn, 40, 120); //4-12V
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatWarn, 40, 120); // 4-12V
break;
case ITEM_SETUP_MEMORY_WARNING:
+2 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -191,7 +191,7 @@ void menuModelCurveOne(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_CURVE_PRESET);
POPUP_MENU_ADD_ITEM(STR_MIRROR);
POPUP_MENU_ADD_ITEM(STR_CLEAR);
popupMenuHandler = onCurveOneMenu;
POPUP_MENU_START(onCurveOneMenu);
}
break;
case EVT_KEY_LONG(KEY_MENU):
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -165,7 +165,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
break;
}
}
popupMenuHandler = onCustomFunctionsMenu;
POPUP_MENU_START(onCustomFunctionsMenu);
}
for (int i=0; i<NUM_BODY_LINES; i++) {
@@ -298,7 +298,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
}
if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) {
popupMenuHandler = onCustomFunctionsFileSelectionMenu;
POPUP_MENU_START(onCustomFunctionsFileSelectionMenu);
}
else {
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
@@ -386,7 +386,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
POPUP_MENU_ADD_ITEM(STR_GLOBALVAR);
if (CFN_GVAR_MODE(cfn) != FUNC_ADJUST_GVAR_INCDEC)
POPUP_MENU_ADD_ITEM(STR_INCDEC);
popupMenuHandler = onAdjustGvarSourceLongEnterPress;
POPUP_MENU_START(onAdjustGvarSourceLongEnterPress);
s_editMode = EDIT_MODIFY_FIELD;
}
}
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -72,7 +72,7 @@ void menuModelCustomScriptOne(uint8_t event)
if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) {
s_editMode = 0;
if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) {
popupMenuHandler = onModelCustomScriptMenu;
POPUP_MENU_START(onModelCustomScriptMenu);
}
else {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
+2 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -183,6 +183,6 @@ void menuModelGVars(uint8_t event)
killEvents(event);
POPUP_MENU_ADD_ITEM(STR_EDIT);
POPUP_MENU_ADD_ITEM(STR_CLEAR);
popupMenuHandler = onGVARSMenu;
POPUP_MENU_START(onGVARSMenu);
}
}
+2 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -433,7 +433,7 @@ void menuModelExposAll(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_COPY);
POPUP_MENU_ADD_ITEM(STR_MOVE);
POPUP_MENU_ADD_ITEM(STR_DELETE);
popupMenuHandler = onExposMenu;
POPUP_MENU_START(onExposMenu);
}
}
}
+2 -2
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -159,7 +159,7 @@ void menuModelLimits(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_RESET);
POPUP_MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS);
POPUP_MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS);
popupMenuHandler = onLimitsMenu;
POPUP_MENU_START(onLimitsMenu);
}
for (int j=0; j<ITEM_LIMITS_COUNT; j++) {
@@ -95,7 +95,7 @@ void menuModelLogicalSwitches(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_PASTE);
if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw)
POPUP_MENU_ADD_ITEM(STR_CLEAR);
popupMenuHandler = onLogicalSwitchesMenu;
POPUP_MENU_START(onLogicalSwitchesMenu);
}
for (int i=0; i<NUM_BODY_LINES; ++i) {
+3 -3
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -222,7 +222,7 @@ void menuModelMixOne(uint8_t event)
else
y = 1 + (k+1)*FH;
int8_t i = k;
#if MENU_COLUMNS < 2
i = i + menuVerticalOffset;
#endif
@@ -457,7 +457,7 @@ void menuModelMixAll(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_COPY);
POPUP_MENU_ADD_ITEM(STR_MOVE);
POPUP_MENU_ADD_ITEM(STR_DELETE);
popupMenuHandler = onMixesMenu;
POPUP_MENU_START(onMixesMenu);
}
}
}
+3 -3
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "opentx.h"
#define MODELSIZE_POS_X 170
#define MODELSEL_W 133
@@ -178,7 +178,7 @@ void menuModelSelect(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_COPY_MODEL);
POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
}
popupMenuHandler = onModelSelectMenu;
POPUP_MENU_START(onModelSelectMenu);
}
else if (eeModelExists(sub)) {
s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE);
+49 -26
View File
@@ -94,6 +94,7 @@ enum menuModelSetupItems {
#define FIELD_PROTOCOL_MAX 1
#define MODEL_SETUP_2ND_COLUMN (LCD_W-17*FW-MENUS_SCROLLBAR_WIDTH-1)
#define MODEL_SETUP_3RD_COLUMN (MODEL_SETUP_2ND_COLUMN+6*FW)
#define MODEL_SETUP_BIND_OFS 3*FW-2
#define MODEL_SETUP_RANGE_OFS 7*FW
#define MODEL_SETUP_SET_FAILSAFE_OFS 10*FW-2
@@ -123,27 +124,27 @@ void onModelSetupBitmapMenu(const char *result)
void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
{
TimerData * timer = &g_model.timers[timerIdx];
TimerData & timer = g_model.timers[timerIdx];
drawStringWithIndex(0*FW, y, STR_TIMER, timerIdx+1);
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, menuHorizontalPosition==0 ? attr : 0);
putsTimer(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, menuHorizontalPosition==1 ? attr|TIMEHOUR : TIMEHOUR, menuHorizontalPosition==2 ? attr|TIMEHOUR : TIMEHOUR);
if (attr && menuHorizontalPosition < 0) lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, 11*FW, FH+1);
putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer.mode, menuHorizontalPosition==0 ? attr : 0);
putsTimer(MODEL_SETUP_3RD_COLUMN+5*FWNUM+2, y, timer.start, menuHorizontalPosition==1 ? attr|TIMEHOUR : TIMEHOUR, menuHorizontalPosition==2 ? attr|TIMEHOUR : TIMEHOUR);
if (attr && menuHorizontalPosition < 0) lcdDrawFilledRect(MODEL_SETUP_2ND_COLUMN-1, y-1, 13*FW-3, FH+1);
if (attr && s_editMode>0) {
div_t qr = div(timer->start, 60);
div_t qr = div(timer.start, 60);
switch (menuHorizontalPosition) {
case 0:
{
swsrc_t timerMode = timer->mode;
swsrc_t timerMode = timer.mode;
if (timerMode < 0) timerMode -= TMRMODE_COUNT-1;
CHECK_INCDEC_MODELVAR_CHECK(event, timerMode, -TMRMODE_COUNT-SWSRC_LAST+1, TMRMODE_COUNT+SWSRC_LAST-1, isSwitchAvailableInTimers);
if (timerMode < 0) timerMode += TMRMODE_COUNT-1;
timer->mode = timerMode;
timer.mode = timerMode;
#if defined(AUTOSWITCH)
if (s_editMode>0) {
swsrc_t val = timer->mode - (TMRMODE_COUNT-1);
swsrc_t val = timer.mode - (TMRMODE_COUNT-1);
swsrc_t switchVal = checkIncDecMovedSwitch(val);
if (val != switchVal) {
timer->mode = switchVal + (TMRMODE_COUNT-1);
timer.mode = switchVal + (TMRMODE_COUNT-1);
storageDirty(EE_MODEL);
}
}
@@ -152,13 +153,34 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
}
case 1:
qr.quot = checkIncDec(event, qr.quot, 0, 1439, EE_MODEL | NO_INCDEC_MARKS); // 23h59
timer->start = qr.rem + qr.quot*60;
timer.start = qr.rem + qr.quot*60;
break;
case 2:
qr.rem -= checkIncDecModel(event, qr.rem+2, 1, 62)-2;
timer->start -= qr.rem ;
if ((int16_t)timer->start < 0) timer->start=0;
if ((int32_t)timer->start > 86399) timer->start=86399; // 23h59:59
timer.start -= qr.rem ;
if ((int16_t)timer.start < 0) timer.start=0;
if ((int32_t)timer.start > 86399) timer.start=86399; // 23h59:59
break;
}
}
}
void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, uint8_t event)
{
TimerData & timer = g_model.timers[timerIdx];
lcd_putsLeft(y, STR_BEEPCOUNTDOWN);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, timer.countdownBeep, (menuHorizontalPosition==0 ? attr : 0));
if (timer.countdownBeep != COUNTDOWN_SILENT) {
lcdDrawNumber(MODEL_SETUP_3RD_COLUMN, y, TIMER_COUNTDOWN_START(timerIdx), (menuHorizontalPosition == 1 ? attr : 0) | LEFT);
lcdDrawChar(lcdLastPos, y, 's');
}
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
CHECK_INCDEC_MODELVAR(event, timer.countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT - 1);
break;
case 1:
timer.countdownStart = -checkIncDecModel(event, -timer.countdownStart, -1, +2);
break;
}
}
@@ -202,7 +224,7 @@ int getSwitchWarningsCount()
#define MULTIMODULE_FAILSAFEROWS(x) HIDDEN_ROW
#endif
#define FAILSAFE_ROWS(x) (IS_MODULE_XJT(x) && HAS_RF_PROTOCOL_FAILSAFE(g_model.moduleData[x].rfProtocol) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : MULTIMODULE_FAILSAFEROWS(x))
#define TIMER_ROWS 2|NAVIGATION_LINE_BY_LINE, 0, CASE_PERSISTENT_TIMERS(0) 0, 0
#define TIMER_ROWS(x) 2|NAVIGATION_LINE_BY_LINE, 0, 0, 0, g_model.timers[x].countdownBeep != COUNTDOWN_SILENT ? (uint8_t)1 : (uint8_t)0
#if defined(MULTIMODULE)
#define MULTIMODULE_HAS_SUBTYPE(x) (x == MM_RF_PROTO_FLYSKY || x == MM_RF_PROTO_FRSKY || x == MM_RF_PROTO_HISKY || x == MM_RF_PROTO_DSM2 || x == MM_RF_PROTO_YD717 || x == MM_RF_PROTO_KN || x == MM_RF_PROTO_SYMAX || x == MM_RF_PROTO_CX10 || x == MM_RF_PROTO_CG023 || x == MM_RF_PROTO_MT99XX || x == MM_RF_PROTO_MJXQ)
@@ -215,11 +237,11 @@ int getSwitchWarningsCount()
#define EXTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : IS_MODULE_MULTIMODULE(EXTERNAL_MODULE) ? MULTIMODULE_MODE_ROWS(EXTERNAL_MODULE) : (uint8_t)0
#if TIMERS == 1
#define TIMERS_ROWS TIMER_ROWS
#define TIMERS_ROWS TIMER_ROWS(0)
#elif TIMERS == 2
#define TIMERS_ROWS TIMER_ROWS, TIMER_ROWS
#define TIMERS_ROWS TIMER_ROWS(0), TIMER_ROWS(1)
#elif TIMERS == 3
#define TIMERS_ROWS TIMER_ROWS, TIMER_ROWS, TIMER_ROWS
#define TIMERS_ROWS TIMER_ROWS(0), TIMER_ROWS(1), TIMER_ROWS(2)
#endif
#if defined(REV9E)
#define SW_WARN_ITEMS() uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW), uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW)
@@ -303,7 +325,7 @@ void menuModelSetup(uint8_t event)
if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) {
s_editMode = 0;
if (sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), g_model.header.bitmap, LIST_NONE_SD_FILE)) {
popupMenuHandler = onModelSetupBitmapMenu;
POPUP_MENU_START(onModelSetupBitmapMenu);
}
else {
POPUP_WARNING(STR_NO_BITMAPS_ON_SD);
@@ -324,7 +346,7 @@ void menuModelSetup(uint8_t event)
break;
case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP:
g_model.timers[0].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[0].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event);
editTimerCountdown(0, y, attr, event);
break;
case ITEM_MODEL_TIMER1_PERSISTENT:
@@ -345,7 +367,7 @@ void menuModelSetup(uint8_t event)
break;
case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP:
g_model.timers[1].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[1].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event);
editTimerCountdown(1, y, attr, event);
break;
case ITEM_MODEL_TIMER2_PERSISTENT:
@@ -367,7 +389,7 @@ void menuModelSetup(uint8_t event)
break;
case ITEM_MODEL_TIMER3_COUNTDOWN_BEEP:
g_model.timers[2].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_BEEPCOUNTDOWN, STR_VBEEPCOUNTDOWN, g_model.timers[2].countdownBeep, COUNTDOWN_SILENT, COUNTDOWN_COUNT-1, attr, event);
editTimerCountdown(2, y, attr, event);
break;
case ITEM_MODEL_TIMER3_PERSISTENT:
@@ -635,7 +657,7 @@ void menuModelSetup(uint8_t event)
lcd_putsLeft(y, STR_MODE);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[INTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (IS_MODULE_XJT(INTERNAL_MODULE))
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[INTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(MODEL_SETUP_3RD_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[INTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
if (attr && s_editMode>0) {
switch (menuHorizontalPosition) {
case 0:
@@ -683,13 +705,13 @@ void menuModelSetup(uint8_t event)
lcd_putsLeft(y, STR_MODE);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (IS_MODULE_XJT(EXTERNAL_MODULE))
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(MODEL_SETUP_3RD_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (IS_MODULE_DSM2(EXTERNAL_MODULE))
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(MODEL_SETUP_3RD_COLUMN, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
#if defined(MULTIMODULE)
else if (IS_MODULE_MULTIMODULE(EXTERNAL_MODULE)) {
int8_t multi_rfProto = min(g_model.moduleData[EXTERNAL_MODULE].multi.rfProtocol, (uint8_t) MM_RF_PROTO_CUSTOM);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_MULTI_PROTOCOLS, multi_rfProto, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(MODEL_SETUP_3RD_COLUMN, y, STR_MULTI_PROTOCOLS, multi_rfProto, menuHorizontalPosition==1 ? attr : 0);
switch(multi_rfProto) {
case MM_RF_PROTO_FLYSKY:
@@ -955,8 +977,9 @@ void menuModelSetup(uint8_t event)
}
if (g_model.moduleData[moduleIdx].multi.rfProtocol != MM_RF_PROTO_DSM2) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.moduleData[moduleIdx].multi.optionValue, LEFT | attr);
if (attr)
if (attr) {
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[moduleIdx].multi.optionValue, -128, 127);
}
}
}
#endif
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -373,7 +373,7 @@ void menuModelSensor(uint8_t event)
case SENSOR_FIELD_FILTER:
ON_OFF_MENU_ITEM(sensor->filter, SENSOR_2ND_COLUMN, y, STR_FILTER, attr, event);
break;
case SENSOR_FIELD_PERSISTENT:
ON_OFF_MENU_ITEM(sensor->persistent, SENSOR_2ND_COLUMN, y, NO_INDENT(STR_PERSISTENT), attr, event);
if (checkIncDec_Ret && !sensor->persistent) {
@@ -410,7 +410,7 @@ void onSensorMenu(const char *result)
}
else if (result == STR_COPY) {
int newIndex = availableTelemetryIndex();
if (newIndex >= 0) {
TelemetrySensor & sourceSensor = g_model.telemetrySensors[index];
TelemetrySensor & newSensor = g_model.telemetrySensors[newIndex];
@@ -419,7 +419,7 @@ void onSensorMenu(const char *result)
TelemetryItem & newItem = telemetryItems[newIndex];
newItem = sourceItem;
storageDirty(EE_MODEL);
}
}
else {
POPUP_WARNING(STR_TELEMETRYFULL);
}
@@ -454,7 +454,7 @@ void menuModelTelemetry(uint8_t event)
delTelemetryIndex(i);
}
}
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS LABEL(TopBar), 0, 0, TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), TELEMETRY_SCREEN_ROWS(2), TELEMETRY_SCREEN_ROWS(3) });
for (int i=0; i<NUM_BODY_LINES; i++) {
@@ -499,7 +499,7 @@ void menuModelTelemetry(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_EDIT);
POPUP_MENU_ADD_ITEM(STR_COPY);
POPUP_MENU_ADD_ITEM(STR_DELETE);
popupMenuHandler = onSensorMenu;
POPUP_MENU_START(onSensorMenu);
}
else if (event == EVT_KEY_BREAK(KEY_ENTER)) {
pushMenu(menuModelSensor);
@@ -552,7 +552,7 @@ void menuModelTelemetry(uint8_t event)
killEvents(KEY_ENTER);
POPUP_CONFIRMATION(STR_CONFIRMDELETE);
}
break;
break;
case ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE:
ON_OFF_MENU_ITEM(g_model.ignoreSensorIds, TELEM_COL2, y, STR_IGNORE_INSTANCE, attr, event);
@@ -670,7 +670,7 @@ void menuModelTelemetry(uint8_t event)
if (menuHorizontalPosition==1 && attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) {
s_editMode = 0;
if (sdListFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), g_model.frsky.screens[screenIndex].script.file)) {
popupMenuHandler = onTelemetryScriptFileSelectionMenu;
POPUP_MENU_START(onTelemetryScriptFileSelectionMenu);
}
else {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
+4 -1
View File
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "opentx.h"
MenuHandlerFunc menuHandlers[5];
uint8_t menuEvent = 0;
@@ -30,6 +30,7 @@ void popMenu()
assert(menuLevel>0);
menuLevel = menuLevel-1;
menuEvent = EVT_ENTRY_UP;
AUDIO_KEY_PRESS();
TRACE("popMenu(%d)", menuLevel);
}
@@ -37,6 +38,7 @@ void chainMenu(MenuHandlerFunc newMenu)
{
menuHandlers[menuLevel] = newMenu;
menuEvent = EVT_ENTRY;
AUDIO_KEY_PRESS();
TRACE("chainMenu(%d, %p)", menuLevel, newMenu);
}
@@ -60,6 +62,7 @@ void pushMenu(MenuHandlerFunc newMenu)
menuHandlers[menuLevel] = newMenu;
menuEvent = EVT_ENTRY;
AUDIO_KEY_PRESS();
TRACE("pushMenu(%d, %p)", menuLevel, newMenu);
}
+1
View File
@@ -408,6 +408,7 @@ extern uint8_t warningInfoFlags;
#define NAVIGATION_MENUS
#define POPUP_MENU_ADD_ITEM(s) do { popupMenuOffsetType = MENU_OFFSET_INTERNAL; if (popupMenuNoItems < POPUP_MENU_MAX_LINES) popupMenuItems[popupMenuNoItems++] = s; } while (0)
#define POPUP_MENU_START(func) do { popupMenuHandler = (func); AUDIO_KEY_PRESS(); } while(0)
#define POPUP_MENU_MAX_LINES 12
#define MENU_MAX_DISPLAY_LINES 6
#define POPUP_MENU_ADD_SD_ITEM(s) POPUP_MENU_ADD_ITEM(s)
+23 -29
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "opentx.h"
vertpos_t menuVerticalOffset;
vertpos_t menuVerticalPosition;
@@ -89,7 +89,7 @@ void onSourceLongEnterPress(const char * result)
break;
}
}
}
}
}
void onSwitchLongEnterPress(const char *result)
@@ -166,14 +166,10 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
newval++;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max);
if (newval > i_max) {
newval = val;
killEvents(event);
AUDIO_WARNING2();
}
else {
AUDIO_KEYPAD_UP();
AUDIO_KEY_ERROR();
}
}
else if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_MINUS) || event==EVT_KEY_REPT(KEY_MINUS))) {
@@ -185,14 +181,10 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
newval--;
}
} while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min);
if (newval < i_min) {
newval = val;
killEvents(event);
AUDIO_WARNING2();
}
else {
AUDIO_KEYPAD_DOWN();
AUDIO_KEY_ERROR();
}
}
@@ -226,35 +218,28 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
}
#endif
if (newval > i_max || newval < i_min) {
newval = (newval > i_max ? i_max : i_min);
killEvents(event);
AUDIO_WARNING2();
}
if (newval != val) {
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval+1) : !stops.contains(newval-1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
if (newval>val) // without AUDIO it's optimized, because the 2 sounds are the same
AUDIO_KEYPAD_UP();
else
AUDIO_KEYPAD_DOWN();
}
}
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
}
else {
checkIncDec_Ret = 0;
}
if (i_flags & INCDEC_SOURCE) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
checkIncDecSelection = MIXSRC_NONE;
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
@@ -280,7 +265,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable(MIXSRC_FIRST_GVAR)) {
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
}
if (i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
for (int i = 0; i < MAX_SENSORS; i++) {
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
@@ -290,7 +275,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
}
}
}
popupMenuHandler = onSourceLongEnterPress;
POPUP_MENU_START(onSourceLongEnterPress);
}
if (checkIncDecSelection != 0) {
newval = checkIncDecSelection;
@@ -315,7 +300,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int
}
if (isValueAvailable && isValueAvailable(SWSRC_ON)) POPUP_MENU_ADD_ITEM(STR_MENU_OTHER);
if (isValueAvailable && isValueAvailable(-newval)) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
popupMenuHandler = onSwitchLongEnterPress;
POPUP_MENU_START(onSwitchLongEnterPress);
s_editMode = EDIT_MODIFY_FIELD;
}
if (checkIncDecSelection != 0) {
@@ -365,7 +350,7 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
if (modelHasNotes()) {
POPUP_MENU_ADD_SD_ITEM(STR_VIEW_CHANNELS);
POPUP_MENU_ADD_ITEM(STR_VIEW_NOTES);
popupMenuHandler = onLongMenuPress;
POPUP_MENU_START(onLongMenuPress);
}
else {
pushMenu(menuChannelsView);
@@ -423,9 +408,11 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
if (s_editMode > 1) break;
if (menuHorizontalPosition < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) {
l_posHorz = 0;
AUDIO_KEY_PRESS();
}
else if (READ_ONLY_UNLOCKED()) {
s_editMode = (s_editMode<=0);
AUDIO_KEY_PRESS();
}
break;
@@ -437,11 +424,13 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
case EVT_KEY_BREAK(KEY_EXIT):
if (s_editMode > 0) {
s_editMode = 0;
AUDIO_KEY_PRESS();
break;
}
if (l_posHorz >= 0 && (COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
l_posHorz = -1;
AUDIO_KEY_PRESS();
}
else {
uint8_t posVertInit = MENU_FIRST_LINE_EDIT;
@@ -449,6 +438,7 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
menuVerticalOffset = 0;
l_posVert = posVertInit;
l_posHorz = POS_HORZ_INIT(l_posVert);
AUDIO_KEY_PRESS();
}
else {
popMenu();
@@ -457,6 +447,8 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
break;
case EVT_KEY_FIRST(KEY_RIGHT):
AUDIO_KEY_PRESS();
// no break
case EVT_KEY_REPT(KEY_RIGHT):
if (s_editMode != 0) break;
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
@@ -485,6 +477,8 @@ void check(const char * name, check_event_t event, uint8_t curr, const MenuHandl
break;
case EVT_KEY_FIRST(KEY_LEFT):
AUDIO_KEY_PRESS();
// no break
case EVT_KEY_REPT(KEY_LEFT):
if (s_editMode != 0) break;
if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) {
+4 -4
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -19,7 +19,6 @@
*/
#include "opentx.h"
#include "timers.h"
#define BIGSIZE MIDSIZE
#define LBOX_CENTERX (BOX_WIDTH/2 + 16)
@@ -460,7 +459,7 @@ void menuMainView(uint8_t event)
POPUP_MENU_ADD_ITEM(STR_RESET_SUBMENU);
POPUP_MENU_ADD_ITEM(STR_STATISTICS);
POPUP_MENU_ADD_ITEM(STR_ABOUT_US);
popupMenuHandler = onMainViewMenu;
POPUP_MENU_START(onMainViewMenu);
break;
#if MENUS_LOCK != 2/*no menus*/
@@ -481,12 +480,14 @@ void menuMainView(uint8_t event)
g_eeGeneral.view = 0;
chainMenu(menuMainViewChannelsMonitor);
}
AUDIO_KEY_PRESS();
break;
case EVT_KEY_LONG(KEY_PAGE):
if (!IS_FAI_ENABLED())
chainMenu(menuTelemetryFrsky);
killEvents(event);
AUDIO_KEY_PRESS();
break;
case EVT_KEY_FIRST(KEY_EXIT):
@@ -495,7 +496,6 @@ void menuMainView(uint8_t event)
gvarDisplayTimer = 0;
}
#endif
AUDIO_KEYPAD_UP();
break;
}
+1 -4
View File
@@ -18,8 +18,7 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "../../timers.h"
#include "opentx.h"
#define STATS_1ST_COLUMN FW/2
#define STATS_2ND_COLUMN 12*FW+FW/2
@@ -118,7 +117,6 @@ void menuStatisticsDebug(uint8_t event)
storageDirty(EE_GENERAL);
sessionTimer = 0;
killEvents(event);
AUDIO_KEYPAD_UP();
break;
case EVT_KEY_FIRST(KEY_ENTER):
#if defined(LUA)
@@ -126,7 +124,6 @@ void menuStatisticsDebug(uint8_t event)
maxLuaDuration = 0;
#endif
maxMixerDuration = 0;
AUDIO_KEYPAD_UP();
break;
#if defined(DEBUG_TRACE_BUFFER)
+4 -4
View File
@@ -2,7 +2,7 @@
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "../../opentx.h"
#include "opentx.h"
#define STATUS_BAR_Y (7*FH+1)
#define TELEM_2ND_COLUMN (11*FW)
@@ -135,7 +135,7 @@ bool displayNumbersTelemetryScreen(FrSkyScreenData & screen)
else {
putsMixerSource(pos[j], 1+FH+2*FH*i, field, 0);
}
if (field >= MIXSRC_FIRST_TELEM) {
TelemetryItem & telemetryItem = telemetryItems[(field-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index
if (!telemetryItem.isAvailable()) {
@@ -237,7 +237,7 @@ void menuTelemetryFrsky(uint8_t event)
killEvents(event);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
popupMenuHandler = onMainViewMenu;
POPUP_MENU_START(onMainViewMenu);
break;
}