diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h
index 9f540ca7c..124625d97 100644
--- a/companion/src/eeprominterface.h
+++ b/companion/src/eeprominterface.h
@@ -516,7 +516,7 @@ class GeneralSettings {
unsigned int gpsFormat;
int speakerVolume;
unsigned int backlightBright;
- unsigned int switchesDelay;
+ int switchesDelay;
int currentCalib;
int temperatureCalib;
int temperatureWarn;
diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp
index 1acb9fb3e..a789decf1 100644
--- a/companion/src/firmwares/opentx/opentxeeprom.cpp
+++ b/companion/src/firmwares/opentx/opentxeeprom.cpp
@@ -2709,7 +2709,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
internalField.Append(new SignedField<2>((int &)generalData.hapticMode));
if (IS_ARM(board))
- internalField.Append(new UnsignedField<8>(generalData.switchesDelay));
+ internalField.Append(new SignedField<8>(generalData.switchesDelay));
else
internalField.Append(new SpareBitsField<8>());
diff --git a/companion/src/generaledit.cpp b/companion/src/generaledit.cpp
index c9e30be10..99b67a5ca 100644
--- a/companion/src/generaledit.cpp
+++ b/companion/src/generaledit.cpp
@@ -307,7 +307,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
}
if (IS_ARM(eepromInterface->getBoard())) {
- ui->switchesDelay->setValue(10*g_eeGeneral.switchesDelay);
+ ui->switchesDelay->setValue(10*(g_eeGeneral.switchesDelay+15));
}
else {
ui->switchesDelay->hide();
@@ -527,7 +527,7 @@ void GeneralEdit::on_backlightautoSB_editingFinished()
void GeneralEdit::on_switchesDelay_valueChanged()
{
- g_eeGeneral.switchesDelay = ui->switchesDelay->value() / 10;
+ g_eeGeneral.switchesDelay = (ui->switchesDelay->value() / 10) - 15;
updateSettings();
}
diff --git a/companion/src/generaledit.ui b/companion/src/generaledit.ui
index e9dbb4759..9943a015e 100644
--- a/companion/src/generaledit.ui
+++ b/companion/src/generaledit.ui
@@ -1977,7 +1977,7 @@ Mode 4:
- Switches Delay (mid position)
+ Play Delay (switch mid position)
@@ -2004,7 +2004,7 @@ p, li { white-space: pre-wrap; }
0
- 250
+ 300
10
diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp
index caa28a008..3ce5166fe 100644
--- a/radio/src/gui/menu_general.cpp
+++ b/radio/src/gui/menu_general.cpp
@@ -406,7 +406,7 @@ void menuGeneralSetup(uint8_t event)
case ITEM_SETUP_VARIO_REPEAT:
lcd_putsLeft(y, STR_REPEAT_AT_ZERO);
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT);
- lcd_putsAtt(lcdLastPos, y, "ms", attr);
+ lcd_putsAtt(lcdLastPos, y, STR_MS, attr);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50);
break;
#endif
@@ -624,10 +624,10 @@ void menuGeneralSetup(uint8_t event)
#if defined(CPUARM)
case ITEM_SETUP_SWITCHES_DELAY:
- lcd_putsLeft(y, "Switches Delay");
- lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*g_eeGeneral.switchesDelay, attr|LEFT);
- lcd_putsAtt(lcdLastPos, y, "ms", attr);
- if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, 0, 25);
+ lcd_putsLeft(y, STR_SWITCHES_DELAY);
+ lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT);
+ lcd_putsAtt(lcdLastPos, y, STR_MS, attr);
+ if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, +15);
break;
#endif
diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h
index 22f41ed9c..cb31ac0de 100644
--- a/radio/src/myeeprom.h
+++ b/radio/src/myeeprom.h
@@ -417,7 +417,7 @@ PACK(typedef struct t_EEGeneral {
int8_t hapticMode:2; // -2=quiet, -1=only alarms, 0=no keys, 1=all
AVR_FIELD(uint8_t blOffBright:4)
AVR_FIELD(uint8_t blOnBright:4)
- ARM_FIELD(uint8_t switchesDelay)
+ ARM_FIELD(int8_t switchesDelay)
uint8_t lightAutoOff;
uint8_t templateSetup; // RETA order for receiver channels
int8_t PPM_Multiplier;
@@ -439,6 +439,8 @@ PACK(typedef struct t_EEGeneral {
}) EEGeneral;
+#define SWITCHES_DELAY() uint8_t(15+g_eeGeneral.switchesDelay)
+#define SWITCHES_DELAY_NONE (-15)
#define HAPTIC_STRENGTH() (3+g_eeGeneral.hapticStrength)
#if defined(PCBTARANIS)
@@ -839,33 +841,35 @@ enum Functions {
FUNC_MAX
};
-#define HAS_ENABLE_PARAM(func) (func < FUNC_FIRST_WITHOUT_ENABLE)
+#define HAS_ENABLE_PARAM(func) ((func) < FUNC_FIRST_WITHOUT_ENABLE)
+
+#if defined(VOICE)
+ #define IS_PLAY_FUNC(func) ((func) >= FUNC_PLAY_SOUND && func <= FUNC_PLAY_VALUE)
+#else
+ #define IS_PLAY_FUNC(func) ((func) == FUNC_PLAY_SOUND)
+#endif
#if defined(CPUARM)
#define IS_PLAY_BOTH_FUNC(func) (0)
- #define IS_VOLUME_FUNC(func) (func == FUNC_VOLUME)
+ #define IS_VOLUME_FUNC(func) ((func) == FUNC_VOLUME)
#else
- #define IS_PLAY_BOTH_FUNC(func) (func == FUNC_PLAY_BOTH)
+ #define IS_PLAY_BOTH_FUNC(func) ((func) == FUNC_PLAY_BOTH)
#define IS_VOLUME_FUNC(func) (0)
#endif
#if defined(GVARS)
- #define IS_ADJUST_GV_FUNC(func) (func == FUNC_ADJUST_GVAR)
+ #define IS_ADJUST_GV_FUNC(func) ((func) == FUNC_ADJUST_GVAR)
#else
#define IS_ADJUST_GV_FUNC(func) (0)
#endif
#if defined(HAPTIC)
- #define IS_HAPTIC_FUNC(func) (func == FUNC_HAPTIC)
+ #define IS_HAPTIC_FUNC(func) ((func) == FUNC_HAPTIC)
#else
#define IS_HAPTIC_FUNC(func) (0)
#endif
-#if defined(VOICE)
- #define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND || (func >= FUNC_PLAY_TRACK && func <= FUNC_PLAY_VALUE) || IS_HAPTIC_FUNC(func))
-#else
- #define HAS_REPEAT_PARAM(func) (func == FUNC_PLAY_SOUND || IS_HAPTIC_FUNC(func))
-#endif
+#define HAS_REPEAT_PARAM(func) (IS_PLAY_FUNC(func) || IS_HAPTIC_FUNC(func))
enum ResetFunctionParam {
FUNC_RESET_TIMER1,
diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp
index 30c28b957..24d986f85 100644
--- a/radio/src/opentx.cpp
+++ b/radio/src/opentx.cpp
@@ -1830,7 +1830,12 @@ void evalFunctions()
if (swtch) {
MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i);
+#if defined(CPUARM)
+ bool active = getSwitch(swtch, IS_PLAY_FUNC(CFN_FUNC(sd)) ? GETSWITCH_MIDPOS_DELAY : 0);
+#else
bool active = getSwitch(swtch);
+#endif
+
if (HAS_ENABLE_PARAM(CFN_FUNC(sd))) {
active &= (bool)CFN_ACTIVE(sd);
diff --git a/radio/src/opentx.h b/radio/src/opentx.h
index cbf3d4f93..811db7c84 100644
--- a/radio/src/opentx.h
+++ b/radio/src/opentx.h
@@ -696,7 +696,14 @@ void perMain();
NOINLINE void per10ms();
getvalue_t getValue(uint8_t i);
+
+#if defined(CPUARM)
+#define GETSWITCH_MIDPOS_DELAY 1
+bool getSwitch(int8_t swtch, uint8_t flags=0);
+#else
bool getSwitch(int8_t swtch);
+#endif
+
void logicalSwitchesTimerTick();
void logicalSwitchesReset();
diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp
index c2a82473a..77508c50a 100644
--- a/radio/src/switches.cpp
+++ b/radio/src/switches.cpp
@@ -111,7 +111,7 @@ uint32_t check3PosSwitchPosition(uint8_t idx, EnumKeys sw, bool startup)
result = (1 << index);
switchesMidposStart[idx] = 0;
}
- else if (startup || (switchesPos & (1 << (sw - SW_SA0 + 1))) || g_eeGeneral.switchesDelay==0 || (switchesMidposStart[idx] && (tmr10ms_t)(get_tmr10ms() - switchesMidposStart[idx]) > g_eeGeneral.switchesDelay)) {
+ else if (startup || (switchesPos & (1 << (sw - SW_SA0 + 1))) || g_eeGeneral.switchesDelay==SWITCHES_DELAY_NONE || (switchesMidposStart[idx] && (tmr10ms_t)(get_tmr10ms() - switchesMidposStart[idx]) > SWITCHES_DELAY())) {
index = sw - SW_SA0 + 1;
result = (1 << index);
switchesMidposStart[idx] = 0;
@@ -158,7 +158,7 @@ void getSwitchesPosition(bool startup)
potsLastposStart[i] = get_tmr10ms();
potsPos[i] = (pos << 4) | previousStoredPos;
}
- else if (startup || g_eeGeneral.switchesDelay==0 || (tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > g_eeGeneral.switchesDelay) {
+ else if (startup || g_eeGeneral.switchesDelay==SWITCHES_DELAY_NONE || (tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > SWITCHES_DELAY()) {
potsLastposStart[i] = 0;
potsPos[i] = (pos << 4) | pos;
if (previousStoredPos != pos) {
@@ -171,8 +171,6 @@ void getSwitchesPosition(bool startup)
}
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
#define POT_POSITION(sw) ((potsPos[(sw)/XPOTS_MULTIPOS_COUNT] & 0x0f) == ((sw) % XPOTS_MULTIPOS_COUNT))
-#else
-#define SWITCH_POSITION(idx) switchState((EnumKeys)(SW_BASE+(idx)))
#endif
bool getLogicalSwitch(uint8_t idx)
@@ -369,7 +367,11 @@ bool getLogicalSwitch(uint8_t idx)
return result;
}
+#if defined(CPUARM)
+bool getSwitch(int8_t swtch, uint8_t flags)
+#else
bool getSwitch(int8_t swtch)
+#endif
{
bool result;
@@ -385,7 +387,13 @@ bool getSwitch(int8_t swtch)
result = true;
}
else if (cs_idx <= SWSRC_LAST_SWITCH) {
- result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
+#if defined(PCBTARANIS)
+ if (flags & GETSWITCH_MIDPOS_DELAY)
+ result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
+ else
+#endif
+ result = switchState((EnumKeys)(SW_BASE+cs_idx-SWSRC_FIRST_SWITCH));
+
#if defined(MODULE_ALWAYS_SEND_PULSES)
if (startupWarningState < STARTUP_WARNING_DONE) {
// if throttle or switch warning is currently active, ignore actual stick position and use wanted values
diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt
index e9a4c45ec..141c44d2d 100644
--- a/radio/src/translations/en.h.txt
+++ b/radio/src/translations/en.h.txt
@@ -579,7 +579,7 @@
#define TR_POTWARNING TR(IF_CPUARM(INDENT) "Pot Warn.", INDENT "Pot Positions")
#define TR_TIMEZONE TR("Time Zone", "GPS Time zone")
#define TR_RXCHANNELORD TR("Rx Channel Ord", "Default channel order")
-#define TR_SWITCHES_DELAY "Switches Delay"
+#define TR_SWITCHES_DELAY "Play Delay (sw. mid pos)"
#define TR_SLAVE CENTER "Slave"
#define TR_MODESRC "Mode\006% Source"
#define TR_MULTIPLIER "Multiplier"