1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 08:45:24 +03:00

Add trim keys to Taranis simu

This commit is contained in:
Andre Bernet 2014-04-06 22:25:34 +02:00
parent b4ae7e232f
commit d33d2b7ae6
7 changed files with 1120 additions and 855 deletions

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);
}

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,

File diff suppressed because it is too large Load diff

View file

@ -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);

View file

@ -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

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

View file

@ -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 {