Merge pull request #1080 from opentx/projectkk2glider/companion_gvars_issue_500

Fixes #500.
This commit is contained in:
Bertrand Songis
2014-05-11 19:37:43 +02:00
6 changed files with 82 additions and 8 deletions
+21 -5
View File
@@ -1440,6 +1440,22 @@ QPushButton:checked {
</item> </item>
</layout> </layout>
</widget> </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> </widget>
</item> </item>
</layout> </layout>
@@ -1451,6 +1467,11 @@ QPushButton:checked {
<header>lcdwidget.h</header> <header>lcdwidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>mySlider</class>
<extends>QSlider</extends>
<header location="global">myslider.h</header>
</customwidget>
<customwidget> <customwidget>
<class>cursorWidget</class> <class>cursorWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@@ -1463,11 +1484,6 @@ QPushButton:checked {
<header>menuwidget.h</header> <header>menuwidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>mySlider</class>
<extends>QSlider</extends>
<header location="global">myslider.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../companion.qrc"/> <include location="../companion.qrc"/>
@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>712</width> <width>726</width>
<height>688</height> <height>688</height>
</rect> </rect>
</property> </property>
@@ -240,6 +240,22 @@
</item> </item>
</layout> </layout>
</widget> </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> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
+33 -2
View File
@@ -285,6 +285,7 @@ void SimulatorDialog::initUi(T * ui)
tabWidget = ui->tabWidget; tabWidget = ui->tabWidget;
logicalSwitchesLayout = ui->logicalSwitchesLayout; logicalSwitchesLayout = ui->logicalSwitchesLayout;
channelsLayout = ui->channelsLayout; channelsLayout = ui->channelsLayout;
gvarsLayout = ui->gvarsLayout;
leftXPerc = ui->leftXPerc; leftXPerc = ui->leftXPerc;
leftYPerc = ui->leftYPerc; leftYPerc = ui->leftYPerc;
rightXPerc = ui->rightXPerc; rightXPerc = ui->rightXPerc;
@@ -416,11 +417,31 @@ void SimulatorDialog::initUi(T * ui)
logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1); 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) { if (flags & SIMULATOR_FLAGS_NOTX) {
ui->tabWidget->setCurrentIndex(1); ui->tabWidget->setCurrentWidget(ui->outputs);
} }
else { else {
ui->lcd->setFocus(); ui->tabWidget->setCurrentWidget(ui->simu);
} }
} }
@@ -532,6 +553,8 @@ void SimulatorDialog::centerSticks()
void SimulatorDialog::start(QByteArray & eeprom) void SimulatorDialog::start(QByteArray & eeprom)
{ {
lastPhase = -1; lastPhase = -1;
numGvars = GetCurrentFirmware()->getCapability(Gvars);
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true); simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
getValues(); getValues();
setupTimer(); setupTimer();
@@ -540,6 +563,8 @@ void SimulatorDialog::start(QByteArray & eeprom)
void SimulatorDialog::start(const char * filename) void SimulatorDialog::start(const char * filename)
{ {
lastPhase = -1; lastPhase = -1;
numGvars = GetCurrentFirmware()->getCapability(Gvars);
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
simulator->start(filename); simulator->start(filename);
getValues(); getValues();
setupTimer(); setupTimer();
@@ -809,6 +834,12 @@ void SimulatorDialog::setValues()
logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF); 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) { if (outputs.beep) {
beepVal = outputs.beep; beepVal = outputs.beep;
} }
@@ -53,9 +53,11 @@ class SimulatorDialog : public QDialog
QTabWidget * tabWidget; QTabWidget * tabWidget;
QGridLayout * logicalSwitchesLayout; QGridLayout * logicalSwitchesLayout;
QGridLayout * channelsLayout; QGridLayout * channelsLayout;
QGridLayout * gvarsLayout;
QVector<QLabel *> logicalSwitchLabels; QVector<QLabel *> logicalSwitchLabels;
QVector<QSlider *> channelSliders; QVector<QSlider *> channelSliders;
QVector<QLabel *> channelValues; QVector<QLabel *> channelValues;
QVector<QLabel *> gvarValues;
void init(); void init();
Node *nodeLeft; Node *nodeLeft;
@@ -65,6 +67,8 @@ class SimulatorDialog : public QDialog
unsigned int backLight; unsigned int backLight;
bool lightOn; bool lightOn;
int switches; int switches;
unsigned int numGvars;
unsigned int numFlightModes;
#ifdef JOYSTICKS #ifdef JOYSTICKS
Joystick *joystick; Joystick *joystick;
int jscal[8][4]; int jscal[8][4];
@@ -59,7 +59,13 @@ for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
#else #else
outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0); outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0);
#endif #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
#endif //GETVALUES_IMPORT
#ifdef LCDCHANGED_IMPORT #ifdef LCDCHANGED_IMPORT
#undef LCDCHANGED_IMPORT #undef LCDCHANGED_IMPORT
@@ -36,6 +36,7 @@ class TxOutputs {
int16_t chans[C9X_NUM_CHNOUT]; int16_t chans[C9X_NUM_CHNOUT];
bool vsw[32]; /* TODO NUM_VIRTUAL_SWITCHES */ bool vsw[32]; /* TODO NUM_VIRTUAL_SWITCHES */
int16_t gvars[9][9]; /*TODO MAX_FLIGHT_MODES, NUM_GVARS */
unsigned int beep; unsigned int beep;
}; };