1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 08:45:24 +03:00

Re #1457 - added display of channels 17-32 to Companion simulator

This commit is contained in:
Damjan Adamic 2014-07-06 19:50:23 +02:00
parent fa3c50df8e
commit a20e5aee3b
4 changed files with 81 additions and 24 deletions

View file

@ -1232,7 +1232,7 @@ QPushButton:checked {
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="simu">
<attribute name="title">
@ -1440,6 +1440,19 @@ QPushButton:checked {
</item>
</layout>
</widget>
<widget class="QWidget" name="outputs2">
<attribute name="title">
<string>Outputs2</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="logicalSwitchesLayout2"/>
</item>
<item>
<layout class="QGridLayout" name="channelsLayout2"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Gvars</string>

View file

@ -70,7 +70,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="simu">
<attribute name="title">
@ -240,6 +240,19 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="outputs2">
<attribute name="title">
<string>Outputs2</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="logicalSwitchesLayout2"/>
</item>
<item>
<layout class="QGridLayout" name="channelsLayout2"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="misc">
<attribute name="title">
<string>Gvars</string>

View file

@ -356,14 +356,28 @@ void SimulatorDialog::initUi(T * ui)
setTrims();
int outputs = std::min(16, GetCurrentFirmware()->getCapability(Outputs));
int outputs = std::min(32,GetCurrentFirmware()->getCapability(Outputs));
if (outputs <= 16) {
int idx = tabWidget->indexOf(ui->outputs2);
tabWidget->removeTab(idx);
}
else {
tabWidget->setTabText(tabWidget->indexOf(ui->outputs), tr("Outputs") + QString(" 1-%1").arg(16));
tabWidget->setTabText(tabWidget->indexOf(ui->outputs2), tr("Outputs") + QString(" 17-%1").arg(outputs));
}
for (int i=0; i<outputs; i++) {
int column = i / (outputs/2);
int line = i % (outputs/2);
QGridLayout * dest = ui->channelsLayout;
int column = i / (std::min(16,outputs)/2);
int line = i % (std::min(16,outputs)/2);
if (i >= 16 ) {
dest = ui->channelsLayout2;
column = (i-16) / (8);
line = (i-16) % (8);
}
QLabel * label = new QLabel(tabWidget);
ModelData model;
label->setText(RawSource(SOURCE_TYPE_CH, i).toString(model));
channelsLayout->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
dest->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
QSlider * slider = new QSlider(tabWidget);
slider->setEnabled(false);
@ -389,30 +403,24 @@ void SimulatorDialog::initUi(T * ui)
slider->setInvertedAppearance(false);
slider->setTickPosition(QSlider::TicksBelow);
channelSliders << slider;
channelsLayout->addWidget(slider, line, column == 0 ? 1 : 4, 1, 1);
dest->addWidget(slider, line, column == 0 ? 1 : 4, 1, 1);
QLabel * value = new QLabel(tabWidget);
value->setMinimumSize(QSize(50, 0));
value->setAlignment(Qt::AlignCenter);
channelValues << value;
channelsLayout->addWidget(value, line, column == 0 ? 2 : 3, 1, 1);
dest->addWidget(value, line, column == 0 ? 2 : 3, 1, 1);
}
int switches = GetCurrentFirmware()->getCapability(LogicalSwitches);
for (int i=0; i<switches; i++) {
QFrame * swtch = new QFrame(tabWidget);
swtch->setAutoFillBackground(true);
swtch->setFrameShape(QFrame::Panel);
swtch->setFrameShadow(QFrame::Raised);
swtch->setLineWidth(2);
QVBoxLayout * layout = new QVBoxLayout(swtch);
layout->setContentsMargins(2, 2, 2, 2);
QLabel * label = new QLabel(swtch);
label->setText(RawSwitch(SWITCH_TYPE_VIRTUAL, i+1).toString());
label->setAlignment(Qt::AlignCenter);
logicalSwitchLabels << label;
layout->addWidget(label);
logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1);
QFrame * swtch1 = createLogicalSwitch(tabWidget, i, logicalSwitchLabels);
logicalSwitchesLayout->addWidget(swtch1, i / (switches/2), i % (switches/2), 1, 1);
if (outputs > 16) {
// repeat logical switches on second outputs tab
QFrame * swtch2 = createLogicalSwitch(tabWidget, i, logicalSwitchLabels2);
ui->logicalSwitchesLayout2->addWidget(swtch2, i / (switches/2), i % (switches/2), 1, 1);
}
}
int fmodes = GetCurrentFirmware()->getCapability(FlightModes);
@ -443,6 +451,23 @@ void SimulatorDialog::initUi(T * ui)
}
}
QFrame * SimulatorDialog::createLogicalSwitch(QWidget * parent, int switchNo, QVector<QLabel *> & labels)
{
QFrame * swtch = new QFrame(tabWidget);
swtch->setAutoFillBackground(true);
swtch->setFrameShape(QFrame::Panel);
swtch->setFrameShadow(QFrame::Raised);
swtch->setLineWidth(2);
QVBoxLayout * layout = new QVBoxLayout(swtch);
layout->setContentsMargins(2, 2, 2, 2);
QLabel * label = new QLabel(swtch);
label->setText(RawSwitch(SWITCH_TYPE_VIRTUAL, switchNo+1).toString());
label->setAlignment(Qt::AlignCenter);
labels << label;
layout->addWidget(label);
return swtch;
}
void SimulatorDialog::onButtonPressed(int value)
{
if (value == Qt::Key_Print) {
@ -814,9 +839,11 @@ void SimulatorDialog::setValues()
Trims trims;
simulator->getTrims(trims);
for (int i=0; i<std::min(16, GetCurrentFirmware()->getCapability(Outputs)); i++) {
channelSliders[i]->setValue(chVal(outputs.chans[i]));
channelValues[i]->setText(QString("%1").arg((qreal)outputs.chans[i]*100/1024, 0, 'f', 1));
for (int i=0; i<GetCurrentFirmware()->getCapability(Outputs); i++) {
if (i < channelSliders.size()) {
channelSliders[i]->setValue(chVal(outputs.chans[i]));
channelValues[i]->setText(QString("%1").arg((qreal)outputs.chans[i]*100/1024, 0, 'f', 1));
}
}
leftXPerc->setText(QString("X %1%").arg((qreal)nodeLeft->getX()*100+trims.values[0]/5, 2, 'f', 0));
@ -830,6 +857,8 @@ void SimulatorDialog::setValues()
for (int i=0; i<GetCurrentFirmware()->getCapability(LogicalSwitches); i++) {
logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF);
if (!logicalSwitchLabels2.isEmpty())
logicalSwitchLabels2[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF);
}
for (unsigned int gv=0; gv<numGvars; gv++) {

View file

@ -55,6 +55,7 @@ class SimulatorDialog : public QDialog
QGridLayout * channelsLayout;
QGridLayout * gvarsLayout;
QVector<QLabel *> logicalSwitchLabels;
QVector<QLabel *> logicalSwitchLabels2;
QVector<QSlider *> channelSliders;
QVector<QLabel *> channelValues;
QVector<QLabel *> gvarValues;
@ -91,6 +92,7 @@ class SimulatorDialog : public QDialog
int getValue(qint8 i);
bool getSwitch(int swtch, bool nc, qint8 level=0);
void setTrims();
QFrame * createLogicalSwitch(QWidget * parent, int switchNo, QVector<QLabel *> & labels);
int beepVal;