Merge branch 'next' of https://github.com/opentx/opentx into kilrah/Switch_and_pot_warnings

Conflicts:
	companion/src/eeprominterface.h
	companion/src/firmwares/opentx/opentxeeprom.cpp
	radio/src/opentx.cpp
	radio/src/translations/es.h.txt
	radio/src/translations/fr.h.txt
This commit is contained in:
Andre Bernet
2014-02-10 14:47:32 +01:00
238 changed files with 18614 additions and 8730 deletions
+7
View File
@@ -495,6 +495,13 @@ void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
}
}
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
void ModelEdit::on_ca_apply_PB_clicked()
{
int index=ui->ca_ctype_CB->currentIndex();
+172 -17
View File
@@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index)
emit modified();
}
void RepeatComboBox::update()
{
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
int value = repeatParam/step;
if (step == 1) {
value++;
}
setCurrentIndex(value);
}
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
generalSettings(generalSettings),
@@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
QStringList paramarmList;
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
@@ -90,12 +99,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
for (int i=0; i<num_fsw; i++) {
AssignFunc func = model.funcSw[i].func;
// The label
QLabel * label = new QLabel(this);
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
label->setProperty("index", i);
label->setText(tr("CF%1").arg(i+1));
gridLayout->addWidget(label, i+1, 0);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
// The switch
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
// The function
fswtchFunc[i] = new QComboBox(this);
@@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i);
populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList);
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
fswtchParamArmT[i]->setEditable(true);
paramLayout->addWidget(fswtchParamArmT[i]);
@@ -286,7 +304,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) {
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125);
@@ -329,6 +347,15 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
}
else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) {
if (modified) model.funcSw[i].param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(0);
fswtchParam[i]->setMaximum(59*60+59);
fswtchParam[i]->setValue(model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncVolume) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
@@ -337,6 +364,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
}
if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
@@ -381,14 +409,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
int vml = GetEepromInterface()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
}
}
}
else {
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
}
}
}
else if (index==FuncBackgroundMusic) {
@@ -453,13 +487,13 @@ void CustomFunctionsPanel::fswPaste()
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion-fsw");
FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
lock = false;
emit modified();
}
}
@@ -468,7 +502,7 @@ void CustomFunctionsPanel::fswDelete()
{
model.funcSw[selectedFunction].clear();
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
emit modified();
@@ -476,17 +510,17 @@ void CustomFunctionsPanel::fswDelete()
void CustomFunctionsPanel::fswCopy()
{
QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
}
void CustomFunctionsPanel::fswCut()
{
fswCopy();
fswDelete();
fswCopy();
fswDelete();
}
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
@@ -508,3 +542,124 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
contextMenu.exec(globalPos);
}
void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
{
b->clear();
b->addItem(QObject::tr("Value"));
b->addItem(QObject::tr("Source"));
b->addItem(QObject::tr("GVAR"));
b->addItem(QObject::tr("Increment"));
b->setCurrentIndex(value);
}
void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList)
{
b->clear();
b->addItem("----");
bool added = false;
QString currentvalue(value);
foreach ( QString entry, paramsList ) {
b->addItem(entry);
if (entry==currentvalue) {
b->setCurrentIndex(b->count()-1);
added = true;
}
}
if (!added && strlen(value)) {
b->addItem(value);
b->setCurrentIndex(b->count()-1);
}
}
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}
else if (reCount == 2) {
qs.append( QObject::tr("REa"));
qs.append( QObject::tr("REb"));
}
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
b->addItem("-1", 0);
b->addItem("+1", 1);
b->setCurrentIndex(value);
break;
}
}
else {
b->hide();
}
}
+8 -1
View File
@@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox
public:
RepeatComboBox(QWidget *parent, int & repeatParam);
void update();
signals:
void modified();
@@ -55,7 +56,13 @@ class CustomFunctionsPanel : public ModelPanel
void fswCut();
private:
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
GeneralSettings & generalSettings;
QStringList paramarmList;
bool phononLock;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
@@ -65,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON
Phonon::MediaObject *clickObject;
+161 -171
View File
@@ -7,7 +7,7 @@
#include <QDoubleSpinBox>
#include "helpers.h"
CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
ModelPanel(parent, model),
selectedSwitch(0)
{
@@ -18,13 +18,13 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
addLabel(gridLayout, tr("V1"), col++);
addLabel(gridLayout, tr("V2"), col++);
addLabel(gridLayout, tr("AND"), col++);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
addLabel(gridLayout, tr("Duration"), col++);
addLabel(gridLayout, tr("Delay"), col++);
}
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
// The label
QLabel * label = new QLabel(this);
label->setProperty("index", i);
@@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V1
cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i);
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this);
@@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V2
cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this);
@@ -78,11 +78,10 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// AND
cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i);
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
gridLayout->addWidget(cswitchAnd[i], i+1, 4);
cswitchAnd[i]->setVisible(false);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
// Duration
cswitchDuration[i] = new QDoubleSpinBox(this);
cswitchDuration[i]->setProperty("index", i);
@@ -91,9 +90,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDuration[i]->setMinimum(0);
cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1);
connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited()));
connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
gridLayout->addWidget(cswitchDuration[i], i+1, 5);
cswitchDuration[i]->setVisible(false);
// Delay
cswitchDelay[i] = new QDoubleSpinBox(this);
@@ -103,75 +101,114 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDelay[i]->setMinimum(0);
cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1);
connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited()));
connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
cswitchDelay[i]->setVisible(false);
}
}
lock = false;
}
CustomSwitchesPanel::~CustomSwitchesPanel()
LogicalSwitchesPanel::~LogicalSwitchesPanel()
{
}
void CustomSwitchesPanel::edited()
void LogicalSwitchesPanel::v1Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model.customSw[i].val1, &model);
if (source.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
emit modified();
}
}
void LogicalSwitchesPanel::v2Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::andEdited(int value)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::durationEdited(double duration)
{
int index = sender()->property("index").toInt();
model.customSw[index].duration = (uint8_t)round(duration*2);
emit modified();
}
void LogicalSwitchesPanel::delayEdited(double delay)
{
int index = sender()->property("index").toInt();
model.customSw[index].delay = (uint8_t)round(delay*2);
emit modified();
}
void LogicalSwitchesPanel::edited()
{
if (!lock) {
lock = true;
int i = sender()->property("index").toInt();
bool chAr;
float value, step;
int newval;
chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt()));
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
if(chAr) {
if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) {
int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt();
bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily());
model.customSw[i].func = newFunc;
if (chAr) {
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) {
model.customSw[i].val1 = -119;
model.customSw[i].val2 = -119;
} else {
}
else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = -129;
model.customSw[i].val3 = 0;
}
else {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0;
}
model.customSw[i].andsw = 0;
setSwitchWidgetVisibility(i);
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2);
model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2);
}
RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func))
switch (model.customSw[i].getFunctionFamily())
{
case (CS_FAMILY_VOFS):
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) {
source = RawSource(model.customSw[i].val1, &model);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
RawSource newSource = RawSource(model.customSw[i].val1, &model);
if (newSource.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
else {
case LS_FAMILY_VOFS:
{
source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
}
@@ -181,84 +218,50 @@ void CustomSwitchesPanel::edited()
}
}
break;
case (CS_FAMILY_TIMERS): {
value = cswitchOffset[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val2) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val2=TimToVal(value);
value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setValue(value);
cswitchOffset[i]->setSingleStep(step);
value=cswitchValue[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val1) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val1=TimToVal(value);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setValue(value);
cswitchValue[i]->setSingleStep(step);
case LS_FAMILY_TIMER:
model.customSw[i].val1 = TimToVal(cswitchValue[i]->value());
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
case (CS_FAMILY_VBOOL):
case (CS_FAMILY_VCOMP):
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt();
case LS_FAMILY_STAY:
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
break;
default:
break;
}
model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt();
emit modified();
lock = false;
}
}
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero)
{
sb->setVisible(true);
sb->setDecimals(1);
sb->setMinimum(allowZero ? 0.0 : 0.1);
sb->setMaximum(175);
float value = ValToTim(timer);
if (value>60)
sb->setSingleStep(1);
else if (value>2)
sb->setSingleStep(0.5);
else
sb->setSingleStep(0.1);
sb->setValue(value);
}
void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{
lock = true;
RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
switch (getCSFunctionFamily(model.customSw[i].func))
switch (model.customSw[i].getFunctionFamily())
{
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
@@ -266,17 +269,19 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step);
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
} else {
}
else {
cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case CS_FAMILY_VBOOL:
case LS_FAMILY_VBOOL:
case LS_FAMILY_STICKY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
@@ -284,7 +289,14 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break;
case CS_FAMILY_VCOMP:
case LS_FAMILY_STAY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
break;
case LS_FAMILY_VCOMP:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
@@ -292,87 +304,65 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break;
case CS_FAMILY_TIMERS:
case LS_FAMILY_TIMER:
cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(true);
cswitchOffset[i]->setVisible(true);
cswitchOffset[i]->setDecimals(1);
cswitchOffset[i]->setMinimum(0.1);
cswitchOffset[i]->setMaximum(175);
float value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setSingleStep(0.1);
if (value>60) {
cswitchOffset[i]->setSingleStep(1);
} else if (value>2) {
cswitchOffset[i]->setSingleStep(0.5);
}
cswitchOffset[i]->setValue(value);
cswitchValue[i]->setDecimals(1);
cswitchValue[i]->setMinimum(0.1);
cswitchValue[i]->setMaximum(175);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setSingleStep(0.1);
if (value>60) {
cswitchValue[i]->setSingleStep(1);
} else if (value>2) {
cswitchValue[i]->setSingleStep(0.5);
}
cswitchValue[i]->setValue(value);
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
cswitchAnd[i]->setVisible(true);
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
cswitchDuration[i]->setVisible(true);
lock = false;
}
void LogicalSwitchesPanel::update()
{
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
lock = true;
populateCSWCB(csw[i], model.customSw[i].func);
lock = false;
setSwitchWidgetVisibility(i);
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]->setVisible(true);
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
}
}
void CustomSwitchesPanel::update()
{
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
populateCSWCB(csw[i], model.customSw[i].func);
setSwitchWidgetVisibility(i);
lock = false;
}
lock = false;
}
void CustomSwitchesPanel::cswPaste()
void LogicalSwitchesPanel::cswPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-csw")) {
QByteArray cswData = mimeData->data("application/x-companion-csw");
CustomSwData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData));
LogicalSwitchData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
emit modified();
updateSelectedSwitch();
}
}
void CustomSwitchesPanel::cswDelete()
void LogicalSwitchesPanel::cswDelete()
{
model.customSw[selectedSwitch].clear();
emit modified();
updateSelectedSwitch();
}
void CustomSwitchesPanel::cswCopy()
void LogicalSwitchesPanel::cswCopy()
{
QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData));
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void CustomSwitchesPanel::updateSelectedSwitch()
void LogicalSwitchesPanel::updateSelectedSwitch()
{
lock = true;
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
@@ -380,14 +370,14 @@ void CustomSwitchesPanel::updateSelectedSwitch()
lock = false;
}
void CustomSwitchesPanel::cswCut()
void LogicalSwitchesPanel::cswCut()
{
cswCopy();
cswDelete();
}
// TODO make something generic here!
void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
{
QLabel *label = (QLabel *)sender();
selectedSwitch = label->property("index").toInt();
+10 -3
View File
@@ -5,18 +5,23 @@
#include <QComboBox>
#include <QDoubleSpinBox>
class CustomSwitchesPanel : public ModelPanel
class LogicalSwitchesPanel : public ModelPanel
{
Q_OBJECT
public:
CustomSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~CustomSwitchesPanel();
LogicalSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~LogicalSwitchesPanel();
virtual void update();
private slots:
void edited();
void v1Edited(int value);
void v2Edited(int value);
void andEdited(int value);
void durationEdited(double duration);
void delayEdited(double delay);
void csw_customContextMenuRequested(QPoint pos);
void cswDelete();
void cswCopy();
@@ -36,6 +41,8 @@ class CustomSwitchesPanel : public ModelPanel
int selectedSwitch;
void updateSelectedSwitch();
void updateV2(int index);
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
};
+40 -44
View File
@@ -17,9 +17,11 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
{
ui->setupUi(this);
int modesCount = GetEepromInterface()->getCapability(FlightPhases);
// Phase name
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(FlightPhases)) {
if (modesCount) {
ui->name->setValidator(new QRegExpValidator(rx, this));
ui->name->setMaxLength(GetEepromInterface()->getCapability(FlightModesName));
connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished()));
@@ -66,14 +68,19 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
for (int i=0; i<4; i++) {
trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]);
if (phaseIdx > 0) {
trimsUse[i]->setProperty("index", i);
populateTrimUseCB(trimsUse[i], phaseIdx);
connect(trimsUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int)));
}
else {
trimsUse[i]->hide();
QComboBox * cb = trimsUse[i];
cb->setProperty("index", i);
cb->addItem(QObject::tr("Trim disabled"), -1);
for (int m=0; m<modesCount; m++) {
if (m == phaseIdx) {
cb->addItem(QObject::tr("Own Trim"), m*2);
}
else if (phaseIdx > 0) {
cb->addItem(QObject::tr("Use Trim from Flight mode %1").arg(m), m*2);
cb->addItem(QObject::tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m*2+1);
}
}
connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int)));
trimsValue[i]->setProperty("index", i);
connect(trimsValue[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrim_valueChanged()));
@@ -123,17 +130,6 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
QLabel *label = new QLabel(ui->gvGB);
label->setText(tr("GVAR%1").arg(i+1));
gvLayout->addWidget(label, i, col++, 1, 1);
#if 0
// TODO remove this capability?
// GVar source (er9x/ersky9x)
if (GetEepromInterface()->getCapability(GvarsHaveSources)) {
QComboBox *source = new QComboBox(ui->gvGB);
source->setProperty("index", i);
populateGvSourceCB(source, model.gvsource[i]);
// connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVSource_currentIndexChanged(int)));
gvLayout->addWidget(source, i, col++, 1, 1);
}
#endif
// GVar name
int nameLen = GetEepromInterface()->getCapability(GvarsName);
if (nameLen > 0) {
@@ -193,7 +189,6 @@ void FlightMode::update()
int chn = CONVERT_MODE(i+1)-1;
if (chn == 2/*TODO constant*/ && model.throttleReversed)
trimsSlider[i]->setInvertedAppearance(true);
trimUpdate(i);
}
@@ -262,23 +257,22 @@ void FlightMode::phaseFadeOut_editingFinished()
void FlightMode::trimUpdate(unsigned int trim)
{
lock = true;
int chn = CONVERT_MODE(trim+1)-1;
int value = phase.trim[chn];
if (phaseIdx > 0 && phase.trimRef[chn] >= 0) {
trimsUse[trim]->setCurrentIndex(1 + phase.trimRef[chn] - (phase.trimRef[chn] >= phaseIdx ? 1 : 0));
value = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn];
trimsValue[trim]->setEnabled(false);
trimsSlider[trim]->setEnabled(false);
}
else {
if (phaseIdx > 0) trimsUse[trim]->setCurrentIndex(0);
trimsValue[trim]->setEnabled(true);
trimsSlider[trim]->setEnabled(true);
}
trimsSlider[trim]->setValue(value);
trimsValue[trim]->setValue(value);
lock = false;
lock = true;
int chn = CONVERT_MODE(trim+1)-1;
int value = model.getTrimValue(phaseIdx, chn);
trimsSlider[trim]->setValue(value);
trimsValue[trim]->setValue(value);
if (phase.trimMode[chn] < 0) {
trimsUse[trim]->setCurrentIndex(0);
trimsValue[trim]->setEnabled(false);
trimsSlider[trim]->setEnabled(false);
}
else {
trimsUse[trim]->setCurrentIndex(1 + 2*phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
trimsValue[trim]->setEnabled(true);
trimsSlider[trim]->setEnabled(true);
}
lock = false;
}
void FlightMode::phaseGVValue_editingFinished()
@@ -380,15 +374,17 @@ void FlightMode::phaseTrimUse_currentIndexChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int trim = comboBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
if (index == 0) {
phase.trim[chn] = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn];
phase.trimRef[chn] = -1;
int data = comboBox->itemData(index).toInt();
if (data < 0) {
phase.trimMode[chn] = -1;
phase.trimRef[chn] = 0;
phase.trim[chn] = 0;
}
else {
phase.trimMode[chn] = data % 2;
phase.trimRef[chn] = data / 2;
phase.trim[chn] = 0;
phase.trimRef[chn] = index - 1 + (index > (int)phaseIdx ? 1 : 0);
}
trimUpdate(trim);
emit modified();
}
@@ -401,7 +397,7 @@ void FlightMode::phaseTrim_valueChanged()
int trim = spinBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = spinBox->value();
phase.trim[chn] = value;
model.setTrimValue(phaseIdx, chn, value);
lock = true;
trimsSlider[trim]->setValue(value);
lock = false;
@@ -416,7 +412,7 @@ void FlightMode::phaseTrimSlider_valueChanged()
int trim = slider->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1;
int value = slider->value();
phase.trim[chn] = value;
model.setTrimValue(phaseIdx, chn, value);
lock = true;
trimsValue[trim]->setValue(value);
lock = false;
+1 -1
View File
@@ -30,7 +30,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs"));
addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes"));
addTab(new Channels(this, model), tr("Channels"));
addTab(new CustomSwitchesPanel(this, model), tr("Logical Switches"));
addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches"));
if (GetEepromInterface()->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment"));
addTab(new Curves(this, model), tr("Curves"));
+20 -22
View File
@@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
{
ui->setupUi(this);
lock = true;
// Mode
populateTimerSwitchCB(ui->mode, timer.mode);
populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES);
if (!GetEepromInterface()->getCapability(PermTimers)) {
ui->persistent->hide();
@@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
ui->countdownBeep->addItem(tr("Beeps"));
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
ui->countdownBeep->addItem(tr("Countdown"));
lock = false;
}
TimerPanel::~TimerPanel()
@@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished()
void TimerPanel::on_mode_currentIndexChanged(int index)
{
timer.mode = TimerMode(ui->mode->itemData(index).toInt());
emit modified();
if (!lock) {
timer.mode = RawSwitch(ui->mode->itemData(index).toInt());
emit modified();
}
}
void TimerPanel::on_persistent_toggled(bool checked)
@@ -123,20 +129,20 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
if (GetEepromInterface()->getCapability(HasFailsafe)) {
for (int i=0; i<16; i++) {
QSlider * slider = new QSlider(this);
slider->setMinimumSize(QSize(30, 50));
slider->setRange(-100, 100);
QSpinBox * spinbox = new QSpinBox(this);
QLabel * label = new QLabel(this);
label->setText(QString::number(i+1));
QDoubleSpinBox * spinbox = new QDoubleSpinBox(this);
spinbox->setMinimumSize(QSize(20, 0));
spinbox->setRange(-100, 100);
slider->setProperty("index", i);
spinbox->setSingleStep(0.1);
spinbox->setDecimals(1);
spinbox->setValue(((double)module.failsafeChannels[i]*100)/1024);
label->setProperty("index", i);
spinbox->setProperty("index", i);
failsafeSliders << slider;
failsafeSpins << spinbox;
ui->failsafesLayout->addWidget(slider, 2*(i/8), i%8, Qt::AlignHCenter);
ui->failsafesLayout->addWidget(label, 2*(i/8), i%8, Qt::AlignHCenter);
ui->failsafesLayout->addWidget(spinbox, 1+2*(i/8), i%8, Qt::AlignHCenter);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
connect(spinbox, SIGNAL(valueChanged(double)), this, SLOT(onFailsafeSpinChanged(double)));
}
}
@@ -217,10 +223,6 @@ void ModulePanel::update()
ui->failsafeMode->setVisible(mask & MASK_FAILSAFES);
ui->failsafeMode->setCurrentIndex(module.failsafeMode);
ui->failsafesFrame->setEnabled(module.failsafeMode == 1);
for (int i=0; i<failsafeSliders.size(); i++) {
failsafeSliders[i]->setValue(module.failsafeChannels[i]);
failsafeSpins[i]->setValue(module.failsafeChannels[i]);
}
}
else {
mask = 0;
@@ -302,16 +304,12 @@ void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
}
}
void ModulePanel::onFailsafeChannelChanged(int value)
void ModulePanel::onFailsafeSpinChanged(double value)
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
module.failsafeChannels[index] = value;
failsafeSpins[index]->setValue(value);
failsafeSliders[index]->setValue(value);
module.failsafeChannels[index] = (value*1024)/100;
emit modified();
lock = false;
}
}
+2 -3
View File
@@ -56,14 +56,13 @@ class ModulePanel : public ModelPanel
void on_ppmFrameLength_editingFinished();
void on_rxNumber_editingFinished();
void on_failsafeMode_currentIndexChanged(int value);
void onFailsafeChannelChanged(int value);
void onFailsafeSpinChanged(double value);
private:
ModuleData & module;
int moduleIdx;
Ui::Module *ui;
QVector<QSpinBox *> failsafeSpins;
QVector<QSlider *> failsafeSliders;
QVector<QDoubleSpinBox *> failsafeSpins;
};
class Setup : public ModelPanel
+1 -1
View File
@@ -352,7 +352,7 @@ void TelemetryCustomScreen::updateBar(int line)
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
RawSourceRange range = source.getRange(true);
int max = round((range.max - range.min) / range.step);
if (255-screen.body.bars[line].barMax > max)
if (int(255-screen.body.bars[line].barMax) > max)
screen.body.bars[line].barMax = 255 - max;
minSB[line]->setEnabled(true);
minSB[line]->setDecimals(range.decimals);
+5 -5
View File
@@ -584,8 +584,8 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch();
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP;
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
updateSwitchesTab();
}
@@ -841,9 +841,9 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch();
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP;
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP;
setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
// redraw switches tab
updateSwitchesTab();