Simu renamed to simulator, in the same directory as companion
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
set(simulation_SRCS
|
||||
simulatordialog.cpp
|
||||
)
|
||||
|
||||
set(simulation_UIS
|
||||
simulatordialog-9x.ui
|
||||
simulatordialog-taranis.ui
|
||||
)
|
||||
|
||||
set(simulation_HDRS
|
||||
simulatordialog.h
|
||||
cursorwidget.h
|
||||
menuwidget.h
|
||||
xcursorwidget.h
|
||||
xmenuwidget.h
|
||||
)
|
||||
|
||||
if(SDL_FOUND)
|
||||
set(simulation_SRCS
|
||||
${simulation_SRCS}
|
||||
joystick.cpp
|
||||
joystickdialog.cpp
|
||||
)
|
||||
|
||||
set(simulation_HDRS
|
||||
${simulation_HDRS}
|
||||
joystick.h
|
||||
joystickdialog.h
|
||||
)
|
||||
|
||||
set(simulation_UIS
|
||||
${simulation_UIS}
|
||||
joystickdialog.ui
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/../..
|
||||
${COMPANION_SRC_DIRECTORY}
|
||||
${RADIO_SRC_DIRECTORY}/fonts/std
|
||||
)
|
||||
|
||||
qt4_wrap_ui(simulation_SRCS ${simulation_UIS})
|
||||
qt4_wrap_cpp(simulation_SRCS ${simulation_HDRS})
|
||||
|
||||
add_library(simulation ${simulation_SRCS})
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#ifndef CURSORWIDGET_H
|
||||
#define CURSORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtGui>
|
||||
|
||||
class cursorWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit cursorWidget(QWidget * parent = 0):
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
float upx[] = {68,28,51,83,105,68};
|
||||
float upy[] = {83,45,32,32,45,83};
|
||||
float minx[] = {74,114,127,127,114,74};
|
||||
float miny[] = {90,51,80,106,130,90};
|
||||
float dox[] = {68,28,51,83,105,68};
|
||||
float doy[] = {98,137,151,151,137,98};
|
||||
float plusx[] = { 80,20,7,7,20,80};
|
||||
float plusy[] = {90,51,80,106,130,90};
|
||||
|
||||
int x=event->x();
|
||||
int y=event->y();
|
||||
setFocus();
|
||||
if (event->button()==Qt::LeftButton) {
|
||||
if (pnpoly(6,upx,upy,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/9xcursup.png);");
|
||||
emit buttonPressed(Qt::Key_Up);
|
||||
}
|
||||
else if (pnpoly(6,minx,miny,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/9xcursmin.png);");
|
||||
emit buttonPressed(Qt::Key_Right);
|
||||
}
|
||||
else if (pnpoly(6,dox,doy,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/9xcursdown.png);");
|
||||
emit buttonPressed(Qt::Key_Down);
|
||||
}
|
||||
else if (pnpoly(6,plusx,plusy,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/9xcursplus.png);");
|
||||
emit buttonPressed(Qt::Key_Left);
|
||||
} else if (sqrt(((float)x-22)*((float)x-22)+((float)y-165)*((float)y-165))<17) {
|
||||
setStyleSheet("background:url(:/images/9xcursphoto.png);");
|
||||
emit buttonPressed(Qt::Key_Print);
|
||||
}
|
||||
}
|
||||
// QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent(QMouseEvent * event)
|
||||
{
|
||||
setStyleSheet("background:url(:/images/9xcurs.png);");
|
||||
emit buttonPressed(0);
|
||||
setFocus();
|
||||
//QWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
|
||||
{
|
||||
int i, j, c = 0;
|
||||
for (i = 0, j = nvert-1; i < nvert; j = i++) {
|
||||
if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
|
||||
c = !c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonPressed(int button);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* CURSORWIDGET_H */
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "joystick.h"
|
||||
|
||||
Joystick::Joystick(QObject *parent, int joystickEventTimeout, bool doAutoRepeat, int repeatDelay)
|
||||
: QObject(parent)
|
||||
{
|
||||
if ( SDL_Init(SDL_INIT_JOYSTICK) == 0 ) {
|
||||
int i;
|
||||
for (i = 0; i < SDL_NumJoysticks(); i++)
|
||||
joystickNames.append(SDL_JoystickName(i));
|
||||
connect(&joystickTimer, SIGNAL(timeout()), this, SLOT(processEvents()));
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: couldn't initialize SDL joystick support");
|
||||
}
|
||||
|
||||
joystick = NULL;
|
||||
numAxes = numButtons = numHats = numTrackballs = 0;
|
||||
autoRepeat = doAutoRepeat;
|
||||
autoRepeatDelay = repeatDelay;
|
||||
eventTimeout = joystickEventTimeout;
|
||||
}
|
||||
|
||||
Joystick::~Joystick()
|
||||
{
|
||||
if ( isOpen() )
|
||||
close();
|
||||
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
bool Joystick::open(int stick)
|
||||
{
|
||||
if ( isOpen() )
|
||||
close();
|
||||
|
||||
joystick = SDL_JoystickOpen(stick);
|
||||
if ( joystick ) {
|
||||
numAxes = SDL_JoystickNumAxes(joystick);
|
||||
numButtons = SDL_JoystickNumButtons(joystick);
|
||||
numHats = SDL_JoystickNumHats(joystick);
|
||||
numTrackballs = SDL_JoystickNumBalls(joystick);
|
||||
joystickTimer.start(eventTimeout);
|
||||
return TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: couldn't open SDL joystick #%d", stick);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void Joystick::close()
|
||||
{
|
||||
joystickTimer.stop();
|
||||
if ( joystick )
|
||||
SDL_JoystickClose(joystick);
|
||||
joystick = NULL;
|
||||
numAxes = numButtons = numHats = numTrackballs = 0;
|
||||
}
|
||||
|
||||
void Joystick::processEvents()
|
||||
{
|
||||
if ( !isOpen() )
|
||||
return;
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numAxes; i++) {
|
||||
Sint16 moved = SDL_JoystickGetAxis(joystick, i);
|
||||
if ( abs(moved) >= deadzones[i] ) {
|
||||
if ( (moved != axes[i]) ) {
|
||||
int deltaMoved = abs(axes[i] - moved);
|
||||
if ( deltaMoved >= sensitivities[i] )
|
||||
emit axisValueChanged(i, moved);
|
||||
axes[i] = moved;
|
||||
axisRepeatTimers[i].restart();
|
||||
} else if (autoRepeat && moved != 0) {
|
||||
if ( axisRepeatTimers[i].elapsed() >= autoRepeatDelay ) {
|
||||
emit axisValueChanged(i, moved);
|
||||
axes[i] = moved;
|
||||
}
|
||||
} else
|
||||
axisRepeatTimers[i].restart();
|
||||
} else
|
||||
emit axisValueChanged(i, 0);
|
||||
}
|
||||
for (i = 0; i < numButtons; i++) {
|
||||
Uint8 changed = SDL_JoystickGetButton(joystick, i);
|
||||
if ( (changed != buttons[i]) ) {
|
||||
emit buttonValueChanged(i, (bool) changed);
|
||||
buttons[i] = changed;
|
||||
buttonRepeatTimers[i].restart();
|
||||
} else if (autoRepeat && changed != 0) {
|
||||
if ( buttonRepeatTimers[i].elapsed() >= autoRepeatDelay ) {
|
||||
emit buttonValueChanged(i, (bool) changed);
|
||||
buttons[i] = changed;
|
||||
}
|
||||
} else
|
||||
buttonRepeatTimers[i].restart();
|
||||
}
|
||||
for (i = 0; i < numHats; i++) {
|
||||
Uint8 changed = SDL_JoystickGetHat(joystick, i);
|
||||
if ( (changed != hats[i]) ) {
|
||||
emit hatValueChanged(i, changed);
|
||||
hats[i] = changed;
|
||||
hatRepeatTimers[i].restart();
|
||||
} else if (autoRepeat && changed != 0) {
|
||||
if ( hatRepeatTimers[i].elapsed() >= autoRepeatDelay ) {
|
||||
emit hatValueChanged(i, changed);
|
||||
hats[i] = changed;
|
||||
}
|
||||
} else
|
||||
hatRepeatTimers[i].restart();
|
||||
}
|
||||
|
||||
for (i = 0; i < numTrackballs; i++) {
|
||||
int dx, dy;
|
||||
SDL_JoystickGetBall(joystick, i, &dx, &dy);
|
||||
if ( dx != 0 || dy != 0 )
|
||||
emit trackballValueChanged(i, dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
int Joystick::getAxisValue(int axis)
|
||||
{
|
||||
if ( isOpen() ) {
|
||||
SDL_JoystickUpdate();
|
||||
return SDL_JoystickGetAxis(joystick, axis);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef _JOYSTICK_H_
|
||||
#define _JOYSTICK_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
#include <SDL.h>
|
||||
|
||||
#define SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT 25
|
||||
#define SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY 250
|
||||
|
||||
class Joystick : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QStringList joystickNames;
|
||||
SDL_Joystick *joystick;
|
||||
int numAxes;
|
||||
int numButtons;
|
||||
int numHats;
|
||||
int numTrackballs;
|
||||
int eventTimeout;
|
||||
int autoRepeatDelay;
|
||||
bool autoRepeat;
|
||||
QTimer joystickTimer;
|
||||
QMap<int, int> deadzones;
|
||||
QMap<int, int> sensitivities;
|
||||
|
||||
Joystick(QObject *parent = 0,
|
||||
int joystickEventTimeout = SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT,
|
||||
bool doAutoRepeat = TRUE,
|
||||
int autoRepeatDelay = SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY);
|
||||
~Joystick();
|
||||
bool open(int);
|
||||
void close();
|
||||
bool isOpen() { return joystick != NULL; }
|
||||
int getAxisValue(int);
|
||||
|
||||
private:
|
||||
QMap<int, Sint16> axes;
|
||||
QMap<int, Uint8> buttons;
|
||||
QMap<int, Uint8> hats;
|
||||
QMap<int, QTime> axisRepeatTimers;
|
||||
QMap<int, QTime> buttonRepeatTimers;
|
||||
QMap<int, QTime> hatRepeatTimers;
|
||||
|
||||
signals:
|
||||
void axisValueChanged(int axis, int value);
|
||||
void buttonValueChanged(int button, bool value);
|
||||
void hatValueChanged(int hat, int value);
|
||||
void trackballValueChanged(int trackball, int deltaX, int deltaY);
|
||||
|
||||
public slots:
|
||||
void processEvents();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
#include "joystickdialog.h"
|
||||
#include "ui_joystickdialog.h"
|
||||
#include <QtGui>
|
||||
|
||||
joystickDialog::joystickDialog(QWidget *parent, int stick) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::joystickDialog) {
|
||||
ui->setupUi(this);
|
||||
int jscaltmp[8][3] = {
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767},
|
||||
{32767, 0, -32767}
|
||||
};
|
||||
memcpy(jscal, jscaltmp, sizeof (jscal));
|
||||
ui->okButton->setDisabled(true);
|
||||
ui->howtoLabel->setText(tr("Move sticks and pots in every direction making full movement\nPress next when finished"));
|
||||
step = 0;
|
||||
|
||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||
cb->setDisabled(true);
|
||||
}
|
||||
foreach(QCheckBox *ib, findChildren<QCheckBox *>(QRegExp("ChInv_[0-9]+"))) {
|
||||
ib->setDisabled(true);
|
||||
}
|
||||
joystickOpen(stick);
|
||||
connect(joystick, SIGNAL(axisValueChanged(int, int)), this, SLOT(onjoystickAxisValueChanged(int, int)));
|
||||
}
|
||||
|
||||
joystickDialog::~joystickDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void joystickDialog::joystickOpen(int stick) {
|
||||
if (stick == -1) {
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
joystick = new Joystick(this, 1, false, 0);
|
||||
int numAxes=std::min(joystick->numAxes,8);
|
||||
if (joystick) {
|
||||
joystick->open(stick);
|
||||
|
||||
for (int j=0; j<numAxes; j++) {
|
||||
joystick->sensitivities[j] = 0;
|
||||
joystick->deadzones[j]=20;
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Cannot open joystick."));
|
||||
this->close();
|
||||
}
|
||||
}
|
||||
|
||||
void joystickDialog::onjoystickAxisValueChanged(int axis, int value) {
|
||||
if (value > jscal[axis][2]) {
|
||||
jscal[axis][2] = value;
|
||||
}
|
||||
if (value < jscal[axis][0]) {
|
||||
jscal[axis][0] = value;
|
||||
}
|
||||
QSlider * sl[]= {ui->Ch_1, ui->Ch_2, ui->Ch_3, ui->Ch_4, ui->Ch_5, ui->Ch_6, ui->Ch_7, ui->Ch_8};
|
||||
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
|
||||
if (ib[axis]->isChecked()) {
|
||||
sl[axis]->setInvertedAppearance(true);
|
||||
} else {
|
||||
sl[axis]->setInvertedAppearance(false);
|
||||
}
|
||||
sl[axis]->setMinimum(jscal[axis][0]);
|
||||
sl[axis]->setMaximum(jscal[axis][2]);
|
||||
sl[axis]->setValue(value);
|
||||
}
|
||||
|
||||
void joystickDialog::on_nextButton_clicked() {
|
||||
int numAxes=std::min(joystick->numAxes,8);
|
||||
switch (step) {
|
||||
case 0:
|
||||
ui->howtoLabel->setText(tr("Place sticks and pots in middle position.\nPress next when done"));
|
||||
step++;
|
||||
break;
|
||||
case 1:
|
||||
for (int i=0; i<numAxes; i++) {
|
||||
jscal[i][1]=0;
|
||||
for (int j=0; j<100;j++) {
|
||||
jscal[i][1]+=joystick->getAxisValue(i);
|
||||
}
|
||||
jscal[i][1]/=100;
|
||||
}
|
||||
ui->howtoLabel->setText(tr("Map joystick channels to controls using comboboxes.\nPress next when done"));
|
||||
step++;
|
||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||
cb->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ui->howtoLabel->setText(tr("Check inversion checkbox to get maximum at top-right position.\nPress next when done"));
|
||||
step++;
|
||||
foreach(QCheckBox *ib, findChildren<QCheckBox *>(QRegExp("ChInv_[0-9]+"))) {
|
||||
ib->setEnabled(true);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
ui->howtoLabel->setText(tr("Press ok to save configuration\nPress cancel to abort joystick calibration"));
|
||||
ui->okButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void joystickDialog::on_cancelButton_clicked() {
|
||||
joystick->close();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void joystickDialog::on_okButton_clicked() {
|
||||
int sticks[8]={0,0,0,0,0,0,0,0};
|
||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||
sticks[cb->currentIndex()]++;
|
||||
}
|
||||
bool duplicated=false;
|
||||
for (int i=1; i<8;i++) {
|
||||
if (sticks[i]>1) {
|
||||
duplicated=true;
|
||||
}
|
||||
}
|
||||
if (duplicated) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Duplicated stick assignement"));
|
||||
return;
|
||||
}
|
||||
joystick->close();
|
||||
QSettings settings;
|
||||
settings.beginGroup("JsCalibration");
|
||||
for (int i=0; i<8;i++) {
|
||||
settings.remove(QString("stick%1_axe").arg(i));
|
||||
settings.remove(QString("stick%1_max").arg(i));
|
||||
settings.remove(QString("stick%1_med").arg(i));
|
||||
settings.remove(QString("stick%1_min").arg(i));
|
||||
settings.remove(QString("stick%1_inv").arg(i));
|
||||
}
|
||||
QCheckBox * ib[]={ui->ChInv_1, ui->ChInv_2, ui->ChInv_3, ui->ChInv_4, ui->ChInv_5, ui->ChInv_6, ui->ChInv_7, ui->ChInv_8};
|
||||
foreach(QComboBox *cb, findChildren<QComboBox *>(QRegExp("jsmapCB_[0-9]+"))) {
|
||||
int axe=cb->objectName().mid(cb->objectName().lastIndexOf("_")+1).toInt()-1;
|
||||
int stick=cb->currentIndex();
|
||||
if (stick>0) {
|
||||
settings.setValue(QString("stick%1_axe").arg(stick),axe);
|
||||
settings.setValue(QString("stick%1_max").arg(stick),jscal[axe][2]);
|
||||
settings.setValue(QString("stick%1_med").arg(stick),jscal[axe][1]);
|
||||
settings.setValue(QString("stick%1_min").arg(stick),jscal[axe][0]);
|
||||
settings.setValue(QString("stick%1_inv").arg(stick),ib[axe]->isChecked() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
this->close();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef JOYSTICKDIALOG_H
|
||||
#define JOYSTICKDIALOG_H
|
||||
|
||||
#include "joystick.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class joystickDialog;
|
||||
}
|
||||
|
||||
class joystickDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit joystickDialog(QWidget *parent = 0, int stick=-1);
|
||||
~joystickDialog();
|
||||
Joystick *joystick;
|
||||
|
||||
public slots:
|
||||
void onjoystickAxisValueChanged(int axis, int value);
|
||||
|
||||
private:
|
||||
Ui::joystickDialog *ui;
|
||||
void joystickOpen(int stick);
|
||||
int jscal[8][3];
|
||||
int step;
|
||||
|
||||
private slots:
|
||||
void on_nextButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
void on_okButton_clicked();
|
||||
|
||||
};
|
||||
|
||||
#endif // JOYSTICKDIALOG_H
|
||||
@@ -0,0 +1,915 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>joystickDialog</class>
|
||||
<widget class="QDialog" name="joystickDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Configure Joystick</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Ch2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSlider" name="Ch_3">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Ch1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="Ch_2">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Ch4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSlider" name="Ch_5">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Ch6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Ch3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSlider" name="Ch_4">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSlider" name="Ch_6">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Ch5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Ch7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSlider" name="Ch_7">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Ch8</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSlider" name="Ch_8">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="3">
|
||||
<widget class="QComboBox" name="jsmapCB_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Not Assigned</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>P3/LS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>RS</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="Ch_1">
|
||||
<property name="minimum">
|
||||
<number>-32767</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32676</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedControls">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_1">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_2">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_3">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_4">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_5">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_6">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_7">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QCheckBox" name="ChInv_8">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="howtoLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background:rgb(255, 255, 0);</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Instructions</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>198</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="nextButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="companion.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef lcd_widget_h
|
||||
#define lcd_widget_h
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class lcdWidget : public QWidget {
|
||||
public:
|
||||
lcdWidget(QWidget * parent = 0):
|
||||
QWidget(parent),
|
||||
lcdBuf(NULL),
|
||||
previousBuf(NULL),
|
||||
lightEnable(false)
|
||||
{
|
||||
}
|
||||
|
||||
~lcdWidget()
|
||||
{
|
||||
if (previousBuf)
|
||||
free(previousBuf);
|
||||
}
|
||||
|
||||
void setData(unsigned char *buf, int width, int height, int depth=1)
|
||||
{
|
||||
lcdBuf = buf;
|
||||
lcdWidth = width;
|
||||
lcdHeight = height;
|
||||
lcdDepth = depth;
|
||||
lcdSize = (width * ((height+7)/8)) * depth;
|
||||
previousBuf = (unsigned char *)malloc(lcdSize);
|
||||
memset(previousBuf, 0, lcdSize);
|
||||
}
|
||||
|
||||
void setBackgroundColor(int red, int green, int blue)
|
||||
{
|
||||
r = red;
|
||||
g = green;
|
||||
b = blue;
|
||||
}
|
||||
|
||||
void makeScreenshot(const QString & fileName)
|
||||
{
|
||||
QPixmap buffer(2*lcdWidth, 2*lcdHeight);
|
||||
QPainter p(&buffer);
|
||||
doPaint(p);
|
||||
QSettings settings;
|
||||
bool toclipboard=settings.value("snapshot_to_clipboard", false).toBool();
|
||||
QApplication::clipboard()->setPixmap( buffer );
|
||||
if (!toclipboard) {
|
||||
QString Path=settings.value("snapshotPath", "").toString();
|
||||
if (Path.isEmpty() || !QDir(Path).exists()) {
|
||||
Path=".";
|
||||
}
|
||||
Path.append(QDir::separator()+fileName);
|
||||
qDebug() << "Screenshot" << Path;
|
||||
buffer.toImage().save(Path);
|
||||
}
|
||||
}
|
||||
|
||||
void onLcdChanged(bool light)
|
||||
{
|
||||
if (light != lightEnable || memcmp(previousBuf, lcdBuf, lcdSize)) {
|
||||
lightEnable = light;
|
||||
memcpy(previousBuf, lcdBuf, lcdSize);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
setFocus();
|
||||
QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
int lcdWidth;
|
||||
int lcdHeight;
|
||||
int lcdDepth;
|
||||
int lcdSize;
|
||||
|
||||
unsigned char *lcdBuf;
|
||||
unsigned char *previousBuf;
|
||||
|
||||
bool lightEnable;
|
||||
int r, g, b;
|
||||
|
||||
inline void doPaint(QPainter & p)
|
||||
{
|
||||
QRgb rgb;
|
||||
|
||||
if (lightEnable)
|
||||
rgb = qRgb(r, g, b);
|
||||
else
|
||||
rgb = qRgb(161, 161, 161);
|
||||
|
||||
p.setBackground(QBrush(rgb));
|
||||
p.eraseRect(0, 0, 2*lcdWidth, 2*lcdHeight);
|
||||
|
||||
if (lcdBuf) {
|
||||
if (lcdDepth == 1) {
|
||||
rgb = qRgb(0, 0, 0);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
}
|
||||
|
||||
unsigned int previousDepth = 0xFF;
|
||||
const int planSize = (lcdWidth * ((lcdHeight+7) / 8));
|
||||
|
||||
for (int y=0; y<lcdHeight; y++) {
|
||||
unsigned int idx = (y/8)*lcdWidth;
|
||||
unsigned int mask = (1 << (y%8));
|
||||
for (int x=0; x<lcdWidth; x++, idx++) {
|
||||
if (lcdDepth == 1) {
|
||||
if (lcdBuf[idx] & mask)
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
else {
|
||||
unsigned int z = (((lcdBuf[idx] & mask) ? 0x1 : 0) + ((lcdBuf[planSize+idx] & mask) ? 0x2 : 0) + ((lcdBuf[2*planSize+idx] & mask) ? 0x4 : 0) + ((lcdBuf[3*planSize+idx] & mask) ? 0x8 : 0));
|
||||
if (z) {
|
||||
if (z != previousDepth) {
|
||||
previousDepth = z;
|
||||
if (lightEnable)
|
||||
rgb = qRgb(r-(z*r)/15, g-(z*g)/15, b-(z*b)/15);
|
||||
else
|
||||
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
}
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
doPaint(p);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial Usage
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QSettings>
|
||||
#include <QSplashScreen>
|
||||
#include <QThread>
|
||||
#include <iostream>
|
||||
#include "simulatordialog.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
#include <windows.h>
|
||||
#define sleep(x) Sleep(x*1000)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <QProxyStyle>
|
||||
|
||||
class MyProxyStyle : public QProxyStyle
|
||||
{
|
||||
public:
|
||||
void polish ( QWidget * w ) {
|
||||
QMenu* mn = dynamic_cast<QMenu*>(w);
|
||||
QPushButton* pb = dynamic_cast<QPushButton*>(w);
|
||||
if(!(mn || pb) && !w->testAttribute(Qt::WA_MacNormalSize))
|
||||
w->setAttribute(Qt::WA_MacSmallSize);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(companion);
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("OpenTX Simulator");
|
||||
app.setOrganizationName("OpenTX");
|
||||
app.setOrganizationDomain("open-tx.org");
|
||||
|
||||
#ifdef __APPLE__
|
||||
app.setStyle(new MyProxyStyle);
|
||||
#endif
|
||||
|
||||
QString dir;
|
||||
if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";
|
||||
|
||||
/* QTranslator companionTranslator;
|
||||
companionTranslator.load(":/companion_" + locale);
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
app.installTranslator(&companionTranslator);
|
||||
app.installTranslator(&qtTranslator);
|
||||
*/
|
||||
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
RegisterFirmwares();
|
||||
SimulatorDialog *dialog;
|
||||
|
||||
if (argc > 1 && !strcmp(argv[1], "taranis")) {
|
||||
current_firmware_variant = GetFirmwareVariant("opentx-taranis-en");
|
||||
dialog = new SimulatorDialogTaranis();
|
||||
}
|
||||
else {
|
||||
dialog = new SimulatorDialog9X();
|
||||
}
|
||||
|
||||
dialog->show();
|
||||
dialog->start("eeprom.bin");
|
||||
|
||||
int result = app.exec();
|
||||
|
||||
delete dialog;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#ifndef MENUWIDGET_H
|
||||
#define MENUWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtGui>
|
||||
|
||||
class menuWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit menuWidget(QWidget * parent = 0):
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
int x=event->x();
|
||||
int y=event->y();
|
||||
setFocus();
|
||||
if (event->button()==Qt::LeftButton) {
|
||||
if (x>25 && x<71 && y>60 && y<81) {
|
||||
setStyleSheet("background:url(:/images/9xmenumenu.png);");
|
||||
emit buttonPressed(Qt::Key_Enter);
|
||||
} else if (x>25 && x<71 && y>117 && y<139) {
|
||||
setStyleSheet("background:url(:/images/9xmenuexit.png);");
|
||||
emit buttonPressed(Qt::Key_Escape);
|
||||
}
|
||||
}
|
||||
// QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent(QMouseEvent * event)
|
||||
{
|
||||
setStyleSheet("background:url(:/images/9xmenu.png);");
|
||||
setFocus();
|
||||
emit buttonPressed(0);
|
||||
// QWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonPressed(int button);
|
||||
|
||||
};
|
||||
#endif /* MENUWIDGET_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,755 @@
|
||||
#include "simulatordialog.h"
|
||||
#include "ui_simulatordialog-9x.h"
|
||||
#include "ui_simulatordialog-taranis.h"
|
||||
#include <iostream>
|
||||
#include "helpers.h"
|
||||
#include "simulatorinterface.h"
|
||||
|
||||
#define GBALL_SIZE 20
|
||||
#define RESX 1024
|
||||
|
||||
int SimulatorDialog::screenshotIdx = 0;
|
||||
|
||||
SimulatorDialog::SimulatorDialog(QWidget * parent, unsigned int flags):
|
||||
QDialog(parent),
|
||||
flags(flags),
|
||||
dialP_4(NULL),
|
||||
timer(NULL),
|
||||
lightOn(false),
|
||||
txInterface(NULL),
|
||||
simulator(NULL),
|
||||
beepVal(0),
|
||||
buttonPressed(0),
|
||||
middleButtonPressed(false)
|
||||
{
|
||||
}
|
||||
|
||||
SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, unsigned int flags):
|
||||
SimulatorDialog(parent, flags),
|
||||
ui(new Ui::SimulatorDialog9X),
|
||||
beepShow(0)
|
||||
{
|
||||
lcdWidth = 128;
|
||||
lcdDepth = 1;
|
||||
|
||||
initUi<Ui::SimulatorDialog9X>(ui);
|
||||
|
||||
QSettings settings;
|
||||
backLight = settings.value("backLight", 0).toInt();
|
||||
if (backLight > 4) backLight = 0;
|
||||
switch (backLight) {
|
||||
case 1:
|
||||
ui->lcd->setBackgroundColor(166,247,159);
|
||||
break;
|
||||
case 2:
|
||||
ui->lcd->setBackgroundColor(247,159,166);
|
||||
break;
|
||||
case 3:
|
||||
ui->lcd->setBackgroundColor(255,195,151);
|
||||
break;
|
||||
case 4:
|
||||
ui->lcd->setBackgroundColor(247,242,159);
|
||||
break;
|
||||
default:
|
||||
ui->lcd->setBackgroundColor(159,165,247);
|
||||
break;
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
SimulatorDialog9X::~SimulatorDialog9X()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, unsigned int flags):
|
||||
SimulatorDialog(parent, flags),
|
||||
ui(new Ui::SimulatorDialogTaranis)
|
||||
{
|
||||
lcdWidth = 212;
|
||||
lcdDepth = 4;
|
||||
|
||||
initUi<Ui::SimulatorDialogTaranis>(ui);
|
||||
dialP_4 = ui->dialP_4;
|
||||
|
||||
ui->lcd->setBackgroundColor(47, 123, 227);
|
||||
|
||||
connect(ui->cursor, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int)));
|
||||
connect(ui->menu, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int)));
|
||||
}
|
||||
|
||||
SimulatorDialogTaranis::~SimulatorDialogTaranis()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
SimulatorDialog::~SimulatorDialog()
|
||||
{
|
||||
delete timer;
|
||||
}
|
||||
|
||||
void SimulatorDialog::closeEvent (QCloseEvent *)
|
||||
{
|
||||
simulator->stop();
|
||||
timer->stop();
|
||||
}
|
||||
|
||||
void SimulatorDialog::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MidButton) {
|
||||
middleButtonPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MidButton) {
|
||||
middleButtonPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog9X::dialChanged()
|
||||
{
|
||||
ui->dialP_1value->setText(QString("%1 %").arg((ui->dialP_1->value()*100)/1024));
|
||||
ui->dialP_2value->setText(QString("%1 %").arg((ui->dialP_2->value()*100)/1024));
|
||||
ui->dialP_3value->setText(QString("%1 %").arg((ui->dialP_3->value()*100)/1024));
|
||||
}
|
||||
|
||||
void SimulatorDialog::wheelEvent (QWheelEvent *event)
|
||||
{
|
||||
simulator->wheelEvent(event->delta() > 0 ? 1 : -1);
|
||||
}
|
||||
|
||||
void SimulatorDialog::keyPressEvent (QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
buttonPressed = Qt::Key_Enter;
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Backspace:
|
||||
buttonPressed = Qt::Key_Escape;
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Minus:
|
||||
case Qt::Key_Plus:
|
||||
case Qt::Key_PageDown:
|
||||
case Qt::Key_Menu:
|
||||
buttonPressed = event->key();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::keyReleaseEvent(QKeyEvent * event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Backspace:
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Plus:
|
||||
case Qt::Key_Minus:
|
||||
case Qt::Key_PageDown:
|
||||
case Qt::Key_Menu:
|
||||
buttonPressed = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::setupTimer()
|
||||
{
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
||||
timer->start(10);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SimulatorDialog::initUi(T * ui)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
lcd = ui->lcd;
|
||||
leftStick = ui->leftStick;
|
||||
rightStick = ui->rightStick;
|
||||
dialP_1 = ui->dialP_1;
|
||||
dialP_2 = ui->dialP_2;
|
||||
dialP_3 = ui->dialP_3;
|
||||
trimHLeft = ui->trimHLeft;
|
||||
trimVLeft = ui->trimVLeft;
|
||||
trimHRight = ui->trimHRight;
|
||||
trimVRight = ui->trimVRight;
|
||||
tabWidget = ui->tabWidget;
|
||||
logicalSwitchesLayout = ui->logicalSwitchesLayout;
|
||||
channelsLayout = ui->channelsLayout;
|
||||
leftXPerc = ui->leftXPerc;
|
||||
leftYPerc = ui->leftYPerc;
|
||||
rightXPerc = ui->rightXPerc;
|
||||
rightYPerc = ui->rightYPerc;
|
||||
|
||||
setupSticks();
|
||||
|
||||
resize(0, 0); // to force min height, min width
|
||||
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");
|
||||
int count=0;
|
||||
for (int j=0; j<8;j++){
|
||||
int axe=settings.value(QString("stick%1_axe").arg(j),-1).toInt();
|
||||
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();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
settings.endGroup();
|
||||
if (count<3) {
|
||||
QMessageBox::critical(this, tr("Warning"), tr("Joystick enabled but not configured correctly"));
|
||||
}
|
||||
if (js_ctrl!=-1) {
|
||||
joystick = new Joystick(this);
|
||||
if (joystick) {
|
||||
if (joystick->open(js_ctrl)) {
|
||||
int numAxes=std::min(joystick->numAxes,8);
|
||||
for (int j=0; j<numAxes; j++) {
|
||||
joystick->sensitivities[j] = 0;
|
||||
joystick->deadzones[j]=0;
|
||||
}
|
||||
nodeRight->setCenteringY(false); //mode 1,3 -> THR on right
|
||||
ui->holdRightY->setChecked(true);
|
||||
nodeRight->setCenteringX(false); //mode 1,3 -> THR on right
|
||||
ui->holdRightX->setChecked(true);
|
||||
nodeLeft->setCenteringY(false); //mode 1,3 -> THR on right
|
||||
ui->holdLeftY->setChecked(true);
|
||||
nodeLeft->setCenteringX(false); //mode 1,3 -> THR on right
|
||||
ui->holdLeftX->setChecked(true);
|
||||
connect(joystick, SIGNAL(axisValueChanged(int, int)), this, SLOT(onjoystickAxisValueChanged(int, int)));
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Warning"), tr("Cannot open joystick, joystick disabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
txInterface = GetEepromInterface();
|
||||
|
||||
windowName = tr("Simulating Tx (%1)").arg(txInterface->getName());
|
||||
setWindowTitle(windowName);
|
||||
|
||||
simulator = txInterface->getSimulator();
|
||||
lcd->setData(simulator->getLcd(), lcdWidth, 64, lcdDepth);
|
||||
|
||||
if (flags & SIMULATOR_FLAGS_STICK_MODE_LEFT) {
|
||||
nodeLeft->setCenteringY(false);
|
||||
ui->holdLeftY->setChecked(true);
|
||||
}
|
||||
else {
|
||||
nodeRight->setCenteringY(false);
|
||||
ui->holdRightY->setChecked(true);
|
||||
}
|
||||
|
||||
setTrims();
|
||||
|
||||
int outputs = std::min(16, txInterface->getCapability(Outputs));
|
||||
for (int i=0; i<outputs; i++) {
|
||||
int column = i / (outputs/2);
|
||||
int line = i % (outputs/2);
|
||||
QLabel * label = new QLabel(tabWidget);
|
||||
label->setText(RawSource(SOURCE_TYPE_CH, i).toString());
|
||||
channelsLayout->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
|
||||
|
||||
QSlider * slider = new QSlider(tabWidget);
|
||||
slider->setEnabled(false);
|
||||
slider->setMaximumSize(QSize(16777215, 18));
|
||||
slider->setStyleSheet(QString::fromUtf8("QSlider::sub-page:horizontal:disabled {\n"
|
||||
"border-color: #999;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"QSlider::add-page:horizontal:disabled {\n"
|
||||
"border-color: #999;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"QSlider::handle:horizontal:disabled {\n"
|
||||
"background: #0000CC;\n"
|
||||
"border: 1px solid #aaa;\n"
|
||||
"border-radius: 4px;\n"
|
||||
"}"));
|
||||
slider->setMinimum(-1024);
|
||||
slider->setMaximum(1024);
|
||||
slider->setPageStep(128);
|
||||
slider->setTracking(false);
|
||||
slider->setOrientation(Qt::Horizontal);
|
||||
slider->setInvertedAppearance(false);
|
||||
slider->setTickPosition(QSlider::TicksBelow);
|
||||
channelSliders << slider;
|
||||
channelsLayout->addWidget(slider, line, column == 0 ? 1 : 4, 1, 1);
|
||||
|
||||
QLabel * value = new QLabel(tabWidget);
|
||||
value->setMinimumSize(QSize(50, 0));
|
||||
value->setAlignment(Qt::AlignCenter);
|
||||
channelValues << value;
|
||||
channelsLayout->addWidget(value, line, column == 0 ? 2 : 3, 1, 1);
|
||||
}
|
||||
|
||||
int switches = txInterface->getCapability(LogicalSwitches);
|
||||
for (int i=0; i<switches; i++) {
|
||||
QFrame * swtch = new QFrame(tabWidget);
|
||||
swtch->setAutoFillBackground(true);
|
||||
swtch->setFrameShape(QFrame::Panel);
|
||||
swtch->setFrameShadow(QFrame::Raised);
|
||||
swtch->setLineWidth(2);
|
||||
QVBoxLayout * layout = new QVBoxLayout(swtch);
|
||||
layout->setContentsMargins(2, 2, 2, 2);
|
||||
QLabel * label = new QLabel(swtch);
|
||||
label->setText(RawSwitch(SWITCH_TYPE_VIRTUAL, i+1).toString());
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
logicalSwitchLabels << label;
|
||||
layout->addWidget(label);
|
||||
logicalSwitchesLayout->addWidget(swtch, i / (switches/2), i % (switches/2), 1, 1);
|
||||
}
|
||||
|
||||
if (flags & SIMULATOR_FLAGS_NOTX) {
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
}
|
||||
else {
|
||||
ui->lcd->setFocus();
|
||||
}
|
||||
|
||||
setupTimer();
|
||||
}
|
||||
|
||||
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) {
|
||||
fileName = QString("screenshot-%1.png").arg(++screenshotIdx);
|
||||
}
|
||||
lcd->makeScreenshot(fileName);
|
||||
}
|
||||
else {
|
||||
buttonPressed = value;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog9X::setLightOn(bool enable)
|
||||
{
|
||||
QString bg = "";
|
||||
if (enable) {
|
||||
QStringList list;
|
||||
list << "bl" << "gr" << "rd" << "or" << "yl";
|
||||
bg = QString("-") + list[backLight];
|
||||
}
|
||||
ui->top->setStyleSheet(QString("background:url(:/images/9xdt.png%1);").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));
|
||||
}
|
||||
|
||||
void SimulatorDialog9X::updateBeepButton()
|
||||
{
|
||||
#define CBEEP_ON "QLabel { background-color: #FF364E }"
|
||||
#define CBEEP_OFF "QLabel { }"
|
||||
|
||||
if (beepVal) {
|
||||
beepShow = 20;
|
||||
}
|
||||
|
||||
ui->label_beep->setStyleSheet(beepShow ? CBEEP_ON : CBEEP_OFF);
|
||||
|
||||
if (beepShow) {
|
||||
beepShow--;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::onTimerEvent()
|
||||
{
|
||||
static unsigned int lcd_counter = 0;
|
||||
if (!simulator->timer10ms()) {
|
||||
QMessageBox::critical(this, "Companion", tr("Firmware %1 error: %2").arg(txInterface->getName()).arg(simulator->getError()));
|
||||
timer->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
getValues();
|
||||
|
||||
if (!(flags & SIMULATOR_FLAGS_NOTX) && tabWidget->currentIndex()==0) {
|
||||
bool lightEnable;
|
||||
if (simulator->lcdChanged(lightEnable)) {
|
||||
lcd->onLcdChanged(lightEnable);
|
||||
if (lightOn != lightEnable) {
|
||||
setLightOn(lightEnable);
|
||||
lightOn = lightEnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(lcd_counter++ % 5)) {
|
||||
|
||||
setValues();
|
||||
|
||||
setTrims();
|
||||
|
||||
centerSticks();
|
||||
|
||||
updateBeepButton();
|
||||
|
||||
if (beepVal) {
|
||||
beepVal = 0;
|
||||
QApplication::beep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::centerSticks()
|
||||
{
|
||||
if (leftStick->scene())
|
||||
nodeLeft->stepToCenter();
|
||||
|
||||
if (rightStick->scene())
|
||||
nodeRight->stepToCenter();
|
||||
}
|
||||
|
||||
void SimulatorDialog::start(QByteArray & eeprom)
|
||||
{
|
||||
simulator->start(eeprom, (flags & SIMULATOR_FLAGS_NOTX) ? false : true);
|
||||
}
|
||||
|
||||
void SimulatorDialog::start(const char * filename)
|
||||
{
|
||||
simulator->start(filename);
|
||||
}
|
||||
|
||||
void SimulatorDialog::setTrims()
|
||||
{
|
||||
Trims trims;
|
||||
simulator->getTrims(trims);
|
||||
|
||||
int trimMin = -125, trimMax = +125;
|
||||
if (trims.extended) {
|
||||
trimMin = -500;
|
||||
trimMax = +500;
|
||||
}
|
||||
trimHLeft->setRange(trimMin, trimMax); trimHLeft->setValue(trims.values[0]);
|
||||
trimVLeft->setRange(trimMin, trimMax); trimVLeft->setValue(trims.values[1]);
|
||||
trimVRight->setRange(trimMin, trimMax); trimVRight->setValue(trims.values[2]);
|
||||
trimHRight->setRange(trimMin, trimMax); trimHRight->setValue(trims.values[3]);
|
||||
}
|
||||
|
||||
void SimulatorDialog9X::getValues()
|
||||
{
|
||||
TxInputs inputs = {
|
||||
{
|
||||
int(1024*nodeLeft->getX()), // LEFT HORZ
|
||||
int(-1024*nodeLeft->getY()), // LEFT VERT
|
||||
int(-1024*nodeRight->getY()), // RGHT VERT
|
||||
int(1024*nodeRight->getX()) // RGHT HORZ
|
||||
},
|
||||
|
||||
{
|
||||
ui->dialP_1->value(),
|
||||
ui->dialP_2->value(),
|
||||
ui->dialP_3->value(), 0
|
||||
},
|
||||
|
||||
{
|
||||
ui->switchTHR->isChecked(),
|
||||
ui->switchRUD->isChecked(),
|
||||
ui->switchELE->isChecked(),
|
||||
ui->switchID2->isChecked() ? 1 : (ui->switchID1->isChecked() ? 0 : -1),
|
||||
ui->switchAIL->isChecked(),
|
||||
ui->switchGEA->isChecked(),
|
||||
ui->switchTRN->isDown(),
|
||||
0, 0, 0
|
||||
},
|
||||
|
||||
{
|
||||
buttonPressed == Qt::Key_Enter,
|
||||
buttonPressed == Qt::Key_Escape,
|
||||
buttonPressed == Qt::Key_Down,
|
||||
buttonPressed == Qt::Key_Up,
|
||||
buttonPressed == Qt::Key_Right,
|
||||
buttonPressed == Qt::Key_Left,
|
||||
},
|
||||
|
||||
middleButtonPressed
|
||||
};
|
||||
|
||||
simulator->setValues(inputs);
|
||||
}
|
||||
|
||||
void SimulatorDialogTaranis::getValues()
|
||||
{
|
||||
TxInputs inputs = {
|
||||
{
|
||||
int(1024*nodeLeft->getX()), // LEFT HORZ
|
||||
int(-1024*nodeLeft->getY()), // LEFT VERT
|
||||
int(-1024*nodeRight->getY()), // RGHT VERT
|
||||
int(1024*nodeRight->getX()) // RGHT HORZ
|
||||
},
|
||||
|
||||
{
|
||||
-ui->dialP_1->value(),
|
||||
ui->dialP_2->value(),
|
||||
-ui->dialP_3->value(),
|
||||
ui->dialP_4->value()
|
||||
},
|
||||
|
||||
{
|
||||
ui->switchA->value() - 1,
|
||||
ui->switchB->value() - 1,
|
||||
ui->switchC->value() - 1,
|
||||
ui->switchD->value() - 1,
|
||||
ui->switchE->value() - 1,
|
||||
ui->switchF->value(),
|
||||
ui->switchG->value() - 1,
|
||||
ui->switchH->value(), 0, 0
|
||||
},
|
||||
|
||||
{
|
||||
buttonPressed == Qt::Key_Menu,
|
||||
buttonPressed == Qt::Key_Escape,
|
||||
buttonPressed == Qt::Key_Enter,
|
||||
buttonPressed == Qt::Key_PageDown,
|
||||
buttonPressed == Qt::Key_Plus,
|
||||
buttonPressed == Qt::Key_Minus
|
||||
},
|
||||
|
||||
middleButtonPressed
|
||||
};
|
||||
|
||||
simulator->setValues(inputs);
|
||||
}
|
||||
|
||||
inline int chVal(int val)
|
||||
{
|
||||
return qMin(1024, qMax(-1024, val));
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_trimHLeft_valueChanged(int value)
|
||||
{
|
||||
simulator->setTrim(0, value);
|
||||
}
|
||||
|
||||
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::setValues()
|
||||
{
|
||||
TxOutputs outputs;
|
||||
simulator->getValues(outputs);
|
||||
Trims trims;
|
||||
simulator->getTrims(trims);
|
||||
|
||||
for (int i=0; i<std::min(16, GetEepromInterface()->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));
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
QString CSWITCH_ON = "QLabel { background-color: #4CC417 }";
|
||||
QString CSWITCH_OFF = "QLabel { }";
|
||||
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
|
||||
logicalSwitchLabels[i]->setStyleSheet(outputs.vsw[i] ? CSWITCH_ON : CSWITCH_OFF);
|
||||
}
|
||||
|
||||
if (outputs.beep) {
|
||||
beepVal = outputs.beep;
|
||||
}
|
||||
}
|
||||
|
||||
void SimulatorDialog::setupSticks()
|
||||
{
|
||||
QGraphicsScene *leftScene = new QGraphicsScene(leftStick);
|
||||
leftScene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
leftStick->setScene(leftScene);
|
||||
|
||||
// leftStick->scene()->addLine(0,10,20,30);
|
||||
|
||||
QGraphicsScene *rightScene = new QGraphicsScene(rightStick);
|
||||
rightScene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
rightStick->setScene(rightScene);
|
||||
|
||||
// rightStick->scene()->addLine(0,10,20,30);
|
||||
|
||||
nodeLeft = new Node();
|
||||
nodeLeft->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
|
||||
nodeLeft->setBallSize(GBALL_SIZE);
|
||||
leftScene->addItem(nodeLeft);
|
||||
|
||||
nodeRight = new Node();
|
||||
nodeRight->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
|
||||
nodeRight->setBallSize(GBALL_SIZE);
|
||||
rightScene->addItem(nodeRight);
|
||||
}
|
||||
|
||||
void SimulatorDialog::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if (leftStick->scene()) {
|
||||
QRect qr = leftStick->contentsRect();
|
||||
qreal w = (qreal)qr.width() - GBALL_SIZE;
|
||||
qreal h = (qreal)qr.height() - GBALL_SIZE;
|
||||
qreal cx = (qreal)qr.width()/2;
|
||||
qreal cy = (qreal)qr.height()/2;
|
||||
leftStick->scene()->setSceneRect(-cx,-cy,w,h);
|
||||
|
||||
QPointF p = nodeLeft->pos();
|
||||
p.setX(qMin(cx, qMax(p.x(), -cx)));
|
||||
p.setY(qMin(cy, qMax(p.y(), -cy)));
|
||||
nodeLeft->setPos(p);
|
||||
}
|
||||
|
||||
if (rightStick->scene()) {
|
||||
QRect qr = rightStick->contentsRect();
|
||||
qreal w = (qreal)qr.width() - GBALL_SIZE;
|
||||
qreal h = (qreal)qr.height() - GBALL_SIZE;
|
||||
qreal cx = (qreal)qr.width()/2;
|
||||
qreal cy = (qreal)qr.height()/2;
|
||||
rightStick->scene()->setSceneRect(-cx,-cy,w,h);
|
||||
|
||||
QPointF p = nodeRight->pos();
|
||||
p.setX(qMin(cx, qMax(p.x(), -cx)));
|
||||
p.setY(qMin(cy, qMax(p.y(), -cy)));
|
||||
nodeRight->setPos(p);
|
||||
}
|
||||
QDialog::resizeEvent(event);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_holdLeftX_clicked(bool checked)
|
||||
{
|
||||
nodeLeft->setCenteringX(!checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_holdLeftY_clicked(bool checked)
|
||||
{
|
||||
nodeLeft->setCenteringY(!checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_holdRightX_clicked(bool checked)
|
||||
{
|
||||
nodeRight->setCenteringX(!checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_holdRightY_clicked(bool checked)
|
||||
{
|
||||
nodeRight->setCenteringY(!checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_FixLeftX_clicked(bool checked)
|
||||
{
|
||||
nodeLeft->setFixedX(checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_FixLeftY_clicked(bool checked)
|
||||
{
|
||||
nodeLeft->setFixedY(checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_FixRightX_clicked(bool checked)
|
||||
{
|
||||
nodeRight->setFixedX(checked);
|
||||
}
|
||||
|
||||
void SimulatorDialog::on_FixRightY_clicked(bool checked)
|
||||
{
|
||||
nodeRight->setFixedY(checked);
|
||||
}
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value)
|
||||
{
|
||||
int stick;
|
||||
if (axis>=0 && axis<=8) {
|
||||
stick=jsmap[axis];
|
||||
int stickval;
|
||||
if (value>jscal[axis][1]) {
|
||||
if ((jscal[axis][2]-jscal[axis][1])==0)
|
||||
return;
|
||||
stickval=(1024*(value-jscal[axis][1]))/(jscal[axis][2]-jscal[axis][1]);
|
||||
}
|
||||
else {
|
||||
if ((jscal[axis][1]-jscal[axis][0])==0)
|
||||
return;
|
||||
stickval=(1024*(value-jscal[axis][1]))/(jscal[axis][1]-jscal[axis][0]);
|
||||
}
|
||||
if (jscal[axis][3]==1) {
|
||||
stickval*=-1;
|
||||
}
|
||||
if (stick==1 || stick==2) {
|
||||
float currX=nodeRight->getX();
|
||||
float currY=nodeRight->getY();
|
||||
if (stick==1 ) {
|
||||
nodeRight->setPos(currX*100-10,-stickval*100/1024-10);
|
||||
}
|
||||
if (stick==2) {
|
||||
nodeRight->setPos(stickval*100/1024-10,currY*100-10);
|
||||
}
|
||||
}
|
||||
else if (stick==3 || stick==4) {
|
||||
float currX=nodeLeft->getX();
|
||||
float currY=nodeLeft->getY();
|
||||
if (stick==3) {
|
||||
nodeLeft->setPos(currX*100-10,-stickval*100/1024-10);
|
||||
}
|
||||
if (stick==4) {
|
||||
nodeLeft->setPos(stickval*100/1024-10,currY*100-10);
|
||||
}
|
||||
}
|
||||
|
||||
if (stick==5) {
|
||||
dialP_1->setValue(stickval);
|
||||
}
|
||||
if (stick==6) {
|
||||
dialP_2->setValue(stickval);
|
||||
}
|
||||
if (stick==7) {
|
||||
dialP_3->setValue(stickval);
|
||||
}
|
||||
if (stick==8 && dialP_4) {
|
||||
dialP_4->setValue(stickval);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
#ifndef SIMULATORDIALOG_H
|
||||
#define SIMULATORDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "modeledit/node.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
#include "joystick.h"
|
||||
#endif
|
||||
|
||||
#define TMR_OFF 0
|
||||
#define TMR_RUNNING 1
|
||||
#define TMR_BEEPING 2
|
||||
#define TMR_STOPPED 3
|
||||
|
||||
#define FLASH_DURATION 10
|
||||
|
||||
namespace Ui {
|
||||
class SimulatorDialog9X;
|
||||
class SimulatorDialogTaranis;
|
||||
}
|
||||
|
||||
// TODO rename + move?
|
||||
class lcdWidget;
|
||||
class mySlider;
|
||||
|
||||
#define SIMULATOR_FLAGS_NOTX 1
|
||||
#define SIMULATOR_FLAGS_STICK_MODE_LEFT 2
|
||||
|
||||
class SimulatorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog(QWidget * parent = NULL, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog();
|
||||
|
||||
void start(const char * filename);
|
||||
void start(QByteArray & eeprom);
|
||||
|
||||
protected:
|
||||
template <class T> void initUi(T * ui);
|
||||
virtual void setLightOn(bool enable) { }
|
||||
virtual void updateBeepButton() { }
|
||||
|
||||
unsigned int flags;
|
||||
lcdWidget * lcd;
|
||||
QGraphicsView * leftStick, * rightStick;
|
||||
QDial * dialP_1, * dialP_2, * dialP_3, * dialP_4;
|
||||
mySlider * trimHLeft, * trimVLeft, * trimHRight, * trimVRight;
|
||||
QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc;
|
||||
QTabWidget * tabWidget;
|
||||
QGridLayout * logicalSwitchesLayout;
|
||||
QGridLayout * channelsLayout;
|
||||
QVector<QLabel *> logicalSwitchLabels;
|
||||
QVector<QSlider *> channelSliders;
|
||||
QVector<QLabel *> channelValues;
|
||||
|
||||
void init();
|
||||
Node *nodeLeft;
|
||||
Node *nodeRight;
|
||||
QTimer *timer;
|
||||
QString windowName;
|
||||
unsigned int backLight;
|
||||
bool lightOn;
|
||||
int switches;
|
||||
#ifdef JOYSTICKS
|
||||
Joystick *joystick;
|
||||
int jscal[8][4];
|
||||
int jsmap[8];
|
||||
#endif
|
||||
|
||||
EEPROMInterface *txInterface;
|
||||
SimulatorInterface *simulator;
|
||||
|
||||
void setupSticks();
|
||||
void setupTimer();
|
||||
void resizeEvent(QResizeEvent *event = 0);
|
||||
|
||||
virtual void getValues() = 0;
|
||||
void setValues();
|
||||
void centerSticks();
|
||||
// void timerTick();
|
||||
|
||||
bool keyState(EnumKeys key);
|
||||
int getValue(qint8 i);
|
||||
bool getSwitch(int swtch, bool nc, qint8 level=0);
|
||||
void setTrims();
|
||||
|
||||
int beepVal;
|
||||
|
||||
int lcdWidth;
|
||||
int lcdDepth;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *);
|
||||
virtual void wheelEvent(QWheelEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void keyReleaseEvent(QKeyEvent *);
|
||||
static int screenshotIdx;
|
||||
int buttonPressed;
|
||||
bool middleButtonPressed;
|
||||
|
||||
private slots:
|
||||
void onButtonPressed(int value);
|
||||
void on_FixRightY_clicked(bool checked);
|
||||
void on_FixRightX_clicked(bool checked);
|
||||
void on_FixLeftY_clicked(bool checked);
|
||||
void on_FixLeftX_clicked(bool checked);
|
||||
void on_holdRightY_clicked(bool checked);
|
||||
void on_holdRightX_clicked(bool checked);
|
||||
void on_holdLeftY_clicked(bool checked);
|
||||
void on_holdLeftX_clicked(bool checked);
|
||||
void on_trimHLeft_valueChanged(int);
|
||||
void on_trimVLeft_valueChanged(int);
|
||||
void on_trimHRight_valueChanged(int);
|
||||
void on_trimVRight_valueChanged(int);
|
||||
void onTimerEvent();
|
||||
|
||||
#ifdef JOYSTICKS
|
||||
void onjoystickAxisValueChanged(int axis, int value);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialog9X: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialog9X(QWidget * parent = NULL, unsigned int flags=0);
|
||||
virtual ~SimulatorDialog9X();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
virtual void setLightOn(bool enable);
|
||||
virtual void updateBeepButton();
|
||||
|
||||
private slots:
|
||||
void dialChanged();
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialog9X * ui;
|
||||
int beepShow;
|
||||
|
||||
};
|
||||
|
||||
class SimulatorDialogTaranis: public SimulatorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimulatorDialogTaranis(QWidget * parent = NULL, unsigned int flags=0);
|
||||
virtual ~SimulatorDialogTaranis();
|
||||
|
||||
protected:
|
||||
virtual void getValues();
|
||||
|
||||
private:
|
||||
Ui::SimulatorDialogTaranis * ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // SIMULATORDIALOG_H
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef INIT_IMPORT
|
||||
#undef INIT_IMPORT
|
||||
#ifdef FRSKY
|
||||
frskyStreaming = 20;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SETVALUES_IMPORT
|
||||
#undef SETVALUES_IMPORT
|
||||
for (int i=0; i<NUM_STICKS; i++)
|
||||
g_anas[i] = inputs.sticks[i];
|
||||
for (int i=0; i<NUM_POTS; i++)
|
||||
g_anas[NUM_STICKS+i] = inputs.pots[i];
|
||||
for (int i=0; i<C9X_NUM_SWITCHES; i++)
|
||||
simuSetSwitch(i, inputs.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);
|
||||
|
||||
#ifdef PCBGRUVIN9X
|
||||
// rotary encoders
|
||||
pind = 0;
|
||||
if (inputs.rotenc) pind |= 0x20;
|
||||
#endif
|
||||
|
||||
#ifdef PCBSKY9X
|
||||
if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GETVALUES_IMPORT
|
||||
#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++)
|
||||
#if defined(BOLD_FONT)
|
||||
outputs.vsw[i] = getSwitch(SWSRC_SW1+i);
|
||||
#else
|
||||
outputs.vsw[i] = getSwitch(SWSRC_SW1+i, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LCDCHANGED_IMPORT
|
||||
#undef LCDCHANGED_IMPORT
|
||||
if (lcd_refresh) {
|
||||
lightEnable = IS_BACKLIGHT_ON();
|
||||
lcd_refresh = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#ifdef TIMER10MS_IMPORT
|
||||
#undef TIMER10MS_IMPORT
|
||||
if (!main_thread_running)
|
||||
return false;
|
||||
per10ms();
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef GETLCD_IMPORT
|
||||
#undef GETLCD_IMPORT
|
||||
return lcd_buf;
|
||||
#endif
|
||||
|
||||
#ifdef GETERROR_IMPORT
|
||||
#undef GETERROR_IMPORT
|
||||
return main_thread_error;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef simulator_interface_h
|
||||
#define simulator_interface_h
|
||||
|
||||
#include "eeprominterface.h"
|
||||
|
||||
struct TxInputs {
|
||||
int sticks[NUM_STICKS]; /* lh lv rv rh */
|
||||
int pots[4]; /* TODO NUM_POTS */
|
||||
int switches[10]; /* TODO NUM_SWITCHES */
|
||||
bool keys[6]; /* TODO NUM_KEYS */
|
||||
bool rotenc;
|
||||
};
|
||||
|
||||
class TxOutputs {
|
||||
public:
|
||||
TxOutputs() {
|
||||
memset(this, 0, sizeof(TxOutputs));
|
||||
}
|
||||
|
||||
int16_t chans[C9X_NUM_CHNOUT];
|
||||
bool vsw[32]; /* TODO NUM_VIRTUAL_SWITCHES */
|
||||
unsigned int beep;
|
||||
};
|
||||
|
||||
struct Trims {
|
||||
int16_t values[NUM_STICKS]; /* lh lv rv rh */
|
||||
bool extended;
|
||||
};
|
||||
|
||||
class SimulatorInterface {
|
||||
|
||||
public:
|
||||
|
||||
virtual void start(QByteArray & eeprom, bool tests=true) = 0;
|
||||
|
||||
virtual void start(const char * filename, bool tests=true) = 0;
|
||||
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual bool timer10ms() = 0;
|
||||
|
||||
virtual uint8_t * getLcd() = 0;
|
||||
|
||||
virtual bool lcdChanged(bool & lightEnable) = 0;
|
||||
|
||||
virtual void setValues(TxInputs &inputs) = 0;
|
||||
|
||||
virtual void getValues(TxOutputs &outputs) = 0;
|
||||
|
||||
virtual void setTrim(unsigned int idx, int value) = 0;
|
||||
|
||||
virtual void getTrims(Trims & trims) = 0;
|
||||
|
||||
virtual unsigned int getPhase() = 0;
|
||||
|
||||
virtual void wheelEvent(uint8_t steps) = 0;
|
||||
|
||||
virtual const char * getError() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#ifndef XCURSORWIDGET_H
|
||||
#define XCURSORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtGui>
|
||||
|
||||
class xcursorWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit xcursorWidget(QWidget * parent = 0):
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
float p1x[] = {20,27,45,56,50,26};
|
||||
float p1y[] = {59,50,52,59,71,72};
|
||||
float p2x[] = {23,30,46,55,47,28};
|
||||
float p2y[] = {107,99,100,106,117,117};
|
||||
float p3x[] = {24,32,46,57,46,29};
|
||||
float p3y[] = {154,144,146,156,167,166};
|
||||
|
||||
int x=event->x();
|
||||
int y=event->y();
|
||||
setFocus();
|
||||
if (event->button()==Qt::LeftButton) {
|
||||
if (pnpoly(6,p1x,p1y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9l1.png);");
|
||||
emit buttonPressed(Qt::Key_Menu);
|
||||
}
|
||||
else if (pnpoly(6,p2x,p2y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9l2.png);");
|
||||
emit buttonPressed(Qt::Key_PageDown);
|
||||
}
|
||||
else if (pnpoly(6,p3x,p3y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9l3.png);");
|
||||
emit buttonPressed(Qt::Key_Escape);
|
||||
} else if ((x>90 && x<118) && (y>177 && y<197)) {
|
||||
setStyleSheet("background:url(:/images/x9l4.png);");
|
||||
emit buttonPressed(Qt::Key_Print);
|
||||
}
|
||||
}
|
||||
// QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent(QMouseEvent * event)
|
||||
{
|
||||
setStyleSheet("background:url(:/images/x9l0.png);");
|
||||
emit buttonPressed(0);
|
||||
setFocus();
|
||||
//QWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
|
||||
{
|
||||
int i, j, c = 0;
|
||||
for (i = 0, j = nvert-1; i < nvert; j = i++) {
|
||||
if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
|
||||
c = !c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonPressed(int button);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* CURSORWIDGET_H */
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Author - Bertrand Songis <bsongis@gmail.com>
|
||||
*
|
||||
* Based on th9x -> http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
#ifndef XMENUWIDGET_H
|
||||
#define XMENUWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtGui>
|
||||
|
||||
class xmenuWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit xmenuWidget(QWidget * parent = 0):
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
float p1x[] = {64,71,90,100,90,72};
|
||||
float p1y[] = {60,50,50,60,73,73};
|
||||
float p2x[] = {63,73,88,98,88,72};
|
||||
float p2y[] = {109,100,100,109,119,119};
|
||||
float p3x[] = {63,72,90,98,88,72};
|
||||
float p3y[] = {155,146,146,155,166,166};
|
||||
|
||||
int x=event->x();
|
||||
int y=event->y();
|
||||
setFocus();
|
||||
if (event->button()==Qt::LeftButton) {
|
||||
if (pnpoly(6,p1x,p1y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9r1.png);");
|
||||
emit buttonPressed(Qt::Key_Plus);
|
||||
}
|
||||
else if (pnpoly(6,p2x,p2y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9r2.png);");
|
||||
emit buttonPressed(Qt::Key_Minus);
|
||||
}
|
||||
else if (pnpoly(6,p3x,p3y,(float)x,(float)y)==1) {
|
||||
setStyleSheet("background:url(:/images/x9r3.png);");
|
||||
emit buttonPressed(Qt::Key_Enter);
|
||||
}
|
||||
}
|
||||
// QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
virtual void mouseReleaseEvent(QMouseEvent * event)
|
||||
{
|
||||
setStyleSheet("background:url(:/images/x9r0.png);");
|
||||
setFocus();
|
||||
emit buttonPressed(0);
|
||||
// QWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
|
||||
{
|
||||
int i, j, c = 0;
|
||||
for (i = 0, j = nvert-1; i < nvert; j = i++) {
|
||||
if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
|
||||
c = !c;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void buttonPressed(int button);
|
||||
|
||||
};
|
||||
#endif /* XMENUWIDGET_H */
|
||||
|
||||
Reference in New Issue
Block a user