diff --git a/radio/src/gui/128x64/radio_calibration.cpp b/radio/src/gui/128x64/radio_calibration.cpp index 5cf0159d8..a8004c7a2 100644 --- a/radio/src/gui/128x64/radio_calibration.cpp +++ b/radio/src/gui/128x64/radio_calibration.cpp @@ -23,14 +23,6 @@ #define XPOT_DELTA 10 #define XPOT_DELAY 10 /* cycles */ -enum CalibrationState { - CALIB_START = 0, - CALIB_SET_MIDPOINT, - CALIB_MOVE_STICKS, - CALIB_STORE, - CALIB_FINISHED -}; - void menuCommonCalib(event_t event) { for (uint8_t i=0; i(g_eeGeneral.switchConfig, 2*(x), 2)) #define SWITCH_EXISTS(x) (SWITCH_CONFIG(x) != SWITCH_NONE) #define IS_CONFIG_3POS(x) (SWITCH_CONFIG(x) == SWITCH_3POS) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index ccdf1ab7f..6d3fb20a4 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -235,41 +235,22 @@ void generalDefault() g_eeGeneral.version = EEPROM_VER; g_eeGeneral.variant = EEPROM_VARIANT; -#if !defined(PCBHORUS) +#if defined(PCBHORUS) + g_eeGeneral.blOffBright = 20; +#else g_eeGeneral.contrast = LCD_CONTRAST_DEFAULT; #endif -#if defined(PCBHORUS) - #if PCBREV >= 13 - g_eeGeneral.potsConfig = 0x1B; // S1 = pot, 6P = multipos, S2 = pot with detent - #else - g_eeGeneral.potsConfig = 0x19; // S1 = pot without detent, 6P = multipos, S2 = pot with detent - #endif - g_eeGeneral.slidersConfig = 0x0f; // 4 sliders - g_eeGeneral.blOffBright = 20; -#elif defined(PCBXLITE) - g_eeGeneral.potsConfig = 0x0F; // S1 and S2 = pot without detent -#elif defined(PCBX7) - g_eeGeneral.potsConfig = (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent -#elif defined(PCBX9LITE) - g_eeGeneral.potsConfig = (POT_WITH_DETENT << 0); // S1 = pot with detent -#elif defined(PCBTARANIS) - g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent - g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent +#if defined(DEFAULT_POTS_CONFIG) + g_eeGeneral.potsConfig = DEFAULT_POTS_CONFIG; #endif -#if defined(PCBXLITES) - g_eeGeneral.switchConfig = (SWITCH_TOGGLE << 10) + (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); -#elif defined(PCBXLITE) - g_eeGeneral.switchConfig = (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); -#elif defined(RADIO_X7) - g_eeGeneral.switchConfig = 0x000006ff; // 4x3POS, 1x2POS, 1xTOGGLE -#elif defined(RADIO_T12) - g_eeGeneral.switchConfig = (SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); -#elif defined(PCBX9LITE) - g_eeGeneral.switchConfig = (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); -#elif defined(PCBTARANIS) || defined(PCBHORUS) - g_eeGeneral.switchConfig = 0x00007bff; // 6x3POS, 1x2POS, 1xTOGGLE +#if defined(DEFAULT_SWITCH_CONFIG) + g_eeGeneral.switchConfig = DEFAULT_SWITCH_CONFIG; +#endif + +#if defined(DEFAULT_SLIDERS_CONFIG) + g_eeGeneral.slidersConfig = DEFAULT_SLIDERS_CONFIG; #endif // vBatWarn is voltage in 100mV, vBatMin is in 100mV but with -9V offset, vBatMax has a -12V offset @@ -311,7 +292,7 @@ void generalDefault() strcpy(g_eeGeneral.currModelFilename, DEFAULT_MODEL_FILENAME); #endif -#if defined(PCBHORUS) +#if defined(COLORLCD) strcpy(g_eeGeneral.themeName, theme->getName()); theme->init(); #endif @@ -1563,7 +1544,7 @@ void opentxClose(uint8_t shutdown) #endif #if defined(LUA) luaClose(&lsScripts); -#if defined(PCBHORUS) +#if defined(COLORLCD) luaClose(&lsWidgets); #endif #endif @@ -1614,7 +1595,8 @@ void opentxResume() sdMount(); storageReadAll(); -#if defined(PCBHORUS) + +#if defined(COLORLCD) loadTheme(); loadFontCache(); #endif @@ -1790,7 +1772,7 @@ void opentxInit() storageReadCurrentModel(); #endif -#if defined(PCBHORUS) +#if defined(COLORLCD) if (!unexpectedShutdown) { // g_model.topbarData is still zero here (because it was not yet read from SDCARD), // but we only remember the pointer to in in constructor. @@ -1861,7 +1843,7 @@ void opentxInit() btInit(); #endif -#if defined(PCBHORUS) +#if defined(COLORLCD) loadTheme(); loadFontCache(); #endif @@ -1919,11 +1901,10 @@ int main() boardInit(); -#if defined(PCBHORUS) +#if defined(COLORLCD) loadFonts(); #endif - #if defined(GUI) && !defined(PCBTARANIS) && !defined(PCBHORUS) // TODO remove this lcdInit(); diff --git a/radio/src/opentx_constants.h b/radio/src/opentx_constants.h new file mode 100644 index 000000000..7267d6d33 --- /dev/null +++ b/radio/src/opentx_constants.h @@ -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. + */ + +#ifndef _OPENTX_CONSTANTS_H_ +#define _OPENTX_CONSTANTS_H_ + +enum SwitchConfig { + SWITCH_NONE, + SWITCH_TOGGLE, + SWITCH_2POS, + SWITCH_3POS, +}; + +enum PotConfig { + POT_NONE, + POT_WITH_DETENT, + POT_MULTIPOS_SWITCH, + POT_WITHOUT_DETENT +}; + +enum SliderConfig { + SLIDER_NONE, + SLIDER_WITH_DETENT, +}; + +enum CalibrationState { + CALIB_START, + CALIB_SET_MIDPOINT, + CALIB_MOVE_STICKS, + CALIB_STORE, + CALIB_FINISHED +}; + +#endif // _OPENTX_CONSTANTS_H_ diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index b2116afb5..26e01fe54 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -22,6 +22,7 @@ #define _BOARD_HORUS_H_ #include "../definitions.h" +#include "../opentx_constants.h" #include "cpu_id.h" #if defined(__cplusplus) && !defined(SIMU) @@ -425,6 +426,10 @@ enum Analogs { #define POT_LAST (SLIDER_FIRST - 1) +#define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) +#define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 4) + (POT_MULTIPOS_SWITCH << 2) + (POT_WITHOUT_DETENT << 0) +#define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 3) + (SLIDER_WITH_DETENT << 2) + (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0) + enum CalibratedAnalogs { CALIBRATED_STICK1, CALIBRATED_STICK2, @@ -521,6 +526,7 @@ void ledBlue(void); #define LCD_DEPTH 16 void lcdInit(void); void lcdRefresh(void); +void lcdCopy(void * dest, void * src); void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color); void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h); void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h); diff --git a/radio/src/targets/sky9x/board.h b/radio/src/targets/sky9x/board.h index 2683e942b..9648b92e9 100644 --- a/radio/src/targets/sky9x/board.h +++ b/radio/src/targets/sky9x/board.h @@ -26,6 +26,7 @@ #include #include "board_lowlevel.h" #include "audio_driver.h" +#include "../opentx_constants.h" extern uint16_t ResetReason; diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index ef9f8a8a0..11cd6c90d 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -23,6 +23,7 @@ #include #include "../definitions.h" +#include "../opentx_constants.h" #include "cpu_id.h" #if defined(__cplusplus) && !defined(SIMU) @@ -448,28 +449,43 @@ enum EnumSwitchesPositions #if defined(PCBXLITES) #define NUM_SWITCHES 6 #define STORAGE_NUM_SWITCHES NUM_SWITCHES + #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 10) + (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) + #define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 2) + (POT_WITHOUT_DETENT << 0) #elif defined(PCBXLITE) #define NUM_SWITCHES 4 #define STORAGE_NUM_SWITCHES 6 + #define DEFAULT_SWITCH_CONFIG (SWITCH_2POS << 6) + (SWITCH_2POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); + #define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 2) + (POT_WITHOUT_DETENT << 0) #elif defined(PCBT12) #define NUM_SWITCHES 6 #define STORAGE_NUM_SWITCHES 8 + #define DEFAULT_SWITCH_CONFIG (SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) + #define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent #elif defined(PCBX7) #define NUM_SWITCHES 8 #define STORAGE_NUM_SWITCHES NUM_SWITCHES + #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 10) + (SWITCH_2POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) + #define DEFAULT_POTS_CONFIG (POT_WITHOUT_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent #elif defined(PCBX9LITE) #define NUM_SWITCHES 5 #define STORAGE_NUM_SWITCHES NUM_SWITCHES + #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 8) + (SWITCH_2POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0); + #define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0); // S1 = pot with detent #elif defined(PCBX9E) #define NUM_SWITCHES 18 // yes, it's perfect like that ! #define STORAGE_NUM_SWITCHES NUM_SWITCHES + #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) + #define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent + #define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0) #else #define NUM_SWITCHES 8 #define STORAGE_NUM_SWITCHES NUM_SWITCHES + #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) + #define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 0) + (POT_WITH_DETENT << 2); // S1 = pot without detent, S2 = pot with detent + #define DEFAULT_SLIDERS_CONFIG (SLIDER_WITH_DETENT << 1) + (SLIDER_WITH_DETENT << 0) #endif #define STORAGE_NUM_SWITCHES_POSITIONS (STORAGE_NUM_SWITCHES * 3) -#define NUM_SWITCHES_POSITIONS (NUM_SWITCHES * 3) void keysInit(void); uint8_t keyState(uint8_t index);