Fixes #500.
Graphical presentation could be better, I am not very familiar with Qt.
This commit is contained in:
@@ -1440,6 +1440,22 @@ QPushButton:checked {
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Gvars</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>711</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gvarsLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -1451,6 +1467,11 @@ QPushButton:checked {
|
||||
<header>lcdwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>mySlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header location="global">myslider.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>cursorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
@@ -1463,11 +1484,6 @@ QPushButton:checked {
|
||||
<header>menuwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>mySlider</class>
|
||||
<extends>QSlider</extends>
|
||||
<header location="global">myslider.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../companion.qrc"/>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>712</width>
|
||||
<width>726</width>
|
||||
<height>688</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -240,6 +240,22 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="misc">
|
||||
<attribute name="title">
|
||||
<string>Gvars</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>691</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gvarsLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -285,6 +285,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||
tabWidget = ui->tabWidget;
|
||||
logicalSwitchesLayout = ui->logicalSwitchesLayout;
|
||||
channelsLayout = ui->channelsLayout;
|
||||
gvarsLayout = ui->gvarsLayout;
|
||||
leftXPerc = ui->leftXPerc;
|
||||
leftYPerc = ui->leftYPerc;
|
||||
rightXPerc = ui->rightXPerc;
|
||||
@@ -416,11 +417,31 @@ void SimulatorDialog::initUi(T * ui)
|
||||
logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1);
|
||||
}
|
||||
|
||||
int fmodes = GetCurrentFirmware()->getCapability(FlightModes);
|
||||
int gvars = GetCurrentFirmware()->getCapability(Gvars);
|
||||
if (gvars>0) {
|
||||
for (int fm=0; fm<fmodes; fm++) {
|
||||
QLabel * label = new QLabel(tabWidget);
|
||||
label->setText(QString("FM%1").arg(fm+1));
|
||||
gvarsLayout->addWidget(label, 0, fm+1);
|
||||
}
|
||||
for (int i=0; i<gvars; i++) {
|
||||
QLabel * label = new QLabel(tabWidget);
|
||||
label->setText(QString("GV%1").arg(i+1));
|
||||
gvarsLayout->addWidget(label, i+1, 0);
|
||||
for (int fm=0; fm<fmodes; fm++) {
|
||||
QLabel * value = new QLabel(tabWidget);
|
||||
gvarValues << value;
|
||||
gvarsLayout->addWidget(value, i+1, fm+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SIMULATOR_FLAGS_NOTX) {
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
ui->tabWidget->setCurrentWidget(ui->outputs);
|
||||
}
|
||||
else {
|
||||
ui->lcd->setFocus();
|
||||
ui->tabWidget->setCurrentWidget(ui->simu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,6 +553,8 @@ void SimulatorDialog::centerSticks()
|
||||
void SimulatorDialog::start(QByteArray & eeprom)
|
||||
{
|
||||
lastPhase = -1;
|
||||
numGvars = GetCurrentFirmware()->getCapability(Gvars);
|
||||
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
|
||||
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
|
||||
getValues();
|
||||
setupTimer();
|
||||
@@ -540,6 +563,8 @@ void SimulatorDialog::start(QByteArray & eeprom)
|
||||
void SimulatorDialog::start(const char * filename)
|
||||
{
|
||||
lastPhase = -1;
|
||||
numGvars = GetCurrentFirmware()->getCapability(Gvars);
|
||||
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
|
||||
simulator->start(filename);
|
||||
getValues();
|
||||
setupTimer();
|
||||
@@ -809,6 +834,12 @@ void SimulatorDialog::setValues()
|
||||
logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF);
|
||||
}
|
||||
|
||||
for (int fm=0; fm<numFlightModes; fm++) {
|
||||
for (int gv=0; gv<numGvars; gv++) {
|
||||
gvarValues[fm*numGvars+gv]->setText(QString("%1").arg(outputs.gvars[fm][gv]));
|
||||
}
|
||||
}
|
||||
|
||||
if (outputs.beep) {
|
||||
beepVal = outputs.beep;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,11 @@ class SimulatorDialog : public QDialog
|
||||
QTabWidget * tabWidget;
|
||||
QGridLayout * logicalSwitchesLayout;
|
||||
QGridLayout * channelsLayout;
|
||||
QGridLayout * gvarsLayout;
|
||||
QVector<QLabel *> logicalSwitchLabels;
|
||||
QVector<QSlider *> channelSliders;
|
||||
QVector<QLabel *> channelValues;
|
||||
QVector<QLabel *> gvarValues;
|
||||
|
||||
void init();
|
||||
Node *nodeLeft;
|
||||
@@ -65,6 +67,8 @@ class SimulatorDialog : public QDialog
|
||||
unsigned int backLight;
|
||||
bool lightOn;
|
||||
int switches;
|
||||
unsigned int numGvars;
|
||||
unsigned int numFlightModes;
|
||||
#ifdef JOYSTICKS
|
||||
Joystick *joystick;
|
||||
int jscal[8][4];
|
||||
|
||||
@@ -59,7 +59,13 @@ for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
|
||||
#else
|
||||
outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0);
|
||||
#endif
|
||||
#ifdef GVAR_VALUE // defined(GVARS)
|
||||
uint8_t phase = getFlightPhase();
|
||||
for (int fm=0; fm<MAX_FLIGHT_MODES; fm++)
|
||||
for (int gv=0; gv<MAX_GVARS; gv++)
|
||||
outputs.gvars[fm][gv] = GVAR_VALUE(gv, fm);
|
||||
#endif
|
||||
#endif //GETVALUES_IMPORT
|
||||
|
||||
#ifdef LCDCHANGED_IMPORT
|
||||
#undef LCDCHANGED_IMPORT
|
||||
|
||||
@@ -36,6 +36,7 @@ class TxOutputs {
|
||||
|
||||
int16_t chans[C9X_NUM_CHNOUT];
|
||||
bool vsw[32]; /* TODO NUM_VIRTUAL_SWITCHES */
|
||||
int16_t gvars[9][9]; /*TODO MAX_FLIGHT_MODES, NUM_GVARS */
|
||||
unsigned int beep;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user