mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-25 17:25:10 +03:00
Issue #650 fixed - 0.1s precision in durations/delays for logical
switches
This commit is contained in:
parent
c98e718e16
commit
56d167e45f
6 changed files with 18 additions and 18 deletions
|
@ -539,9 +539,9 @@ QString LogicalSwitchData::toString(const ModelData & model)
|
||||||
|
|
||||||
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
||||||
if (delay)
|
if (delay)
|
||||||
result += QObject::tr(" Delay %1 sec").arg(delay/2.0);
|
result += QObject::tr(" Delay %1 sec").arg(delay/10.0);
|
||||||
if (duration)
|
if (duration)
|
||||||
result += QObject::tr(" Duration %1 sec").arg(duration/2.0);
|
result += QObject::tr(" Duration %1 sec").arg(duration/10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -85,8 +85,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
// Duration
|
// Duration
|
||||||
cswitchDuration[i] = new QDoubleSpinBox(this);
|
cswitchDuration[i] = new QDoubleSpinBox(this);
|
||||||
cswitchDuration[i]->setProperty("index", i);
|
cswitchDuration[i]->setProperty("index", i);
|
||||||
cswitchDuration[i]->setSingleStep(0.5);
|
cswitchDuration[i]->setSingleStep(0.1);
|
||||||
cswitchDuration[i]->setMaximum(50);
|
cswitchDuration[i]->setMaximum(25);
|
||||||
cswitchDuration[i]->setMinimum(0);
|
cswitchDuration[i]->setMinimum(0);
|
||||||
cswitchDuration[i]->setAccelerated(true);
|
cswitchDuration[i]->setAccelerated(true);
|
||||||
cswitchDuration[i]->setDecimals(1);
|
cswitchDuration[i]->setDecimals(1);
|
||||||
|
@ -96,8 +96,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
|
||||||
// Delay
|
// Delay
|
||||||
cswitchDelay[i] = new QDoubleSpinBox(this);
|
cswitchDelay[i] = new QDoubleSpinBox(this);
|
||||||
cswitchDelay[i]->setProperty("index", i);
|
cswitchDelay[i]->setProperty("index", i);
|
||||||
cswitchDelay[i]->setSingleStep(0.5);
|
cswitchDelay[i]->setSingleStep(0.1);
|
||||||
cswitchDelay[i]->setMaximum(50);
|
cswitchDelay[i]->setMaximum(25);
|
||||||
cswitchDelay[i]->setMinimum(0);
|
cswitchDelay[i]->setMinimum(0);
|
||||||
cswitchDelay[i]->setAccelerated(true);
|
cswitchDelay[i]->setAccelerated(true);
|
||||||
cswitchDelay[i]->setDecimals(1);
|
cswitchDelay[i]->setDecimals(1);
|
||||||
|
@ -164,14 +164,14 @@ void LogicalSwitchesPanel::andEdited(int value)
|
||||||
void LogicalSwitchesPanel::durationEdited(double duration)
|
void LogicalSwitchesPanel::durationEdited(double duration)
|
||||||
{
|
{
|
||||||
int index = sender()->property("index").toInt();
|
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();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogicalSwitchesPanel::delayEdited(double delay)
|
void LogicalSwitchesPanel::delayEdited(double delay)
|
||||||
{
|
{
|
||||||
int index = sender()->property("index").toInt();
|
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();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,8 +325,8 @@ void LogicalSwitchesPanel::update()
|
||||||
lock = true;
|
lock = true;
|
||||||
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
|
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
|
||||||
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
|
||||||
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
|
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
|
||||||
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
|
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
|
||||||
}
|
}
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -470,8 +470,8 @@ void ConvertModel_215_to_216(ModelData &model)
|
||||||
if (sw.func >= LS_FUNC_STAY) sw.func += 1;
|
if (sw.func >= LS_FUNC_STAY) sw.func += 1;
|
||||||
sw.v1 = oldModel.customSw[i].v1;
|
sw.v1 = oldModel.customSw[i].v1;
|
||||||
sw.v2 = oldModel.customSw[i].v2;
|
sw.v2 = oldModel.customSw[i].v2;
|
||||||
sw.delay = oldModel.customSw[i].delay;
|
sw.delay = oldModel.customSw[i].delay * 5;
|
||||||
sw.duration = oldModel.customSw[i].duration;
|
sw.duration = oldModel.customSw[i].duration * 5;
|
||||||
sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw);
|
sw.andsw = ConvertSwitch_215_to_216(oldModel.customSw[i].andsw);
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
uint8_t cstate = cswFamily(sw.func);
|
uint8_t cstate = cswFamily(sw.func);
|
||||||
|
|
|
@ -4363,7 +4363,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
case LS_FIELD_DURATION:
|
case LS_FIELD_DURATION:
|
||||||
lcd_putsLeft(y, STR_DURATION);
|
lcd_putsLeft(y, STR_DURATION);
|
||||||
if (cs->duration > 0)
|
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
|
else
|
||||||
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
|
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
|
||||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION);
|
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION);
|
||||||
|
@ -4371,7 +4371,7 @@ void menuModelLogicalSwitchOne(uint8_t event)
|
||||||
case LS_FIELD_DELAY:
|
case LS_FIELD_DELAY:
|
||||||
lcd_putsLeft(y, STR_DELAY);
|
lcd_putsLeft(y, STR_DELAY);
|
||||||
if (cs->delay > 0)
|
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
|
else
|
||||||
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
|
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr);
|
||||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY);
|
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY);
|
||||||
|
|
|
@ -712,8 +712,8 @@ enum LogicalSwitchesFunctions {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CPUARM)
|
#if defined(CPUARM)
|
||||||
#define MAX_LS_DURATION 120 /*60s*/
|
#define MAX_LS_DURATION 250 /*25s*/
|
||||||
#define MAX_LS_DELAY 120 /*60s*/
|
#define MAX_LS_DELAY 250 /*25s*/
|
||||||
#define MAX_LS_ANDSW SWSRC_LAST
|
#define MAX_LS_ANDSW SWSRC_LAST
|
||||||
typedef int16_t ls_telemetry_value_t;
|
typedef int16_t ls_telemetry_value_t;
|
||||||
PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
|
PACK(typedef struct t_LogicalSwitchData { // Custom Switches data
|
||||||
|
|
|
@ -1589,13 +1589,13 @@ bool getSwitch(int8_t swtch)
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50);
|
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs->duration) {
|
if (cs->duration) {
|
||||||
if (result && !cswStates[cs_idx]) {
|
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;
|
cswStates[cs_idx] = result;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue