1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Fixes #1205 - Delay only applied to Play family function, with a

configurable delay, between 0 and 300ms (default is 150ms).
This commit is contained in:
bsongis 2014-06-10 16:19:44 +02:00
parent 831cd81320
commit e4d03b8c70
10 changed files with 52 additions and 28 deletions

View file

@ -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;

View file

@ -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>());

View file

@ -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();
}

View file

@ -1977,7 +1977,7 @@ Mode 4:
</sizepolicy>
</property>
<property name="text">
<string>Switches Delay (mid position)</string>
<string>Play Delay (switch mid position)</string>
</property>
</widget>
</item>
@ -2004,7 +2004,7 @@ p, li { white-space: pre-wrap; }
<number>0</number>
</property>
<property name="maximum">
<number>250</number>
<number>300</number>
</property>
<property name="singleStep">
<number>10</number>

View file

@ -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

View file

@ -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,

View file

@ -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);

View file

@ -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();

View file

@ -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) {
#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

View file

@ -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"