mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
parent
6609481c23
commit
31d734d14a
7 changed files with 70 additions and 38 deletions
|
@ -109,7 +109,8 @@ class LimitData {
|
||||||
int offset;
|
int offset;
|
||||||
int ppmCenter;
|
int ppmCenter;
|
||||||
bool symetrical;
|
bool symetrical;
|
||||||
char name[LIMITDATA_NAME_LEN+1];
|
int failsafe;
|
||||||
|
char name[LIMITDATA_NAME_LEN + 1];
|
||||||
CurveReference curve;
|
CurveReference curve;
|
||||||
QString minToString() const;
|
QString minToString() const;
|
||||||
QString maxToString() const;
|
QString maxToString() const;
|
||||||
|
|
|
@ -1174,8 +1174,7 @@ void ModelData::updateModuleFailsafes(ModuleData * md)
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
|
||||||
switch (updRefInfo.action)
|
switch (updRefInfo.action) {
|
||||||
{
|
|
||||||
case REF_UPD_ACT_CLEAR:
|
case REF_UPD_ACT_CLEAR:
|
||||||
break;
|
break;
|
||||||
case REF_UPD_ACT_SHIFT:
|
case REF_UPD_ACT_SHIFT:
|
||||||
|
@ -1183,16 +1182,16 @@ void ModelData::updateModuleFailsafes(ModuleData * md)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (updRefInfo.shift > 0) {
|
if (updRefInfo.shift > 0) {
|
||||||
for (int i = (CPN_MAX_CHNOUT - 1); i > updRefInfo.index1; i--) {
|
for (int i = CPN_MAX_CHNOUT - 1; i > updRefInfo.index1; i--) {
|
||||||
md->failsafeChannels[i] = md->failsafeChannels[i - 1];
|
limitData[i].failsafe = limitData[i - 1].failsafe;
|
||||||
}
|
}
|
||||||
md->failsafeChannels[updRefInfo.index1] = 0;
|
limitData[updRefInfo.index1].failsafe = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = (updRefInfo.index1 + 1); i < (CPN_MAX_CHNOUT - 1); i++) {
|
for (int i = updRefInfo.index1 + 1; i < CPN_MAX_CHNOUT - 1; i++) {
|
||||||
md->failsafeChannels[i - 1] = md->failsafeChannels[i];
|
limitData[i - 1].failsafe = limitData[i].failsafe;
|
||||||
}
|
}
|
||||||
md->failsafeChannels[CPN_MAX_CHNOUT - 1] = 0;
|
limitData[CPN_MAX_CHNOUT - 1].failsafe = 0;
|
||||||
}
|
}
|
||||||
updated = true;
|
updated = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1200,17 +1199,18 @@ void ModelData::updateModuleFailsafes(ModuleData * md)
|
||||||
int tmp;
|
int tmp;
|
||||||
if (updRefInfo.index1 >= 0 && updRefInfo.index1 < CPN_MAX_CHNOUT) {
|
if (updRefInfo.index1 >= 0 && updRefInfo.index1 < CPN_MAX_CHNOUT) {
|
||||||
updated = true;
|
updated = true;
|
||||||
tmp = md->failsafeChannels[updRefInfo.index1];
|
tmp = limitData[updRefInfo.index1].failsafe;
|
||||||
if (updRefInfo.index2 >= 0 && updRefInfo.index2 < CPN_MAX_CHNOUT)
|
if (updRefInfo.index2 >= 0 && updRefInfo.index2 < CPN_MAX_CHNOUT)
|
||||||
md->failsafeChannels[updRefInfo.index1] = md->failsafeChannels[updRefInfo.index2];
|
limitData[updRefInfo.index1].failsafe = limitData[updRefInfo.index2].failsafe;
|
||||||
else
|
else
|
||||||
md->failsafeChannels[updRefInfo.index1] = 0;
|
limitData[updRefInfo.index1].failsafe = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
if (updRefInfo.index2 >= 0 && updRefInfo.index2 < CPN_MAX_CHNOUT)
|
if (updRefInfo.index2 >= 0 && updRefInfo.index2 < CPN_MAX_CHNOUT) {
|
||||||
updated = true;
|
updated = true;
|
||||||
md->failsafeChannels[updRefInfo.index2] = tmp;
|
limitData[updRefInfo.index2].failsafe = tmp;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Error - unhandled action:" << updRefInfo.action;
|
qDebug() << "Error - unhandled action:" << updRefInfo.action;
|
||||||
|
|
|
@ -158,7 +158,11 @@ class ModuleData {
|
||||||
Q_DECLARE_TR_FUNCTIONS(ModuleData)
|
Q_DECLARE_TR_FUNCTIONS(ModuleData)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModuleData() { clear(); }
|
ModuleData()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int modelId;
|
unsigned int modelId;
|
||||||
unsigned int protocol; // type in datastructs.h
|
unsigned int protocol; // type in datastructs.h
|
||||||
int rfProtocol; // rfProtocol in datastructs.h
|
int rfProtocol; // rfProtocol in datastructs.h
|
||||||
|
@ -168,7 +172,6 @@ class ModuleData {
|
||||||
unsigned int channelsStart;
|
unsigned int channelsStart;
|
||||||
int channelsCount; // 0=8 channels
|
int channelsCount; // 0=8 channels
|
||||||
unsigned int failsafeMode;
|
unsigned int failsafeMode;
|
||||||
int failsafeChannels[CPN_MAX_CHNOUT];
|
|
||||||
|
|
||||||
struct PPM {
|
struct PPM {
|
||||||
int delay;
|
int delay;
|
||||||
|
|
|
@ -2184,7 +2184,7 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||||
|
|
||||||
class ModuleField: public TransformedField {
|
class ModuleField: public TransformedField {
|
||||||
public:
|
public:
|
||||||
ModuleField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version):
|
ModuleField(DataField * parent, ModuleData & module, ModelData & model, Board::Type board, unsigned int version):
|
||||||
TransformedField(parent, internalField),
|
TransformedField(parent, internalField),
|
||||||
internalField(this, "Module"),
|
internalField(this, "Module"),
|
||||||
module(module),
|
module(module),
|
||||||
|
@ -2198,8 +2198,8 @@ class ModuleField: public TransformedField {
|
||||||
internalField.Append(new UnsignedField<3>(this, module.subType));
|
internalField.Append(new UnsignedField<3>(this, module.subType));
|
||||||
internalField.Append(new BoolField<1>(this, module.invertedSerial));
|
internalField.Append(new BoolField<1>(this, module.invertedSerial));
|
||||||
if (version <= 218) {
|
if (version <= 218) {
|
||||||
for (int i=0; i<32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
internalField.Append(new SignedField<16>(this, module.failsafeChannels[i]));
|
internalField.Append(new SignedField<16>(this, model.limitData[i].failsafe));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2393,12 +2393,12 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig
|
||||||
|
|
||||||
int modulesCount = (version <= 218 ? 3 : 2);
|
int modulesCount = (version <= 218 ? 3 : 2);
|
||||||
for (int module = 0; module < modulesCount; module++) {
|
for (int module = 0; module < modulesCount; module++) {
|
||||||
internalField.Append(new ModuleField(this, modelData.moduleData[module], board, version));
|
internalField.Append(new ModuleField(this, modelData.moduleData[module], modelData, board, version));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version >= 219) {
|
if (version >= 219) {
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
internalField.Append(new SignedField<16>(this, modelData.moduleData[0].failsafeChannels[i]));
|
internalField.Append(new SignedField<16>(this, modelData.limitData[i].failsafe));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -792,18 +792,22 @@ void ModulePanel::on_lowPower_stateChanged(int state)
|
||||||
module.multi.lowPowerMode = (state == Qt::Checked);
|
module.multi.lowPowerMode = (state == Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
// updtSb (update spin box(es)): 0=none or bitmask of FailsafeValueDisplayTypes
|
void ModulePanel::onFailsafeModified(unsigned channel)
|
||||||
void ModulePanel::setChannelFailsafeValue(const int channel, const int value, quint8 updtSb)
|
|
||||||
{
|
{
|
||||||
if (channel < 0 || channel >= CPN_MAX_CHNOUT)
|
updateFailsafeUI(channel, FAILSAFE_DISPLAY_PERCENT | FAILSAFE_DISPLAY_USEC);
|
||||||
return;
|
}
|
||||||
|
|
||||||
module.failsafeChannels[channel] = value;
|
void ModulePanel::updateFailsafeUI(unsigned channel, quint8 updtSb)
|
||||||
|
{
|
||||||
|
int value = model->limitData[channel].failsafe;
|
||||||
double pctVal = divRoundClosest(value * 1000, 1024) / 10.0;
|
double pctVal = divRoundClosest(value * 1000, 1024) / 10.0;
|
||||||
// qDebug() << value << pctVal;
|
|
||||||
|
|
||||||
if (failsafeGroupsMap.contains(channel)) {
|
if (failsafeGroupsMap.contains(channel)) {
|
||||||
const ChannelFailsafeWidgetsGroup & grp = failsafeGroupsMap.value(channel);
|
const ChannelFailsafeWidgetsGroup & grp = failsafeGroupsMap.value(channel);
|
||||||
|
bool disable = (value == FAILSAFE_CHANNEL_HOLD || value == FAILSAFE_CHANNEL_NOPULSE);
|
||||||
|
if (grp.combo) {
|
||||||
|
grp.combo->setCurrentIndex(grp.combo->findData(disable ? value : 0));
|
||||||
|
}
|
||||||
if ((updtSb & FAILSAFE_DISPLAY_PERCENT) && grp.sbPercent) {
|
if ((updtSb & FAILSAFE_DISPLAY_PERCENT) && grp.sbPercent) {
|
||||||
grp.sbPercent->blockSignals(true);
|
grp.sbPercent->blockSignals(true);
|
||||||
grp.sbPercent->setValue(pctVal);
|
grp.sbPercent->setValue(pctVal);
|
||||||
|
@ -815,8 +819,21 @@ void ModulePanel::setChannelFailsafeValue(const int channel, const int value, qu
|
||||||
grp.sbUsec->blockSignals(false);
|
grp.sbUsec->blockSignals(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!lock)
|
}
|
||||||
|
|
||||||
|
// updtSb (update spin box(es)): 0=none or bitmask of FailsafeValueDisplayTypes
|
||||||
|
void ModulePanel::setChannelFailsafeValue(const int channel, const int value, quint8 updtSb)
|
||||||
|
{
|
||||||
|
if (channel < 0 || channel >= CPN_MAX_CHNOUT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
model->limitData[channel].failsafe = value;
|
||||||
|
updateFailsafeUI(channel, updtSb);
|
||||||
|
|
||||||
|
if (!lock) {
|
||||||
|
emit failsafeModified(channel);
|
||||||
emit modified();
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::onFailsafeUsecChanged(int value)
|
void ModulePanel::onFailsafeUsecChanged(int value)
|
||||||
|
@ -853,8 +870,9 @@ void ModulePanel::onFailsafeComboIndexChanged(int index)
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int channel = sender()->property("index").toInt(&ok);
|
int channel = sender()->property("index").toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
module.failsafeChannels[channel] = cb->itemData(index).toInt();
|
model->limitData[channel].failsafe = cb->itemData(index).toInt();
|
||||||
updateFailsafe(channel);
|
updateFailsafe(channel);
|
||||||
|
emit failsafeModified(channel);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
lock = false;
|
lock = false;
|
||||||
|
@ -886,12 +904,12 @@ void ModulePanel::onExtendedLimitsToggled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::updateFailsafe(int channel)
|
void ModulePanel::updateFailsafe(unsigned channel)
|
||||||
{
|
{
|
||||||
if (channel >= CPN_MAX_CHNOUT || !failsafeGroupsMap.contains(channel))
|
if (channel >= CPN_MAX_CHNOUT || !failsafeGroupsMap.contains(channel))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int failsafeValue = module.failsafeChannels[channel];
|
const int failsafeValue = model->limitData[channel].failsafe;
|
||||||
const ChannelFailsafeWidgetsGroup & grp = failsafeGroupsMap.value(channel);
|
const ChannelFailsafeWidgetsGroup & grp = failsafeGroupsMap.value(channel);
|
||||||
const bool valDisable = (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE);
|
const bool valDisable = (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE);
|
||||||
|
|
||||||
|
@ -903,7 +921,7 @@ void ModulePanel::updateFailsafe(int channel)
|
||||||
grp.sbUsec->setDisabled(valDisable);
|
grp.sbUsec->setDisabled(valDisable);
|
||||||
|
|
||||||
if (!valDisable)
|
if (!valDisable)
|
||||||
setChannelFailsafeValue(channel, failsafeValue, (FAILSAFE_DISPLAY_PERCENT | FAILSAFE_DISPLAY_USEC));
|
setChannelFailsafeValue(channel, failsafeValue, FAILSAFE_DISPLAY_PERCENT | FAILSAFE_DISPLAY_USEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModulePanel::onClearAccessRxClicked()
|
void ModulePanel::onClearAccessRxClicked()
|
||||||
|
@ -1166,13 +1184,21 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||||
ui->trimsDisplay->hide();
|
ui->trimsDisplay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=firmware->getCapability(NumFirstUsableModule); i<firmware->getCapability(NumModules); i++) {
|
for (int i = firmware->getCapability(NumFirstUsableModule); i < firmware->getCapability(NumModules); i++) {
|
||||||
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
||||||
ui->modulesLayout->addWidget(modules[i]);
|
ui->modulesLayout->addWidget(modules[i]);
|
||||||
connect(modules[i], &ModulePanel::modified, this, &SetupPanel::modified);
|
connect(modules[i], &ModulePanel::modified, this, &SetupPanel::modified);
|
||||||
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = firmware->getCapability(NumFirstUsableModule); i < firmware->getCapability(NumModules); i++) {
|
||||||
|
for (int j = firmware->getCapability(NumFirstUsableModule); j < firmware->getCapability(NumModules); j++) {
|
||||||
|
if (i != j) {
|
||||||
|
connect(modules[i], SIGNAL(failsafeModified(unsigned)), modules[j], SLOT(onFailsafeModified(unsigned)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (firmware->getCapability(ModelTrainerEnable)) {
|
if (firmware->getCapability(ModelTrainerEnable)) {
|
||||||
modules[CPN_MAX_MODULES] = new ModulePanel(this, model, model.moduleData[CPN_MAX_MODULES], generalSettings, firmware, -1);
|
modules[CPN_MAX_MODULES] = new ModulePanel(this, model, model.moduleData[CPN_MAX_MODULES], generalSettings, firmware, -1);
|
||||||
ui->modulesLayout->addWidget(modules[CPN_MAX_MODULES]);
|
ui->modulesLayout->addWidget(modules[CPN_MAX_MODULES]);
|
||||||
|
|
|
@ -61,15 +61,17 @@ class ModulePanel : public ModelPanel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx);
|
ModulePanel(QWidget * parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx);
|
||||||
virtual ~ModulePanel();
|
virtual ~ModulePanel();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onExtendedLimitsToggled();
|
void onExtendedLimitsToggled();
|
||||||
|
void onFailsafeModified(unsigned index);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void channelsRangeChanged();
|
void channelsRangeChanged();
|
||||||
|
void failsafeModified(unsigned index);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupFailsafes();
|
void setupFailsafes();
|
||||||
|
@ -95,7 +97,7 @@ class ModulePanel : public ModelPanel
|
||||||
void onFailsafeUsecChanged(int value);
|
void onFailsafeUsecChanged(int value);
|
||||||
void onFailsafePercentChanged(double value);
|
void onFailsafePercentChanged(double value);
|
||||||
void onFailsafesDisplayValueTypeChanged(int type);
|
void onFailsafesDisplayValueTypeChanged(int type);
|
||||||
void updateFailsafe(int channel);
|
void updateFailsafe(unsigned channel);
|
||||||
void on_optionValue_editingFinished();
|
void on_optionValue_editingFinished();
|
||||||
void onClearAccessRxClicked();
|
void onClearAccessRxClicked();
|
||||||
|
|
||||||
|
@ -114,6 +116,7 @@ class ModulePanel : public ModelPanel
|
||||||
Ui::Module *ui;
|
Ui::Module *ui;
|
||||||
QMap<int, ChannelFailsafeWidgetsGroup> failsafeGroupsMap;
|
QMap<int, ChannelFailsafeWidgetsGroup> failsafeGroupsMap;
|
||||||
static quint8 failsafesValueDisplayType; // FailsafeValueDisplayTypes
|
static quint8 failsafesValueDisplayType; // FailsafeValueDisplayTypes
|
||||||
|
void updateFailsafeUI(unsigned channel, quint8 updtSb);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SetupPanel : public ModelPanel
|
class SetupPanel : public ModelPanel
|
||||||
|
|
|
@ -897,9 +897,8 @@ QString ModelPrinter::printFailsafe(int idx)
|
||||||
ModuleData module = model.moduleData[idx];
|
ModuleData module = model.moduleData[idx];
|
||||||
strl << printLabelValue(tr("Failsafe Mode"), printFailsafeMode(module.failsafeMode));
|
strl << printLabelValue(tr("Failsafe Mode"), printFailsafeMode(module.failsafeMode));
|
||||||
if (module.failsafeMode == FAILSAFE_CUSTOM) {
|
if (module.failsafeMode == FAILSAFE_CUSTOM) {
|
||||||
for (int i=0; i<module.channelsCount; i++) {
|
for (int i = 0; i < module.channelsCount; i++) {
|
||||||
//strl << QString("%1(%2)").arg(printChannelName(module.channelsStart + i).trimmed()).arg(printFailsafeValue(module.failsafeChannels[i]));
|
strl << printLabelValue(printChannelName(module.channelsStart + i).trimmed(), printFailsafeValue(model.limitData[i].failsafe));
|
||||||
strl << printLabelValue(printChannelName(module.channelsStart + i).trimmed(), printFailsafeValue(module.failsafeChannels[i]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strl.join(" ");
|
return strl.join(" ");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue