From d33d2b7ae6a9939712e64778c80b4c8c93d2e5ad Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sun, 6 Apr 2014 22:25:34 +0200 Subject: [PATCH] Add trim keys to Taranis simu --- companion/src/eeprominterface.cpp | 8 +- companion/src/eeprominterface.h | 14 + .../src/simulation/simulatordialog-taranis.ui | 1882 +++++++++-------- companion/src/simulation/simulatordialog.cpp | 64 +- companion/src/simulation/simulatordialog.h | 4 + companion/src/simulation/simulatorimport.h | 2 +- companion/src/simulation/simulatorinterface.h | 1 + 7 files changed, 1120 insertions(+), 855 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index eb231f563..087ce2042 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -14,6 +14,10 @@ QString EEPROMWarnings; const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" }; +const char leftArrow[] = {(char)0xE2, (char)0x86, (char)0x90, 0}; +const char rightArrow[] = {(char)0xE2, (char)0x86, (char)0x92, 0}; +const char upArrow[] = {(char)0xE2, (char)0x86, (char)0x91, 0}; +const char downArrow[] = {(char)0xE2, (char)0x86, (char)0x93, 0}; const uint8_t chout_ar[] = { // First number is 0..23 -> template setup, Second is relevant channel out 1,2,3,4 , 1,2,4,3 , 1,3,2,4 , 1,3,4,2 , 1,4,2,3 , 1,4,3,2, @@ -299,13 +303,13 @@ QString RawSource::toString() QString SwitchUp(const char sw) { - const char result[] = {'S', sw, (char)0xE2, (char)0x86, (char)0x91, 0}; + const char result[] = {'S', sw, *upArrow}; return QString::fromUtf8(result); } QString SwitchDn(const char sw) { - const char result[] = {'S', sw, (char)0xE2, (char)0x86, (char)0x93, 0}; + const char result[] = {'S', sw, *downArrow}; return QString::fromUtf8(result); } diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index ab2ad16b4..c3d6d7d72 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -106,6 +106,16 @@ const uint8_t modn12x3[4][4]= { #define DSW_SG1 19 #define DSW_SG2 20 +#define TRIM_LH_L 0 +#define TRIM_LH_R 1 +#define TRIM_LV_DN 2 +#define TRIM_LV_UP 3 +#define TRIM_RV_DN 4 +#define TRIM_RV_UP 5 +#define TRIM_RH_L 6 +#define TRIM_RH_R 7 +#define TRIM_NONE 8 + // Beep center bits #define BC_BIT_RUD (0x01) #define BC_BIT_ELE (0x02) @@ -162,6 +172,10 @@ enum HeliSwashTypes { extern const char * switches9X[]; extern const char * switchesX9D[]; +extern const char leftArrow[]; +extern const char rightArrow[]; +extern const char upArrow[]; +extern const char downArrow[]; enum ThrottleSource { THROTTLE_SOURCE_THR, diff --git a/companion/src/simulation/simulatordialog-taranis.ui b/companion/src/simulation/simulatordialog-taranis.ui index ad41fe74a..9dd1608e0 100644 --- a/companion/src/simulation/simulatordialog-taranis.ui +++ b/companion/src/simulation/simulatordialog-taranis.ui @@ -36,6 +36,212 @@ 0 + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 570 + 5 + + + + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + + Taranis Simulator + + + + + + QLayout::SetMinimumSize + + + 0 + + + + + + 0 + 0 + + + + + 120 + 208 + + + + true + + + background:url(:/images/x9l0.png); + + + + + + + + 0 + 0 + + + + + 424 + 38 + + + + background:url(:/images/x9t0.png) + + + + + + + + 0 + 0 + + + + + 120 + 208 + + + + background:url(:/images/x9r0.png) + + + + + + + + 0 + 0 + + + + + 424 + 128 + + + + + + + + + 0 + 0 + + + + + 424 + 42 + + + + background:url(:/images/x9b0.png) + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 438 + 6 + + + + + + + + + + + Outputs + + + + + + + + + + + + @@ -72,8 +278,795 @@ 6 + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + S1 + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + SB + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 245 + 245 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + SA + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + SE + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SF + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + SF + + + SF + + + 1 + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + LS + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + SA + + + Qt::AlignCenter + + + + + + + SB + + + Qt::AlignCenter + + + + + + + SE + + + Qt::AlignCenter + + + + + + + LS + + + Qt::AlignCenter + + + + + + + S1 + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + S2 + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + S2 + + + Qt::AlignCenter + + + @@ -326,73 +1319,6 @@ QPushButton:checked { - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Vertical - - - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - S2 - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - @@ -579,16 +1505,6 @@ QPushButton:checked { - - - - S2 - - - Qt::AlignCenter - - - @@ -599,23 +1515,7 @@ QPushButton:checked { - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Horizontal - - - - + 20 @@ -645,368 +1545,31 @@ QPushButton:checked { - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix Y - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Fix X - - - true - - - - - - - - 8 - - - - QPushButton { - background-color: #EEEEEE; - border-style: outset; - border-width: 1px; - border-radius: 4px; - border-color: black; - padding: 2px; - } - -QPushButton:checked { - background-color: #4CC417; - border-style: inset; - } - - - Hold X - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - S1 - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - 20 - - - 20 - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - SB - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 245 - 245 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - SA - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - Right Double Click to Reset - - - -125 - - - 125 - - - Qt::Horizontal - - - - - - - + - + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + + + + + 0 0 @@ -1021,419 +1584,36 @@ QPushButton:checked { 125 - Qt::Vertical + Qt::Horizontal - - - Qt::Horizontal + + + + 0 + 0 + - - QSizePolicy::MinimumExpanding - - + - 5 - 20 + 23 + 23 - + + -> + + - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - SE - - - 2 - - - 1 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - SF - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 16777215 - 50 - - - - SF - - - SF - - - 1 - - - 1 - - - 0 - - - 0 - - - Qt::Vertical - - - true - - - QSlider::TicksBothSides - - - 1 - - - - - - - - 0 - 0 - - - - - 42 - 42 - - - - LS - - - -1024 - - - 1024 - - - 128 - - - 64.000000000000000 - - - true - - - - - - - SA - - - Qt::AlignCenter - - - - - - - SB - - - Qt::AlignCenter - - - - - - - SE - - - Qt::AlignCenter - - - - - - - LS - - - Qt::AlignCenter - - - - - - - S1 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 570 - 5 - - - - - - - - true - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - - Taranis Simulator - - - - - - QLayout::SetMinimumSize - - - 0 - - - - - - 0 - 0 - - - - - 120 - 208 - - - - true - - - background:url(:/images/x9l0.png); - - - - - - - - 0 - 0 - - - - - 424 - 38 - - - - background:url(:/images/x9t0.png) - - - - - - - - 0 - 0 - - - - - 120 - 208 - - - - background:url(:/images/x9r0.png) - - - - - - - - 0 - 0 - - - - - 424 - 128 - - - - - - - - - 0 - 0 - - - - - 424 - 42 - - - - background:url(:/images/x9b0.png) - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - 438 - 6 - - - - - - - - - - - Outputs - - - - - - - - - - - - diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 0f805e979..0da2626b5 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -69,6 +69,7 @@ SimulatorDialog9X::~SimulatorDialog9X() SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int flags): SimulatorDialog(parent, flags), + trimPressed (TRIM_NONE), ui(new Ui::SimulatorDialogTaranis) { lcdWidth = 212; @@ -79,8 +80,33 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int fl ui->lcd->setBackgroundColor(47, 123, 227); + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVR_U->setText(QString::fromUtf8(upArrow)); + ui->trimVR_D->setText(QString::fromUtf8(downArrow)); + ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVL_U->setText(QString::fromUtf8(upArrow)); + ui->trimVL_D->setText(QString::fromUtf8(downArrow)); + 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())); + connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); } SimulatorDialogTaranis::~SimulatorDialogTaranis() @@ -125,6 +151,31 @@ void SimulatorDialog::wheelEvent (QWheelEvent *event) simulator->wheelEvent(event->delta() > 0 ? 1 : -1); } +void SimulatorDialogTaranis::onTrimPressed() +{ + if (sender()->objectName() == QString("trimHL_L")) + trimPressed = TRIM_LH_L; + else if (sender()->objectName() == QString("trimHL_R")) + trimPressed = TRIM_LH_R; + else if (sender()->objectName() == QString("trimVL_D")) + trimPressed = TRIM_LV_DN; + else if (sender()->objectName() == QString("trimVL_U")) + trimPressed = TRIM_LV_UP; + else if (sender()->objectName() == QString("trimVR_D")) + trimPressed = TRIM_RV_DN; + else if (sender()->objectName() == QString("trimVR_U")) + trimPressed = TRIM_RV_UP; + else if (sender()->objectName() == QString("trimHR_L")) + trimPressed = TRIM_RH_L; + else if (sender()->objectName() == QString("trimHR_R")) + trimPressed = TRIM_RH_R; +} + +void SimulatorDialogTaranis::onTrimReleased() +{ + trimPressed = TRIM_NONE; +} + void SimulatorDialog::keyPressEvent (QKeyEvent *event) { switch (event->key()) { @@ -542,7 +593,18 @@ void SimulatorDialogTaranis::getValues() buttonPressed == Qt::Key_Minus }, - middleButtonPressed + middleButtonPressed, + + { + trimPressed == TRIM_LH_L, + trimPressed == TRIM_LH_R, + trimPressed == TRIM_LV_DN, + trimPressed == TRIM_LV_UP, + trimPressed == TRIM_RV_DN, + trimPressed == TRIM_RV_UP, + trimPressed == TRIM_RH_L, + trimPressed == TRIM_RH_R + } }; simulator->setValues(inputs); diff --git a/companion/src/simulation/simulatordialog.h b/companion/src/simulation/simulatordialog.h index eb8c6b2e2..1a4aca1b2 100644 --- a/companion/src/simulation/simulatordialog.h +++ b/companion/src/simulation/simulatordialog.h @@ -157,11 +157,15 @@ class SimulatorDialogTaranis: public SimulatorDialog virtual ~SimulatorDialogTaranis(); protected: + int trimPressed; virtual void getValues(); private: Ui::SimulatorDialogTaranis * ui; + private slots: + void onTrimPressed(); + void onTrimReleased(); }; #endif // SIMULATORDIALOG_H diff --git a/companion/src/simulation/simulatorimport.h b/companion/src/simulation/simulatorimport.h index ab1f83c6d..60efc010a 100644 --- a/companion/src/simulation/simulatorimport.h +++ b/companion/src/simulation/simulatorimport.h @@ -36,7 +36,7 @@ for (int i=0; i