This commit is contained in:
bsongis
2015-05-10 12:36:24 +02:00
parent cde0824f05
commit 274303a658
7 changed files with 1870 additions and 1751 deletions
@@ -1020,7 +1020,7 @@ QPushButton:checked {
</spacer>
</item>
<item row="2" column="0">
<widget class="myQDial" name="dialP_1">
<widget class="myQDial" name="dial0">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -1054,7 +1054,7 @@ QPushButton:checked {
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="dialP_1value">
<widget class="QLabel" name="dialValue0">
<property name="text">
<string notr="true">0 %</string>
</property>
@@ -1077,7 +1077,7 @@ QPushButton:checked {
</spacer>
</item>
<item row="5" column="0">
<widget class="myQDial" name="dialP_2">
<widget class="myQDial" name="dial1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -1114,7 +1114,7 @@ QPushButton:checked {
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="dialP_2value">
<widget class="QLabel" name="dialValue1">
<property name="text">
<string notr="true">0 %</string>
</property>
@@ -1137,7 +1137,7 @@ QPushButton:checked {
</spacer>
</item>
<item row="8" column="0">
<widget class="myQDial" name="dialP_3">
<widget class="myQDial" name="dial2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -1171,7 +1171,7 @@ QPushButton:checked {
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="dialP_3value">
<widget class="QLabel" name="dialValue2">
<property name="text">
<string notr="true">0 %</string>
</property>
File diff suppressed because it is too large Load Diff
+43 -36
View File
@@ -50,7 +50,6 @@ void SimulatorDialog::updateDebugOutput()
SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags):
QDialog(parent),
flags(flags),
dialP_4(NULL),
timer(NULL),
lightOn(false),
simulator(simulator),
@@ -118,10 +117,9 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simul
ui->trimHL_R->setText(QString::fromUtf8(rightArrow));
ui->trimVL_U->setText(QString::fromUtf8(upArrow));
ui->trimVL_D->setText(QString::fromUtf8(downArrow));
connect(ui->dialP_1, SIGNAL(valueChanged(int)), this, SLOT(dialChanged()));
connect(ui->dialP_2, SIGNAL(valueChanged(int)), this, SLOT(dialChanged()));
connect(ui->dialP_3, SIGNAL(valueChanged(int)), this, SLOT(dialChanged()));
for (int i=0; i<pots.count(); i++) {
connect(pots[i], SIGNAL(valueChanged(int)), this, SLOT(dialChanged(i)));
}
connect(ui->cursor, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int)));
connect(ui->menu, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int)));
connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed()));
@@ -156,20 +154,31 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterf
{
lcdWidth = 212;
lcdDepth = 4;
initUi<Ui::SimulatorDialogTaranis>(ui);
// install simulator TRACE hook
simulator->installTraceHook(traceCb);
dialP_4 = ui->dialP_4;
ui->lcd->setBackgroundColor(47, 123, 227);
//restore switches
if (g.simuSW())
// restore switches
if (g.simuSW()) {
restoreSwitches();
}
for (int i=0; i<pots.count(); i++) {
if (flags & (SIMULATOR_FLAGS_S1_MULTI << i)) {
pots[i]->setValue(-1024);
pots[i]->setSingleStep(2048/5);
pots[i]->setPageStep(2048/5);
}
else if (!(flags & (SIMULATOR_FLAGS_S1 << i))) {
pots[i]->hide();
potLabels[i]->hide();
}
}
ui->trimHR_L->setText(QString::fromUtf8(leftArrow));
ui->trimHR_R->setText(QString::fromUtf8(rightArrow));
ui->trimVR_U->setText(QString::fromUtf8(upArrow));
@@ -232,11 +241,9 @@ void SimulatorDialog::mouseReleaseEvent(QMouseEvent *event)
}
}
void SimulatorDialog9X::dialChanged()
void SimulatorDialog::dialChanged(int index)
{
ui->dialP_1value->setText(QString("%1 %").arg((ui->dialP_1->value()*100)/1024));
ui->dialP_2value->setText(QString("%1 %").arg((ui->dialP_2->value()*100)/1024));
ui->dialP_3value->setText(QString("%1 %").arg((ui->dialP_3->value()*100)/1024));
potValues[index]->setText(QString("%1 %").arg((pots[index]->value()*100)/1024));
}
void SimulatorDialog::wheelEvent (QWheelEvent *event)
@@ -371,9 +378,11 @@ void SimulatorDialog::initUi(T * ui)
lcd = ui->lcd;
leftStick = ui->leftStick;
rightStick = ui->rightStick;
dialP_1 = ui->dialP_1;
dialP_2 = ui->dialP_2;
dialP_3 = ui->dialP_3;
pots = findWidgets<QDial *>(this, "pot%1");
potLabels = findWidgets<QLabel *>(this, "potLabel%1");
potValues = findWidgets<QLabel *>(this, "potValue%1");
sliders = findWidgets<QSlider *>(this, "slider%1");
trimHLeft = ui->trimHLeft;
trimVLeft = ui->trimVLeft;
trimHRight = ui->trimHRight;
@@ -726,9 +735,9 @@ void SimulatorDialog9X::getValues()
},
{
ui->dialP_1->value(),
ui->dialP_2->value(),
ui->dialP_3->value(), 0
pots[0]->value(),
pots[1]->value(),
pots[2]->value()
},
{
@@ -820,6 +829,13 @@ void SimulatorDialogTaranis::on_switchH_sliderReleased()
void SimulatorDialogTaranis::getValues()
{
for (int i=0; i<pots.count(); i++) {
if (flags & (SIMULATOR_FLAGS_S1_MULTI << i)) {
int s1 = round((pots[i]->value()+1024)/(2048.0/5))*(2048.0/5)-1024;
pots[i]->setValue(s1);
}
}
TxInputs inputs = {
{
int(1024*nodeLeft->getX()), // LEFT HORZ
@@ -829,11 +845,11 @@ void SimulatorDialogTaranis::getValues()
},
{
-ui->dialP_1->value(),
ui->dialP_2->value(),
0,
-ui->dialP_3->value(),
ui->dialP_4->value()
-pots[0]->value(),
pots[1]->value(),
((flags && SIMULATOR_FLAGS_S3) ? pots[2]->value() : 0),
-sliders[0]->value(),
sliders[1]->value()
},
{
@@ -1107,18 +1123,9 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value)
}
else if (stick==4) {
nodeLeft->setX(stickval/1024.0);
}
else if (stick==5) {
dialP_1->setValue(stickval);
}
else if (stick==6) {
dialP_2->setValue(stickval);
}
else if (stick==7) {
dialP_3->setValue(stickval);
}
else if (stick==8 && dialP_4) {
dialP_4->setValue(stickval);
else if (stick >= 5 && stick < 5+pots.count()) {
pots[stick-5]->setValue(stickval);
}
}
}
+16 -6
View File
@@ -27,8 +27,16 @@ namespace Ui {
class lcdWidget;
class mySlider;
#define SIMULATOR_FLAGS_NOTX 1
#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2
#define SIMULATOR_FLAGS_NOTX 1
#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2
#define SIMULATOR_FLAGS_S1 4
#define SIMULATOR_FLAGS_S2 8
#define SIMULATOR_FLAGS_S3 16
#define SIMULATOR_FLAGS_S4 32 // reserved for the future
#define SIMULATOR_FLAGS_S1_MULTI 64
#define SIMULATOR_FLAGS_S2_MULTI 128
#define SIMULATOR_FLAGS_S3_MULTI 256
#define SIMULATOR_FLAGS_S4_MULTI 512 // reserved for the future
class SimulatorDialog : public QDialog
{
@@ -50,7 +58,11 @@ class SimulatorDialog : public QDialog
unsigned int flags;
lcdWidget * lcd;
QGraphicsView * leftStick, * rightStick;
QDial * dialP_1, * dialP_2, * dialP_3, * dialP_4;
QVector<QDial *> pots;
QVector<QLabel *> potLabels;
QVector<QLabel *> potValues;
QVector<QSlider *> sliders;
mySlider * trimHLeft, * trimVLeft, * trimHRight, * trimVRight;
QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc;
QTabWidget * tabWidget;
@@ -119,6 +131,7 @@ class SimulatorDialog : public QDialog
private slots:
void onButtonPressed(int value);
void dialChanged(int index);
void on_FixRightY_clicked(bool checked);
void on_FixRightX_clicked(bool checked);
void on_FixLeftY_clicked(bool checked);
@@ -160,9 +173,6 @@ class SimulatorDialog9X: public SimulatorDialog
void saveSwitches(void);
void restoreSwitches(void);
private slots:
void dialChanged();
private:
Ui::SimulatorDialog9X * ui;
static uint32_t switchstatus;