diff --git a/radio/src/gui/128x64/gui.h b/radio/src/gui/128x64/gui.h index 38e149530..5e7a24552 100644 --- a/radio/src/gui/128x64/gui.h +++ b/radio/src/gui/128x64/gui.h @@ -150,8 +150,6 @@ int checkIncDec(event_t event, int val, int i_min, int i_max, unsigned int i_fla int16_t checkIncDec(event_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags=0); #endif -int8_t checkIncDecMovedSwitch(int8_t val); - #if defined(CPUM64) int8_t checkIncDecModel(event_t event, int8_t i_val, int8_t i_min, int8_t i_max); int8_t checkIncDecModelZero(event_t event, int8_t i_val, int8_t i_max); diff --git a/radio/src/gui/128x64/navigation.cpp b/radio/src/gui/128x64/navigation.cpp index ea40a7504..1a50b2958 100644 --- a/radio/src/gui/128x64/navigation.cpp +++ b/radio/src/gui/128x64/navigation.cpp @@ -35,22 +35,6 @@ int16_t p1valdiff; int8_t p2valdiff; #endif -#if defined(AUTOSWITCH) -int8_t checkIncDecMovedSwitch(int8_t val) -{ - if (s_editMode>0) { - int8_t swtch = getMovedSwitch(); - if (swtch) { - if (IS_CONFIG_TOGGLE(swtch) && swtch==val) - val = -val; - else - val = swtch; - } - } - return val; -} -#endif - int8_t checkIncDec_Ret; #if defined(PCBX7) diff --git a/radio/src/gui/212x64/navigation.cpp b/radio/src/gui/212x64/navigation.cpp index 7863199ae..e041486da 100644 --- a/radio/src/gui/212x64/navigation.cpp +++ b/radio/src/gui/212x64/navigation.cpp @@ -27,28 +27,6 @@ int8_t s_editMode; uint8_t noHighlightCounter; uint8_t menuCalibrationState; int checkIncDecSelection = 0; - -#if defined(AUTOSWITCH) -swsrc_t checkIncDecMovedSwitch(swsrc_t val) -{ - if (s_editMode > 0) { - swsrc_t swtch = getMovedSwitch(); - if (swtch) { - div_t info = switchInfo(swtch); - if (IS_CONFIG_TOGGLE(info.quot)) { - if (info.rem != 0) { - val = (val == swtch ? swtch-2 : swtch); - } - } - else { - val = swtch; - } - } - } - return val; -} -#endif - int8_t checkIncDec_Ret; INIT_STOPS(stops100, 3, -100, 0, 100) diff --git a/radio/src/gui/CMakeLists.txt b/radio/src/gui/CMakeLists.txt index c1fd3dcf4..f1a9e90d3 100644 --- a/radio/src/gui/CMakeLists.txt +++ b/radio/src/gui/CMakeLists.txt @@ -26,6 +26,7 @@ set(GUI_SRC set(SRC ${SRC} gui/common/widgets.cpp + gui/common/navigation.cpp ) include_directories(gui gui/${GUI_DIR}) diff --git a/radio/src/gui/common/navigation.cpp b/radio/src/gui/common/navigation.cpp new file mode 100644 index 000000000..72aa2e1aa --- /dev/null +++ b/radio/src/gui/common/navigation.cpp @@ -0,0 +1,51 @@ +/* + * 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" + +#if defined(AUTOSWITCH) +swsrc_t checkIncDecMovedSwitch(swsrc_t val) +{ + if (s_editMode>0) { + swsrc_t swtch = getMovedSwitch(); + if (swtch) { +#if defined(PCBTARANIS) || defined(PCBHORUS) + div_t info = switchInfo(swtch); + if (IS_CONFIG_TOGGLE(info.quot)) { + if (info.rem != 0) { + val = (val == swtch ? swtch-2 : swtch); + } + } + else { + val = swtch; + } +#else + if (IS_CONFIG_TOGGLE(swtch) && swtch==val) { + val = -val; + } + else { + val = swtch; + } +#endif + } + } + return val; +} +#endif \ No newline at end of file diff --git a/radio/src/gui/gui_common.h b/radio/src/gui/gui_common.h index 0c368193b..a673f9cdf 100644 --- a/radio/src/gui/gui_common.h +++ b/radio/src/gui/gui_common.h @@ -86,6 +86,8 @@ bool isSwitchWarningStateAvailable(int state); void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0); #endif +swsrc_t checkIncDecMovedSwitch(swsrc_t val); + #if defined(CPUARM) #include "telemetry/telemetry_sensors.h" void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags flags);