diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index eeceb1d05..fd5ddce45 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -408,6 +408,8 @@ QString RawSwitch::toString() return QObject::tr("ON"); case SWITCH_TYPE_OFF: return QObject::tr("OFF"); + case SWITCH_TYPE_ONE: + return QObject::tr("One"); case SWITCH_TYPE_FLIGHT_MODE: return CHECK_IN_ARRAY(flightModes, index-1); case SWITCH_TYPE_NONE: diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 3db7660c5..a861210cb 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -385,6 +385,7 @@ enum RawSwitchType { SWITCH_TYPE_ROTARY_ENCODER, SWITCH_TYPE_ON, SWITCH_TYPE_OFF, + SWITCH_TYPE_ONE, SWITCH_TYPE_FLIGHT_MODE, SWITCH_TYPE_TIMER_MODE }; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 5915e3b24..a847dbe7c 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -89,12 +89,15 @@ class SwitchesConversionTable: public ConversionTable { if (!(flags & POPULATE_TIMER_MODES)) { addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset); addConversion(RawSwitch(SWITCH_TYPE_ON), val++); - } - - if (IS_ARM(board)) { - for (int i=1; i<=MAX_FLIGHT_MODES(board, version); i++) { - addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, -i), -val+offset); - addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i), val++); + if (version >= 216) { + addConversion(RawSwitch(SWITCH_TYPE_ONE, -1), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_ONE, 1), val++); + if (IS_ARM(board)) { + for (int i=1; i<=MAX_FLIGHT_MODES(board, version); i++) { + addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, -i), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i), val++); + } + } } } diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index d9d6fdde6..83516069f 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -400,6 +400,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin b->clear(); if (attr & POPULATE_ONOFF) { + // !FMx if (IS_ARM(GetCurrentFirmware()->getBoard())) { for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<0; i++) { item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i); @@ -407,6 +408,11 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin if (item == value) b->setCurrentIndex(b->count()-1); } } + // !One + item = RawSwitch(SWITCH_TYPE_ONE, 1); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + // OFF item = RawSwitch(SWITCH_TYPE_OFF); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); @@ -494,9 +500,15 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } if (attr & POPULATE_ONOFF) { + // ON item = RawSwitch(SWITCH_TYPE_ON); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); + // One + item = RawSwitch(SWITCH_TYPE_ONE, 1); + b->addItem(item.toString(), item.toValue()); + if (item == value) b->setCurrentIndex(b->count()-1); + // FMx if (IS_ARM(GetCurrentFirmware()->getBoard())) { for (int i=1; i<=GetCurrentFirmware()->getCapability(FlightModes); i++) { item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i); diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 72f770c56..b9cfd6eff 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -307,7 +307,7 @@ void getSwitchAudioFile(char * filename, int index) { char * str = getModelPath(filename); int len = STR_VSWITCHES[0]; - strncpy(str, &STR_VSWITCHES[1+len*index], len); + strncpy(str, &STR_VSWITCHES[1+len*(index+1)], len); str += len-1; if (*str == '\300') { strcpy(str, "-up"); @@ -331,7 +331,7 @@ void getLogicalSwitchAudioFile(char * filename, int index, unsigned int event) { char * str = getModelPath(filename); int len = STR_VSWITCHES[0]; - strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH-1)], len); + strncpy(str, &STR_VSWITCHES[1+len*(index+SWSRC_FIRST_LOGICAL_SWITCH)], len); str += len; strcpy(str, suffixes[event]); strcat(str, SOUNDS_EXT); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 70aff9bf7..1b3d6e1f3 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -1279,7 +1279,7 @@ void menuModelSetup(uint8_t event) else { if ((states & 0x01) && swactive) attr = INVERS; - c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*i)); + c = pgm_read_byte(STR_VSWITCHES - 2 + 9 + (3*(i+1))); states >>= 1; } if (line && (m_posHorz == i)) { diff --git a/radio/src/lcd.cpp b/radio/src/lcd.cpp index 1cb35c1f1..162a91d23 100644 --- a/radio/src/lcd.cpp +++ b/radio/src/lcd.cpp @@ -1042,22 +1042,18 @@ void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att) void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) { - if (idx == SWSRC_NONE) - return lcd_putsiAtt(x, y, STR_MMMINV, 0, att); - if (idx == SWSRC_ON) - return lcd_putsiAtt(x, y, STR_OFFON, 1, att); if (idx == SWSRC_OFF) return lcd_putsiAtt(x, y, STR_OFFON, 0, att); if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); - idx = -idx; + idx = 1-idx; } #if defined(CPUARM) && defined(FLIGHT_MODES) if (idx >= SWSRC_FIRST_FLIGHT_MODE) putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att); else #endif - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); + lcd_putsiAtt(x, y, STR_VSWITCHES, idx, att); } #if defined(FLIGHT_MODES) diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index efa89a1af..7a68b4b27 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1389,6 +1389,7 @@ enum SwitchSources { SWSRC_LAST_LOGICAL_SWITCH = SWSRC_FIRST_LOGICAL_SWITCH+NUM_LOGICAL_SWITCH-1, SWSRC_ON, + SWSRC_One, #if defined(CPUARM) SWSRC_FIRST_FLIGHT_MODE, diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 8dadc0d4d..2ec4a4d53 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -169,7 +169,10 @@ bool getSwitch(int8_t swtch) uint8_t cs_idx = abs(swtch); - if (cs_idx == SWSRC_ON) { + if (cs_idx == SWSRC_One) { + result = !s_mixer_first_run_done; + } + else if (cs_idx == SWSRC_ON) { result = true; } else if (cs_idx <= SWSRC_LAST_SWITCH) { diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index fdbb5b71b..753919e86 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -412,11 +412,11 @@ #if defined(PCBTARANIS) #define TR_6POS_POTS "S11""S12""S13""S14""S15""S16""S21""S22""S23""S24""S25""S26""S31""S32""S33""S34""S35""S36" - #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW + #define TR_VSWITCHES "---""SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One" #elif defined(CPUARM) - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One" #else - #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW + #define TR_VSWITCHES "---" TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0" "One" #endif #if defined(HELI)