diff --git a/companion/src/eepromimportexport.h b/companion/src/eepromimportexport.h index 91eda318c..242c1f7f7 100644 --- a/companion/src/eepromimportexport.h +++ b/companion/src/eepromimportexport.h @@ -650,12 +650,14 @@ class ConversionField: public TransformedField { if (!error.isEmpty()) EEPROMWarnings += error + "\n"; } - else if (shift) { + + if (shift) { if (val < min) _field = min + shift; else if (val > max) _field = max + shift; else _field = val + shift; } - else { + + if (exportFunc) { _field = exportFunc(val); } } @@ -666,10 +668,10 @@ class ConversionField: public TransformedField { if (table->importValue(_field, field)) return; } - else if (shift) { - field = _field - shift; - } - else { + + field = _field - shift; + + if (importFunc) { field = importFunc(_field); } diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 749a54d70..19185142b 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -541,9 +541,9 @@ QString LogicalSwitchData::toString(const ModelData & model) if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { if (delay) - result += QObject::tr(" Delay %1 sec").arg(delay/2.0); + result += QObject::tr(" Delay %1 sec").arg(delay/10.0); if (duration) - result += QObject::tr(" Duration %1 sec").arg(duration/2.0); + result += QObject::tr(" Duration %1 sec").arg(duration/10.0); } return result; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 5adaba1c8..de08d6abb 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1198,8 +1198,9 @@ class LogicalSwitchField: public TransformedField { if (IS_ARM(board)) { internalField.Append(new ConversionField< UnsignedField<8> >(csw.func, &functionsConversionTable, "Function")); - internalField.Append(new UnsignedField<8>(csw.delay)); - internalField.Append(new UnsignedField<8>(csw.duration)); + int scale = (version >= 216 ? 0 : 5); + internalField.Append(new ConversionField< UnsignedField<8> >(csw.delay, 0, scale)); + internalField.Append(new ConversionField< UnsignedField<8> >(csw.duration, 0, scale)); if (version >= 214) { internalField.Append(new ConversionField< SignedField<8> >((int &)csw.andsw, andswitchesConversionTable, "AND switch")); } diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index d86a1a487..d965c772c 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -85,8 +85,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): // Duration cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i]->setProperty("index", i); - cswitchDuration[i]->setSingleStep(0.5); - cswitchDuration[i]->setMaximum(50); + cswitchDuration[i]->setSingleStep(0.1); + cswitchDuration[i]->setMaximum(25); cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setDecimals(1); @@ -96,8 +96,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): // Delay cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i]->setProperty("index", i); - cswitchDelay[i]->setSingleStep(0.5); - cswitchDelay[i]->setMaximum(50); + cswitchDelay[i]->setSingleStep(0.1); + cswitchDelay[i]->setMaximum(25); cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setDecimals(1); @@ -164,14 +164,14 @@ void LogicalSwitchesPanel::andEdited(int value) void LogicalSwitchesPanel::durationEdited(double duration) { int index = sender()->property("index").toInt(); - model.customSw[index].duration = (uint8_t)round(duration*2); + model.customSw[index].duration = (uint8_t)round(duration*10); emit modified(); } void LogicalSwitchesPanel::delayEdited(double delay) { int index = sender()->property("index").toInt(); - model.customSw[index].delay = (uint8_t)round(delay*2); + model.customSw[index].delay = (uint8_t)round(delay*10); emit modified(); } @@ -325,8 +325,8 @@ void LogicalSwitchesPanel::update() lock = true; populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw)); if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { - cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); - cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); + cswitchDuration[i]->setValue(model.customSw[i].duration/10.0); + cswitchDelay[i]->setValue(model.customSw[i].delay/10.0); } lock = false; } diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 6079c5b30..32ee65bed 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -471,8 +471,8 @@ void ConvertModel_215_to_216(ModelData &model) if (sw.func >= LS_FUNC_STAY) sw.func += 1; sw.v1 = oldModel.customSw[i].v1; sw.v2 = oldModel.customSw[i].v2; - sw.delay = oldModel.customSw[i].delay; - sw.duration = oldModel.customSw[i].duration; + sw.delay = oldModel.customSw[i].delay * 5; + sw.duration = oldModel.customSw[i].duration * 5; sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw); #if defined(PCBTARANIS) uint8_t cstate = cswFamily(sw.func); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index c445eed28..f5128f20e 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4379,7 +4379,7 @@ void menuModelLogicalSwitchOne(uint8_t event) case LS_FIELD_DURATION: lcd_putsLeft(y, STR_DURATION); if (cs->duration > 0) - lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->duration, attr|PREC1|LEFT); + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->duration, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); @@ -4387,7 +4387,7 @@ void menuModelLogicalSwitchOne(uint8_t event) case LS_FIELD_DELAY: lcd_putsLeft(y, STR_DELAY); if (cs->delay > 0) - lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->delay, attr|PREC1|LEFT); + lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->delay, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); @@ -4677,7 +4677,7 @@ void menuModelLogicalSwitches(uint8_t event) #if defined(CPUARM) // CSW duration if (cs->duration > 0) - lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); @@ -4689,7 +4689,7 @@ void menuModelLogicalSwitches(uint8_t event) } } else if (cs->delay > 0) { - lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 700307ba7..11e8ce8a2 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -719,8 +719,8 @@ enum LogicalSwitchesFunctions { }; #if defined(CPUARM) -#define MAX_LS_DURATION 120 /*60s*/ -#define MAX_LS_DELAY 120 /*60s*/ +#define MAX_LS_DURATION 250 /*25s*/ +#define MAX_LS_DELAY 250 /*25s*/ #define MAX_LS_ANDSW SWSRC_LAST typedef int16_t ls_telemetry_value_t; PACK(typedef struct t_LogicalSwitchData { // Custom Switches data diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index f60faeba7..c33cebcdb 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1634,13 +1634,13 @@ bool getSwitch(int8_t swtch) result = false; } else { - cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50); + cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*10); } } if (cs->duration) { if (result && !cswStates[cs_idx]) { - cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*50); + cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*10); } cswStates[cs_idx] = result;