Merge pull request #943 from opentx/kilrah/simu_trim_keys

Kilrah/simu trim keys
This commit is contained in:
Bertrand Songis
2014-04-07 10:41:14 +02:00
8 changed files with 1393 additions and 925 deletions
+6 -2
View File
@@ -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);
}
+14
View File
@@ -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,
+237 -69
View File
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<width>739</width>
<height>613</height>
</rect>
</property>
@@ -73,23 +73,7 @@
<number>6</number>
</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>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0">
<item row="1" column="1">
<widget class="QGraphicsView" name="leftStick">
<property name="minimumSize">
@@ -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>
@@ -391,42 +375,126 @@ 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>
</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>
</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>
</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>
</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 +510,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">
@@ -609,7 +677,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 +801,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>
@@ -763,21 +831,121 @@ 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>
</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>
</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>
</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>
</widget>
</item>
</layout>
</item>
</layout>
</item>
File diff suppressed because it is too large Load Diff
+100 -2
View File
@@ -20,6 +20,7 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
simulator(NULL),
beepVal(0),
buttonPressed(0),
trimPressed (TRIM_NONE),
middleButtonPressed(false)
{
}
@@ -55,11 +56,36 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
break;
}
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()
@@ -79,8 +105,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 +176,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()) {
@@ -498,7 +574,18 @@ 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);
@@ -542,7 +629,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);
@@ -102,6 +102,7 @@ class SimulatorDialog : public QDialog
virtual void keyReleaseEvent(QKeyEvent *);
static int screenshotIdx;
int buttonPressed;
int trimPressed;
bool middleButtonPressed;
private slots:
@@ -119,6 +120,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);
+1 -1
View File
@@ -36,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
@@ -25,6 +25,7 @@ struct TxInputs {
int switches[10]; /* TODO NUM_SWITCHES */
bool keys[6]; /* TODO NUM_KEYS */
bool rotenc;
bool trims[8];
};
class TxOutputs {