feat(cpn): Radiomaster Boxer support (#2910)

* feat(cpn): Initial Radiomaster Boxer support

* fix(build): Halt if invalid simulator plugin specified

* fix: 6POS not correctly defined

* chore: Less EEPROM stuff needed

* Start of simulator support

* Enable left buttons and fix area mapping of page up and down

* fix(cpn): Internal reference to pots

---------

Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
Peter Feerick
2023-02-11 20:10:12 +10:00
committed by GitHub
co-authored by elecpower
parent d4633ea1de
commit 60cdb897ee
23 changed files with 385 additions and 7 deletions
+2
View File
@@ -21,6 +21,7 @@ set(simulation_SRCS
simulateduiwidgetJumperT18.cpp
simulateduiwidgetTX12.cpp
simulateduiwidgetZorro.cpp
simulateduiwidgetBoxer.cpp
simulateduiwidgetT8.cpp
simulateduiwidgetTX16S.cpp
simulateduiwidgetNV14.cpp
@@ -56,6 +57,7 @@ set(simulation_UIS
simulateduiwidgetJumperT18.ui
simulateduiwidgetTX12.ui
simulateduiwidgetZorro.ui
simulateduiwidgetBoxer.ui
simulateduiwidgetT8.ui
simulateduiwidgetTX16S.ui
simulateduiwidgetNV14.ui
@@ -121,6 +121,7 @@ namespace Ui {
class SimulatedUIWidgetTX16S;
class SimulatedUIWidgetTX12;
class SimulatedUIWidgetZorro;
class SimulatedUIWidgetBoxer;
class SimulatedUIWidgetT8;
class SimulatedUIWidgetNV14;
}
@@ -345,6 +346,18 @@ class SimulatedUIWidgetZorro: public SimulatedUIWidget
Ui::SimulatedUIWidgetZorro * ui;
};
class SimulatedUIWidgetBoxer: public SimulatedUIWidget
{
Q_OBJECT
public:
explicit SimulatedUIWidgetBoxer(SimulatorInterface * simulator, QWidget * parent = nullptr);
virtual ~SimulatedUIWidgetBoxer();
private:
Ui::SimulatedUIWidgetBoxer * ui;
};
class SimulatedUIWidgetT8: public SimulatedUIWidget
{
Q_OBJECT
@@ -0,0 +1,67 @@
#include "simulateduiwidget.h"
#include "ui_simulateduiwidgetBoxer.h"
// NOTE: RadioUiAction(NUMBER,...): NUMBER relates to enum EnumKeys in the specific board.h
SimulatedUIWidgetBoxer::SimulatedUIWidgetBoxer(SimulatorInterface *simulator, QWidget * parent):
SimulatedUIWidget(simulator, parent),
ui(new Ui::SimulatedUIWidgetBoxer)
{
RadioUiAction * act;
ui->setupUi(this);
// add actions in order of appearance on the help menu
act = new RadioUiAction(5, QList<int>() << Qt::Key_Up, SIMU_STR_HLP_KEY_UP, SIMU_STR_HLP_ACT_MDL);
addRadioWidget(ui->rightbuttons->addArea(QRect(80, 10, 60, 30), "Boxer/right-mdl.png", act));
m_mouseMidClickAction = new RadioUiAction(1, QList<int>() << Qt::Key_Enter << Qt::Key_Return, SIMU_STR_HLP_KEYS_ACTIVATE, SIMU_STR_HLP_ACT_ROT_DN);
addRadioWidget(ui->rightbuttons->addArea(QRect(40, 60, 46, 90), "Boxer/right-ent.png", m_mouseMidClickAction));
act = new RadioUiAction(4, QList<int>() << Qt::Key_Left, SIMU_STR_HLP_KEY_LFT, SIMU_STR_HLP_ACT_SYS);
addRadioWidget(ui->leftbuttons->addArea(QRect(18, 10, 66, 30), "Boxer/left-sys.png", act));
act = new RadioUiAction(6, QList<int>() << Qt::Key_Right, SIMU_STR_HLP_KEY_RGT, SIMU_STR_HLP_ACT_TELE);
addRadioWidget(ui->leftbuttons->addArea(QRect(72, 149, 62, 24), "Boxer/left-tele.png", act));
act = new RadioUiAction(3, QList<int>() << Qt::Key_PageDown, SIMU_STR_HLP_KEY_PGDN, SIMU_STR_HLP_ACT_PGDN);
addRadioWidget(ui->leftbuttons->addArea(QRect(72, 79, 62, 24), "Boxer/left-pagedn.png", act));
act = new RadioUiAction(2, QList<int>() << Qt::Key_PageUp, SIMU_STR_HLP_KEY_PGUP, SIMU_STR_HLP_ACT_PGUP);
addRadioWidget(ui->leftbuttons->addArea(QRect(72, 114, 62, 24), "Boxer/left-pageup.png", act));
act = new RadioUiAction(0, QList<int>() << Qt::Key_Down << Qt::Key_Delete << Qt::Key_Escape << Qt::Key_Backspace, SIMU_STR_HLP_KEYS_EXIT, SIMU_STR_HLP_ACT_EXIT);
addRadioWidget(ui->leftbuttons->addArea(QRect(72, 44, 62, 24), "Boxer/left-rtn.png", act));
m_scrollUpAction = new RadioUiAction(-1, QList<int>() << 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<int>() << Qt::Key_Plus << Qt::Key_Right, SIMU_STR_HLP_KEYS_GO_RGT, SIMU_STR_HLP_ACT_ROT_RGT);
connectScrollActions();
m_backlightColors << QColor(215, 243, 255); // X7 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);
}
SimulatedUIWidgetBoxer::~SimulatedUIWidgetBoxer()
{
delete ui;
}
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SimulatedUIWidgetBoxer</class>
<widget class="QWidget" name="SimulatedUIWidgetBoxer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>567</width>
<height>186</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>567</width>
<height>186</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>567</width>
<height>186</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Radiomaster Boxer Simulator</string>
</property>
<property name="styleSheet">
<string notr="true">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));</string>
</property>
<widget class="ButtonsWidget" name="leftbuttons" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>157</width>
<height>186</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>157</width>
<height>186</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>157</width>
<height>186</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:url(:/images/simulator/Boxer/left.png);</string>
</property>
</widget>
<widget class="ButtonsWidget" name="rightbuttons" native="true">
<property name="geometry">
<rect>
<x>410</x>
<y>0</y>
<width>157</width>
<height>186</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>157</width>
<height>186</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>157</width>
<height>186</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:url(:/images/simulator/Boxer/right.png)</string>
</property>
</widget>
<widget class="QWidget" name="bottom" native="true">
<property name="geometry">
<rect>
<x>155</x>
<y>176</y>
<width>256</width>
<height>10</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>10</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>10</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:url(:/images/simulator/Boxer/bottom.png)</string>
</property>
</widget>
<widget class="LcdWidget" name="lcd" native="true">
<property name="geometry">
<rect>
<x>155</x>
<y>48</y>
<width>256</width>
<height>128</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>180</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(215, 243, 255);</string>
</property>
</widget>
<widget class="QWidget" name="top" native="true">
<property name="geometry">
<rect>
<x>137</x>
<y>0</y>
<width>300</width>
<height>49</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>49</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:url(:/images/simulator/Boxer/top.png)</string>
</property>
</widget>
<zorder>bottom</zorder>
<zorder>top</zorder>
<zorder>rightbuttons</zorder>
<zorder>leftbuttons</zorder>
<zorder>lcd</zorder>
</widget>
<customwidgets>
<customwidget>
<class>LcdWidget</class>
<extends>QWidget</extends>
<header>lcdwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonsWidget</class>
<extends>QWidget</extends>
<header>buttonswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../companion.qrc"/>
</resources>
<connections/>
</ui>
@@ -116,6 +116,9 @@ SimulatorWidget::SimulatorWidget(QWidget * parent, SimulatorInterface * simulato
case Board::BOARD_RADIOMASTER_ZORRO:
radioUiWidget = new SimulatedUIWidgetZorro(simulator, this);
break;
case Board::BOARD_RADIOMASTER_BOXER:
radioUiWidget = new SimulatedUIWidgetBoxer(simulator, this);
break;
case Board::BOARD_RADIOMASTER_T8:
radioUiWidget = new SimulatedUIWidgetT8(simulator, this);
break;