diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index ee840cc777..dac1038283 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -34,6 +34,7 @@ #define TARANIS_X7_VARIANT 0x4000 #define TARANIS_XLITE_VARIANT 0x2000 #define TARANIS_XLITES_VARIANT 0x1000 +#define TARANIS_X3_VARIANT 0x0800 #define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT) #define SIMU_M128_VARIANTS (M128_VARIANT|SIMU_STOCK_VARIANTS) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index c66c31a7da..3c76006065 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -314,6 +314,9 @@ int OpenTxEepromInterface::save(uint8_t * eeprom, const RadioData & radioData, u else if (IS_TARANIS_X9E(board)) { variant |= TARANIS_X9E_VARIANT; } + else if (IS_TARANIS_X3(board)) { + variant |= TARANIS_X3_VARIANT; + } else if (IS_TARANIS_X7(board)) { variant |= TARANIS_X7_VARIANT; } @@ -692,6 +695,8 @@ int OpenTxFirmware::getCapability(::Capability capability) return SIMU_M128_VARIANTS; else if (IS_TARANIS_X9E(board)) return TARANIS_X9E_VARIANT; + else if (IS_TARANIS_X3(board)) + return TARANIS_X3_VARIANT; else if (IS_TARANIS_X7(board)) return TARANIS_X7_VARIANT; else if (IS_TARANIS_XLITES(board)) diff --git a/companion/src/simulation/CMakeLists.txt b/companion/src/simulation/CMakeLists.txt index 20de5301d9..e435617035 100644 --- a/companion/src/simulation/CMakeLists.txt +++ b/companion/src/simulation/CMakeLists.txt @@ -4,6 +4,7 @@ set(simulation_SRCS radiooutputswidget.cpp simulateduiwidget.cpp simulateduiwidget9X.cpp + simulateduiwidgetX3.cpp simulateduiwidgetX7.cpp simulateduiwidgetX9.cpp simulateduiwidgetXLITE.cpp @@ -24,6 +25,7 @@ set(simulation_UIS debugoutput.ui radiooutputswidget.ui simulateduiwidget9X.ui + simulateduiwidgetX3.ui simulateduiwidgetX7.ui simulateduiwidgetX9.ui simulateduiwidgetXLITE.ui diff --git a/companion/src/simulation/simulateduiwidget.h b/companion/src/simulation/simulateduiwidget.h index b02d735351..8496159832 100644 --- a/companion/src/simulation/simulateduiwidget.h +++ b/companion/src/simulation/simulateduiwidget.h @@ -47,7 +47,7 @@ class SimulatedUIWidget : public QWidget protected: - explicit SimulatedUIWidget(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidget(SimulatorInterface * simulator, QWidget * parent = nullptr); public: @@ -104,6 +104,7 @@ class SimulatedUIWidget : public QWidget // Each subclass is responsible for its own Ui namespace Ui { class SimulatedUIWidget9X; + class SimulatedUIWidgetX3; class SimulatedUIWidgetX7; class SimulatedUIWidgetX9; class SimulatedUIWidgetXLITE; @@ -117,7 +118,7 @@ class SimulatedUIWidget9X: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidget9X(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidget9X(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidget9X(); protected: @@ -128,12 +129,24 @@ class SimulatedUIWidget9X: public SimulatedUIWidget }; +class SimulatedUIWidgetX3: public SimulatedUIWidget +{ + Q_OBJECT + + public: + explicit SimulatedUIWidgetX3(SimulatorInterface * simulator, QWidget * parent = nullptr); + virtual ~SimulatedUIWidgetX3(); + + private: + Ui::SimulatedUIWidgetX3 * ui; +}; + class SimulatedUIWidgetX7: public SimulatedUIWidget { Q_OBJECT public: - explicit SimulatedUIWidgetX7(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetX7(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetX7(); private: @@ -145,7 +158,7 @@ class SimulatedUIWidgetX9: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidgetX9(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetX9(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetX9(); private: @@ -157,7 +170,7 @@ class SimulatedUIWidgetXLITE: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidgetXLITE(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetXLITE(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetXLITE(); private: @@ -169,7 +182,7 @@ class SimulatedUIWidgetX9E: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidgetX9E(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetX9E(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetX9E(); private: @@ -181,7 +194,7 @@ class SimulatedUIWidgetX10: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidgetX10(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetX10(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetX10(); private: @@ -193,7 +206,7 @@ class SimulatedUIWidgetX12: public SimulatedUIWidget Q_OBJECT public: - explicit SimulatedUIWidgetX12(SimulatorInterface * simulator, QWidget * parent = NULL); + explicit SimulatedUIWidgetX12(SimulatorInterface * simulator, QWidget * parent = nullptr); virtual ~SimulatedUIWidgetX12(); private: diff --git a/companion/src/simulation/simulateduiwidgetX3.cpp b/companion/src/simulation/simulateduiwidgetX3.cpp new file mode 100644 index 0000000000..9743022606 --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetX3.cpp @@ -0,0 +1,66 @@ +#include "simulateduiwidget.h" +#include "ui_simulateduiwidgetX3.h" + +// NOTE: RadioUiAction(NUMBER,...): NUMBER relates to enum EnumKeys in the specific board.h + +SimulatedUIWidgetX3::SimulatedUIWidgetX3(SimulatorInterface *simulator, QWidget * parent): + SimulatedUIWidget(simulator, parent), + ui(new Ui::SimulatedUIWidgetX3) +{ + RadioUiAction * act; + QPolygon polygon; + + ui->setupUi(this); + + // add actions in order of appearance on the help menu + + QPoint ctr(70, 91); + polygon << polyArc(ctr.x(), ctr.y(), 50, -90, 90) << polyArc(ctr.x(), ctr.y(), 22, -90, 90); + act = new RadioUiAction(3, QList() << Qt::Key_PageUp << Qt::Key_Up, SIMU_STR_HLP_KEYS_GO_UP, SIMU_STR_HLP_ACT_PAGE); + addRadioWidget(ui->leftbuttons->addArea(polygon, "X3/left_page.png", act)); + + act = new RadioUiAction(0, QList() << Qt::Key_PageDown << Qt::Key_Down, SIMU_STR_HLP_KEYS_GO_DN, SIMU_STR_HLP_ACT_MENU_ICN); + addRadioWidget(ui->leftbuttons->addArea(polyArc(ctr.x(), ctr.y(), 20), "X3/left_menu.png", act)); + + polygon.clear(); + polygon << polyArc(ctr.x(), ctr.y(), 50, 90, 270) << polyArc(ctr.x(), ctr.y(), 22, 90, 270); + act = new RadioUiAction(1, QList() << Qt::Key_Delete << Qt::Key_Escape << Qt::Key_Backspace, SIMU_STR_HLP_KEYS_EXIT, SIMU_STR_HLP_ACT_EXIT); + addRadioWidget(ui->leftbuttons->addArea(polygon, "X3/left_exit.png", act)); + + m_scrollUpAction = new RadioUiAction(-1, QList() << Qt::Key_Minus << Qt::Key_Equal << Qt::Key_Left, SIMU_STR_HLP_KEYS_GO_LFT, SIMU_STR_HLP_ACT_ROT_LFT); + m_scrollDnAction = new RadioUiAction(-1, QList() << Qt::Key_Plus << Qt::Key_Right, SIMU_STR_HLP_KEYS_GO_RGT, SIMU_STR_HLP_ACT_ROT_RGT); + connectScrollActions(); + + m_mouseMidClickAction = new RadioUiAction(2, QList() << Qt::Key_Enter << Qt::Key_Return, SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN); + addRadioWidget(ui->rightbuttons->addArea(polyArc(88, 92, 33), "X3/right_ent.png", m_mouseMidClickAction)); + + addRadioWidget(ui->leftbuttons->addArea(QRect(9, 154, 30, 30), "X3/left_scrnshot.png", m_screenshotAction)); + + m_backlightColors << QColor(215, 243, 255); // X3 Blue + m_backlightColors << QColor(166,247,159); + m_backlightColors << QColor(247,159,166); + m_backlightColors << QColor(255,195,151); + m_backlightColors << QColor(247,242,159); + + setLcd(ui->lcd); + + QString css = "#radioUiWidget {" + "background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1," + "stop:0 rgba(255, 255, 255, 255)," + "stop:0.757062 rgba(241, 238, 238, 255)," + "stop:1 rgba(247, 245, 245, 255));" + "}"; + + QTimer * tim = new QTimer(this); + tim->setSingleShot(true); + connect(tim, &QTimer::timeout, [this, css]() { + emit customStyleRequest(css); + }); + tim->start(100); +} + +SimulatedUIWidgetX3::~SimulatedUIWidgetX3() +{ + delete ui; +} + diff --git a/companion/src/simulation/simulateduiwidgetX3.ui b/companion/src/simulation/simulateduiwidgetX3.ui new file mode 100644 index 0000000000..297ad11c4a --- /dev/null +++ b/companion/src/simulation/simulateduiwidgetX3.ui @@ -0,0 +1,258 @@ + + + SimulatedUIWidgetX3 + + + + 0 + 0 + 570 + 208 + + + + + 0 + 0 + + + + + 570 + 208 + + + + + 570 + 208 + + + + Taranis X3 Simulator + + + background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255), stop:0.757062 rgba(241, 238, 238, 255), stop:1 rgba(247, 245, 245, 255)); + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 157 + 186 + + + + + 157 + 186 + + + + background:url(:/images/simulator/X7/left.png); + + + + + + + + 0 + 0 + + + + + 256 + 128 + + + + + 424 + 128 + + + + background-color: rgb(215, 243, 255); + + + + + + + + 0 + 0 + + + + + 157 + 186 + + + + + 157 + 186 + + + + background:url(:/images/simulator/X7/right.png) + + + + + + + + 0 + 0 + + + + + 256 + 48 + + + + + 256 + 48 + + + + background:url(:/images/simulator/X7/top.png) + + + + + + + + 0 + 0 + + + + + 256 + 10 + + + + + 256 + 10 + + + + background:url(:/images/simulator/X7/bottom.png) + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + + 16777215 + 12 + + + + + 0 + 12 + + + + background-color: rgb(255, 255, 255); + + + + + + + + + + + 0 + 0 + + + + + 0 + 10 + + + + + 16777215 + 10 + + + + background-color: rgb(247, 245, 245); + + + + + + + + + + + LcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+
+ + +
diff --git a/companion/src/simulation/simulatorwidget.cpp b/companion/src/simulation/simulatorwidget.cpp index 442f55d410..216b5fe9cc 100644 --- a/companion/src/simulation/simulatorwidget.cpp +++ b/companion/src/simulation/simulatorwidget.cpp @@ -69,6 +69,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato setWindowTitle(windowName); switch(m_board) { + case Board::BOARD_TARANIS_X3: + radioUiWidget = new SimulatedUIWidgetX3(simulator, this); + break; case Board::BOARD_TARANIS_X7: radioUiWidget = new SimulatedUIWidgetX7(simulator, this); break; @@ -80,9 +83,6 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato case Board::BOARD_TARANIS_XLITES: radioUiWidget = new SimulatedUIWidgetXLITE(simulator, this); break; - case Board::BOARD_TARANIS_X3: - radioUiWidget = new SimulatedUIWidgetX7(simulator, this); - break; case Board::BOARD_TARANIS_X9E: radioUiWidget = new SimulatedUIWidgetX9E(simulator, this); break; diff --git a/radio/src/targets/taranis/CMakeLists.txt b/radio/src/targets/taranis/CMakeLists.txt index 51aeaba615..5325962210 100644 --- a/radio/src/targets/taranis/CMakeLists.txt +++ b/radio/src/targets/taranis/CMakeLists.txt @@ -97,7 +97,7 @@ elseif(PCB STREQUAL X3) set(FLAVOUR x3) add_definitions(-DBOARD_NAME="x9lite") add_definitions(-DPCBX3 -DSOFTWARE_VOLUME) - add_definitions(-DEEPROM_VARIANT=0x4000) + add_definitions(-DEEPROM_VARIANT=0x0800) add_definitions(-DPWR_BUTTON_${PWR_BUTTON}) set(GUI_DIR 128x64) set(NAVIGATION_TYPE x7)