Merge remote-tracking branch 'origin/next' into bsongis/9XR-PRO_port

Conflicts:
	companion/src/eeprominterface.cpp
	companion/src/eeprominterface.h
	companion/src/firmwares/opentx/opentxeeprom.cpp
	companion/src/firmwares/opentx/opentxinterface.cpp
	companion/src/firmwares/opentx/opentxinterface.h
	companion/src/mdichild.cpp
	radio/src/Makefile
This commit is contained in:
bsongis
2014-05-11 22:48:48 +02:00
477 changed files with 116230 additions and 71400 deletions
+300 -92
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<width>739</width>
<height>613</height>
</rect>
</property>
@@ -74,22 +74,6 @@
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
<item row="1" column="2">
<widget class="mySlider" name="trimVLeft">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGraphicsView" name="leftStick">
<property name="minimumSize">
@@ -137,7 +121,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>THR</string>
<string notr="true">THR</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -167,7 +151,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>RUD</string>
<string notr="true">RUD</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -197,7 +181,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>ELE</string>
<string notr="true">ELE</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -227,7 +211,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>AIL</string>
<string notr="true">AIL</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -360,7 +344,7 @@ QPushButton:checked {
</item>
</layout>
</item>
<item row="7" column="1">
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>20</number>
@@ -371,7 +355,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="leftXPerc">
<property name="text">
<string>TextLabel</string>
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -381,7 +365,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="leftYPerc">
<property name="text">
<string>TextLabel</string>
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -391,42 +375,138 @@ QPushButton:checked {
</layout>
</item>
<item row="2" column="1">
<widget class="mySlider" name="trimHLeft">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="trimHL_L">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">&lt;-</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="mySlider" name="trimHLeft">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="trimHL_R">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">-&gt;</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="trimVL_U">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">^</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="mySlider" name="trimVLeft">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="trimVL_D">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">v</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
<item row="1" column="0">
<widget class="mySlider" name="trimVRight">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0">
<item row="1" column="2">
<widget class="QGraphicsView" name="rightStick">
<property name="minimumSize">
<size>
@@ -442,7 +522,7 @@ QPushButton:checked {
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="3">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="switchTRN">
@@ -467,7 +547,7 @@ QPushButton:pressed {
}</string>
</property>
<property name="text">
<string>TRN</string>
<string notr="true">TRN</string>
</property>
</widget>
</item>
@@ -494,7 +574,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>GEA</string>
<string notr="true">GEA</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -527,7 +607,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>ID0</string>
<string notr="true">ID0</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -564,7 +644,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>ID1</string>
<string notr="true">ID1</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -597,7 +677,7 @@ QPushButton:checked {
}</string>
</property>
<property name="text">
<string>ID2</string>
<string notr="true">ID2</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -609,7 +689,7 @@ QPushButton:checked {
</item>
</layout>
</item>
<item row="0" column="1">
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="holdRightX">
@@ -733,7 +813,7 @@ QPushButton:checked {
</item>
</layout>
</item>
<item row="3" column="1">
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="leftMargin">
<number>20</number>
@@ -744,7 +824,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="rightXPerc">
<property name="text">
<string>TextLabel</string>
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -754,7 +834,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="rightYPerc">
<property name="text">
<string>TextLabel</string>
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -763,21 +843,133 @@ QPushButton:checked {
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="mySlider" name="trimHRight">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<item row="2" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="trimHR_L">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">&lt;-</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="mySlider" name="trimHRight">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="trimHR_R">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">-&gt;</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="trimVR_U">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">^</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="mySlider" name="trimVRight">
<property name="toolTip">
<string>Right Double Click to Reset</string>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="trimVR_D">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="text">
<string notr="true">v</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
@@ -842,7 +1034,7 @@ QPushButton:checked {
</size>
</property>
<property name="toolTip">
<string>P1</string>
<string notr="true">P1</string>
</property>
<property name="minimum">
<number>-1024</number>
@@ -864,7 +1056,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="dialP_1value">
<property name="text">
<string>0 %</string>
<string notr="true">0 %</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -899,7 +1091,7 @@ QPushButton:checked {
</size>
</property>
<property name="toolTip">
<string>P2</string>
<string notr="true">P2</string>
</property>
<property name="minimum">
<number>-1024</number>
@@ -924,7 +1116,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="dialP_2value">
<property name="text">
<string>0 %</string>
<string notr="true">0 %</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -959,7 +1151,7 @@ QPushButton:checked {
</size>
</property>
<property name="toolTip">
<string>P3</string>
<string notr="true">P3</string>
</property>
<property name="minimum">
<number>-1024</number>
@@ -981,7 +1173,7 @@ QPushButton:checked {
<item>
<widget class="QLabel" name="dialP_3value">
<property name="text">
<string>0 %</string>
<string notr="true">0 %</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -1248,6 +1440,22 @@ QPushButton:checked {
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Gvars</string>
</attribute>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>711</width>
<height>211</height>
</rect>
</property>
<layout class="QGridLayout" name="gvarsLayout"/>
</widget>
</widget>
</widget>
</item>
</layout>
@@ -1259,6 +1467,11 @@ QPushButton:checked {
<header>lcdwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>mySlider</class>
<extends>QSlider</extends>
<header location="global">myslider.h</header>
</customwidget>
<customwidget>
<class>cursorWidget</class>
<extends>QWidget</extends>
@@ -1271,11 +1484,6 @@ QPushButton:checked {
<header>menuwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>mySlider</class>
<extends>QSlider</extends>
<header location="global">myslider.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../companion.qrc"/>
File diff suppressed because it is too large Load Diff
+287 -42
View File
@@ -18,12 +18,16 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
lightOn(false),
txInterface(NULL),
simulator(NULL),
lastPhase(-1),
beepVal(0),
buttonPressed(0),
trimPressed (TRIM_NONE),
middleButtonPressed(false)
{
}
uint32_t SimulatorDialog9X::switchstatus = 0;
SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
SimulatorDialog(parent, flags),
ui(new Ui::SimulatorDialog9X),
@@ -34,8 +38,7 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
initUi<Ui::SimulatorDialog9X>(ui);
QSettings settings;
backLight = settings.value("backLight", 0).toInt();
backLight = g.backLight();
if (backLight > 4) backLight = 0;
switch (backLight) {
case 1:
@@ -55,18 +58,50 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
break;
}
//restore switches
if (g.simuSW())
restoreSwitches();
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->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()));
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()));
}
SimulatorDialog9X::~SimulatorDialog9X()
{
saveSwitches();
delete ui;
}
uint32_t SimulatorDialogTaranis::switchstatus = 0;
SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int flags):
SimulatorDialog(parent, flags),
ui(new Ui::SimulatorDialogTaranis)
@@ -79,18 +114,49 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int fl
ui->lcd->setBackgroundColor(47, 123, 227);
//restore switches
if (g.simuSW())
restoreSwitches();
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()
{
saveSwitches();
delete ui;
}
SimulatorDialog::~SimulatorDialog()
{
delete timer;
delete simulator;
}
void SimulatorDialog::closeEvent (QCloseEvent *)
@@ -125,6 +191,31 @@ void SimulatorDialog::wheelEvent (QWheelEvent *event)
simulator->wheelEvent(event->delta() > 0 ? 1 : -1);
}
void SimulatorDialog::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 SimulatorDialog::onTrimReleased()
{
trimPressed = TRIM_NONE;
}
void SimulatorDialog::keyPressEvent (QKeyEvent *event)
{
switch (event->key()) {
@@ -194,6 +285,7 @@ void SimulatorDialog::initUi(T * ui)
tabWidget = ui->tabWidget;
logicalSwitchesLayout = ui->logicalSwitchesLayout;
channelsLayout = ui->channelsLayout;
gvarsLayout = ui->gvarsLayout;
leftXPerc = ui->leftXPerc;
leftYPerc = ui->leftYPerc;
rightXPerc = ui->rightXPerc;
@@ -205,31 +297,26 @@ void SimulatorDialog::initUi(T * ui)
setFixedSize(width(), height());
#ifdef JOYSTICKS
QSettings settings;
bool js_enable = settings.value("js_support",false).toBool();
int js_ctrl=settings.value("js_ctrl",-1).toInt();
if (js_enable) {
settings.beginGroup("JsCalibration");
if (g.jsSupport()) {
int count=0;
for (int j=0; j<8;j++){
int axe=settings.value(QString("stick%1_axe").arg(j),-1).toInt();
for (int j=0; j<8; j++){
int axe = g.joystick[j].stick_axe();
if (axe>=0 && axe<8) {
jsmap[axe]=j;
jscal[axe][0]=settings.value(QString("stick%1_min").arg(j),-32767).toInt();
jscal[axe][1]=settings.value(QString("stick%1_med").arg(j),0).toInt();
jscal[axe][2]=settings.value(QString("stick%1_max").arg(j),0).toInt();
jscal[axe][3]=settings.value(QString("stick%1_inv").arg(j),0).toInt();
jscal[axe][0] = g.joystick[j].stick_min();
jscal[axe][1] = g.joystick[j].stick_med();
jscal[axe][2] = g.joystick[j].stick_max();
jscal[axe][3] = g.joystick[j].stick_inv();
count++;
}
}
settings.endGroup();
if (count<3) {
QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly"));
}
if (js_ctrl!=-1) {
if (g.jsCtrl()!=-1) {
joystick = new Joystick(this);
if (joystick) {
if (joystick->open(js_ctrl)) {
if (joystick->open(g.jsCtrl())) {
int numAxes=std::min(joystick->numAxes,8);
for (int j=0; j<numAxes; j++) {
joystick->sensitivities[j] = 0;
@@ -255,10 +342,10 @@ void SimulatorDialog::initUi(T * ui)
txInterface = GetEepromInterface();
windowName = tr("Simulating Tx (%1)").arg(txInterface->getName());
windowName = tr("Simulating Radio (%1)").arg(txInterface->getName());
setWindowTitle(windowName);
simulator = txInterface->getSimulator();
simulator = GetCurrentFirmware()->getSimulator();
lcd->setData(simulator->getLcd(), lcdWidth, 64, lcdDepth);
if (flags & SIMULATOR_FLAGS_STICK_MODE_LEFT) {
@@ -272,7 +359,7 @@ void SimulatorDialog::initUi(T * ui)
setTrims();
int outputs = std::min(16, txInterface->getCapability(Outputs));
int outputs = std::min(16, GetCurrentFirmware()->getCapability(Outputs));
for (int i=0; i<outputs; i++) {
int column = i / (outputs/2);
int line = i % (outputs/2);
@@ -313,7 +400,7 @@ void SimulatorDialog::initUi(T * ui)
channelsLayout->addWidget(value, line, column == 0 ? 2 : 3, 1, 1);
}
int switches = txInterface->getCapability(LogicalSwitches);
int switches = GetCurrentFirmware()->getCapability(LogicalSwitches);
for (int i=0; i<switches; i++) {
QFrame * swtch = new QFrame(tabWidget);
swtch->setAutoFillBackground(true);
@@ -330,23 +417,39 @@ void SimulatorDialog::initUi(T * ui)
logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1);
}
if (flags & SIMULATOR_FLAGS_NOTX) {
ui->tabWidget->setCurrentIndex(1);
}
else {
ui->lcd->setFocus();
int fmodes = GetCurrentFirmware()->getCapability(FlightModes);
int gvars = GetCurrentFirmware()->getCapability(Gvars);
if (gvars>0) {
for (int fm=0; fm<fmodes; fm++) {
QLabel * label = new QLabel(tabWidget);
label->setText(QString("FM%1").arg(fm+1));
gvarsLayout->addWidget(label, 0, fm+1);
}
for (int i=0; i<gvars; i++) {
QLabel * label = new QLabel(tabWidget);
label->setText(QString("GV%1").arg(i+1));
gvarsLayout->addWidget(label, i+1, 0);
for (int fm=0; fm<fmodes; fm++) {
QLabel * value = new QLabel(tabWidget);
gvarValues << value;
gvarsLayout->addWidget(value, i+1, fm+1);
}
}
}
setupTimer();
if (flags & SIMULATOR_FLAGS_NOTX) {
ui->tabWidget->setCurrentWidget(ui->outputs);
}
else {
ui->tabWidget->setCurrentWidget(ui->simu);
}
}
void SimulatorDialog::onButtonPressed(int value)
{
if (value == Qt::Key_Print) {
QSettings settings;
bool toclipboard = settings.value("snapshot_to_clipboard", false).toBool();
QString fileName = "";
if (!toclipboard) {
if (!g.snapToClpbrd()) {
fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
}
lcd->makeScreenshot(fileName);
@@ -364,7 +467,7 @@ void SimulatorDialog9X::setLightOn(bool enable)
list << "bl" << "gr" << "rd" << "or" << "yl";
bg = QString("-") + list[backLight];
}
ui->top->setStyleSheet(QString("background:url(:/images/9xdt.png%1);").arg(bg));
ui->top->setStyleSheet(QString("background:url(:/images/9xdt%1.png);").arg(bg));
ui->bottom->setStyleSheet(QString("background:url(:/images/9xdb%1.png);").arg(bg));
ui->left->setStyleSheet(QString("background:url(:/images/9xdl%1.png);").arg(bg));
ui->right->setStyleSheet(QString("background:url(:/images/9xdr%1.png);").arg(bg));
@@ -397,7 +500,7 @@ void SimulatorDialog::onTimerEvent()
getValues();
if (!(flags & SIMULATOR_FLAGS_NOTX) && tabWidget->currentIndex()==0) {
if (tabWidget->currentIndex()==0) {
bool lightEnable;
if (simulator->lcdChanged(lightEnable)) {
lcd->onLcdChanged(lightEnable);
@@ -408,6 +511,19 @@ void SimulatorDialog::onTimerEvent()
}
}
//display current flight mode in window title
unsigned int currentPhase = simulator->getPhase();
if (currentPhase != lastPhase) {
lastPhase = currentPhase;
const char * phase_name = simulator->getPhaseName(currentPhase);
if ( phase_name && phase_name[0] ) {
setWindowTitle(windowName + QString(" [fm: %1]").arg(QString(phase_name)));
}
else {
setWindowTitle(windowName + QString(" [fm: %1]").arg(simulator->getPhase()));
}
}
if (!(lcd_counter++ % 5)) {
setValues();
@@ -436,12 +552,22 @@ void SimulatorDialog::centerSticks()
void SimulatorDialog::start(QByteArray & eeprom)
{
lastPhase = -1;
numGvars = GetCurrentFirmware()->getCapability(Gvars);
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
getValues();
setupTimer();
}
void SimulatorDialog::start(const char * filename)
{
lastPhase = -1;
numGvars = GetCurrentFirmware()->getCapability(Gvars);
numFlightModes = GetCurrentFirmware()->getCapability(FlightModes);
simulator->start(filename);
getValues();
setupTimer();
}
void SimulatorDialog::setTrims()
@@ -496,12 +622,73 @@ void SimulatorDialog9X::getValues()
buttonPressed == Qt::Key_Left,
},
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);
}
void SimulatorDialog9X::saveSwitches(void)
{
// qDebug() << "SimulatorDialog9X::saveSwitches()";
switchstatus=ui->switchTHR->isChecked();
switchstatus<<=1;
switchstatus+=(ui->switchRUD->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchID2->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchID1->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchID0->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchGEA->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchELE->isChecked()&0x1);
switchstatus<<=1;
switchstatus+=(ui->switchAIL->isChecked()&0x1);
}
void SimulatorDialog9X::restoreSwitches(void)
{
// qDebug() << "SimulatorDialog9X::restoreSwitches()";
ui->switchAIL->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchELE->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchGEA->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchID0->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchID1->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchID2->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchRUD->setChecked(switchstatus & 0x1);
switchstatus >>=1;
ui->switchTHR->setChecked(switchstatus & 0x1);
}
void SimulatorDialogTaranis::resetSH()
{
ui->switchH->setValue(0);
}
void SimulatorDialogTaranis::on_switchH_sliderReleased()
{
QTimer::singleShot(400, this, SLOT(resetSH()));
}
void SimulatorDialogTaranis::getValues()
{
TxInputs inputs = {
@@ -515,6 +702,7 @@ void SimulatorDialogTaranis::getValues()
{
-ui->dialP_1->value(),
ui->dialP_2->value(),
0,
-ui->dialP_3->value(),
ui->dialP_4->value()
},
@@ -539,12 +727,63 @@ 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);
}
void SimulatorDialogTaranis::saveSwitches(void)
{
// qDebug() << "SimulatorDialogTaranis::saveSwitches()";
switchstatus=ui->switchA->value();
switchstatus<<=2;
switchstatus+=ui->switchB->value();
switchstatus<<=2;
switchstatus+=ui->switchC->value();
switchstatus<<=2;
switchstatus+=ui->switchD->value();
switchstatus<<=2;
switchstatus+=ui->switchE->value();
switchstatus<<=2;
switchstatus+=ui->switchF->value();
switchstatus<<=2;
switchstatus+=ui->switchG->value();
switchstatus<<=2;
switchstatus+=ui->switchH->value();
}
void SimulatorDialogTaranis::restoreSwitches(void)
{
// qDebug() << "SimulatorDialogTaranis::restoreSwitches()";
ui->switchH->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchG->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchF->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchE->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchD->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchC->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchB->setValue(switchstatus & 0x3);
switchstatus>>=2;
ui->switchA->setValue(switchstatus & 0x3);
}
inline int chVal(int val)
{
return qMin(1024, qMax(-1024, val));
@@ -560,16 +799,16 @@ void SimulatorDialog::on_trimVLeft_valueChanged(int value)
simulator->setTrim(1, value);
}
void SimulatorDialog::on_trimHRight_valueChanged(int value)
{
simulator->setTrim(3, value);
}
void SimulatorDialog::on_trimVRight_valueChanged(int value)
{
simulator->setTrim(2, value);
}
void SimulatorDialog::on_trimHRight_valueChanged(int value)
{
simulator->setTrim(3, value);
}
void SimulatorDialog::setValues()
{
TxOutputs outputs;
@@ -577,7 +816,7 @@ void SimulatorDialog::setValues()
Trims trims;
simulator->getTrims(trims);
for (int i=0; i<std::min(16, GetEepromInterface()->getCapability(Outputs)); i++) {
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));
}
@@ -585,16 +824,22 @@ void SimulatorDialog::setValues()
leftXPerc->setText(QString("X %1%").arg((qreal)nodeLeft->getX()*100+trims.values[0]/5, 2, 'f', 0));
leftYPerc->setText(QString("Y %1%").arg((qreal)nodeLeft->getY()*-100+trims.values[1]/5, 2, 'f', 0));
rightXPerc->setText(QString("X %1%").arg((qreal)nodeRight->getX()*100+trims.values[2]/5, 2, 'f', 0));
rightYPerc->setText(QString("Y %1%").arg((qreal)nodeRight->getY()*-100+trims.values[3]/5, 2, 'f', 0));
rightXPerc->setText(QString("X %1%").arg((qreal)nodeRight->getX()*100+trims.values[3]/5, 2, 'f', 0));
rightYPerc->setText(QString("Y %1%").arg((qreal)nodeRight->getY()*-100+trims.values[2]/5, 2, 'f', 0));
QString CSWITCH_ON = "QLabel { background-color: #4CC417 }";
QString CSWITCH_OFF = "QLabel { }";
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
for (int i=0; i<GetCurrentFirmware()->getCapability(LogicalSwitches); i++) {
logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF);
}
for (unsigned int fm=0; fm<numFlightModes; fm++) {
for (unsigned int gv=0; gv<numGvars; gv++) {
gvarValues[fm*numGvars+gv]->setText(QString("%1").arg(outputs.gvars[fm][gv]));
}
}
if (outputs.beep) {
beepVal = outputs.beep;
}
@@ -53,9 +53,11 @@ class SimulatorDialog : public QDialog
QTabWidget * tabWidget;
QGridLayout * logicalSwitchesLayout;
QGridLayout * channelsLayout;
QGridLayout * gvarsLayout;
QVector<QLabel *> logicalSwitchLabels;
QVector<QSlider *> channelSliders;
QVector<QLabel *> channelValues;
QVector<QLabel *> gvarValues;
void init();
Node *nodeLeft;
@@ -65,6 +67,8 @@ class SimulatorDialog : public QDialog
unsigned int backLight;
bool lightOn;
int switches;
unsigned int numGvars;
unsigned int numFlightModes;
#ifdef JOYSTICKS
Joystick *joystick;
int jscal[8][4];
@@ -73,6 +77,7 @@ class SimulatorDialog : public QDialog
EEPROMInterface *txInterface;
SimulatorInterface *simulator;
unsigned int lastPhase;
void setupSticks();
void setupTimer();
@@ -102,6 +107,7 @@ class SimulatorDialog : public QDialog
virtual void keyReleaseEvent(QKeyEvent *);
static int screenshotIdx;
int buttonPressed;
int trimPressed;
bool middleButtonPressed;
private slots:
@@ -119,6 +125,8 @@ class SimulatorDialog : public QDialog
void on_trimHRight_valueChanged(int);
void on_trimVRight_valueChanged(int);
void onTimerEvent();
void onTrimPressed();
void onTrimReleased();
#ifdef JOYSTICKS
void onjoystickAxisValueChanged(int axis, int value);
@@ -138,12 +146,15 @@ class SimulatorDialog9X: public SimulatorDialog
virtual void getValues();
virtual void setLightOn(bool enable);
virtual void updateBeepButton();
void saveSwitches(void);
void restoreSwitches(void);
private slots:
void dialChanged();
private:
Ui::SimulatorDialog9X * ui;
static uint32_t switchstatus;
int beepShow;
};
@@ -158,10 +169,16 @@ class SimulatorDialogTaranis: public SimulatorDialog
protected:
virtual void getValues();
void saveSwitches(void);
void restoreSwitches(void);
private:
Ui::SimulatorDialogTaranis * ui;
static uint32_t switchstatus;
private slots:
void resetSH();
void on_switchH_sliderReleased();
};
#endif // SIMULATORDIALOG_H
+12 -2
View File
@@ -14,6 +14,10 @@
*
*/
#if !defined(NUM_LOGICAL_SWITCH) && defined(NUM_CSW)
#define NUM_LOGICAL_SWITCH NUM_CSW
#endif
#ifdef INIT_IMPORT
#undef INIT_IMPORT
#ifdef FRSKY
@@ -32,7 +36,7 @@ for (int i=0; i<C9X_NUM_SWITCHES; i++)
for (int i=0; i<C9X_NUM_KEYS; i++)
simuSetKey(i, inputs.keys[i]);
for (int i=0; i<NUM_STICKS*2; i++)
simuSetTrim(i, 0);
simuSetTrim(i, inputs.trims[i]);
#ifdef PCBGRUVIN9X
// rotary encoders
@@ -49,13 +53,19 @@ if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40;
#undef GETVALUES_IMPORT
memset(outputs.chans, 0, sizeof(outputs.chans));
memcpy(outputs.chans, g_chans512, sizeof(g_chans512));
for (int i=0; i<NUM_CSW; i++)
for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
#if defined(BOLD_FONT)
outputs.vsw[i] = getSwitch(SWSRC_SW1+i);
#else
outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0);
#endif
#ifdef GVAR_VALUE // defined(GVARS)
uint8_t phase = getFlightPhase();
for (int fm=0; fm<MAX_FLIGHT_MODES; fm++)
for (int gv=0; gv<MAX_GVARS; gv++)
outputs.gvars[fm][gv] = GVAR_VALUE(gv, fm);
#endif
#endif //GETVALUES_IMPORT
#ifdef LCDCHANGED_IMPORT
#undef LCDCHANGED_IMPORT
@@ -21,10 +21,11 @@
struct TxInputs {
int sticks[NUM_STICKS]; /* lh lv rv rh */
int pots[4]; /* TODO NUM_POTS */
int pots[5]; /* TODO NUM_POTS */
int switches[10]; /* TODO NUM_SWITCHES */
bool keys[6]; /* TODO NUM_KEYS */
bool rotenc;
bool trims[8];
};
class TxOutputs {
@@ -35,6 +36,7 @@ class TxOutputs {
int16_t chans[C9X_NUM_CHNOUT];
bool vsw[32]; /* TODO NUM_VIRTUAL_SWITCHES */
int16_t gvars[9][9]; /*TODO MAX_FLIGHT_MODES, NUM_GVARS */
unsigned int beep;
};
@@ -47,6 +49,8 @@ class SimulatorInterface {
public:
virtual ~SimulatorInterface() {};
virtual void start(QByteArray & eeprom, bool tests=true) = 0;
virtual void start(const char * filename, bool tests=true) = 0;
@@ -68,6 +72,8 @@ class SimulatorInterface {
virtual void getTrims(Trims & trims) = 0;
virtual unsigned int getPhase() = 0;
virtual const char * getPhaseName(unsigned int phase) = 0;
virtual void wheelEvent(uint8_t steps) = 0;