From faa6cd7a3c9edf13e0c5349f701bd2633e9d6ff2 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 13:18:17 +0200 Subject: [PATCH 01/26] Haptic support --- radio/src/Makefile | 6 ++ radio/src/haptic.cpp | 8 +-- radio/src/opentx.h | 15 ----- radio/src/targets/gruvin9x/board_gruvin9x.h | 3 +- radio/src/targets/mega2560/board_mega2560.h | 2 + radio/src/targets/sky9x/board_sky9x.h | 3 +- radio/src/targets/stock/board_stock.h | 4 ++ radio/src/targets/taranis/board_taranis.cpp | 8 +++ radio/src/targets/taranis/board_taranis.h | 7 ++ radio/src/targets/taranis/hal.h | 11 ++++ radio/src/targets/taranis/haptic_driver.cpp | 71 +++++++++++++++++++++ 11 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 radio/src/targets/taranis/haptic_driver.cpp diff --git a/radio/src/Makefile b/radio/src/Makefile index 110f03c04..ef34d18b1 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -703,6 +703,12 @@ ifeq ($(PCB), TARANIS) CPPSRC += targets/taranis/a7105_driver.cpp endif + ifeq ($(HAPTIC), YES) + CPPDEFS += -DHAPTIC + CPPSRC += haptic.cpp + CPPSRC += targets/taranis/haptic_driver.cpp + endif + endif CC = $(TRGT)gcc diff --git a/radio/src/haptic.cpp b/radio/src/haptic.cpp index ff97d6f21..158d8ca57 100644 --- a/radio/src/haptic.cpp +++ b/radio/src/haptic.cpp @@ -54,20 +54,20 @@ void hapticQueue::heartbeat() #else if (buzzTimeLeft > 0) { buzzTimeLeft--; // time gets counted down -#if defined(PCBSKY9X) +#if defined(PCBSXY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) hapticOn(g_eeGeneral.hapticStrength * 20); #else if (hapticTick-- > 0) { - HAPTIC_ON; // haptic output 'high' + HAPTIC_ON; } else { - HAPTIC_OFF; // haptic output 'high' + HAPTIC_OFF; hapticTick = g_eeGeneral.hapticStrength; } #endif } else { - HAPTIC_OFF; // haptic output 'high' + HAPTIC_OFF; if (buzzPause > 0) { buzzPause--; } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 5c607aea9..1ddafc247 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -904,21 +904,6 @@ enum Analogs { #define BUZZER_ON PORTE |= (1 << OUT_E_BUZZER) #define BUZZER_OFF PORTE &= ~(1 << OUT_E_BUZZER) -#if defined(HAPTIC) - #if defined(PCBSKY9X) - #define HAPTIC_OFF hapticOff() - #elif defined(PCBGRUVIN9X) - #define HAPTIC_ON PORTD &= ~(1 << OUT_D_HAPTIC) - #define HAPTIC_OFF PORTD |= (1 << OUT_D_HAPTIC) - #else - #define HAPTIC_ON PORTG |= (1 << OUT_G_HAPTIC) - #define HAPTIC_OFF PORTG &= ~(1 << OUT_G_HAPTIC) - #endif -#else - #define HAPTIC_ON - #define HAPTIC_OFF -#endif - #define BITMASK(bit) (1<<(bit)) /// liefert Dimension eines Arrays diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.h b/radio/src/targets/gruvin9x/board_gruvin9x.h index 2d10ea8f8..a38cecff1 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.h +++ b/radio/src/targets/gruvin9x/board_gruvin9x.h @@ -185,7 +185,8 @@ void pwrOff(); #define usbPlugged() false // Haptic driver -#define hapticOff() // TODO hapticOn() cleaner ... +#define HAPTIC_ON PORTD &= ~(1 << OUT_D_HAPTIC) +#define HAPTIC_OFF PORTD |= (1 << OUT_D_HAPTIC) // Rotary encoder driver #if ROTARY_ENCODERS <= 2 diff --git a/radio/src/targets/mega2560/board_mega2560.h b/radio/src/targets/mega2560/board_mega2560.h index 5943e87c4..42bb029f8 100644 --- a/radio/src/targets/mega2560/board_mega2560.h +++ b/radio/src/targets/mega2560/board_mega2560.h @@ -189,5 +189,7 @@ void pwrOff(); // Haptic driver #define hapticOff() // TODO hapticOn() cleaner ... +#define HAPTIC_ON PORTD &= ~(1 << OUT_D_HAPTIC) +#define HAPTIC_OFF PORTD |= (1 << OUT_D_HAPTIC) #endif diff --git a/radio/src/targets/sky9x/board_sky9x.h b/radio/src/targets/sky9x/board_sky9x.h index 45f45e936..237435f9b 100644 --- a/radio/src/targets/sky9x/board_sky9x.h +++ b/radio/src/targets/sky9x/board_sky9x.h @@ -237,8 +237,9 @@ extern int8_t Coproc_temp; extern int8_t Coproc_maxtemp; // Haptic driver -void hapticOff(void) ; +void hapticOff(void); void hapticOn(uint32_t pwmPercent); +#define HAPTIC_OFF hapticOff() // BlueTooth driver #if defined(BLUETOOTH) diff --git a/radio/src/targets/stock/board_stock.h b/radio/src/targets/stock/board_stock.h index 53c99012f..497232ad0 100644 --- a/radio/src/targets/stock/board_stock.h +++ b/radio/src/targets/stock/board_stock.h @@ -230,6 +230,10 @@ extern uint8_t RotEncoder ; void rotencPoll(); #endif +// Haptic +#define HAPTIC_ON PORTG |= (1 << OUT_G_HAPTIC) +#define HAPTIC_OFF PORTG &= ~(1 << OUT_G_HAPTIC) + // USB fake driver #define usbPlugged() false diff --git a/radio/src/targets/taranis/board_taranis.cpp b/radio/src/targets/taranis/board_taranis.cpp index 5266f1c98..dca639737 100644 --- a/radio/src/targets/taranis/board_taranis.cpp +++ b/radio/src/targets/taranis/board_taranis.cpp @@ -130,6 +130,10 @@ void interrupt5ms() AUDIO_HEARTBEAT(); +#if defined(HAPTIC) + HAPTIC_HEARTBEAT(); +#endif + if ( ++pre_scale >= 2 ) { pre_scale = 0 ; per10ms(); @@ -155,6 +159,10 @@ void boardInit() eepromInit(); sportInit(); usbInit(); + +#if defined(HAPTIC) + hapticInit(); +#endif #if defined(DEBUG) DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE); diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index 195dc3e3e..a84dff53e 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -239,6 +239,13 @@ void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t si // Debug driver void debugPutc(const char c); +// Haptic +void hapticOff(void); +void hapticOn(uint32_t pwmPercent); +void hapticInit(void); +#define HAPTIC_OFF hapticOff() +#define HAPTIC_ON hapticOn(100) + extern uint8_t currentTrainerMode; #endif diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 592feb2c7..ef6bfa74b 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -333,4 +333,15 @@ #define I2C_EEPROM_ADDRESS 0xA2 #define I2C_CAT5137_ADDRESS 0x5C //0101110 +// Haptic +#if defined(REVPLUS) + #define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOB + #define GPIO_HAPTIC GPIOB + #define PIN_HAPTIC GPIO_Pin_8 +#else + #define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOC + #define GPIO_HAPTIC GPIOC + #define PIN_HAPTIC GPIO_Pin_12 +#endif + #endif diff --git a/radio/src/targets/taranis/haptic_driver.cpp b/radio/src/targets/taranis/haptic_driver.cpp new file mode 100644 index 000000000..8fe82268c --- /dev/null +++ b/radio/src/targets/taranis/haptic_driver.cpp @@ -0,0 +1,71 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * 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" + +void hapticOff(void) +{ +#if defined(REVPLUS) + return; //TODO PWM support +#else + GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC); +#endif +} + +void hapticOn(uint32_t pwmPercent) +{ +#if defined(REVPLUS) + // pwmPercent 0-100 + return; //TODO PWM support +#else + // No PWM before REVPLUS + GPIO_SetBits(GPIO_HAPTIC, PIN_HAPTIC); +#endif +} + +void hapticInit(void) +{ + GPIO_InitTypeDef GPIO_InitStructure; + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE); + + /* GPIO Configuration*/ + GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure); +} From 699707fba496bc5016299fdc129981baa516623d Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 13:35:46 +0200 Subject: [PATCH 02/26] REVPLUS default options --- radio/src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/radio/src/Makefile b/radio/src/Makefile index ef34d18b1..e27660a0e 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -618,6 +618,9 @@ ifeq ($(PCB), TARANIS) CPPDEFS = -DREV3 else ifeq ($(PCBREV), REV4a) CPPDEFS = -DREV4a + else ifeq ($(PCBREV), REVPLUS) + CPPDEFS = -DREVPLUS + HAPTIC = YES else CPPDEFS = -DREV4 endif From 528f1a4267458cd6f786537e0aa1a076b66e41c4 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 13:49:10 +0200 Subject: [PATCH 03/26] Gruvin is an m2560 --- radio/src/targets/gruvin9x/board_gruvin9x.h | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.h b/radio/src/targets/gruvin9x/board_gruvin9x.h index a38cecff1..73ddc822f 100644 --- a/radio/src/targets/gruvin9x/board_gruvin9x.h +++ b/radio/src/targets/gruvin9x/board_gruvin9x.h @@ -185,6 +185,7 @@ void pwrOff(); #define usbPlugged() false // Haptic driver +#define hapticOff() // TODO hapticOn() cleaner ... #define HAPTIC_ON PORTD &= ~(1 << OUT_D_HAPTIC) #define HAPTIC_OFF PORTD |= (1 << OUT_D_HAPTIC) From f29952616f41d9589e163112e0fc526fd6a0c1f2 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 13:59:30 +0200 Subject: [PATCH 04/26] Typo --- radio/src/haptic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/haptic.cpp b/radio/src/haptic.cpp index 158d8ca57..3cbaf4cf4 100644 --- a/radio/src/haptic.cpp +++ b/radio/src/haptic.cpp @@ -54,7 +54,7 @@ void hapticQueue::heartbeat() #else if (buzzTimeLeft > 0) { buzzTimeLeft--; // time gets counted down -#if defined(PCBSXY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) +#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) hapticOn(g_eeGeneral.hapticStrength * 20); #else if (hapticTick-- > 0) { From 5ad4543d918c43c9bad39c378ee6975f434bdaf4 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 14:43:57 +0200 Subject: [PATCH 05/26] Taranis Plus support in companion - DON'T FORGET COMPILE SCRIPT --- companion/src/eeprominterface.cpp | 1 + companion/src/eeprominterface.h | 5 +++-- .../src/firmwares/opentx/opentxinterface.cpp | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 868e107ce..83aab80b3 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1191,6 +1191,7 @@ void RegisterEepromInterfaces() eepromInterfaces.push_back(new OpenTxEepromInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new OpenTxEepromInterface(BOARD_SKY9X)); eepromInterfaces.push_back(new OpenTxEepromInterface(BOARD_TARANIS)); + eepromInterfaces.push_back(new OpenTxEepromInterface(BOARD_TARANIS_PLUS)); if (g.rev4aSupport()) eepromInterfaces.push_back(new OpenTxEepromInterface(BOARD_TARANIS_REV4a)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK)); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index edb779d72..60b173ae7 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -48,14 +48,15 @@ enum BoardEnum { BOARD_GRUVIN9X, BOARD_SKY9X, BOARD_TARANIS, + BOARD_TARANIS_PLUS, BOARD_TARANIS_REV4a }; #define IS_9X(board) (board==BOARD_STOCK || board==BOARD_M128) #define IS_STOCK(board) (board==BOARD_STOCK) #define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560) -#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) -#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a) +#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) +#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) const uint8_t modn12x3[4][4]= { {1, 2, 3, 4}, diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 13b7c86f5..c0dca9f26 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -65,6 +65,8 @@ const char * OpenTxEepromInterface::getName() return "OpenTX for Gruvin9x board / 9X"; case BOARD_TARANIS: return "OpenTX for FrSky Taranis"; + case BOARD_TARANIS_PLUS: + return "OpenTX for FrSky Taranis Plus"; case BOARD_TARANIS_REV4a: return "OpenTX for FrSky Taranis Rev4a"; case BOARD_SKY9X: @@ -86,6 +88,7 @@ const int OpenTxEepromInterface::getEEpromSize() case BOARD_SKY9X: return EESIZE_SKY9X; case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: return EESIZE_TARANIS; case BOARD_TARANIS_REV4a: return EESIZE_TARANIS_REV4a; @@ -359,6 +362,7 @@ int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t if (!version) { switch(board) { case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: case BOARD_TARANIS_REV4a: case BOARD_SKY9X: version = 216; @@ -929,6 +933,7 @@ QString OpenTxFirmware::getFirmwareUrl(QString & id) break; case BOARD_SKY9X: case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: case BOARD_TARANIS_REV4a: url.append(QString("/getfw.php?fw=%1.bin").arg(id)); break; @@ -955,6 +960,7 @@ QString OpenTxFirmware::getReleaseNotesUrl() url.append("9x.txt"); break; case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: case BOARD_TARANIS_REV4a: url.append("taranis.txt"); break; @@ -987,6 +993,7 @@ QString OpenTxFirmware::getStampUrl() url.append("sky9x.txt"); break; case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: case BOARD_TARANIS_REV4a: url.append("taranis.txt"); break; @@ -1009,6 +1016,7 @@ SimulatorInterface * OpenTxFirmware::getSimulator() case BOARD_SKY9X: return new Open9xSky9xSimulator(); case BOARD_TARANIS: + case BOARD_TARANIS_PLUS: case BOARD_TARANIS_REV4a: return new OpentxTaranisSimulator(); default: @@ -1222,6 +1230,16 @@ void registerOpenTxFirmwares() openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font")); openTx->addOptions(fai_options); firmwares.push_back(openTx); + + /* Taranis Plus board */ + openTx = new OpenTxFirmware("opentx-taranisplus", QObject::tr("OpenTX for FrSky Taranis Plus"), BOARD_TARANIS_PLUS, true); + openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); + openTx->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); + openTx->addOption("nogvars", QObject::tr("Disable Global variables")); + openTx->addOption("ppmus", QObject::tr("Channel values displayed in us")); + openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font")); + openTx->addOptions(fai_options); + firmwares.push_back(openTx); if (g.rev4aSupport()) { openTx = new OpenTxFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), BOARD_TARANIS_REV4a, true); From e3955159a295e7ef8eccf0f7e3692fcb5e36350a Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 15:03:17 +0200 Subject: [PATCH 06/26] Enable haptic fields for Taranis, add option for revisions < REVPLUS --- companion/src/firmwares/opentx/opentxinterface.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index c0dca9f26..275741c07 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -562,10 +562,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case SoundPitch: return 1; case Haptic: - if (IS_TARANIS(board)) - return 0; - else - return 1; + return 1; case ModelTrainerEnable: if (IS_TARANIS(board)) return 1; @@ -576,10 +573,7 @@ int OpenTxFirmware::getCapability(const Capability capability) return 1; case HapticLength: case HapticMode: - if (IS_TARANIS(board)) - return 0; - else - return 1; + return 1; case Beeperlen: return 1; case MaxVolume: @@ -1226,6 +1220,7 @@ void registerOpenTxFirmwares() openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); openTx->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); openTx->addOption("nogvars", QObject::tr("Disable Global variables")); + openTx->addOption("haptic", QObject::tr("Haptic module installed")); openTx->addOption("ppmus", QObject::tr("Channel values displayed in us")); openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font")); openTx->addOptions(fai_options); @@ -1246,6 +1241,7 @@ void registerOpenTxFirmwares() openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); openTx->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); openTx->addOption("nogvars", QObject::tr("Disable Global variables")); + openTx->addOption("haptic", QObject::tr("Haptic module installed")); openTx->addOption("ppmus", QObject::tr("Channel values displayed in us")); openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font")); openTx->addOptions(fai_options); From 147b6af9cf0fa13c8daac831a50911bb2ed9e455 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 15:30:30 +0200 Subject: [PATCH 07/26] Backlight color UI in firmware, backend TODO --- radio/src/gui/menu_general.cpp | 11 ++++++++++- radio/src/opentx.h | 6 ++++++ radio/src/translations.cpp | 1 + radio/src/translations.h | 3 ++- radio/src/translations/cz.h.txt | 1 + radio/src/translations/de.h.txt | 1 + radio/src/translations/en.h.txt | 1 + radio/src/translations/es.h.txt | 1 + radio/src/translations/fi.h.txt | 1 + radio/src/translations/fr.h.txt | 1 + radio/src/translations/it.h.txt | 1 + radio/src/translations/pl.h.txt | 1 + radio/src/translations/pt.h.txt | 1 + radio/src/translations/se.h.txt | 1 + 14 files changed, 29 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 2459bfd04..88ac1fe73 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -180,6 +180,7 @@ enum menuGeneralSetupItems { ITEM_SETUP_BACKLIGHT_MODE, ITEM_SETUP_BACKLIGHT_DELAY, IF_CPUARM(ITEM_SETUP_BRIGHTNESS) + IF_REVPLUS(ITEM_SETUP_BACKLIGHT_COLOR) CASE_PWM_BACKLIGHT(ITEM_SETUP_BACKLIGHT_BRIGHTNESS_OFF) CASE_PWM_BACKLIGHT(ITEM_SETUP_BACKLIGHT_BRIGHTNESS_ON) ITEM_SETUP_FLASH_BEEP, @@ -219,7 +220,7 @@ void menuGeneralSetup(uint8_t event) } #endif - MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_VARIO_CPUARM(LABEL(VARIO)) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_PCBSKY9X(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, IF_CPUARM(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH_PARAM(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/}); + MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_VARIO_CPUARM(LABEL(VARIO)) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_VARIO_CPUARM(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) 0, LABEL(ALARMS), 0, CASE_PCBSKY9X(0) CASE_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, IF_CPUARM(0) IF_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH_PARAM(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/}); uint8_t sub = m_posVert - 1; @@ -529,6 +530,14 @@ void menuGeneralSetup(uint8_t event) break; #endif +#if defined(PCBTARANIS) && defined(REVPLUS) + case ITEM_SETUP_BACKLIGHT_COLOR: + lcd_putsLeft(y, STR_BLCOLOR); + displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 255, attr); + if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 255, EE_GENERAL | NO_INCDEC_MARKS); + break; +#endif + #if defined(PWM_BACKLIGHT) case ITEM_SETUP_BACKLIGHT_BRIGHTNESS_OFF: lcd_putsLeft(y, STR_BLOFFBRIGHTNESS); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 1ddafc247..e083c6cc0 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -210,6 +210,12 @@ #define IF_GVARS(x) #endif +#if defined(PCBTARANIS) && defined(REVPLUS) +#define IF_REVPLUS(x) x, +#else +#define IF_REVPLUS(x) +#endif + #if ROTARY_ENCODERS > 0 #define ROTARY_ENCODER_NAVIGATION #endif diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 0fa37e668..09e3794c5 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -469,6 +469,7 @@ const pm_char STR_FLASH_BOOTLOADER[] PROGMEM = TR_FLASH_BOOTLOADER; const pm_char STR_WRITING[] PROGMEM = TR_WRITING; const pm_char STR_CONFIRM_FORMAT[] PROGMEM = TR_CONFIRM_FORMAT; const pm_char STR_EEBACKUP[] PROGMEM = TR_EEBACKUP; +const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; #if LCD_W >= 212 const pm_char STR_MODELNAME[] PROGMEM = TR_MODELNAME; diff --git a/radio/src/translations.h b/radio/src/translations.h index 2fff18ae0..117e58146 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -619,7 +619,8 @@ extern const pm_char STR_VIEW_TEXT[]; extern const pm_char STR_FLASH_BOOTLOADER[]; extern const pm_char STR_WRITING[]; extern const pm_char STR_CONFIRM_FORMAT[]; -extern const pm_char STR_EEBACKUP[]; +extern const pm_char STR_EEBACKUP[]; +extern const pm_char STR_BLCOLOR[]; #if defined(VOICE) && defined(CPUARM) struct LanguagePack { diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 9158b80a5..a42247d4b 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Zhasnout po" #define TR_BLONBRIGHTNESS INDENT"Jas Zap." #define TR_BLOFFBRIGHTNESS INDENT"Jas Vyp." +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN TR("úvodníLogo", "Zobrazit úvodní logo") #define TR_THROTTLEWARNING TR("* Plyn", INDENT "Páka Plynu") #define TR_SWITCHWARNING TR("* Spínače", INDENT "Polohy Spínačů") diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 05d7540ef..e6d46fc2e 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -546,6 +546,7 @@ #define TR_BLDELAY INDENT"Dauer" #define TR_BLONBRIGHTNESS INDENT"An Helligkeit" #define TR_BLOFFBRIGHTNESS INDENT"Aus Helligkeit" +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Startbild Ein für" #define TR_THROTTLEWARNING TR("Gas Alarm", INDENT "Gas Alarm") #define TR_SWITCHWARNING TR("Sch. Alarm", INDENT "Schalter Alarm") diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 1b087d325..30a051410 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -546,6 +546,7 @@ #define TR_BLDELAY INDENT "Duration" #define TR_BLONBRIGHTNESS INDENT "ON Brightness" #define TR_BLOFFBRIGHTNESS INDENT "OFF Brightness" +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" #define TR_THROTTLEWARNING TR("T-Warning", INDENT "Throttle State") #define TR_SWITCHWARNING TR("S-Warning", INDENT "Switch Positions") diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 2fceee467..ff1fb329c 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Duracion" #define TR_BLONBRIGHTNESS INDENT"MAS Brillo" #define TR_BLOFFBRIGHTNESS INDENT"MENOS Brillo" +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Ptalla.inicio" #define TR_THROTTLEWARNING TR("Aviso-A", INDENT "Aviso Acelerador") #define TR_SWITCHWARNING TR("Aviso-I", INDENT "Aviso Intrptor") diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 3e094d87c..97db8a6a4 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Duration" #define TR_BLONBRIGHTNESS INDENT"ON Brightness" #define TR_BLOFFBRIGHTNESS INDENT"OFF Brightness" +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" #define TR_THROTTLEWARNING TR("T-Warning", INDENT "Throttle Warning") #define TR_SWITCHWARNING TR("S-Warning", INDENT "Switch Warning") diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 2f367a47f..e52f38978 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT "Durée" #define TR_BLONBRIGHTNESS INDENT "Luminosité ON" #define TR_BLOFFBRIGHTNESS INDENT "Luminosité OFF" +#define TR_BLCOLOR INDENT "Couleur" #define TR_SPLASHSCREEN "Logo d'accueil" #define TR_THROTTLEWARNING TR("Alerte gaz", INDENT "Alerte gaz") #define TR_SWITCHWARNING TR("Alerte int", INDENT "Pos. interrupteurs") diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 24cfdb453..8a5fafcb3 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Durata" #define TR_BLONBRIGHTNESS TR(INDENT"Lumin. ON",INDENT"Luminosità ON") #define TR_BLOFFBRIGHTNESS TR(INDENT"Lumin. OFF",INDENT"Luminosità OFF") +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN TR("Schermo avvio", "Schermata di avvio") #define TR_THROTTLEWARNING TR("All. Thr", INDENT "Allarme Throttle") #define TR_SWITCHWARNING TR("Avv. Int.", INDENT "Avviso Interr.") diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 18c1c21b7..dccb489a1 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Czas trwania" #define TR_BLONBRIGHTNESS INDENT"Jasnośc wł." #define TR_BLOFFBRIGHTNESS INDENT"Jasność wył." +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Logo ekranu" #define TR_THROTTLEWARNING TR("(\043)Gaz", INDENT "(\043)Gaz") #define TR_SWITCHWARNING TR("(\043)Przełącznik", INDENT "(\043)Przełącznik") diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index dd14c5ed2..db64404b3 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -542,6 +542,7 @@ #define TR_BLDELAY INDENT"Tempo Backlight" #define TR_BLONBRIGHTNESS INDENT"ON Brightness" #define TR_BLOFFBRIGHTNESS INDENT"OFF Brightness" +#define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" #define TR_THROTTLEWARNING TR("Avisa Acel", INDENT "Avisa Acel") #define TR_SWITCHWARNING TR("Avisa Chav", INDENT "Avisa Chav") diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 085a74532..89745566c 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -543,6 +543,7 @@ #define TR_BLONBRIGHTNESS INDENT"På Ljusstyrka" #define TR_BLOFFBRIGHTNESS INDENT"Av Ljusstyrka" #define TR_SPLASHSCREEN "Startbild" +#define TR_BLCOLOR INDENT "Color" #define TR_THROTTLEWARNING TR("Gasvarning", INDENT "Gasvarning") #define TR_SWITCHWARNING TR("Bryt.varn.", INDENT "Brytarvarning") #define TR_POTWARNING TR("Rattvarn.", INDENT "Rattvarning") From 57d541efc1bd81a155b32fee96c2be29cf1721bb Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 15:31:12 +0200 Subject: [PATCH 08/26] Backlight color support in companion --- companion/src/eeprominterface.h | 11 +- companion/src/generaledit.cpp | 16 + companion/src/generaledit.h | 1 + companion/src/generaledit.ui | 1687 ++++++++++++++++--------------- 4 files changed, 884 insertions(+), 831 deletions(-) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 60b173ae7..37903f939 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -52,11 +52,12 @@ enum BoardEnum { BOARD_TARANIS_REV4a }; -#define IS_9X(board) (board==BOARD_STOCK || board==BOARD_M128) -#define IS_STOCK(board) (board==BOARD_STOCK) -#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560) -#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) -#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) +#define IS_9X(board) (board==BOARD_STOCK || board==BOARD_M128) +#define IS_STOCK(board) (board==BOARD_STOCK) +#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560) +#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) +#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a || board==BOARD_TARANIS_PLUS) +#define IS_TARANIS_PLUS(board) (board==BOARD_TARANIS_PLUS) const uint8_t modn12x3[4][4]= { {1, 2, 3, 4}, diff --git a/companion/src/generaledit.cpp b/companion/src/generaledit.cpp index 5e4cb6c54..b1ceb6803 100644 --- a/companion/src/generaledit.cpp +++ b/companion/src/generaledit.cpp @@ -283,6 +283,16 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) : ui->serialPortMode->hide(); ui->serialPortLabel->hide(); } + + if (IS_TARANIS_PLUS(eepromInterface->getBoard())) { + ui->backlightColor_SL->setValue(g_eeGeneral.backlightColor); + } + else { + ui->backlightColor_label->hide(); + ui->backlightColor_SL->hide(); + ui->backlightColor1_label->hide(); + ui->backlightColor2_label->hide(); + } } GeneralEdit::~GeneralEdit() @@ -486,6 +496,12 @@ void GeneralEdit::on_backlightautoSB_editingFinished() } } +void GeneralEdit::on_backlightColor_SL_valueChanged() +{ + g_eeGeneral.backlightColor = ui->backlightColor_SL->value(); + updateSettings(); +} + void GeneralEdit::on_timezoneSB_editingFinished() { g_eeGeneral.timezone = ui->timezoneSB->value(); diff --git a/companion/src/generaledit.h b/companion/src/generaledit.h index 395adc24c..5fd046de0 100644 --- a/companion/src/generaledit.h +++ b/companion/src/generaledit.h @@ -50,6 +50,7 @@ private slots: void on_tabWidget_currentChanged(int index); void on_displayTypeCB_currentIndexChanged(int index); void on_BLBright_SB_editingFinished(); + void on_backlightColor_SL_valueChanged(); void on_re_CB_currentIndexChanged(int index); void on_countrycode_CB_currentIndexChanged(int index); void on_units_CB_currentIndexChanged(int index); diff --git a/companion/src/generaledit.ui b/companion/src/generaledit.ui index 1b59ef886..fdc220b55 100644 --- a/companion/src/generaledit.ui +++ b/companion/src/generaledit.ui @@ -113,532 +113,7 @@ These will be relevant for all models in the same EEPROM. Setup - - - - - - Country Code - - - - - - - - America - - - - - Japan - - - - - Europe - - - - - - - - - - - - - - - - Mode selection: - -Mode 1: - Left stick: Elevator, Rudder - Right stick: Throttle, Aileron - -Mode 2: - Left stick: Throttle, Rudder - Right stick: Elevator, Aileron - -Mode 3: - Left stick: Elevator, Aileron - Right stick: Throttle, Rudder - -Mode 4: - Left stick: Throttle, Aileron - Right stick: Elevator, Rudder - - - - - 1 - - - - Mode 1 (RUD ELE THR AIL) - - - - - Mode 2 (RUD THR ELE AIL) - - - - - Mode 3 (AIL ELE THR RUD) - - - - - Mode 4 (AIL THR ELE RUD) - - - - - - - - - 4800 Baud - - - - - 9600 Baud - - - - - 14400 Baud - - - - - 19200 Baud - - - - - 38400 Baud - - - - - 57600 Baud - - - - - 76800 Baud - - - - - 115200 Baud - - - - - - - - Haptic Length - - - - - - - - - Beep volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - Wav volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - Vario volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - Background volume - - - - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - - - Beeper Length - - - - - - - Vario pitch at zero - - - - - - - MAVLink Baud Rate - - - - - - - - - Voice Language - - - - - - - - - - - - Speaker Volume - - - - - - - Readonly Unlock - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Vertical - - - - 20 - 5 - - - - - - - - Sound Mode - - - - - - - - 0 - 0 - - - - - - - - - - If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. - - - min - - - 120 - - - - - - - - - - - - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. - - - - Quiet - - - - - Alarms Only - - - - - No Keys - - - - - All - - - - - - - - - Quiet - - - - - Only Alarms - - - - - No Keys - - - - - All - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Haptic Mode - - - - - - - Stick Mode - - - - - - - - 0 - 0 - - - - Default Channel Order - - - - - - - - Metric - - - - - Imperial - - - - - - - - -14 - - - 12 - - - 0 - - - - - - - - X-Short - - - - - Short - - - - - Normal - - - - - Long - - - - - X-Long - - - - - - - - - Beeper - - - - - Speaker - - - - - BeeperVoice - - - - - SpeakerVoice - - - - - - - - Haptic Strength - - - - - - - FAI Mode - - - - + @@ -674,7 +149,7 @@ Mode 4: - + @@ -810,7 +285,7 @@ Mode 4: - + If you enable FAI, you loose the vario, the play functions, the telemetry screen. This function cannot be disabled by the radio. @@ -820,7 +295,367 @@ Mode 4: - + + + + + + Color 1 + + + + + + + 255 + + + Qt::Horizontal + + + + + + + Color 2 + + + + + + + + + + + Country Code + + + + + + + + America + + + + + Japan + + + + + Europe + + + + + + + + + + + + + + + + Mode selection: + +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + + + + 1 + + + + Mode 1 (RUD ELE THR AIL) + + + + + Mode 2 (RUD THR ELE AIL) + + + + + Mode 3 (AIL ELE THR RUD) + + + + + Mode 4 (AIL THR ELE RUD) + + + + + + + + Beeper Length + + + + + + + Vario pitch at zero + + + + + + + + + Voice Language + + + + + + + + + + + + Readonly Unlock + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Vertical + + + + 20 + 5 + + + + + + + + Sound Mode + + + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + Quiet + + + + + Alarms Only + + + + + No Keys + + + + + All + + + + + + + + + Quiet + + + + + Only Alarms + + + + + No Keys + + + + + All + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Haptic Mode + + + + + + + Stick Mode + + + + + + + + 0 + 0 + + + + Default Channel Order + + + + + + + + Metric + + + + + Imperial + + + + + + + + -14 + + + 12 + + + 0 + + + + + + + + X-Short + + + + + Short + + + + + Normal + + + + + Long + + + + + X-Long + + + + + + + + + Beeper + + + + + Speaker + + + + + BeeperVoice + + + + + SpeakerVoice + + + + + + + + FAI Mode + + + + @@ -845,39 +680,13 @@ Mode 4: - - - - - 0 - 0 - - - - 23 - - - - + Measurement Units - - - - - 0 - 0 - - - - 5 - - - @@ -912,14 +721,14 @@ p, li { white-space: pre-wrap; } - + Timeshift from UTC - + QLayout::SetMinimumSize @@ -1447,7 +1256,7 @@ p, li { white-space: pre-wrap; } - + Hz @@ -1466,69 +1275,7 @@ p, li { white-space: pre-wrap; } - - - - "No Sound" Warning - - - - - - - Low Memory Warning - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - - 0 - 0 - - - - Show Splash Screen on Startup - - - - + @@ -1538,108 +1285,7 @@ p, li { white-space: pre-wrap; } - - - - - - - Contrast - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - Inactivity Timer - - - - - - - - Standard - - - - - Optrex - - - - - - - - LCD Display Type - - - - - - - - 0 - 0 - - - - - - - - - - - - - 10 - - - 45 - - - 25 - - - - + @@ -1682,14 +1328,251 @@ Acceptable values are 5v..10v - - + + - BackLight Switch + Vario pitch at max - + + + + + 0 + 0 + + + + + + + + + + If this value is not 0, any keypress will turn on the backlight and turn it off after the specified number of seconds. + + + sec + + + 600 + + + 5 + + + + + + + Hz + + + 1300 + + + 2900 + + + 10 + + + 1700 + + + + + + + ms + + + 200 + + + 1000 + + + 10 + + + 500 + + + + + + + Backlight Brightness + + + + + + + Vario repeat at zero + + + + + + + Backlight Auto OFF after + + + + + + + 100 + + + + + + + + + + RotEnc Navigation + + + + + + + Backlight color + + + + + + + + Standard + + + + + Optrex + + + + + + + + + + + Contrast + + + + + + + + 0 + 0 + + + + + + + + + + If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. + + + min + + + 120 + + + + + + + + 4800 Baud + + + + + 9600 Baud + + + + + 14400 Baud + + + + + 19200 Baud + + + + + 38400 Baud + + + + + 57600 Baud + + + + + 76800 Baud + + + + + 115200 Baud + + + + + + + + Backlight Switch + + + + + + + + 0 + 0 + + + + 23 + + + + + + + + 0 + 0 + + + + Show Splash Screen on Startup + + + + @@ -1707,6 +1590,152 @@ Acceptable values are 5v..10v + + + + LCD Display Type + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + + + + + MAVLink Baud Rate + + + + + + + + 0 + 0 + + + + + + + + + + + + + 10 + + + 45 + + + 25 + + + + + + + Speaker Volume + + + + + + + Haptic Length + + + + + + + Inactivity Timer + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + + + + + + 0 + 0 + + + + 5 + + + @@ -1786,116 +1815,122 @@ Acceptable values are 5v..10v - - + + - Vario pitch at max + "No Sound" Warning - - - - - 0 - 0 - - - - - - - - - - If this value is not 0, any keypress will turn on the backlight and turn it off after the specified number of seconds. - - - sec - - - 600 - - - 5 - - - - - - - Hz - - - 1300 - - - 2900 - - - 10 - - - 1700 - - - - - - - ms - - - 200 - - - 1000 - - - 10 - - - 500 - - - - - + + - BackLight Brightness + Low Memory Warning - - + + - Vario repeat at zero + Haptic Strength - - - - BackLight Auto OFF after - - - - - - - 100 - - - - - - - - - - RotEnc Navigation - - + + + + + + Beep volume + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + Wav volume + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + Vario volume + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + Background volume + + + + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + From 7600924d94589198d4129887be77679417696d38 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 17:28:16 +0200 Subject: [PATCH 09/26] Make displaySlider generally available --- radio/src/gui/menu_general.cpp | 14 -------------- radio/src/gui/menus.cpp | 16 ++++++++++++++++ radio/src/gui/menus.h | 9 +++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 88ac1fe73..673b514a4 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -110,33 +110,19 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = { #endif #if !defined(CPUM64) - void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr) - { - lcd_putc(RADIO_SETUP_2ND_COLUMN+(value*4*FW)/max, y, '$'); - lcd_hline(RADIO_SETUP_2ND_COLUMN, y+3, 5*FW-1, SOLID); - if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, 5*FW-1, FH-1); - } #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ displaySlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } #elif defined(GRAPHICS) - void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr) - { - lcd_putc(RADIO_SETUP_2ND_COLUMN+2*FW+(value*FW), y, '$'); - lcd_hline(RADIO_SETUP_2ND_COLUMN, y+3, 5*FW-1, SOLID); - if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(RADIO_SETUP_2ND_COLUMN, y, 5*FW-1, FH-1); - } #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ display5posSlider(RADIO_SETUP_2ND_COLUMN, y, tmp, attr); \ value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } - #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) #else #define SLIDER_5POS(y, value, label, event, attr) value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, STR_VBEEPLEN, value, -2, +2, attr, event) - #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) #endif #if defined(SPLASH) && !defined(FSPLASH) diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index 0c8e0a136..1897b68be 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1136,6 +1136,22 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t return value; } +#if !defined(CPUM64) + void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr) + { + lcd_putc(x+(value*4*FW)/max, y, '$'); + lcd_hline(x, y+3, 5*FW-1, SOLID); + if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); + } +#elif defined(GRAPHICS) + void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr) + { + lcd_putc(x+2*FW+(value*FW), y, '$'); + lcd_hline(x, y+3, 5*FW-1, SOLID); + if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); + } +#endif + #if defined(GVARS) #if defined(CPUARM) int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event) diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index 7def27e21..5a1f516f7 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -138,6 +138,15 @@ void menuStatisticsView(uint8_t event); void menuStatisticsDebug(uint8_t event); void menuAboutView(uint8_t event); +#if !defined(CPUM64) + void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr); +#elif defined(GRAPHICS) + void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr); + #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) +#else + #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) +#endif + #if defined(PCBTARANIS) void menuMainViewChannelsMonitor(uint8_t event); void menuChannelsView(uint8_t event); From dfead504f7ee09dc304252c65783f82d1ba97e6e Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Wed, 23 Apr 2014 17:31:09 +0200 Subject: [PATCH 10/26] Backlight color in SFs for REVPLUS 100 steps instead of 255, should be enough... --- companion/src/generaledit.ui | 2 +- radio/src/gui/menu_general.cpp | 4 ++-- radio/src/gui/menu_model.cpp | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/companion/src/generaledit.ui b/companion/src/generaledit.ui index fdc220b55..c1f11c91d 100644 --- a/companion/src/generaledit.ui +++ b/companion/src/generaledit.ui @@ -307,7 +307,7 @@ These will be relevant for all models in the same EEPROM. - 255 + 100 Qt::Horizontal diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 673b514a4..ac1d97a80 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -519,8 +519,8 @@ void menuGeneralSetup(uint8_t event) #if defined(PCBTARANIS) && defined(REVPLUS) case ITEM_SETUP_BACKLIGHT_COLOR: lcd_putsLeft(y, STR_BLCOLOR); - displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 255, attr); - if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 255, EE_GENERAL | NO_INCDEC_MARKS); + displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 100, attr); + if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 100, EE_GENERAL | NO_INCDEC_MARKS); break; #endif diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 3c9eae936..d194b6607 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -5074,6 +5074,14 @@ void menuModelCustomFunctions(uint8_t event) lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } +#endif +#if defined(PCBTARANIS) && defined(REVPLUS) + else if (func == FUNC_BACKLIGHT) { + displaySlider(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, CFN_PARAM(sd), 100, attr); + INCDEC_SET_FLAG(NO_INCDEC_MARKS); + val_min = 0; + val_max = 100; + } #endif else if (func == FUNC_RESET) { val_max = FUNC_RESET_PARAM_LAST; From 91c84dbb657fb7d7a39e466d92881b25fe097407 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 16:16:07 +0200 Subject: [PATCH 11/26] Color slider for backlight SF in companion --- companion/src/modeledit/customfunctions.cpp | 16 ++++++++++++++++ companion/src/modeledit/customfunctions.h | 1 + 2 files changed, 17 insertions(+) diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 51de7cc69..652b50a24 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -161,6 +161,15 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); + + fswtchBLcolor[i] = new QSlider(this); + fswtchBLcolor[i]->setProperty("index", i); + fswtchBLcolor[i]->setMinimum(0); + fswtchBLcolor[i]->setMaximum(100); + fswtchBLcolor[i]->setSingleStep(1); + fswtchBLcolor[i]->setOrientation(Qt::Horizontal); + paramLayout->addWidget(fswtchBLcolor[i]); + connect(fswtchBLcolor[i], SIGNAL(sliderReleased()), this, SLOT(customFunctionEdited())); #ifdef PHONON playBT[i] = new QPushButton(this); @@ -271,6 +280,7 @@ void CustomFunctionsPanel::playMusic() #define CUSTOM_FUNCTION_ENABLE (1<<5) #define CUSTOM_FUNCTION_REPEAT (1<<6) #define CUSTOM_FUNCTION_PLAY (1<<7) +#define CUSTOM_FUNCTION_BL_COLOR (1<<8) void CustomFunctionsPanel::customFunctionEdited() { @@ -447,6 +457,11 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } + else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) { + if (modified) model.funcSw[i].param = (uint8_t)fswtchBLcolor[i]->value(); + fswtchBLcolor[i]->setValue(model.funcSw[i].param); + widgetsMask |= CUSTOM_FUNCTION_BL_COLOR; + } else { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); @@ -468,6 +483,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) fswtchEnable[i]->setChecked(false); fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); + fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); #ifdef PHONON playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); #endif diff --git a/companion/src/modeledit/customfunctions.h b/companion/src/modeledit/customfunctions.h index fecab42a3..40d69cede 100644 --- a/companion/src/modeledit/customfunctions.h +++ b/companion/src/modeledit/customfunctions.h @@ -74,6 +74,7 @@ class CustomFunctionsPanel : public ModelPanel QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; + QSlider * fswtchBLcolor[C9X_MAX_CUSTOM_FUNCTIONS]; #ifdef PHONON Phonon::MediaObject *clickObject; Phonon::AudioOutput *clickOutput; From 09295d377d094cb7024a08855cab6029c1ba4d33 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 16:16:30 +0200 Subject: [PATCH 12/26] Simu now simulates REVPLUS --- companion/src/firmwares/opentx/opentxTaranisSimulator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 52ada6c30..f9104e688 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -53,6 +53,7 @@ #define LUA_MODEL_SCRIPTS #define EEPROM_VARIANT 3 #define HAPTIC +#define REVPLUS #define NUM_POTS 5 From 7fc1372f8fc065a0ebac2f525c61c749866cc5e4 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 16:17:16 +0200 Subject: [PATCH 13/26] Some fields were broken for REV4a and REVPLUS --- companion/src/firmwares/opentx/opentxeeprom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b74433cff..65d5140d6 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -698,7 +698,7 @@ class FlightModeField: public TransformedField { for (int i=0; i(trimExt[i])); } - else if (board == BOARD_TARANIS && version >= 216) { + else if (IS_TARANIS(board) && version >= 216) { for (int i=0; i(phase.trim[i])); internalField.Append(new UnsignedField<5>(trimMode[i])); @@ -739,7 +739,7 @@ class FlightModeField: public TransformedField { virtual void beforeExport() { for (int i=0; i= 216) { + if (IS_TARANIS(board) && version >= 216) { if (phase.trimMode[i] < 0) trimMode[i] = TRIM_MODE_NONE; else @@ -767,7 +767,7 @@ class FlightModeField: public TransformedField { virtual void afterImport() { for (int i=0; i= 216) { + if (IS_TARANIS(board) && version >= 216) { if (trimMode[i] == TRIM_MODE_NONE) { phase.trimMode[i] = -1; } From bdf4e6d0d1a8eeaffe1cdf6ec5a910f80efb8341 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 16:47:12 +0200 Subject: [PATCH 14/26] LCD pins remapped --- radio/src/targets/taranis/aspi.h | 22 ++++++++--------- radio/src/targets/taranis/hal.h | 30 +++++++++++++++++------- radio/src/targets/taranis/lcd_driver.cpp | 13 +++++++--- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/radio/src/targets/taranis/aspi.h b/radio/src/targets/taranis/aspi.h index a3f4f829f..6a17c8391 100644 --- a/radio/src/targets/taranis/aspi.h +++ b/radio/src/targets/taranis/aspi.h @@ -1,6 +1,6 @@ /** ****************************************************************************** - * @file Project/spi/spi.h + * @file Project/spi/spi.h * @author FrSky Application Team * @Hardware version V0.2 * @date 11-July-2012 @@ -19,20 +19,20 @@ extern "C" { #define __no_operation __NOP -#define LCD_NCS_HIGH() GPIO_LCD->BSRRL = PIN_LCD_NCS -#define LCD_NCS_LOW() GPIO_LCD->BSRRH = PIN_LCD_NCS +#define LCD_NCS_HIGH() GPIO_LCD_NCS->BSRRL = PIN_LCD_NCS +#define LCD_NCS_LOW() GPIO_LCD_NCS->BSRRH = PIN_LCD_NCS -#define LCD_A0_HIGH() GPIO_LCD->BSRRL = PIN_LCD_A0 -#define LCD_A0_LOW() GPIO_LCD->BSRRH = PIN_LCD_A0 +#define LCD_A0_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_A0 +#define LCD_A0_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_A0 -#define LCD_RST_HIGH() GPIO_LCD->BSRRL = PIN_LCD_RST -#define LCD_RST_LOW() GPIO_LCD->BSRRH = PIN_LCD_RST +#define LCD_RST_HIGH() GPIO_LCD_RST->BSRRL = PIN_LCD_RST +#define LCD_RST_LOW() GPIO_LCD_RST->BSRRH = PIN_LCD_RST -#define LCD_CLK_HIGH() GPIO_LCD->BSRRL = PIN_LCD_CLK -#define LCD_CLK_LOW() GPIO_LCD->BSRRH = PIN_LCD_CLK +#define LCD_CLK_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_CLK +#define LCD_CLK_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_CLK -#define LCD_MOSI_HIGH() GPIO_LCD->BSRRL = PIN_LCD_MOSI -#define LCD_MOSI_LOW() GPIO_LCD->BSRRH = PIN_LCD_MOSI +#define LCD_MOSI_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_MOSI +#define LCD_MOSI_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_MOSI void AspiCmd(u8 Command_Byte); void AspiData(u8 Para_data); diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index ef6bfa74b..655598944 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -225,14 +225,28 @@ #define GPIOBL GPIOB #define GPIO_PinSource_BL GPIO_PinSource8 -// LCD GPIOD 10-14 -#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD -#define GPIO_LCD GPIOD -#define PIN_LCD_MOSI GPIO_Pin_10 //PD.10 -#define PIN_LCD_CLK GPIO_Pin_11 //PD.11 -#define PIN_LCD_NCS GPIO_Pin_14 //PD.14 -#define PIN_LCD_A0 GPIO_Pin_13 //PD.13 -#define PIN_LCD_RST GPIO_Pin_12 //pd12 test //RESET occurs when powered up,but should delay before initialize +// LCD +#if defined(REVPLUS) + #define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD + #define GPIO_LCD_SPI GPIOC + #define GPIO_LCD_NCS GPIOA + #define GPIO_LCD_RST GPIOD + #define PIN_LCD_MOSI GPIO_Pin_12 //PC.12 + #define PIN_LCD_CLK GPIO_Pin_10 //PC.10 + #define PIN_LCD_NCS GPIO_Pin_15 //PA.15 + #define PIN_LCD_A0 GPIO_Pin_11 //PC.11 + #define PIN_LCD_RST GPIO_Pin_12 //PD.12 +#else + #define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD + #define GPIO_LCD_SPI GPIOD + #define GPIO_LCD_NCS GPIOD + #define GPIO_LCD_RST GPIOD + #define PIN_LCD_MOSI GPIO_Pin_10 //PD.10 + #define PIN_LCD_CLK GPIO_Pin_11 //PD.11 + #define PIN_LCD_NCS GPIO_Pin_14 //PD.14 + #define PIN_LCD_A0 GPIO_Pin_13 //PD.13 + #define PIN_LCD_RST GPIO_Pin_12 //PD.12 +#endif // Audio - I2S3 #define CODEC_I2S SPI3 diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index e9e3c1129..8de433294 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -171,16 +171,23 @@ static void LCD_Hardware_Init() GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIO_LCD, &GPIO_InitStructure); + GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure); LCD_NCS_HIGH(); /*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/ - GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS |PIN_LCD_RST; + GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_Init(GPIO_LCD_NCS, &GPIO_InitStructure); - GPIO_Init(GPIO_LCD, &GPIO_InitStructure); + /*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/ + GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure); } //275us From c03708a4dc3c66fedb26be1d8920e200977655c1 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 17:12:17 +0200 Subject: [PATCH 15/26] More pin remappings --- radio/src/targets/taranis/hal.h | 99 ++++++++++++++++---------- radio/src/targets/taranis/pwr_driver.c | 14 +++- 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 655598944..7361b0e69 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -14,10 +14,10 @@ #define GPIO_BUTTON_MENU GPIOD->IDR #define GPIO_BUTTON_EXIT GPIOD->IDR #define GPIO_BUTTON_PAGE GPIOD->IDR -#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10 +#define PIN_BUTTON_PLUS GPIO_Pin_10 //SW3 PE.10 #define PIN_BUTTON_MINUS GPIO_Pin_11 //SW1 PE.12 -#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11 -#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07 +#define PIN_BUTTON_ENTER GPIO_Pin_12 //SW2 PE.11 +#define PIN_BUTTON_MENU GPIO_Pin_7 //SW4 PD.07 #define PIN_BUTTON_PAGE GPIO_Pin_3 //SW6 PD.02 #define PIN_BUTTON_EXIT GPIO_Pin_2 //SW5 PD.03 @@ -30,12 +30,12 @@ #define GPIO_TRIM_LV_UP GPIOE->IDR #define GPIO_TRIM_RV_DN GPIOC->IDR #define GPIO_TRIM_RH_R GPIOC->IDR -#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03 -#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02 -#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01 -#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13 +#define PIN_TRIM_RV_DN GPIO_Pin_3 //PC.03 +#define PIN_TRIM_RV_UP GPIO_Pin_2 //PC.02 +#define PIN_TRIM_RH_L GPIO_Pin_1 //PC.01 +#define PIN_TRIM_RH_R GPIO_Pin_13 //PC.13 #if defined(REV3) - #define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04 + #define PIN_TRIM_LH_R GPIO_Pin_4 //PE.04 #define PIN_TRIM_LH_L GPIO_Pin_3 //PE.03 #else #define PIN_TRIM_LH_L GPIO_Pin_4 //PE.04 @@ -47,7 +47,7 @@ // Switchs #if defined(REV3) #define GPIO_PIN_SW_F (~GPIOE->IDR) - #define PIN_SW_F GPIO_Pin_14 //PE.14 + #define PIN_SW_F GPIO_Pin_14 //PE.14 #else #define GPIO_PIN_SW_F GPIOE->IDR #define PIN_SW_F GPIO_Pin_14 //PE.14 @@ -55,8 +55,8 @@ #define GPIO_PIN_SW_E_L GPIOB->IDR #define GPIO_PIN_SW_E_H GPIOB->IDR -#define PIN_SW_E_L GPIO_Pin_3 //PB.03 -#define PIN_SW_E_H GPIO_Pin_4 //PB.04 +#define PIN_SW_E_L GPIO_Pin_3 //PB.03 +#define PIN_SW_E_H GPIO_Pin_4 //PB.04 #if defined(REV3) #define GPIO_PIN_SW_B_L GPIOB->IDR @@ -73,8 +73,8 @@ #if defined(REV3) #define GPIO_PIN_SW_A_H (~GPIOB->IDR) #define GPIO_PIN_SW_A_L (~GPIOE->IDR) - #define PIN_SW_A_H GPIO_Pin_7 //PB.07 - #define PIN_SW_A_L GPIO_Pin_2 //PE.02 + #define PIN_SW_A_H GPIO_Pin_7 //PB.07 + #define PIN_SW_A_L GPIO_Pin_2 //PE.02 #else #define GPIO_PIN_SW_A_H GPIOB->IDR #define GPIO_PIN_SW_A_L GPIOE->IDR @@ -86,7 +86,7 @@ #define GPIO_PIN_SW_G_H (~GPIOA->IDR) #define GPIO_PIN_SW_G_L (~GPIOB->IDR) #define PIN_SW_G_H GPIO_Pin_5 //PA.05 - #define PIN_SW_G_L GPIO_Pin_0 //PB.00 + #define PIN_SW_G_L GPIO_Pin_0 //PB.00 #else #define GPIO_PIN_SW_G_H GPIOE->IDR #define GPIO_PIN_SW_G_L GPIOE->IDR @@ -98,7 +98,7 @@ #define GPIO_PIN_SW_C_H (~GPIOB->IDR) #define GPIO_PIN_SW_C_L (~GPIOE->IDR) #define PIN_SW_C_H GPIO_Pin_1 //PB.01 - #define PIN_SW_C_L GPIO_Pin_7 //PE.07 + #define PIN_SW_C_L GPIO_Pin_7 //PE.07 #else #define GPIO_PIN_SW_C_H GPIOE->IDR #define GPIO_PIN_SW_C_L GPIOA->IDR @@ -109,18 +109,26 @@ #if defined(REV3) #define GPIO_PIN_SW_D_H (~GPIOE->IDR) #define GPIO_PIN_SW_D_L (~GPIOE->IDR) - #define PIN_SW_D_H GPIO_Pin_9 //PE.09 - #define PIN_SW_D_L GPIO_Pin_8 //PE.08 + #define PIN_SW_D_H GPIO_Pin_9 //PE.09 + #define PIN_SW_D_L GPIO_Pin_8 //PE.08 +#elif defined(REVPLUS) + #define GPIO_PIN_SW_D_H (GPIOE->IDR) + #define GPIO_PIN_SW_D_L (GPIOE->IDR) + #define PIN_SW_D_H GPIO_Pin_7 //PE.07 + #define PIN_SW_D_L GPIO_Pin_13 //PE.13 #else #define GPIO_PIN_SW_D_H GPIOE->IDR #define GPIO_PIN_SW_D_L GPIOB->IDR - #define PIN_SW_D_H GPIO_Pin_7 //PE.07 - #define PIN_SW_D_L GPIO_Pin_1 //PB.01 + #define PIN_SW_D_H GPIO_Pin_7 //PE.07 + #define PIN_SW_D_L GPIO_Pin_1 //PB.01 #endif #if defined(REV3) #define GPIO_PIN_SW_H (~GPIOE->IDR) #define PIN_SW_H GPIO_Pin_13 //PE.13 +#elif defined(REVPLUS) + #define GPIO_PIN_SW_H GPIOD->IDR + #define PIN_SW_H GPIO_Pin_14 //PD.14 #else #define GPIO_PIN_SW_H GPIOE->IDR #define PIN_SW_H GPIO_Pin_13 //PE.13 @@ -139,6 +147,9 @@ #else #define PIN_FLP_J2 GPIO_Pin_0 //PB.00 #endif +#if defined(REVPLUS) + #define PIN_FLP_J3 GPIO_Pin_1 //PB.01 +#endif #define PIN_MVOLT GPIO_Pin_0 //PC.00 #if defined(REV3) #define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC @@ -156,8 +167,15 @@ #define RCC_AHB1Periph_GPIOPWR RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD #define GPIOPWRLED GPIOC #define GPIOPWR GPIOD -#define PIN_INT_RF_PWR GPIO_Pin_15 +#define GPIO_EXT_RF_PWR GPIOD #define PIN_EXT_RF_PWR GPIO_Pin_8 +#if defined(REVPLUS) + #define GPIO_INT_RF_PWR GPIOC + #define PIN_INT_RF_PWR GPIO_Pin_6 +#else + #define GPIO_INT_RF_PWR GPIOD + #define PIN_INT_RF_PWR GPIO_Pin_15 +#endif // Trainer Port #define GPIO_TR_INOUT GPIOC @@ -219,11 +237,20 @@ #define PIN_FS_DM GPIO_Pin_11 //PA.11 #define PIN_FS_DP GPIO_Pin_12 //PA.12 -// BackLight PB8 -#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB -#define GPIO_Pin_BL GPIO_Pin_8 //PB.08 -#define GPIOBL GPIOB -#define GPIO_PinSource_BL GPIO_PinSource8 +// BackLight +#if defined (REVPLUS) + #define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD + #define GPIO_Pin_BL GPIO_Pin_15 //PD.15 + #define GPIOBL GPIOD + #define GPIO_PinSource_BL GPIO_PinSource15 + #define GPIO_Pin_BLW GPIO_Pin_13 //PD.13 + #define GPIO_PinSource_BLW GPIO_PinSource13 +#else + #define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB + #define GPIO_Pin_BL GPIO_Pin_8 //PB.08 + #define GPIOBL GPIOB + #define GPIO_PinSource_BL GPIO_PinSource8 +#endif // LCD #if defined(REVPLUS) @@ -310,13 +337,13 @@ #define RCC_AHB1Periph_GPIO_SD RCC_AHB1Periph_GPIOB #define RCC_APBPeriphClockCmd_SPI_SD RCC_APB1PeriphClockCmd #define RCC_APBPeriph_SPI_SD RCC_APB1Periph_SPI2 -#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1 -#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ +#define RCC_AHB1Periph_DMA_SD RCC_AHB1Periph_DMA1 +#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 //10.5<20MHZ,make sure < 20MHZ //disabled io_ctl and cp/wp -#define CARD_SUPPLY_SWITCHABLE 0 -#define SOCKET_WP_CONNECTED 0 -#define SOCKET_CP_CONNECTED 0 +#define CARD_SUPPLY_SWITCHABLE 0 +#define SOCKET_WP_CONNECTED 0 +#define SOCKET_CP_CONNECTED 0 /* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */ #define STM32_SD_DISK_IOCTRL_FORCE 0 @@ -326,13 +353,13 @@ #endif #ifdef STM32_SD_USE_DMA -#define DMA_Channel_SPI_SD_RX DMA1_Stream3 -#define DMA_Channel_SPI_SD_TX DMA1_Stream4 +#define DMA_Channel_SPI_SD_RX DMA1_Stream3 +#define DMA_Channel_SPI_SD_TX DMA1_Stream4 -#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3 -#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4 -#define DMA_Channel_SPI2_TX DMA_Channel_0 -#define DMA_Channel_SPI2_RX DMA_Channel_0 +#define DMA_FLAG_SPI_SD_TC_RX DMA_FLAG_TCIF3 +#define DMA_FLAG_SPI_SD_TC_TX DMA_FLAG_TCIF4 +#define DMA_Channel_SPI2_TX DMA_Channel_0 +#define DMA_Channel_SPI2_RX DMA_Channel_0 #endif // Audio----I2S3-----SPI3 diff --git a/radio/src/targets/taranis/pwr_driver.c b/radio/src/targets/taranis/pwr_driver.c index 2df7d5d2b..3d1dc7de8 100644 --- a/radio/src/targets/taranis/pwr_driver.c +++ b/radio/src/targets/taranis/pwr_driver.c @@ -66,13 +66,21 @@ void pwrInit() GPIO_Init(GPIOPWRLED, &GPIO_InitStructure); #if !defined(REV3) - GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR | PIN_EXT_RF_PWR); - GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR | PIN_EXT_RF_PWR; + GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR; + GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOPWR, &GPIO_InitStructure); + GPIO_Init(GPIO_INT_RF_PWR, &GPIO_InitStructure); + + GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR); + GPIO_InitStructure.GPIO_Pin = PIN_EXT_RF_PWR; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIO_EXT_RF_PWR, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_TRNDET; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; From 314a9d468d5a81e4883167ff612b6a5bda3a5f79 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 17:23:22 +0200 Subject: [PATCH 16/26] ) --- radio/src/targets/taranis/pwr_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/targets/taranis/pwr_driver.c b/radio/src/targets/taranis/pwr_driver.c index 3d1dc7de8..d896a2ab6 100644 --- a/radio/src/targets/taranis/pwr_driver.c +++ b/radio/src/targets/taranis/pwr_driver.c @@ -66,7 +66,7 @@ void pwrInit() GPIO_Init(GPIOPWRLED, &GPIO_InitStructure); #if !defined(REV3) - GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR; + GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR); GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; From 7ca42a8472987c49297aca39ba27577452cb1487 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 17:54:11 +0200 Subject: [PATCH 17/26] Forgot to update a couple of macros --- radio/src/targets/taranis/board_taranis.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index 889d6c4dc..adfed44b2 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -203,10 +203,10 @@ void pwrInit(void); uint32_t pwrCheck(void); void pwrOff(void); #define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown) -#define INTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_INT_RF_PWR) -#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_INT_RF_PWR) -#define EXTERNAL_RF_ON() GPIO_SetBits(GPIOPWR, PIN_EXT_RF_PWR) -#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIOPWR, PIN_EXT_RF_PWR) +#define INTERNAL_RF_ON() GPIO_SetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR) +#define INTERNAL_RF_OFF() GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR) +#define EXTERNAL_RF_ON() GPIO_SetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR) +#define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR) // Backlight driver #define setBacklight(xx) TIM10->CCR1 = 100-xx From 3a7f12232384281912579cea9437e385a3a031e7 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Tue, 29 Apr 2014 18:34:11 +0200 Subject: [PATCH 18/26] Backlight driver, totally untested. Backlight SF color not handled yet. --- radio/src/targets/taranis/board_taranis.cpp | 12 ++++++++++ radio/src/targets/taranis/board_taranis.h | 17 ++++++++++---- radio/src/targets/taranis/hal.h | 3 +++ radio/src/targets/taranis/lcd_driver.cpp | 25 +++++++++++++++++---- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/radio/src/targets/taranis/board_taranis.cpp b/radio/src/targets/taranis/board_taranis.cpp index dca639737..5efac5549 100644 --- a/radio/src/targets/taranis/board_taranis.cpp +++ b/radio/src/targets/taranis/board_taranis.cpp @@ -171,4 +171,16 @@ void boardInit() } #endif +#if defined(REVPLUS) +void turnBacklightOn(uint8_t level, uint8_t color) +{ + TIM4->CCR4 = (100-level)*color; + TIM4->CCR2 = (100-level)*(100-color); +} +void turnBacklightOff(void) +{ + TIM4->CCR4 = 0; + TIM4->CCR2 = 0; +} +#endif diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index adfed44b2..0e068f897 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -209,10 +209,19 @@ void pwrOff(void); #define EXTERNAL_RF_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR) // Backlight driver -#define setBacklight(xx) TIM10->CCR1 = 100-xx -#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright -#define __BACKLIGHT_OFF TIM10->CCR1 = 0 -#define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0) +#if defined(REVPLUS) +void turnBacklightOn(uint8_t level, uint8_t color); +void turnBacklightOff(void); + #define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor) + #define __BACKLIGHT_ON turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor) + #define __BACKLIGHT_OFF turnBacklightOff() + #define IS_BACKLIGHT_ON() (TIM4->CCR4 != 0) || (TIM4->CCR2 != 0) +#else + #define setBacklight(xx) TIM10->CCR1 = 100-xx + #define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright + #define __BACKLIGHT_OFF TIM10->CCR1 = 0 + #define IS_BACKLIGHT_ON() (TIM10->CCR1 != 0) +#endif // USB driver #define BOOTLOADER_REQUEST() (0) diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 7361b0e69..b823e63a2 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -241,13 +241,16 @@ #if defined (REVPLUS) #define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD #define GPIO_Pin_BL GPIO_Pin_15 //PD.15 + #define Pin_BL_AF GPIO_AF_TIM4 #define GPIOBL GPIOD #define GPIO_PinSource_BL GPIO_PinSource15 #define GPIO_Pin_BLW GPIO_Pin_13 //PD.13 + #define Pin_BLW_AF GPIO_AF_TIM4 #define GPIO_PinSource_BLW GPIO_PinSource13 #else #define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB #define GPIO_Pin_BL GPIO_Pin_8 //PB.08 + #define Pin_BL_AF GPIO_AF_TIM10 #define GPIOBL GPIOB #define GPIO_PinSource_BL GPIO_PinSource8 #endif diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 8de433294..4ba9b57ff 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -137,24 +137,41 @@ static void LCD_BL_Config() { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL; + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOBL, &GPIO_InitStructure); + GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF); - GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, GPIO_AF_TIM10); - +#if defined(REVPLUS) + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BLW; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOBL, &GPIO_InitStructure); + GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BLW_AF); + + RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock + TIM4->ARR = 100 ; + TIM4->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1; + TIM4->CCMR1 = 0x60 ; // PWM + TIM4->CCER = 1 ; + TIM4->CCR1 = 80; + TIM4->EGR = 0 ; + TIM4->CR1 = 1 ; +#else RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock TIM10->ARR = 100 ; TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1; TIM10->CCMR1 = 0x60 ; // PWM TIM10->CCER = 1 ; - TIM10->CCR1 = 80; TIM10->EGR = 0 ; TIM10->CR1 = 1 ; +#endif } /** Init the anolog spi gpio From aa733fa060875b8da70786aa36ab7821afb113cc Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 19:00:23 +0200 Subject: [PATCH 19/26] [Taranis+] LCD driver now ok --- radio/src/targets/taranis/lcd_driver.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 4ba9b57ff..33520e9fa 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -98,12 +98,12 @@ const uint8_t lcdPalette[4] = { 0, 0x03, 0x06, 0x0F }; #define LCD_WRITE_BIT(bit) \ if (bit) \ - GPIOD->BSRRL = PIN_LCD_MOSI; \ + LCD_MOSI_HIGH(); \ else \ - GPIOD->BSRRH = PIN_LCD_MOSI; \ - GPIOD->BSRRH = PIN_LCD_CLK; /* Clock low */ \ + LCD_MOSI_LOW(); \ + LCD_CLK_LOW(); \ __no_operation(); \ - GPIOD->BSRRL = PIN_LCD_CLK; /* Clock high */ + LCD_CLK_HIGH(); void lcdRefresh() { @@ -183,13 +183,15 @@ static void LCD_Hardware_Init() GPIO_InitTypeDef GPIO_InitStructure; /*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/ - GPIO_InitStructure.GPIO_Pin =PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0; + GPIO_InitStructure.GPIO_Pin = PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure); + LCD_NCS_HIGH(); + /*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/ GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; @@ -200,10 +202,6 @@ static void LCD_Hardware_Init() /*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/ GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure); } From c70da8878a5f7b65947abb7bd042378ece89c9c3 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 19:05:03 +0200 Subject: [PATCH 20/26] Cosmetics --- radio/src/translations/en.h.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 4567f804b..15adca40f 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -52,7 +52,7 @@ #define TR_NCHANNELS "\0014CH\0016CH\0018CH10CH12CH14CH16CH" #define LEN_VBEEPMODE "\005" -#define TR_VBEEPMODE "Quiet""Alarm""NoKey""All " +#define TR_VBEEPMODE "Quiet""Alarm""NoKey""All\0 " #define LEN_VBEEPLEN "\005" #define TR_VBEEPLEN "0====""=0===""==0==""===0=""====0" From 1c4eac406d08a81aa02cf083566a222bf1df731a Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 20:12:25 +0200 Subject: [PATCH 21/26] Cosmetics --- radio/src/targets/taranis/hal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index b823e63a2..4f84843a9 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -109,18 +109,18 @@ #if defined(REV3) #define GPIO_PIN_SW_D_H (~GPIOE->IDR) #define GPIO_PIN_SW_D_L (~GPIOE->IDR) - #define PIN_SW_D_H GPIO_Pin_9 //PE.09 - #define PIN_SW_D_L GPIO_Pin_8 //PE.08 + #define PIN_SW_D_H GPIO_Pin_9 //PE.09 + #define PIN_SW_D_L GPIO_Pin_8 //PE.08 #elif defined(REVPLUS) #define GPIO_PIN_SW_D_H (GPIOE->IDR) #define GPIO_PIN_SW_D_L (GPIOE->IDR) - #define PIN_SW_D_H GPIO_Pin_7 //PE.07 - #define PIN_SW_D_L GPIO_Pin_13 //PE.13 + #define PIN_SW_D_H GPIO_Pin_7 //PE.07 + #define PIN_SW_D_L GPIO_Pin_13 //PE.13 #else #define GPIO_PIN_SW_D_H GPIOE->IDR #define GPIO_PIN_SW_D_L GPIOB->IDR - #define PIN_SW_D_H GPIO_Pin_7 //PE.07 - #define PIN_SW_D_L GPIO_Pin_1 //PB.01 + #define PIN_SW_D_H GPIO_Pin_7 //PE.07 + #define PIN_SW_D_L GPIO_Pin_1 //PB.01 #endif #if defined(REV3) From aba29cb355bfc38286dff14b23f20dd921613b2d Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 20:13:03 +0200 Subject: [PATCH 22/26] Taranis+ switches driver fix --- radio/src/targets/taranis/keys_driver.cpp | 29 +++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/radio/src/targets/taranis/keys_driver.cpp b/radio/src/targets/taranis/keys_driver.cpp index d8e97524b..58673786d 100644 --- a/radio/src/targets/taranis/keys_driver.cpp +++ b/radio/src/targets/taranis/keys_driver.cpp @@ -230,14 +230,17 @@ bool switchState(EnumKeys enuk) void keysInit() { GPIO_InitTypeDef GPIO_InitStructure; - /* GPIOC GPIOD clock enable */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE); - /* GPIO Configuration*/ #if defined(REV3) GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP | PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_H; +#elif defined(REVPLUS) + GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L + | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP + | PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L; #else GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP @@ -249,29 +252,23 @@ void keysInit() GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOE, &GPIO_InitStructure); +#if defined(REVPLUS) + GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H; +#else GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; +#endif GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOC, &GPIO_InitStructure); #if defined(REV3) GPIO_InitStructure.GPIO_Pin = PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_G_L; +#elif defined(REVPLUS) + GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H; #else GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_D_L; #endif - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOB, &GPIO_InitStructure); #if defined(REV3) @@ -279,10 +276,6 @@ void keysInit() #else GPIO_InitStructure.GPIO_Pin = PIN_SW_C_L; #endif - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; GPIO_Init(GPIOA, &GPIO_InitStructure); } #endif From 1e0c549444cf0398824561941affcc190f4d4ff4 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 20:13:27 +0200 Subject: [PATCH 23/26] Taranis+ haptic driver fix --- radio/src/targets/taranis/lcd_driver.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index 33520e9fa..48ce626f7 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -157,11 +157,15 @@ static void LCD_BL_Config() RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock TIM4->ARR = 100 ; TIM4->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1; - TIM4->CCMR1 = 0x60 ; // PWM - TIM4->CCER = 1 ; - TIM4->CCR1 = 80; + TIM4->CCMR1 = TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2M_2 ; // PWM + TIM4->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2 ; // PWM + TIM4->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E ; + + int BacklightBrightness = 40 ; + TIM4->CCR2 = BacklightBrightness ; + TIM4->CCR4 = BacklightBrightness ; TIM4->EGR = 0 ; - TIM4->CR1 = 1 ; + TIM4->CR1 = TIM_CR1_CEN ; // Counter enable #else RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock TIM10->ARR = 100 ; From 0e4ff42d792aa887144f938759a1a4109023f42c Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 1 May 2014 20:24:54 +0200 Subject: [PATCH 24/26] Taranis+ bootloader - only one fix ;) --- radio/src/bootloader/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radio/src/bootloader/Makefile b/radio/src/bootloader/Makefile index 1e5fa0730..8ebc1362b 100644 --- a/radio/src/bootloader/Makefile +++ b/radio/src/bootloader/Makefile @@ -121,6 +121,8 @@ else CPPDEFS += -DREV3 else ifeq ($(PCBREV), REV4a) CPPDEFS += -DREV4a + else ifeq ($(PCBREV), REVPLUS) + CPPDEFS += -DREVPLUS else CPPDEFS += -DREV4 endif From 0e2647fa13663f06301f7c8a4fcf700cc2e61640 Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 11 May 2014 15:33:22 +0200 Subject: [PATCH 25/26] Warnings removed --- radio/src/targets/taranis/board_taranis.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index 0e068f897..5fd7d7bd6 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -143,8 +143,8 @@ void delay_01us(uint16_t nb); // Flash Write driver #define FLASH_PAGESIZE 256 -void unlockFlash(); -void lockFlash(); +void unlockFlash(void); +void lockFlash(void); void writeFlash(uint32_t * address, uint32_t * buffer); uint32_t isFirmwareStart(const void * buffer); uint32_t isBootloaderStart(const void * buffer); From 72a36b065ed656cd12c671078e5905549354025f Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 11 May 2014 15:49:18 +0200 Subject: [PATCH 26/26] PWM Haptic --- radio/src/targets/taranis/hal.h | 1 + radio/src/targets/taranis/haptic_driver.cpp | 31 ++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 4f84843a9..082e725c5 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -380,6 +380,7 @@ // Haptic #if defined(REVPLUS) #define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOB + #define GPIO_PinSource_HAPTIC GPIO_PinSource8 #define GPIO_HAPTIC GPIOB #define PIN_HAPTIC GPIO_Pin_8 #else diff --git a/radio/src/targets/taranis/haptic_driver.cpp b/radio/src/targets/taranis/haptic_driver.cpp index b459405c1..c6df245cd 100644 --- a/radio/src/targets/taranis/haptic_driver.cpp +++ b/radio/src/targets/taranis/haptic_driver.cpp @@ -39,8 +39,7 @@ void hapticOff(void) { #if defined(REVPLUS) - GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC); // Temp, TODO PWM support - return; + TIM10->CCR1 = 0; #else GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC); #endif @@ -48,9 +47,11 @@ void hapticOff(void) #if defined(REVPLUS) void hapticOn(uint32_t pwmPercent) -{ // pwmPercent 0-100 - GPIO_SetBits(GPIO_HAPTIC, PIN_HAPTIC); // Temp, TODO PWM support - return; +{ + if (pwmPercent > 100) { + pwmPercent = 100; + } + TIM10->CCR1 = pwmPercent; } #else void hapticOn() @@ -62,14 +63,24 @@ void hapticOn() void hapticInit(void) { - GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE); - - /* GPIO Configuration*/ + GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure); + + GPIO_PinAFConfig(GPIO_HAPTIC, GPIO_PinSource_HAPTIC, GPIO_AF_TIM10); + + RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock + TIM10->ARR = 100 ; + TIM10->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 10000 - 1; + TIM10->CCMR1 = TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 ; // PWM + TIM10->CCER = TIM_CCER_CC1E ; + + TIM10->CCR1 = 0 ; + TIM10->EGR = 0 ; + TIM10->CR1 = TIM_CR1_CEN ; // Counter enable }