Merge pull request #745 from opentx/bsongis/Issue650_precise_logical_switches_delays_durations
Issue #650 fixed - 0.1s precision in durations/delays for logical
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user