1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 22:35:12 +03:00

Merge branch 'next' of https://github.com/opentx/opentx into kilrah/Switch_and_pot_warnings

Conflicts:
	companion/src/eeprominterface.h
	companion/src/firmwares/opentx/opentxeeprom.cpp
	radio/src/opentx.cpp
	radio/src/translations/es.h.txt
	radio/src/translations/fr.h.txt
This commit is contained in:
Andre Bernet 2014-02-10 14:47:32 +01:00
commit 2a83cffc53
238 changed files with 18616 additions and 8732 deletions

View file

@ -19,3 +19,4 @@ Grootwitbaas - 9xforums.com (mac)
Adrian Amberg (splash screens) Adrian Amberg (splash screens)
Wallaguest1 - 9xforums.com (splash screens) Wallaguest1 - 9xforums.com (splash screens)
HC1969 - 9xforums.com (splash screens) HC1969 - 9xforums.com (splash screens)

View file

@ -96,7 +96,6 @@ Michael Collins
Michael Manning Michael Manning
Craig Lorentz Craig Lorentz
Jonathan Modellismo - jonathan.it Jonathan Modellismo - jonathan.it
Aviomotive - www.aviomotive.com
André Lasseret André Lasseret
Felipe Alexandre de Oliveira Felipe Alexandre de Oliveira
Brian Harris Brian Harris
@ -312,3 +311,10 @@ Dietmar Drees
Bradley Murchie Bradley Murchie
Richard Fahie Richard Fahie
James Kaufman James Kaufman
Henry Deucker
Christian Fuchs
Arold Reinders
Robert Miller
Aviomotive - www.aviomotive.com
Mark Gaskievicz
Roland Müller

View file

@ -156,6 +156,8 @@ SET( companion_SRCS
mountlist.cpp mountlist.cpp
avroutputdialog.cpp avroutputdialog.cpp
preferencesdialog.cpp preferencesdialog.cpp
apppreferencesdialog.cpp
fwpreferencesdialog.cpp
burnconfigdialog.cpp burnconfigdialog.cpp
comparedialog.cpp comparedialog.cpp
contributorsdialog.cpp contributorsdialog.cpp
@ -177,6 +179,8 @@ SET( companion_SRCS
SET( companion_MOC_HDRS SET( companion_MOC_HDRS
avroutputdialog.h avroutputdialog.h
preferencesdialog.h preferencesdialog.h
apppreferencesdialog.h
fwpreferencesdialog.h
burnconfigdialog.h burnconfigdialog.h
comparedialog.h comparedialog.h
printdialog.h printdialog.h
@ -211,6 +215,8 @@ SET( companion_UIS
fusesdialog.ui fusesdialog.ui
logsdialog.ui logsdialog.ui
preferencesdialog.ui preferencesdialog.ui
apppreferencesdialog.ui
fwpreferencesdialog.ui
simulatordialog.ui simulatordialog.ui
xsimulatordialog.ui xsimulatordialog.ui
burnconfigdialog.ui burnconfigdialog.ui

View file

@ -0,0 +1,224 @@
#include "apppreferencesdialog.h"
#include "ui_apppreferencesdialog.h"
#include "mainwindow.h"
#include "helpers.h"
#ifdef JOYSTICKS
#include "joystick.h"
#include "joystickdialog.h"
#endif
#include <QDesktopServices>
#include <QtGui>
appPreferencesDialog::appPreferencesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::appPreferencesDialog)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("preferences.png"));
initSettings();
connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
#ifndef JOYSTICKS
ui->joystickCB->hide();
ui->joystickCB->setDisabled(true);
ui->joystickcalButton->hide();
ui->joystickChkB->hide();
ui->label_11->hide();
#endif
resize(0,0);
}
appPreferencesDialog::~appPreferencesDialog()
{
delete ui;
}
void appPreferencesDialog::writeValues()
{
QSettings settings;
settings.setValue("startup_check_companion", ui->startupCheck_companion9x->isChecked());
settings.setValue("startup_check_fw", ui->startupCheck_fw->isChecked());
settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked());
settings.setValue("show_splash", ui->showSplash->isChecked());
settings.setValue("simuSW", ui->simuSW->isChecked());
settings.setValue("history_size", ui->historySize->value());
settings.setValue("backLight", ui->backLightColor->currentIndex());
settings.setValue("libraryPath", ui->libraryPath->text());
settings.setValue("gePath", ui->ge_lineedit->text());
settings.setValue("embedded_splashes", ui->splashincludeCB->currentIndex());
settings.setValue("backupEnable", ui->backupEnable->isChecked());
if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) {
settings.setValue("js_support", ui->joystickChkB ->isChecked());
settings.setValue("js_ctrl", ui->joystickCB ->currentIndex());
}
else {
settings.remove("js_support");
settings.remove("js_ctrl");
}
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
}
void appPreferencesDialog::on_snapshotPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString());
if (!fileName.isEmpty()) {
settings.setValue("snapshotpath", fileName);
settings.setValue("snapshot_to_clipboard", false);
ui->snapshotPath->setText(fileName);
}
}
void appPreferencesDialog::initSettings()
{
QSettings settings;
ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool());
QString Path=settings.value("snapshotPath", "").toString();
if (QDir(Path).exists()) {
ui->snapshotPath->setText(Path);
ui->snapshotPath->setReadOnly(true);
}
if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true);
}
ui->startupCheck_companion9x->setChecked(settings.value("startup_check_companion", true).toBool());
ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool());
ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool());
ui->showSplash->setChecked(settings.value("show_splash", true).toBool());
ui->historySize->setValue(settings.value("history_size", 10).toInt());
ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt());
ui->simuSW->setChecked(settings.value("simuSW", false).toBool());
Path=settings.value("libraryPath", "").toString();
if (QDir(Path).exists()) {
ui->libraryPath->setText(Path);
}
Path=settings.value("gePath", "").toString();
if (QFile(Path).exists()) {
ui->ge_lineedit->setText(Path);
}
Path=settings.value("backupPath", "").toString();
if (!Path.isEmpty()) {
if (QDir(Path).exists()) {
ui->backupPath->setText(Path);
ui->backupEnable->setEnabled(true);
ui->backupEnable->setChecked(settings.value("backupEnable", true).toBool());
} else {
ui->backupEnable->setDisabled(true);
}
} else {
ui->backupEnable->setDisabled(true);
}
ui->splashincludeCB->setCurrentIndex(settings.value("embedded_splashes", 0).toInt());
#ifdef JOYSTICKS
ui->joystickChkB->setChecked(settings.value("js_support", false).toBool());
if (ui->joystickChkB->isChecked()) {
QStringList joystickNames;
joystickNames << tr("No joysticks found");
joystick = new Joystick(0,false,0,0);
ui->joystickcalButton->setDisabled(true);
ui->joystickCB->setDisabled(true);
if ( joystick ) {
if ( joystick->joystickNames.count() > 0 ) {
joystickNames = joystick->joystickNames;
ui->joystickCB->setEnabled(true);
ui->joystickcalButton->setEnabled(true);
}
joystick->close();
}
ui->joystickCB->clear();
ui->joystickCB->insertItems(0, joystickNames);
ui->joystickCB->setCurrentIndex(settings.value("js_ctrl", 0).toInt());
}
else {
ui->joystickCB->clear();
ui->joystickCB->setDisabled(true);
ui->joystickcalButton->setDisabled(true);
}
#endif
}
void appPreferencesDialog::on_libraryPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString());
if (!fileName.isEmpty()) {
settings.setValue("libraryPath", fileName);
ui->libraryPath->setText(fileName);
}
}
void appPreferencesDialog::on_snapshotClipboardCKB_clicked()
{
QSettings settings;
if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true);
settings.setValue("snapshot_to_clipboard", true);
} else {
ui->snapshotPath->setEnabled(true);
ui->snapshotPath->setReadOnly(true);
ui->snapshotPathButton->setEnabled(true);
settings.setValue("snapshot_to_clipboard", false);
}
}
void appPreferencesDialog::on_backupPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString());
if (!fileName.isEmpty()) {
settings.setValue("backupPath", fileName);
ui->backupPath->setText(fileName);
}
ui->backupEnable->setEnabled(true);
}
void appPreferencesDialog::on_ge_pathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text());
if (!fileName.isEmpty()) {
ui->ge_lineedit->setText(fileName);
}
}
#ifdef JOYSTICKS
void appPreferencesDialog::on_joystickChkB_clicked() {
if (ui->joystickChkB->isChecked()) {
QStringList joystickNames;
joystickNames << tr("No joysticks found");
joystick = new Joystick(0,false,0,0);
ui->joystickcalButton->setDisabled(true);
ui->joystickCB->setDisabled(true);
if ( joystick ) {
if ( joystick->joystickNames.count() > 0 ) {
joystickNames = joystick->joystickNames;
ui->joystickCB->setEnabled(true);
ui->joystickcalButton->setEnabled(true);
}
joystick->close();
}
ui->joystickCB->clear();
ui->joystickCB->insertItems(0, joystickNames);
}
else {
ui->joystickCB->clear();
ui->joystickCB->setDisabled(true);
ui->joystickcalButton->setDisabled(true);
}
}
void appPreferencesDialog::on_joystickcalButton_clicked() {
joystickDialog * jd=new joystickDialog(this, ui->joystickCB->currentIndex());
jd->exec();
}
#endif

View file

@ -0,0 +1,40 @@
#ifndef APPPREFERENCESDIALOG_H
#define APPPREFERENCESDIALOG_H
#include <QDialog>
#include <QCheckBox>
#include "eeprominterface.h"
namespace Ui {
class appPreferencesDialog;
}
class Joystick;
class appPreferencesDialog : public QDialog
{
Q_OBJECT
public:
explicit appPreferencesDialog(QWidget *parent = 0);
~appPreferencesDialog();
Joystick *joystick;
private:
Ui::appPreferencesDialog *ui;
void initSettings();
private slots:
void writeValues();
void on_libraryPathButton_clicked();
void on_snapshotPathButton_clicked();
void on_snapshotClipboardCKB_clicked();
void on_backupPathButton_clicked();
void on_ge_pathButton_clicked();
#ifdef JOYSTICKS
void on_joystickChkB_clicked();
void on_joystickcalButton_clicked();
#endif
};
#endif // APPPREFERENCESDIALOG_H

View file

@ -0,0 +1,505 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>appPreferencesDialog</class>
<widget class="QDialog" name="appPreferencesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>456</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>685</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Application Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item row="20" column="8">
<widget class="QPushButton" name="libraryPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="22" column="1" colspan="8">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1" colspan="8">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Joystick</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Simulator capture folder</string>
</property>
</widget>
</item>
<item row="15" column="1" colspan="7">
<widget class="QCheckBox" name="simuSW">
<property name="text">
<string>Remember simulator switch values</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>User Splash Screens</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Files to keep</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="7">
<widget class="QCheckBox" name="wizardEnable_ChkB">
<property name="text">
<string>Offer to use wizard for new models</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="18" column="1" colspan="8">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QComboBox" name="backLightColor">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Green</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
</widget>
</item>
<item row="7" column="1" colspan="7">
<widget class="QCheckBox" name="startupCheck_companion9x">
<property name="text">
<string>Automatic check for Companion updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1" colspan="8">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="13" column="1" colspan="7">
<widget class="QLineEdit" name="snapshotPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="1" colspan="7">
<widget class="QCheckBox" name="snapshotClipboardCKB">
<property name="text">
<string>Only capture to clipboard</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="historySize">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>40</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>15</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="12" column="1" colspan="8">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1" colspan="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1" colspan="7">
<widget class="QLineEdit" name="ge_lineedit">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="8">
<widget class="QPushButton" name="joystickcalButton">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Automatic Backup Folder</string>
</property>
</widget>
</item>
<item row="23" column="7" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="13" column="8">
<widget class="QPushButton" name="snapshotPathButton">
<property name="text">
<string>Open Folder</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="10" column="1" colspan="7">
<widget class="QLineEdit" name="backupPath">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QComboBox" name="joystickCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Simulator BackLight</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="11" column="1" colspan="7">
<widget class="QCheckBox" name="backupEnable">
<property name="text">
<string>Enable automatic backup before writing firmware</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="7">
<widget class="QCheckBox" name="showSplash">
<property name="text">
<string>Show splash screen when Companion starts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="ge_pathButton">
<property name="text">
<string>Find Executable</string>
</property>
</widget>
</item>
<item row="10" column="8">
<widget class="QPushButton" name="backupPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="17" column="4" colspan="4">
<widget class="QCheckBox" name="joystickChkB">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="ge_label">
<property name="text">
<string>Google Earth Executable</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="7">
<widget class="QCheckBox" name="startupCheck_fw">
<property name="text">
<string>Automatic check for OpenTX firmware updates</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QComboBox" name="splashincludeCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Include companion splashes</string>
</property>
</item>
<item>
<property name="text">
<string>Only user defined splashes</string>
</property>
</item>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Splash Screen Library</string>
</property>
</widget>
</item>
<item row="20" column="1" colspan="7">
<widget class="QLineEdit" name="libraryPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<zorder>startupCheck_companion9x</zorder>
<zorder>backupEnable</zorder>
<zorder>line</zorder>
<zorder>backupPath</zorder>
<zorder>line_2</zorder>
<zorder>startupCheck_fw</zorder>
<zorder>wizardEnable_ChkB</zorder>
<zorder>ge_label</zorder>
<zorder>label_5</zorder>
<zorder>showSplash</zorder>
<zorder>line_3</zorder>
<zorder>ge_pathButton</zorder>
<zorder>line_4</zorder>
<zorder>backupPathButton</zorder>
<zorder>label_3</zorder>
<zorder>backLightColor</zorder>
<zorder>snapshotPath</zorder>
<zorder>snapshotPathButton</zorder>
<zorder>snapshotClipboardCKB</zorder>
<zorder>label_11</zorder>
<zorder>joystickCB</zorder>
<zorder>joystickcalButton</zorder>
<zorder>ge_lineedit</zorder>
<zorder>simuSW</zorder>
<zorder>buttonBox</zorder>
<zorder>line_5</zorder>
<zorder>joystickChkB</zorder>
<zorder>label_17</zorder>
<zorder>label_19</zorder>
<zorder>historySize</zorder>
<zorder>label_9</zorder>
<zorder>libraryPath</zorder>
<zorder>libraryPathButton</zorder>
<zorder>line_6</zorder>
<zorder>splashincludeCB</zorder>
<zorder>label_10</zorder>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>ge_lineedit</tabstop>
<tabstop>ge_pathButton</tabstop>
<tabstop>historySize</tabstop>
<tabstop>showSplash</tabstop>
<tabstop>startupCheck_fw</tabstop>
<tabstop>startupCheck_companion9x</tabstop>
<tabstop>wizardEnable_ChkB</tabstop>
<tabstop>backupPath</tabstop>
<tabstop>backupPathButton</tabstop>
<tabstop>backupEnable</tabstop>
<tabstop>snapshotPath</tabstop>
<tabstop>snapshotPathButton</tabstop>
<tabstop>snapshotClipboardCKB</tabstop>
<tabstop>simuSW</tabstop>
<tabstop>backLightColor</tabstop>
<tabstop>joystickCB</tabstop>
<tabstop>joystickChkB</tabstop>
<tabstop>joystickcalButton</tabstop>
</tabstops>
<resources>
<include location="companion.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>appPreferencesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>376</x>
<y>596</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>appPreferencesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>396</x>
<y>596</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -325,7 +325,8 @@
<file>themes/monochrome/16/print.png</file> <file>themes/monochrome/16/print.png</file>
<file>themes/monochrome/16/compare.png</file> <file>themes/monochrome/16/compare.png</file>
<file>themes/monochrome/16/saveas.png</file> <file>themes/monochrome/16/saveas.png</file>
<file>themes/monochrome/16/preferences.png</file> <file>themes/monochrome/16/apppreferences.png</file>
<file>themes/monochrome/16/fwpreferences.png</file>
<file>themes/monochrome/16/movedown.png</file> <file>themes/monochrome/16/movedown.png</file>
<file>themes/monochrome/16/currentmodel.png</file> <file>themes/monochrome/16/currentmodel.png</file>
<file>themes/monochrome/16/read_flash.png</file> <file>themes/monochrome/16/read_flash.png</file>
@ -367,7 +368,8 @@
<file>themes/monochrome/24/print.png</file> <file>themes/monochrome/24/print.png</file>
<file>themes/monochrome/24/compare.png</file> <file>themes/monochrome/24/compare.png</file>
<file>themes/monochrome/24/saveas.png</file> <file>themes/monochrome/24/saveas.png</file>
<file>themes/monochrome/24/preferences.png</file> <file>themes/monochrome/24/apppreferences.png</file>
<file>themes/monochrome/24/fwpreferences.png</file>
<file>themes/monochrome/24/movedown.png</file> <file>themes/monochrome/24/movedown.png</file>
<file>themes/monochrome/24/currentmodel.png</file> <file>themes/monochrome/24/currentmodel.png</file>
<file>themes/monochrome/24/read_flash.png</file> <file>themes/monochrome/24/read_flash.png</file>
@ -409,7 +411,8 @@
<file>themes/monochrome/32/print.png</file> <file>themes/monochrome/32/print.png</file>
<file>themes/monochrome/32/compare.png</file> <file>themes/monochrome/32/compare.png</file>
<file>themes/monochrome/32/saveas.png</file> <file>themes/monochrome/32/saveas.png</file>
<file>themes/monochrome/32/preferences.png</file> <file>themes/monochrome/32/apppreferences.png</file>
<file>themes/monochrome/32/fwpreferences.png</file>
<file>themes/monochrome/32/movedown.png</file> <file>themes/monochrome/32/movedown.png</file>
<file>themes/monochrome/32/currentmodel.png</file> <file>themes/monochrome/32/currentmodel.png</file>
<file>themes/monochrome/32/read_flash.png</file> <file>themes/monochrome/32/read_flash.png</file>
@ -451,7 +454,8 @@
<file>themes/monochrome/48/print.png</file> <file>themes/monochrome/48/print.png</file>
<file>themes/monochrome/48/compare.png</file> <file>themes/monochrome/48/compare.png</file>
<file>themes/monochrome/48/saveas.png</file> <file>themes/monochrome/48/saveas.png</file>
<file>themes/monochrome/48/preferences.png</file> <file>themes/monochrome/48/apppreferences.png</file>
<file>themes/monochrome/48/fwpreferences.png</file>
<file>themes/monochrome/48/movedown.png</file> <file>themes/monochrome/48/movedown.png</file>
<file>themes/monochrome/48/currentmodel.png</file> <file>themes/monochrome/48/currentmodel.png</file>
<file>themes/monochrome/48/read_flash.png</file> <file>themes/monochrome/48/read_flash.png</file>
@ -493,7 +497,8 @@
<file>themes/classic/16/print.png</file> <file>themes/classic/16/print.png</file>
<file>themes/classic/16/compare.png</file> <file>themes/classic/16/compare.png</file>
<file>themes/classic/16/saveas.png</file> <file>themes/classic/16/saveas.png</file>
<file>themes/classic/16/preferences.png</file> <file>themes/classic/16/apppreferences.png</file>
<file>themes/classic/16/fwpreferences.png</file>
<file>themes/classic/16/movedown.png</file> <file>themes/classic/16/movedown.png</file>
<file>themes/classic/16/currentmodel.png</file> <file>themes/classic/16/currentmodel.png</file>
<file>themes/classic/16/read_flash.png</file> <file>themes/classic/16/read_flash.png</file>
@ -535,7 +540,8 @@
<file>themes/classic/24/print.png</file> <file>themes/classic/24/print.png</file>
<file>themes/classic/24/compare.png</file> <file>themes/classic/24/compare.png</file>
<file>themes/classic/24/saveas.png</file> <file>themes/classic/24/saveas.png</file>
<file>themes/classic/24/preferences.png</file> <file>themes/classic/24/apppreferences.png</file>
<file>themes/classic/24/fwpreferences.png</file>
<file>themes/classic/24/movedown.png</file> <file>themes/classic/24/movedown.png</file>
<file>themes/classic/24/currentmodel.png</file> <file>themes/classic/24/currentmodel.png</file>
<file>themes/classic/24/read_flash.png</file> <file>themes/classic/24/read_flash.png</file>
@ -577,7 +583,8 @@
<file>themes/classic/32/print.png</file> <file>themes/classic/32/print.png</file>
<file>themes/classic/32/compare.png</file> <file>themes/classic/32/compare.png</file>
<file>themes/classic/32/saveas.png</file> <file>themes/classic/32/saveas.png</file>
<file>themes/classic/32/preferences.png</file> <file>themes/classic/32/apppreferences.png</file>
<file>themes/classic/32/fwpreferences.png</file>
<file>themes/classic/32/movedown.png</file> <file>themes/classic/32/movedown.png</file>
<file>themes/classic/32/currentmodel.png</file> <file>themes/classic/32/currentmodel.png</file>
<file>themes/classic/32/read_flash.png</file> <file>themes/classic/32/read_flash.png</file>
@ -619,7 +626,8 @@
<file>themes/classic/48/print.png</file> <file>themes/classic/48/print.png</file>
<file>themes/classic/48/compare.png</file> <file>themes/classic/48/compare.png</file>
<file>themes/classic/48/saveas.png</file> <file>themes/classic/48/saveas.png</file>
<file>themes/classic/48/preferences.png</file> <file>themes/classic/48/apppreferences.png</file>
<file>themes/classic/48/fwpreferences.png</file>
<file>themes/classic/48/movedown.png</file> <file>themes/classic/48/movedown.png</file>
<file>themes/classic/48/currentmodel.png</file> <file>themes/classic/48/currentmodel.png</file>
<file>themes/classic/48/read_flash.png</file> <file>themes/classic/48/read_flash.png</file>
@ -661,7 +669,8 @@
<file>themes/monoblue/16/print.png</file> <file>themes/monoblue/16/print.png</file>
<file>themes/monoblue/16/compare.png</file> <file>themes/monoblue/16/compare.png</file>
<file>themes/monoblue/16/saveas.png</file> <file>themes/monoblue/16/saveas.png</file>
<file>themes/monoblue/16/preferences.png</file> <file>themes/monoblue/16/apppreferences.png</file>
<file>themes/monoblue/16/fwpreferences.png</file>
<file>themes/monoblue/16/movedown.png</file> <file>themes/monoblue/16/movedown.png</file>
<file>themes/monoblue/16/currentmodel.png</file> <file>themes/monoblue/16/currentmodel.png</file>
<file>themes/monoblue/16/read_flash.png</file> <file>themes/monoblue/16/read_flash.png</file>
@ -703,7 +712,8 @@
<file>themes/monoblue/24/print.png</file> <file>themes/monoblue/24/print.png</file>
<file>themes/monoblue/24/compare.png</file> <file>themes/monoblue/24/compare.png</file>
<file>themes/monoblue/24/saveas.png</file> <file>themes/monoblue/24/saveas.png</file>
<file>themes/monoblue/24/preferences.png</file> <file>themes/monoblue/24/apppreferences.png</file>
<file>themes/monoblue/24/fwpreferences.png</file>
<file>themes/monoblue/24/movedown.png</file> <file>themes/monoblue/24/movedown.png</file>
<file>themes/monoblue/24/currentmodel.png</file> <file>themes/monoblue/24/currentmodel.png</file>
<file>themes/monoblue/24/read_flash.png</file> <file>themes/monoblue/24/read_flash.png</file>
@ -745,7 +755,8 @@
<file>themes/monoblue/32/print.png</file> <file>themes/monoblue/32/print.png</file>
<file>themes/monoblue/32/compare.png</file> <file>themes/monoblue/32/compare.png</file>
<file>themes/monoblue/32/saveas.png</file> <file>themes/monoblue/32/saveas.png</file>
<file>themes/monoblue/32/preferences.png</file> <file>themes/monoblue/32/apppreferences.png</file>
<file>themes/monoblue/32/fwpreferences.png</file>
<file>themes/monoblue/32/movedown.png</file> <file>themes/monoblue/32/movedown.png</file>
<file>themes/monoblue/32/currentmodel.png</file> <file>themes/monoblue/32/currentmodel.png</file>
<file>themes/monoblue/32/read_flash.png</file> <file>themes/monoblue/32/read_flash.png</file>
@ -787,7 +798,8 @@
<file>themes/monoblue/48/print.png</file> <file>themes/monoblue/48/print.png</file>
<file>themes/monoblue/48/compare.png</file> <file>themes/monoblue/48/compare.png</file>
<file>themes/monoblue/48/saveas.png</file> <file>themes/monoblue/48/saveas.png</file>
<file>themes/monoblue/48/preferences.png</file> <file>themes/monoblue/48/apppreferences.png</file>
<file>themes/monoblue/48/fwpreferences.png</file>
<file>themes/monoblue/48/movedown.png</file> <file>themes/monoblue/48/movedown.png</file>
<file>themes/monoblue/48/currentmodel.png</file> <file>themes/monoblue/48/currentmodel.png</file>
<file>themes/monoblue/48/read_flash.png</file> <file>themes/monoblue/48/read_flash.png</file>
@ -829,7 +841,8 @@
<file>themes/monowhite/16/print.png</file> <file>themes/monowhite/16/print.png</file>
<file>themes/monowhite/16/compare.png</file> <file>themes/monowhite/16/compare.png</file>
<file>themes/monowhite/16/saveas.png</file> <file>themes/monowhite/16/saveas.png</file>
<file>themes/monowhite/16/preferences.png</file> <file>themes/monowhite/16/apppreferences.png</file>
<file>themes/monowhite/16/fwpreferences.png</file>
<file>themes/monowhite/16/movedown.png</file> <file>themes/monowhite/16/movedown.png</file>
<file>themes/monowhite/16/currentmodel.png</file> <file>themes/monowhite/16/currentmodel.png</file>
<file>themes/monowhite/16/read_flash.png</file> <file>themes/monowhite/16/read_flash.png</file>
@ -871,7 +884,8 @@
<file>themes/monowhite/24/print.png</file> <file>themes/monowhite/24/print.png</file>
<file>themes/monowhite/24/compare.png</file> <file>themes/monowhite/24/compare.png</file>
<file>themes/monowhite/24/saveas.png</file> <file>themes/monowhite/24/saveas.png</file>
<file>themes/monowhite/24/preferences.png</file> <file>themes/monowhite/24/apppreferences.png</file>
<file>themes/monowhite/24/fwpreferences.png</file>
<file>themes/monowhite/24/movedown.png</file> <file>themes/monowhite/24/movedown.png</file>
<file>themes/monowhite/24/currentmodel.png</file> <file>themes/monowhite/24/currentmodel.png</file>
<file>themes/monowhite/24/read_flash.png</file> <file>themes/monowhite/24/read_flash.png</file>
@ -913,7 +927,8 @@
<file>themes/monowhite/32/print.png</file> <file>themes/monowhite/32/print.png</file>
<file>themes/monowhite/32/compare.png</file> <file>themes/monowhite/32/compare.png</file>
<file>themes/monowhite/32/saveas.png</file> <file>themes/monowhite/32/saveas.png</file>
<file>themes/monowhite/32/preferences.png</file> <file>themes/monowhite/32/apppreferences.png</file>
<file>themes/monowhite/32/fwpreferences.png</file>
<file>themes/monowhite/32/movedown.png</file> <file>themes/monowhite/32/movedown.png</file>
<file>themes/monowhite/32/currentmodel.png</file> <file>themes/monowhite/32/currentmodel.png</file>
<file>themes/monowhite/32/read_flash.png</file> <file>themes/monowhite/32/read_flash.png</file>
@ -955,7 +970,8 @@
<file>themes/monowhite/48/print.png</file> <file>themes/monowhite/48/print.png</file>
<file>themes/monowhite/48/compare.png</file> <file>themes/monowhite/48/compare.png</file>
<file>themes/monowhite/48/saveas.png</file> <file>themes/monowhite/48/saveas.png</file>
<file>themes/monowhite/48/preferences.png</file> <file>themes/monowhite/48/apppreferences.png</file>
<file>themes/monowhite/48/fwpreferences.png</file>
<file>themes/monowhite/48/movedown.png</file> <file>themes/monowhite/48/movedown.png</file>
<file>themes/monowhite/48/currentmodel.png</file> <file>themes/monowhite/48/currentmodel.png</file>
<file>themes/monowhite/48/read_flash.png</file> <file>themes/monowhite/48/read_flash.png</file>

View file

@ -83,7 +83,6 @@ void compareDialog::printDiff()
printCurves(); printCurves();
printGvars(); printGvars();
printSwitches(); printSwitches();
printSafetySwitches();
printFSwitches(); printFSwitches();
printFrSky(); printFrSky();
te->scrollToAnchor("1"); te->scrollToAnchor("1");
@ -1040,9 +1039,9 @@ void compareDialog::printSwitches()
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">"; QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>"); str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">"); str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
QString sw1 = getCustomSwitchStr(&g_model1->customSw[i], *g_model1); QString sw1 = g_model1->customSw[i].toString(*g_model1);
QString sw2 = getCustomSwitchStr(&g_model2->customSw[i], *g_model2); QString sw2 = g_model2->customSw[i].toString(*g_model2);
if (!(sw1.isEmpty() && sw2.isEmpty())) { if (!(sw1.isEmpty() && sw2.isEmpty())) {
str.append("<tr>"); str.append("<tr>");
color=getColor1(sw1,sw2); color=getColor1(sw1,sw2);
@ -1096,8 +1095,8 @@ void compareDialog::printFSwitches()
str.append("<tr>"); str.append("<tr>");
if (g_model1->funcSw[i].swtch.type) { if (g_model1->funcSw[i].swtch.type) {
str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1)); str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1));
str.append(doTC(getFuncName(g_model1->funcSw[i].func),color1)); str.append(doTC(g_model1->funcSw[i].funcToString(),color1));
str.append(doTC(FuncParam(g_model1->funcSw[i].func,g_model1->funcSw[i].param,g_model1->funcSw[i].paramarm, g_model1->funcSw[i].adjustMode),color1)); str.append(doTC(g_model1->funcSw[i].paramToString(),color1));
int index=g_model1->funcSw[i].func; int index=g_model1->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model1->funcSw[i].repeatParam),color1)); str.append(doTC(QString("%1").arg(g_model1->funcSw[i].repeatParam),color1));
@ -1115,8 +1114,8 @@ void compareDialog::printFSwitches()
str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true)); str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true));
if (g_model2->funcSw[i].swtch.type) { if (g_model2->funcSw[i].swtch.type) {
str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2)); str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2));
str.append(doTC(getFuncName(g_model2->funcSw[i].func),color2)); str.append(doTC(g_model2->funcSw[i].funcToString(),color2));
str.append(doTC(FuncParam(g_model2->funcSw[i].func,g_model2->funcSw[i].param,g_model2->funcSw[i].paramarm, g_model2->funcSw[i].adjustMode),color2)); str.append(doTC(g_model2->funcSw[i].paramToString(),color2));
int index=g_model2->funcSw[i].func; int index=g_model2->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model2->funcSw[i].repeatParam),color2)); str.append(doTC(QString("%1").arg(g_model2->funcSw[i].repeatParam),color2));
@ -1142,55 +1141,6 @@ void compareDialog::printFSwitches()
te->append(str); te->append(str);
} }
void compareDialog::printSafetySwitches()
{
QString color1;
QString color2;
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 style=\"page-break-before:always;\" width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\"><tr>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("<td width=\"10%\">&nbsp;</td>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if ((g_model1->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)||(g_model2->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)) {
if ((g_model1->safetySw[i].swtch!=g_model2->safetySw[i].swtch)||(g_model1->safetySw[i].val!=g_model2->safetySw[i].val)) {
color1="green";
color2="red";
} else {
color1="grey";
color2="grey";
}
str.append("<tr>");
if (g_model1->safetySw[i].swtch.type) {
str.append(doTC(g_model1->safetySw[i].swtch.toString(),color1));
str.append(doTC(QString::number(g_model1->safetySw[i].val),color1));
}
else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
if (g_model2->safetySw[i].swtch.type) {
str.append(doTC(g_model2->safetySw[i].swtch.toString(),color2));
str.append(doTC(QString::number(g_model2->safetySw[i].val),color2));
} else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void compareDialog::printFrSky() void compareDialog::printFrSky()
{ {
QString color; QString color;

View file

@ -7,14 +7,39 @@
#include "splashlibrary.h" #include "splashlibrary.h"
#include "flashinterface.h" #include "flashinterface.h"
Side::Side(){
imageLabel = 0;
fileNameEdit = 0;
saveButton = 0;
source=new Source;
*source = UNDEFINED;
}
void Side::copyImage( Side side ){
if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED))
imageLabel->setPixmap(*side.imageLabel->pixmap());
}
customizeSplashDialog::customizeSplashDialog(QWidget *parent) : customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::customizeSplashDialog) ui(new Ui::customizeSplashDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->libraryButton->setIcon(CompanionIcon("library.png")); ui->leftLibraryButton->setIcon(CompanionIcon("library.png"));
ui->HowToLabel->clear(); ui->rightLibraryButton->setIcon(CompanionIcon("library.png"));
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
left.imageLabel = ui->leftImageLabel;
right.imageLabel = ui->rightImageLabel;
left.fileNameEdit = ui->leftFileNameEdit;
right.fileNameEdit = ui->rightFileNameEdit;
left.saveButton = ui->leftSaveButton;
right.saveButton = ui->rightSaveButton;
left.libraryButton = ui->leftLibraryButton;
right.libraryButton = ui->rightLibraryButton;
left.invertButton = ui->leftInvertButton;
right.invertButton = ui->rightInvertButton;
resize(0,0);
} }
customizeSplashDialog::~customizeSplashDialog() customizeSplashDialog::~customizeSplashDialog()
@ -22,92 +47,101 @@ customizeSplashDialog::~customizeSplashDialog()
delete ui; delete ui;
} }
void customizeSplashDialog::on_FlashLoadButton_clicked() void customizeSplashDialog::on_copyRightToLeftButton_clicked() {
left.copyImage(right);
}
void customizeSplashDialog::on_copyLeftToRightButton_clicked() {
right.copyImage(left);
}
void customizeSplashDialog::on_leftLoadFwButton_clicked() {loadFirmware(left);}
void customizeSplashDialog::on_rightLoadFwButton_clicked() {loadFirmware(right);}
void customizeSplashDialog::loadFirmware(Side side)
{ {
QSettings settings; QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true);
ui->SaveFlashButton->setDisabled(true);
ui->SaveImageButton->setDisabled(true);
ui->ImageFileName->clear();
ui->imageLabel->clear();
ui->HowToLabel->clear();
ui->HowToLabel->setStyleSheet("background:rgb(255, 255, 0)");
QFile file(fileName); QFile file(fileName);
if (!file.exists()) { if (fileName.isEmpty() || !file.exists())
ui->FWFileName->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
return; return;
}
if (fileName.isEmpty()) {
ui->FWFileName->clear();
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
return;
}
ui->FWFileName->setText(fileName);
FlashInterface flash(fileName); FlashInterface flash(fileName);
if (flash.hasSplash()) { if (!flash.hasSplash()) {
ui->HowToLabel->append("<center>" + tr("Select an image to customize your splash <br />or save actual firmware splash") + "</center>");
ui->ImageLoadButton->setEnabled(true);
ui->libraryButton->setEnabled(true);
ui->SaveImageButton->setEnabled(true);
ui->imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
ui->imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
} else {
QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file")); QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file"));
return; return;
} }
side.saveButton->setEnabled(true);
side.imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
side.imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
side.fileNameEdit->setText(fileName);
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
*side.source=FW;
side.saveButton->setEnabled(true);
side.libraryButton->setEnabled(true);
side.invertButton->setEnabled(true);
} }
} }
void customizeSplashDialog::on_ImageLoadButton_clicked() { void customizeSplashDialog::on_leftLoadPictButton_clicked() {loadPicture(left);}
void customizeSplashDialog::on_rightLoadPictButton_clicked() {loadPicture(right);}
void customizeSplashDialog::loadPicture(Side side)
{
QString supportedImageFormats; QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) { for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings; QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) { if (fileName.isEmpty()){
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); return;
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
ui->HowToLabel->clear();
ui->ImageFileName->setText(fileName);
if (ui->imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2)));
} else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
ui->SaveFlashButton->setEnabled(true);
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
} }
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
if (side.imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32);
QRgb col;
int gray;
int width = image.width();
int height = image.height();
for (int i = 0; i < width; ++i)
{
for (int j = 0; j < height; ++j)
{
col = image.pixel(i, j);
gray = qGray(col);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2)));
} else {
side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
}
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
side.fileNameEdit->setText(fileName);
*side.source=PICT;
side.saveButton->setEnabled(true);
side.libraryButton->setEnabled(true);
side.invertButton->setEnabled(true);
} }
void customizeSplashDialog::on_libraryButton_clicked() { void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left);}
void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);}
void customizeSplashDialog::loadProfile(Side side)
{
}
void customizeSplashDialog::on_leftLibraryButton_clicked(){libraryButton_clicked(left);}
void customizeSplashDialog::on_rightLibraryButton_clicked(){libraryButton_clicked(right);}
void customizeSplashDialog::libraryButton_clicked( Side side )
{
QString fileName; QString fileName;
splashLibrary *ld = new splashLibrary(this,&fileName); splashLibrary *ld = new splashLibrary(this,&fileName);
@ -118,9 +152,7 @@ void customizeSplashDialog::on_libraryButton_clicked() {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return; return;
} }
ui->HowToLabel->clear(); if (side.imageLabel->width()==424) {
ui->ImageFileName->setText(fileName);
if (ui->imageLabel->width()==424) {
image=image.convertToFormat(QImage::Format_RGB32); image=image.convertToFormat(QImage::Format_RGB32);
QRgb col; QRgb col;
int gray; int gray;
@ -135,57 +167,52 @@ void customizeSplashDialog::on_libraryButton_clicked() {
image.setPixel(i, j, qRgb(gray, gray, gray)); image.setPixel(i, j, qRgb(gray, gray, gray));
} }
} }
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2))); side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2)));
} else { } else {
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
} }
ui->SaveFlashButton->setEnabled(true);
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
} }
} }
void customizeSplashDialog::on_SaveFlashButton_clicked() void customizeSplashDialog::on_leftSaveButton_clicked(){saveButton_clicked(left);}
void customizeSplashDialog::on_rightSaveButton_clicked(){saveButton_clicked(right);}
void customizeSplashDialog::saveButton_clicked(Side side)
{ {
QString fileName;
QSettings settings; QSettings settings;
ui->HowToLabel->clear(); QString fileName = side.fileNameEdit->text();
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER, 0, QFileDialog::DontConfirmOverwrite);
if (fileName.isEmpty()) { if (*side.source == FW)
return; {
FlashInterface flash(fileName);
if (!flash.hasSplash()) {
QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName));
return;
}
QImage image = side.imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
if (flash.setSplash(image) && (flash.saveFlash(fileName) > 0))
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
else
QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName));
} }
FlashInterface flash(ui->FWFileName->text()); else if (*side.source == PICT)
if (!flash.hasSplash()) { {
QMessageBox::critical(this, tr("Error"), tr("Error reading file %1").arg(fileName)); if (!fileName.isEmpty()) {
return; QImage image = side.imageLabel->pixmap()->toImage().scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
} if (image.save(fileName))
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image = ui->imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); else
flash.setSplash(image); QMessageBox::critical(this, tr("Error"), tr("The image file %1 could not be stored").arg(fileName));
if (flash.saveFlash(fileName) > 0) { }
ui->HowToLabel->setStyleSheet("background:rgb(0,255.0);");
ui->HowToLabel->append("<center>" + tr("Firmware correctly saved.") + "</center>");
} else {
ui->HowToLabel->setStyleSheet("background:rgb(255.0.0);");
ui->HowToLabel->append("<center>" + tr("Firmware not saved.") + "</center>");
} }
} }
void customizeSplashDialog::on_InvertColorButton_clicked() void customizeSplashDialog::on_leftInvertButton_clicked(){invertButton_clicked(left);}
void customizeSplashDialog::on_rightInvertButton_clicked(){invertButton_clicked(right);}
void customizeSplashDialog::invertButton_clicked(Side side)
{ {
QImage image = ui->imageLabel->pixmap()->toImage(); QImage image = side.imageLabel->pixmap()->toImage();
image.invertPixels(); image.invertPixels();
ui->imageLabel->setPixmap(QPixmap::fromImage(image)); side.imageLabel->setPixmap(QPixmap::fromImage(image));
} }
void customizeSplashDialog::on_SaveImageButton_clicked()
{
QString fileName;
QSettings settings;
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastImagesDir").toString(), tr("PNG images (*.png);;"), 0, QFileDialog::DontConfirmOverwrite);
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
image.save(fileName, "PNG");
}
}

View file

@ -10,24 +10,61 @@ namespace Ui
class customizeSplashDialog; class customizeSplashDialog;
} }
enum Source {FW, PICT, PROFILE, UNDEFINED};
class Side
{
public:
Side();
void copyImage( Side );
QLabel *imageLabel;
QLineEdit *fileNameEdit;
QPushButton *saveButton;
QPushButton *invertButton;
QToolButton *libraryButton;
Source *source;
};
class customizeSplashDialog : public QDialog class customizeSplashDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Side left;
Side right;
public: public:
explicit customizeSplashDialog(QWidget *parent = 0); explicit customizeSplashDialog(QWidget *parent = 0);
~customizeSplashDialog(); ~customizeSplashDialog();
private slots: private slots:
void on_FlashLoadButton_clicked(); void on_leftLoadFwButton_clicked();
void on_ImageLoadButton_clicked(); void on_leftLoadPictButton_clicked();
void on_libraryButton_clicked(); void on_leftLoadProfileButton_clicked();
void on_SaveFlashButton_clicked(); void on_leftLibraryButton_clicked();
void on_InvertColorButton_clicked(); void on_leftSaveButton_clicked();
void on_SaveImageButton_clicked(); void on_leftInvertButton_clicked();
void on_rightLoadFwButton_clicked();
void on_rightLoadPictButton_clicked();
void on_rightLoadProfileButton_clicked();
void on_rightLibraryButton_clicked();
void on_rightSaveButton_clicked();
void on_rightInvertButton_clicked();
void on_copyRightToLeftButton_clicked();
void on_copyLeftToRightButton_clicked();
private: private:
void loadFirmware( Side );
void loadPicture( Side );
void loadProfile( Side );
void libraryButton_clicked( Side );
void saveButton_clicked( Side );
void invertButton_clicked( Side );
Ui::customizeSplashDialog *ui; Ui::customizeSplashDialog *ui;
enum sideEnum { LEFT, RIGHT };
}; };
#endif // CUSTOMIZESPLASHDIALOG_H #endif // CUSTOMIZESPLASHDIALOG_H

View file

@ -2,88 +2,508 @@
<ui version="4.0"> <ui version="4.0">
<class>customizeSplashDialog</class> <class>customizeSplashDialog</class>
<widget class="QDialog" name="customizeSplashDialog"> <widget class="QDialog" name="customizeSplashDialog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>366</width> <width>1086</width>
<height>303</height> <height>285</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Customize Splash</string> <string>Transmitter Splash Screen Editor</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="companion.qrc"> <iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset> <normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<item row="0" column="0"> <property name="spacing">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <number>6</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item> <item>
<spacer name="horizontalSpacer"> <widget class="Line" name="line_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
<widget class="QLabel" name="imageLabel"> <widget class="Line" name="line_13">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="companion.qrc">:/images/customize.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="spacing">
<number>6</number>
</property>
<item> <item>
<widget class="QPushButton" name="SaveImageButton"> <spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="leftFileNameEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>424</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>426</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="spacing">
<number>6</number>
</property>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="leftImageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text"> <property name="text">
<string>Save Image</string> <string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="leftInvertButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="leftLibraryButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Open Splash Library</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="leftLoadFwButton">
<property name="text">
<string>Load FW</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="leftLoadPictButton">
<property name="text">
<string>Load Pict</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="leftLoadProfileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="leftSaveButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QToolButton" name="copyRightToLeftButton">
<property name="text">
<string>...</string>
</property>
<property name="arrowType">
<enum>Qt::LeftArrow</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="copyLeftToRightButton">
<property name="text">
<string>...</string>
</property>
<property name="arrowType">
<enum>Qt::RightArrow</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="Line" name="line_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="spacing">
<number>6</number>
</property>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="rightFileNameEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>426</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="spacing">
<number>6</number>
</property>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="rightImageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>424</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="rightInvertButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Invert</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -101,164 +521,120 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="InvertColorButton"> <widget class="QToolButton" name="rightLibraryButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Open Splash Library</string>
</property>
<property name="text"> <property name="text">
<string>Invert Color</string> <string>...</string>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPushButton" name="rightLoadFwButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Load FW</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rightLoadPictButton">
<property name="text">
<string>Load Pict</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rightLoadProfileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="rightSaveButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2"> <widget class="Line" name="line_6">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="HowToLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:rgb(255, 255, 0);</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLineEdit" name="FWFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QPushButton" name="FlashLoadButton">
<property name="text">
<string>Load Firmware</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="ImageFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="ImageLoadButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Load Image</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="libraryButton">
<property name="toolTip">
<string>Open Splash Library</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>208</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="SaveFlashButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save Firmware</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<tabstops>
<tabstop>leftFileNameEdit</tabstop>
<tabstop>leftInvertButton</tabstop>
<tabstop>leftLoadPictButton</tabstop>
<tabstop>leftSaveButton</tabstop>
<tabstop>copyLeftToRightButton</tabstop>
<tabstop>copyRightToLeftButton</tabstop>
<tabstop>rightFileNameEdit</tabstop>
<tabstop>rightInvertButton</tabstop>
<tabstop>rightLoadFwButton</tabstop>
<tabstop>rightLoadPictButton</tabstop>
<tabstop>rightSaveButton</tabstop>
</tabstops>
<resources> <resources>
<include location="companion.qrc"/> <include location="companion.qrc"/>
</resources> </resources>

View file

@ -93,6 +93,17 @@ class DataField {
const char *name; const char *name;
}; };
class ProxyField: public DataField {
public:
ProxyField():
DataField("Proxy")
{
}
virtual DataField * getField() = 0;
};
template<int N> template<int N>
class UnsignedField: public DataField { class UnsignedField: public DataField {
public: public:
@ -273,9 +284,10 @@ class SpareBitsField: public UnsignedField<N> {
template<int N> template<int N>
class CharField: public DataField { class CharField: public DataField {
public: public:
CharField(char *field): CharField(char *field, bool truncate=true):
DataField("Char"), DataField("Char"),
field(field) field(field),
truncate(truncate)
{ {
} }
@ -283,7 +295,7 @@ class CharField: public DataField {
{ {
output.resize(N*8); output.resize(N*8);
int b = 0; int b = 0;
int len = strlen(field); int len = truncate ? strlen(field) : N;
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
int idx = (i>=len ? 0 : field[i]); int idx = (i>=len ? 0 : field[i]);
for (int j=0; j<8; j++, b++) { for (int j=0; j<8; j++, b++) {
@ -313,6 +325,7 @@ class CharField: public DataField {
protected: protected:
char * field; char * field;
bool truncate;
}; };
int8_t char2idx(char c); int8_t char2idx(char c);

View file

@ -268,62 +268,52 @@ QString RawSwitch::toString()
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26") QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
}; };
switch(type) { static const QString trimsSwitches[] = {
case SWITCH_TYPE_SWITCH: QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"),
if (IS_TARANIS(GetEepromInterface()->getBoard())) QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"),
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1); QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"),
else QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right")
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1); };
case SWITCH_TYPE_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
case SWITCH_TYPE_MULTIPOS_POT:
return CHECK_IN_ARRAY(multiposPots, index);
case SWITCH_TYPE_ON:
return QObject::tr("ON");
case SWITCH_TYPE_ONM:
if (index==0) {
return QObject::tr("ONE");
}
else if (index==1) {
return QObject::tr("!ONE");
}
break;
case SWITCH_TYPE_TRN:
if (index==0) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"s";
else
return QObject::tr("TRNs");
} else if (index==1) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"l";
else
return QObject::tr("TRNl");
}
break;
case SWITCH_TYPE_REA:
if (index==0) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAs");
} else if (index==1) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAl");
}
break;
case SWITCH_TYPE_OFF:
return QObject::tr("OFF");
case SWITCH_TYPE_MOMENT_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switchesX9D, -index-1)+QString("t");
else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switches9X, -index-1)+QString("t");
case SWITCH_TYPE_MOMENT_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(virtualSwitches, -index-1)+QString("t");
default:
break;
}
return QObject::tr("----"); static const QString rotaryEncoders[] = {
QObject::tr("REa"), QObject::tr("REb")
};
static const QString timerModes[] = {
QObject::tr("OFF"), QObject::tr("ABS"),
QObject::tr("THs"), QObject::tr("TH%"), QObject::tr("THt")
};
if (index < 0) {
return QString("!") + RawSwitch(type, -index).toString();
}
else {
switch(type) {
case SWITCH_TYPE_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return CHECK_IN_ARRAY(switchesX9D, index-1);
else
return CHECK_IN_ARRAY(switches9X, index-1);
case SWITCH_TYPE_VIRTUAL:
return CHECK_IN_ARRAY(virtualSwitches, index-1);
case SWITCH_TYPE_MULTIPOS_POT:
return CHECK_IN_ARRAY(multiposPots, index-1);
case SWITCH_TYPE_TRIM:
return CHECK_IN_ARRAY(trimsSwitches, index-1);
case SWITCH_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotaryEncoders, index-1);
case SWITCH_TYPE_ON:
return QObject::tr("ON");
case SWITCH_TYPE_OFF:
return QObject::tr("OFF");
case SWITCH_TYPE_NONE:
return QObject::tr("----");
case SWITCH_TYPE_TIMER_MODE:
return CHECK_IN_ARRAY(timerModes, index);
default:
return QObject::tr("???");
}
}
} }
QString CurveReference::toString() QString CurveReference::toString()
@ -345,6 +335,392 @@ QString CurveReference::toString()
} }
} }
CSFunctionFamily LogicalSwitchData::getFunctionFamily()
{
if (func == LS_FN_STAY)
return LS_FAMILY_STAY;
else if (func == LS_FN_TIMER)
return LS_FAMILY_TIMER;
else if (func == LS_FN_STICKY)
return LS_FAMILY_STICKY;
else if (func < LS_FN_AND || func > LS_FN_ELESS)
return LS_FAMILY_VOFS;
else if (func < LS_FN_EQUAL)
return LS_FAMILY_VBOOL;
else
return LS_FAMILY_VCOMP;
}
QString LogicalSwitchData::funcToString()
{
switch (func) {
case LS_FN_OFF:
return QObject::tr("---");
case LS_FN_VPOS:
return QObject::tr("a>x");
case LS_FN_VNEG:
return QObject::tr("a<x");
case LS_FN_APOS:
return QObject::tr("|a|>x");
case LS_FN_ANEG:
return QObject::tr("|a|<x");
case LS_FN_AND:
return QObject::tr("AND");
case LS_FN_OR:
return QObject::tr("OR");
case LS_FN_XOR:
return QObject::tr("XOR");
case LS_FN_EQUAL:
return QObject::tr("a=b");
case LS_FN_NEQUAL:
return QObject::tr("a!=b");
case LS_FN_GREATER:
return QObject::tr("a>b");
case LS_FN_LESS:
return QObject::tr("a<b");
case LS_FN_EGREATER:
return QObject::tr("a>=b");
case LS_FN_ELESS:
return QObject::tr("a<=b");
case LS_FN_DPOS:
return QObject::tr("d>=x");
case LS_FN_DAPOS:
return QObject::tr("|d|>=x");
case LS_FN_VEQUAL:
return QObject::tr("a~x");
case LS_FN_TIMER:
return QObject::tr("Timer");
case LS_FN_STICKY:
return QObject::tr("Sticky");
case LS_FN_STAY:
return QObject::tr("Stay");
default:
return QObject::tr("Unknown");
}
}
QString LogicalSwitchData::toString(const ModelData & model)
{
QString result = "";
if (!func)
return result;
if (andsw!=0) {
result +="( ";
}
switch (getFunctionFamily()) {
case LS_FAMILY_STAY:
result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3));
break;
case LS_FAMILY_STICKY:
result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString());
break;
case LS_FAMILY_TIMER:
result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2));
break;
case LS_FAMILY_VOFS: {
RawSource source = RawSource(val1, &model);
RawSourceRange range = source.getRange();
if (val1)
result += source.toString();
else
result += "0";
result.remove(" ");
if (func == LS_FN_APOS || func == LS_FN_ANEG)
result = "|" + result + "|";
else if (func == LS_FN_DAPOS)
result = "|d(" + result + ")|";
else if (func == LS_FN_DPOS) result = "d(" + result + ")";
if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DAPOS || func == LS_FN_DPOS)
result += " &gt; ";
else if (func == LS_FN_ANEG || func == LS_FN_VNEG)
result += " &lt; ";
result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
break;
}
case LS_FAMILY_VBOOL:
result = RawSwitch(val1).toString();
switch (func) {
case LS_FN_AND:
result += " AND ";
break;
case LS_FN_OR:
result += " OR ";
break;
case LS_FN_XOR:
result += " XOR ";
break;
default:
break;
}
result += RawSwitch(val2).toString();
break;
case LS_FAMILY_VCOMP:
if (val1)
result += RawSource(val1).toString();
else
result += "0";
switch (func) {
case LS_FN_EQUAL:
result += " = ";
break;
case LS_FN_NEQUAL:
result += " != ";
break;
case LS_FN_GREATER:
result += " &gt; ";
break;
case LS_FN_LESS:
result += " &lt; ";
break;
case LS_FN_EGREATER:
result += " &gt;= ";
break;
case LS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (val2)
result += RawSource(val2).toString();
else
result += "0";
break;
}
if (andsw!=0) {
result +=" ) AND ";
result += RawSwitch(andsw).toString();
}
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
if (delay)
result += QObject::tr(" Delay %1 sec").arg(delay/2.0);
if (duration)
result += QObject::tr(" Duration %1 sec").arg(duration/2.0);
}
return result;
}
#if 0
QStringList FuncSwData::toStringList()
{
QStringList result;
QStringList qs;
result << swtch.toString();
result << funcToString();
if (func < FuncInstantTrim) {
result << QString("%1").arg(param);
}
else if (func==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
RawSource item(param);
result << item.toString();
}
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
result << QString("%1").arg(param);
} else {
result << paramarm;
}
}
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
switch (adjustMode) {
case 0:
result << QObject::tr("Value ")+QString("%1").arg(param);
break;
case 1:
result << RawSource(param).toString();
break;
case 2:
result << RawSource(param).toString();
break;
case 3:
if (param==0) {
result << QObject::tr("Decr:")+QString(" -1");
}
else {
result << QObject::tr("Incr:")+QString(" +1");
}
break;
default:
break;
}
}
if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green"));
} else {
str.append(doTC( "&nbsp;","green"));
}
if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) {
str.append(doTC((g_model->funcSw[i].enabled ? "ON" : "OFF"),"green"));
} else {
str.append(doTC( "---","green"));
}
return result;
}
#endif
QString FuncSwData::funcToString()
{
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString());
else if (func == FuncTrainer)
return QObject::tr("Trainer");
else if (func == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (func == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (func == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (func == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (func == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (func == FuncPlaySound)
return QObject::tr("Play Sound");
else if (func == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (func == FuncReset)
return QObject::tr("Reset");
else if (func >= FuncSetTimer1 && func <= FuncSetTimer2)
return QObject::tr("Set Timer %1").arg(func-FuncSetTimer1+1);
else if (func == FuncVario)
return QObject::tr("Vario");
else if (func == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (func == FuncPlayBoth)
return QObject::tr("Play Both");
else if (func == FuncPlayValue)
return QObject::tr("Play Value");
else if (func == FuncLogs)
return QObject::tr("Start Logs");
else if (func == FuncVolume)
return QObject::tr("Volume");
else if (func == FuncBacklight)
return QObject::tr("Backlight");
else if (func == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (func == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(func-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
QString FuncSwData::paramToString()
{
QStringList qs;
if (func <= FuncInstantTrim) {
return QString("%1").arg(param);
}
else if (func==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
RawSource item(param);
return item.toString();
}
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
return QString("%1").arg(param);
} else {
return paramarm;
}
}
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
switch (adjustMode) {
case 0:
return QObject::tr("Value ")+QString("%1").arg(param);
break;
case 1:
return RawSource(param).toString();
break;
case 2:
return RawSource(param).toString();
break;
case 3:
if (param==0) {
return QObject::tr("Decr:")+QString(" -1");
}
else {
return QObject::tr("Incr:")+QString(" +1");
}
break;
default:
return "";
}
}
return "";
}
QString FuncSwData::repeatToString()
{
if (repeatParam==0) {
return QObject::tr("No repeat");
}
else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*repeatParam);
}
}
GeneralSettings::GeneralSettings() GeneralSettings::GeneralSettings()
{ {
memset(this, 0, sizeof(GeneralSettings)); memset(this, 0, sizeof(GeneralSettings));
@ -497,7 +873,8 @@ void ModelData::clear()
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
moduleData[0].protocol=PXX_XJT_X16; moduleData[0].protocol=PXX_XJT_X16;
moduleData[1].protocol=OFF; moduleData[1].protocol=OFF;
} else { }
else {
moduleData[0].protocol=PPM; moduleData[0].protocol=PPM;
moduleData[1].protocol=OFF; moduleData[1].protocol=OFF;
} }
@ -505,20 +882,17 @@ void ModelData::clear()
phaseData[i].clear(); phaseData[i].clear();
clearInputs(); clearInputs();
clearMixes(); clearMixes();
for(int i=0; i<4; i++){
mixData[i].destCh = i+1;
mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i);
mixData[i].weight = 100;
}
for (int i=0; i<C9X_NUM_CHNOUT; i++) for (int i=0; i<C9X_NUM_CHNOUT; i++)
limitData[i].clear(); limitData[i].clear();
for (int i=0; i<NUM_STICKS; i++) for (int i=0; i<NUM_STICKS; i++)
expoData[i].clear(); expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++) for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear(); customSw[i].clear();
for (int i=0; i<C9X_MAX_CURVES; i++) { for (int i=0; i<C9X_MAX_CURVES; i++)
curves[i].clear(5); curves[i].clear(5);
} for (int i=0; i<2; i++)
timers[i].clear();
swashRingData.clear(); swashRingData.clear();
frsky.clear(); frsky.clear();
@ -536,17 +910,57 @@ void ModelData::setDefault(uint8_t id)
sprintf(name, "MODEL%02d", id+1); sprintf(name, "MODEL%02d", id+1);
} }
unsigned int ModelData::getTrimFlightPhase(uint8_t idx, int8_t phase) int ModelData::getTrimValue(int phaseIdx, int trimIdx)
{ {
// if (phase == -1) phase = getFlightPhase(); int result = 0;
for (int i=0; i<C9X_MAX_PHASES; i++) {
for (uint8_t i=0; i<C9X_MAX_PHASES; i++) { PhaseData & phase = phaseData[phaseIdx];
if (phase == 0 || phaseData[phase].trimRef[idx] < 0) return phase; if (phase.trimMode[trimIdx] < 0) {
phase = phaseData[phase].trimRef[idx]; return result;
}
else {
if (phase.trimRef[trimIdx] == phaseIdx || phaseIdx == 0) {
return result + phase.trim[trimIdx];
}
else {
phaseIdx = phase.trimRef[trimIdx];
if (phase.trimMode[trimIdx] == 0)
result = 0;
else
result += phase.trim[trimIdx];
}
}
} }
return 0; return 0;
} }
void ModelData::setTrimValue(int phaseIdx, int trimIdx, int value)
{
for (uint8_t i=0; i<C9X_MAX_PHASES; i++) {
PhaseData & phase = phaseData[phaseIdx];
int mode = phase.trimMode[trimIdx];
int p = phase.trimRef[trimIdx];
int & trim = phase.trim[trimIdx];
if (mode < 0)
return;
if (p == phaseIdx || phaseIdx == 0) {
trim = value;
break;;
}
else if (mode == 0) {
phaseIdx = p;
}
else {
trim = value - getTrimValue(p, trimIdx);
if (trim < -500)
trim = -500;
if (trim > 500)
trim = 500;
break;
}
}
}
void ModelData::removeGlobalVar(int & var) void ModelData::removeGlobalVar(int & var)
{ {
if (var >= 126 && var <= 130) if (var >= 126 && var <= 130)

View file

@ -72,7 +72,6 @@ const uint8_t modn12x3[4][4]= {
#define C9X_MAX_POINTS 17 #define C9X_MAX_POINTS 17
#define C9X_MAX_GVARS 9 #define C9X_MAX_GVARS 9
#define C9X_MAX_ENCODERS 2 #define C9X_MAX_ENCODERS 2
#define NUM_SAFETY_CHNOUT 16
#define C9X_NUM_CHNOUT 32 // number of real output channels #define C9X_NUM_CHNOUT 32 // number of real output channels
#define C9X_NUM_CSW 32 // number of custom switches #define C9X_NUM_CSW 32 // number of custom switches
#define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches #define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches
@ -147,44 +146,6 @@ enum EnumKeys {
#endif #endif
}; };
enum CSFunction {
CS_FN_OFF,
CS_FN_VPOS,
CS_FN_VNEG,
CS_FN_APOS,
CS_FN_ANEG,
CS_FN_AND,
CS_FN_OR,
CS_FN_XOR,
CS_FN_EQUAL,
CS_FN_NEQUAL,
CS_FN_GREATER,
CS_FN_LESS,
CS_FN_EGREATER,
CS_FN_ELESS,
CS_FN_DPOS,
CS_FN_DAPOS,
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
CS_FN_TIM,
CS_FN_MAXF
};
enum CSFunctionFamily {
CS_FAMILY_VOFS,
CS_FAMILY_VBOOL,
CS_FAMILY_VCOMP,
CS_FAMILY_TIMERS
};
inline CSFunctionFamily getCSFunctionFamily(int fn)
{
if (fn==CS_FN_TIM) {
return (CS_FAMILY_TIMERS);
} else {
return ((fn<CS_FN_AND || fn>CS_FN_ELESS) ? CS_FAMILY_VOFS : (fn<CS_FN_EQUAL ? CS_FAMILY_VBOOL : CS_FAMILY_VCOMP));
}
}
#define CHAR_FOR_NAMES " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-." #define CHAR_FOR_NAMES " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-."
#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*" #define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*"
@ -357,13 +318,11 @@ enum RawSwitchType {
SWITCH_TYPE_SWITCH, SWITCH_TYPE_SWITCH,
SWITCH_TYPE_VIRTUAL, SWITCH_TYPE_VIRTUAL,
SWITCH_TYPE_MULTIPOS_POT, SWITCH_TYPE_MULTIPOS_POT,
SWITCH_TYPE_MOMENT_SWITCH, SWITCH_TYPE_TRIM,
SWITCH_TYPE_MOMENT_VIRTUAL, SWITCH_TYPE_ROTARY_ENCODER,
SWITCH_TYPE_ON, SWITCH_TYPE_ON,
SWITCH_TYPE_OFF, SWITCH_TYPE_OFF,
SWITCH_TYPE_ONM, SWITCH_TYPE_TIMER_MODE
SWITCH_TYPE_TRN,
SWITCH_TYPE_REA,
}; };
class RawSwitch { class RawSwitch {
@ -617,30 +576,63 @@ class MixData {
void clear() { memset(this, 0, sizeof(MixData)); } void clear() { memset(this, 0, sizeof(MixData)); }
}; };
class CustomSwData { // Custom Switches data enum CSFunction {
public: LS_FN_OFF,
CustomSwData() { clear(); } LS_FN_VPOS,
int val1; //input LS_FN_VNEG,
int val2; //offset LS_FN_APOS,
unsigned int func; LS_FN_ANEG,
unsigned int delay; LS_FN_AND,
unsigned int duration; LS_FN_OR,
unsigned int andsw; LS_FN_XOR,
void clear() { memset(this, 0, sizeof(CustomSwData)); } LS_FN_EQUAL,
LS_FN_NEQUAL,
LS_FN_GREATER,
LS_FN_LESS,
LS_FN_EGREATER,
LS_FN_ELESS,
LS_FN_DPOS,
LS_FN_DAPOS,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_TIMER,
LS_FN_STICKY,
LS_FN_STAY,
// later ... LS_FN_RANGE,
LS_FN_MAX
}; };
class SafetySwData { // Custom Switches data enum CSFunctionFamily {
public: LS_FAMILY_VOFS,
SafetySwData() { clear(); } LS_FAMILY_VBOOL,
RawSwitch swtch; LS_FAMILY_VCOMP,
int val; LS_FAMILY_TIMER,
LS_FAMILY_STICKY,
LS_FAMILY_STAY,
};
void clear() { memset(this, 0, sizeof(SafetySwData)); } class LogicalSwitchData { // Custom Switches data
public:
LogicalSwitchData(unsigned int func=0)
{
clear();
this->func = func;
}
unsigned int func;
int val1;
int val2;
int val3;
unsigned int delay;
unsigned int duration;
int andsw;
void clear() { memset(this, 0, sizeof(LogicalSwitchData)); }
CSFunctionFamily getFunctionFamily();
QString funcToString();
QString toString(const ModelData & model);
}; };
enum AssignFunc { enum AssignFunc {
FuncSafetyCh1 = 0, FuncSafetyCh1 = 0,
FuncSafetyCh16 = FuncSafetyCh1+15, FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
FuncTrainer, FuncTrainer,
FuncTrainerRUD, FuncTrainerRUD,
FuncTrainerELE, FuncTrainerELE,
@ -650,6 +642,8 @@ enum AssignFunc {
FuncPlaySound, FuncPlaySound,
FuncPlayHaptic, FuncPlayHaptic,
FuncReset, FuncReset,
FuncSetTimer1,
FuncSetTimer2,
FuncVario, FuncVario,
FuncPlayPrompt, FuncPlayPrompt,
FuncPlayBoth, FuncPlayBoth,
@ -666,7 +660,7 @@ enum AssignFunc {
class FuncSwData { // Function Switches data class FuncSwData { // Function Switches data
public: public:
FuncSwData() { clear(); } FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
RawSwitch swtch; RawSwitch swtch;
AssignFunc func; AssignFunc func;
int param; int param;
@ -675,12 +669,17 @@ class FuncSwData { // Function Switches data
unsigned int adjustMode; unsigned int adjustMode;
int repeatParam; int repeatParam;
void clear() { memset(this, 0, sizeof(FuncSwData)); } void clear() { memset(this, 0, sizeof(FuncSwData)); }
QString funcToString();
QString paramToString();
QString repeatToString();
QStringList toStringList();
}; };
class PhaseData { class PhaseData {
public: public:
PhaseData() { clear(); } PhaseData() { clear(); }
int trimRef[NUM_STICKS]; // int trimMode[NUM_STICKS];
int trimRef[NUM_STICKS];
int trim[NUM_STICKS]; int trim[NUM_STICKS];
RawSwitch swtch; RawSwitch swtch;
char name[10+1]; char name[10+1];
@ -688,7 +687,7 @@ class PhaseData {
unsigned int fadeOut; unsigned int fadeOut;
int rotaryEncoders[2]; int rotaryEncoders[2];
int gvars[C9X_MAX_GVARS]; int gvars[C9X_MAX_GVARS];
void clear() { memset(this, 0, sizeof(PhaseData)); for (int i=0; i<NUM_STICKS; i++) trimRef[i] = -1; } void clear() { memset(this, 0, sizeof(PhaseData)); }
}; };
class SwashRingData { // Swash Ring data class SwashRingData { // Swash Ring data
@ -808,32 +807,17 @@ class MavlinkData {
void clear() { memset(this, 0, sizeof(MavlinkData)); } void clear() { memset(this, 0, sizeof(MavlinkData)); }
}; };
enum TimerMode {
TMRMODE_OFF=0,
TMRMODE_ABS,
TMRMODE_THs,
TMRMODE_THp,
TMRMODE_THt,
TMRMODE_FIRST_SWITCH,
TMRMODE_FIRST_MOMENT_SWITCH = TMRMODE_FIRST_SWITCH+64,
TMRMODE_FIRST_CHPERC = TMRMODE_FIRST_MOMENT_SWITCH+64,
TMRMODE_FIRST_NEG_SWITCH=-TMRMODE_FIRST_SWITCH,
TMRMODE_FIRST_NEG_MOMENT_SWITCH=-TMRMODE_FIRST_MOMENT_SWITCH,
/* sw/!sw, !m_sw/!m_sw */
};
class TimerData { class TimerData {
public: public:
TimerData() { clear(); } TimerData() { clear(); }
TimerMode mode; // timer trigger source -> off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw RawSwitch mode;
bool minuteBeep; bool minuteBeep;
unsigned int countdownBeep; unsigned int countdownBeep;
bool dir; // 0=>Count Down, 1=>Count Up bool dir; // 0=>Count Down, 1=>Count Up
unsigned int val; unsigned int val;
bool persistent; bool persistent;
int pvalue; int pvalue;
void clear() { memset(this, 0, sizeof(TimerData)); } void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); }
}; };
enum Protocol { enum Protocol {
@ -894,13 +878,11 @@ class ModelData {
ExpoData expoData[C9X_MAX_EXPOS]; ExpoData expoData[C9X_MAX_EXPOS];
CurveData curves[C9X_MAX_CURVES]; CurveData curves[C9X_MAX_CURVES];
CustomSwData customSw[C9X_NUM_CSW]; LogicalSwitchData customSw[C9X_NUM_CSW];
FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS]; FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS];
SafetySwData safetySw[C9X_NUM_CHNOUT];
SwashRingData swashRingData; SwashRingData swashRingData;
unsigned int thrTraceSrc; unsigned int thrTraceSrc;
int8_t traineron; // 0 disable trainer, 1 allow trainer int8_t traineron; // 0 disable trainer, 1 allow trainer
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId; unsigned int modelId;
unsigned int switchWarningStates; unsigned int switchWarningStates;
unsigned int nSwToWarn; unsigned int nSwToWarn;
@ -928,8 +910,9 @@ class ModelData {
void clear(); void clear();
bool isempty(); bool isempty();
void setDefault(uint8_t id); void setDefault(uint8_t id);
unsigned int getTrimFlightPhase(uint8_t idx, int8_t phase);
int getTrimValue(int phaseIdx, int trimIdx);
void setTrimValue(int phaseIdx, int trimIdx, int value);
ModelData removeGlobalVars(); ModelData removeGlobalVars();
void clearMixes(); void clearMixes();
@ -965,10 +948,10 @@ enum Capability {
Pots, Pots,
Switches, Switches,
SwitchesPositions, SwitchesPositions,
CustomSwitches, LogicalSwitches,
CustomAndSwitches, CustomAndSwitches,
HasNegAndSwitches, HasNegAndSwitches,
CustomSwitchesExt, LogicalSwitchesExt,
RotaryEncoders, RotaryEncoders,
Outputs, Outputs,
ChannelsName, ChannelsName,
@ -1018,7 +1001,6 @@ enum Capability {
GvarsInCS, GvarsInCS,
GvarsAreNamed, GvarsAreNamed,
GvarsFlightPhases, GvarsFlightPhases,
GvarsHaveSources,
GvarsName, GvarsName,
NoTelemetryProtocol, NoTelemetryProtocol,
TelemetryCustomScreens, TelemetryCustomScreens,
@ -1104,10 +1086,6 @@ class EEPROMInterface
virtual int isAvailable(Protocol proto, int port=0) = 0; virtual int isAvailable(Protocol proto, int port=0) = 0;
virtual bool isAvailable(const RawSwitch & swtch, UseContext context) { return true; }
virtual bool isAvailable(const RawSource & source, UseContext context) { return true; }
virtual SimulatorInterface * getSimulator() = 0; virtual SimulatorInterface * getSimulator() = 0;
virtual const int getEEpromSize() = 0; virtual const int getEEpromSize() = 0;
@ -1189,14 +1167,14 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
// virtual switches // virtual switches
for (int i=0; i<C9X_NUM_CSW; i++) { for (int i=0; i<C9X_NUM_CSW; i++) {
RawSource source; RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func)) { switch (model.customSw[i].getFunctionFamily()) {
case CS_FAMILY_VCOMP: case LS_FAMILY_VCOMP:
source = RawSource(model.customSw[i].val2); source = RawSource(model.customSw[i].val2);
if (source.type == SOURCE_TYPE_STICK) if (source.type == SOURCE_TYPE_STICK)
source.index = applyStickMode(source.index + 1, mode) - 1; source.index = applyStickMode(source.index + 1, mode) - 1;
model.customSw[i].val2 = source.toValue(); model.customSw[i].val2 = source.toValue();
// no break // no break
case CS_FAMILY_VOFS: case LS_FAMILY_VOFS:
source = RawSource(model.customSw[i].val1); source = RawSource(model.customSw[i].val1);
if (source.type == SOURCE_TYPE_STICK) if (source.type == SOURCE_TYPE_STICK)
source.index = applyStickMode(source.index + 1, mode) - 1; source.index = applyStickMode(source.index + 1, mode) - 1;

View file

@ -17,9 +17,9 @@ RawSwitch er9xToSwitch(int8_t sw)
else if (sw == -22) else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9) else if (swa <= 22+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22); return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22);
else else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
} }
t_Er9xTrainerMix::t_Er9xTrainerMix() t_Er9xTrainerMix::t_Er9xTrainerMix()
@ -269,22 +269,22 @@ RawSource er9xToSource(int8_t value)
} }
} }
Er9xCustomSwData::operator CustomSwData () Er9xLogicalSwitchData::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = er9xToSource(v1).toValue(); c9x.val1 = er9xToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = er9xToSource(v2).toValue(); c9x.val2 = er9xToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue(); c9x.val2 = er9xToSwitch(v2).toValue();
} }
@ -298,14 +298,6 @@ t_Er9xSafetySwData::t_Er9xSafetySwData()
memset(this, 0, sizeof(t_Er9xSafetySwData)); memset(this, 0, sizeof(t_Er9xSafetySwData));
} }
t_Er9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = er9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData() t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{ {
memset(this, 0, sizeof(t_Er9xFrSkyChannelData)); memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
@ -343,10 +335,11 @@ t_Er9xFrSkyData::operator FrSkyData ()
return c9x; return c9x;
} }
TimerMode getEr9xTimerMode(int mode) RawSwitch getEr9xTimerMode(int mode)
{ {
/*
if (mode <= -33) if (mode <= -33)
return TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+33)); return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33));
else if (mode <= -1) else if (mode <= -1)
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 16) else if (mode < 16)
@ -354,7 +347,9 @@ TimerMode getEr9xTimerMode(int mode)
else if (mode < 16+21) else if (mode < 16+21)
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16)); return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
else else
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21)); return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21));
*/
return RawSwitch();
} }
t_Er9xModelData::operator ModelData () t_Er9xModelData::operator ModelData ()
@ -381,7 +376,7 @@ t_Er9xModelData::operator ModelData ()
break; break;
} }
c9x.traineron= traineron; c9x.traineron= traineron;
c9x.t2throttle = t2throttle; // c9x.t2throttle = t2throttle;
c9x.moduleData[0].ppmFrameLength=ppmFrameLength; c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim; c9x.thrTrim = thrTrim;
@ -471,8 +466,8 @@ t_Er9xModelData::operator ModelData ()
for (int i=0; i<ER9X_NUM_CSW; i++) for (int i=0; i<ER9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++) // for (int i=0; i<ER9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;

View file

@ -154,21 +154,20 @@ PACK(typedef struct t_Er9xMixData {
}) Er9xMixData; }) Er9xMixData;
PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data PACK(typedef struct t_Er9xLogicalSwitchData { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func:4; uint8_t func:4;
uint8_t andsw:4; uint8_t andsw:4;
operator CustomSwData(); operator LogicalSwitchData();
t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); } t_Er9xLogicalSwitchData() { memset(this, 0, sizeof(t_Er9xLogicalSwitchData)); }
}) Er9xCustomSwData; }) Er9xLogicalSwitchData;
PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Er9xSafetySwData(); t_Er9xSafetySwData();
}) Er9xSafetySwData; }) Er9xSafetySwData;
@ -242,7 +241,7 @@ PACK(typedef struct t_Er9xModelData {
int8_t trim[4]; int8_t trim[4];
int8_t curves5[ER9X_MAX_CURVE5][5]; int8_t curves5[ER9X_MAX_CURVE5][5];
int8_t curves9[ER9X_MAX_CURVE9][9]; int8_t curves9[ER9X_MAX_CURVE9][9];
Er9xCustomSwData customSw[ER9X_NUM_CSW]; Er9xLogicalSwitchData customSw[ER9X_NUM_CSW];
uint8_t frSkyVoltThreshold ; uint8_t frSkyVoltThreshold ;
int8_t tmrModeB; int8_t tmrModeB;
uint8_t numVoice; uint8_t numVoice;

View file

@ -75,11 +75,11 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode)
for (int i=0; i<ER9X_MAX_MIXERS; i++) for (int i=0; i<ER9X_MAX_MIXERS; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ER9X_NUM_CSW; i++) { for (int i=0; i<ER9X_NUM_CSW; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) { switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case CS_FAMILY_VCOMP: case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // no break
case CS_FAMILY_VOFS: case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode); model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break; break;
default: default:
@ -239,7 +239,7 @@ int Er9xInterface::getCapability(const Capability capability)
return 9; return 9;
case CustomFunctions: case CustomFunctions:
return 0; return 0;
case CustomSwitches: case LogicalSwitches:
return 12; return 12;
case CustomAndSwitches: case CustomAndSwitches:
return 5; return 5;
@ -281,8 +281,6 @@ int Er9xInterface::getCapability(const Capability capability)
case ModelVoice: case ModelVoice:
case Gvars: case Gvars:
return 7; return 7;
case GvarsHaveSources:
return 1;
case GetThrSwitch: case GetThrSwitch:
return DSW_THR; return DSW_THR;
default: default:

View file

@ -5,14 +5,12 @@
extern RawSwitch er9xToSwitch(int8_t sw); extern RawSwitch er9xToSwitch(int8_t sw);
TimerMode getErSky9xTimerMode(int mode) RawSwitch getErSky9xTimerMode(int mode)
{ {
if (mode<4) if (mode<4)
return TimerMode(mode); return RawSwitch(SWITCH_TYPE_TIMER_MODE, mode);
else if (mode < 20)
return TimerMode(TMRMODE_FIRST_CHPERC+(mode-4));
else else
return TimerMode(0); return RawSwitch();
} }
RawSwitch ersky9xToSwitch(int8_t sw) RawSwitch ersky9xToSwitch(int8_t sw)
@ -29,9 +27,9 @@ RawSwitch ersky9xToSwitch(int8_t sw)
else if (sw == -34) else if (sw == -34)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 34+9) else if (swa <= 34+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-34 : sw+34); return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-34 : sw+34);
else else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9); return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9);
} }
t_Ersky9xTrainerMix::t_Ersky9xTrainerMix() t_Ersky9xTrainerMix::t_Ersky9xTrainerMix()
@ -355,22 +353,22 @@ RawSource ersky9xToSource_v11(int8_t value)
} }
} }
Ersky9xCustomSwData_v10::operator CustomSwData () Ersky9xLogicalSwitchData_v10::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = ersky9xToSource_v10(v1).toValue(); c9x.val1 = ersky9xToSource_v10(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = ersky9xToSource_v10(v2).toValue(); c9x.val2 = ersky9xToSource_v10(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue(); c9x.val2 = er9xToSwitch(v2).toValue();
} }
@ -378,22 +376,22 @@ Ersky9xCustomSwData_v10::operator CustomSwData ()
return c9x; return c9x;
} }
Ersky9xCustomSwData_v11::operator CustomSwData () Ersky9xLogicalSwitchData_v11::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = ersky9xToSource_v11(v1).toValue(); c9x.val1 = ersky9xToSource_v11(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = ersky9xToSource_v11(v2).toValue(); c9x.val2 = ersky9xToSource_v11(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue(); c9x.val2 = er9xToSwitch(v2).toValue();
} }
@ -406,27 +404,11 @@ t_Ersky9xSafetySwData_v10::t_Ersky9xSafetySwData_v10()
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v10)); memset(this, 0, sizeof(t_Ersky9xSafetySwData_v10));
} }
t_Ersky9xSafetySwData_v10::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = er9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11() t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11()
{ {
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v11)); memset(this, 0, sizeof(t_Ersky9xSafetySwData_v11));
} }
t_Ersky9xSafetySwData_v11::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = ersky9xToSwitch(opt.ss.swtch);
c9x.val = opt.ss.val;
return c9x;
}
t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10() t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10()
{ {
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v10)); memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v10));
@ -612,8 +594,8 @@ t_Ersky9xModelData_v10::operator ModelData ()
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++) // for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;
@ -733,8 +715,8 @@ t_Ersky9xModelData_v11::operator ModelData ()
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++) // for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;

View file

@ -19,8 +19,7 @@
#include <inttypes.h> #include <inttypes.h>
#include "eeprominterface.h" #include "eeprominterface.h"
extern TimerMode getEr9xTimerMode(int mode); extern RawSwitch getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
//eeprom data //eeprom data
#define ERSKY9X_MAX_MIXERS_V10 32 #define ERSKY9X_MAX_MIXERS_V10 32
@ -186,31 +185,30 @@ PACK(typedef struct t_Ersky9xMixData_v11 {
t_Ersky9xMixData_v11(); t_Ersky9xMixData_v11();
}) Ersky9xMixData_v11; }) Ersky9xMixData_v11;
PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data PACK(typedef struct t_Ersky9xLogicalSwitchData_v10 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); } t_Ersky9xLogicalSwitchData_v10() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v10)); }
}) Ersky9xCustomSwData_v10; }) Ersky9xLogicalSwitchData_v10;
PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data PACK(typedef struct t_Ersky9xLogicalSwitchData_v11 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
uint8_t andsw; uint8_t andsw;
uint8_t res ; uint8_t res ;
operator CustomSwData(); operator LogicalSwitchData();
t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); } t_Ersky9xLogicalSwitchData_v11() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v11)); }
}) Ersky9xCustomSwData_v11; }) Ersky9xLogicalSwitchData_v11;
PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Ersky9xSafetySwData_v10(); t_Ersky9xSafetySwData_v10();
}) Ersky9xSafetySwData_v10; }) Ersky9xSafetySwData_v10;
@ -230,7 +228,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
} vs ; } vs ;
} opt ; } opt ;
operator SafetySwData();
t_Ersky9xSafetySwData_v11(); t_Ersky9xSafetySwData_v11();
}) Ersky9xSafetySwData_v11; }) Ersky9xSafetySwData_v11;
@ -363,7 +360,7 @@ PACK(typedef struct t_Ersky9xModelData_v10 {
int8_t trim[4]; int8_t trim[4];
int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9]; int8_t curves9[ERSKY9X_MAX_CURVE9][9];
Ersky9xCustomSwData_v10 customSw[ERSKY9X_NUM_CSW_V10]; Ersky9xLogicalSwitchData_v10 customSw[ERSKY9X_NUM_CSW_V10];
uint8_t frSkyVoltThreshold ; uint8_t frSkyVoltThreshold ;
uint8_t res3[2]; uint8_t res3[2];
Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10]; Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10];
@ -412,7 +409,7 @@ PACK(typedef struct t_Ersky9xModelData_v11 {
int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9]; int8_t curves9[ERSKY9X_MAX_CURVE9][9];
int8_t curvexy[18]; int8_t curvexy[18];
Ersky9xCustomSwData_v11 customSw[ERSKY9X_NUM_CSW_V11]; Ersky9xLogicalSwitchData_v11 customSw[ERSKY9X_NUM_CSW_V11];
uint8_t frSkyVoltThreshold ; uint8_t frSkyVoltThreshold ;
uint8_t bt_telemetry; uint8_t bt_telemetry;
uint8_t numVoice; // 0-16, rest are Safety switches uint8_t numVoice; // 0-16, rest are Safety switches

View file

@ -74,11 +74,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod
for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++) for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) { for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) { switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case CS_FAMILY_VCOMP: case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // no break
case CS_FAMILY_VOFS: case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode); model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break; break;
default: default:
@ -106,11 +106,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v11 & model, unsigned int mod
for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++) for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) { for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) { switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case CS_FAMILY_VCOMP: case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // no break
case CS_FAMILY_VOFS: case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode); model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break; break;
default: default:
@ -285,7 +285,7 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 9; return 9;
case CustomFunctions: case CustomFunctions:
return 0; return 0;
case CustomSwitches: case LogicalSwitches:
return ERSKY9X_NUM_CSW_V11; return ERSKY9X_NUM_CSW_V11;
case CustomAndSwitches: case CustomAndSwitches:
return 1; return 1;
@ -317,8 +317,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 125; return 125;
case MaxVolume: case MaxVolume:
return 23; return 23;
case GvarsHaveSources:
return 1;
case TelemetryMaxMultiplier: case TelemetryMaxMultiplier:
return 2; return 2;
case LCDWidth: case LCDWidth:

View file

@ -301,22 +301,22 @@ RawSource gruvin9xToSource(int8_t value)
} }
} }
Gruvin9xCustomSwData::operator CustomSwData () Gruvin9xLogicalSwitchData::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = gruvin9xToSource(v1).toValue(); c9x.val1 = gruvin9xToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = gruvin9xToSource(v2).toValue(); c9x.val2 = gruvin9xToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = gruvin9xToSwitch(v1).toValue(); c9x.val1 = gruvin9xToSwitch(v1).toValue();
c9x.val2 = gruvin9xToSwitch(v2).toValue(); c9x.val2 = gruvin9xToSwitch(v2).toValue();
} }
@ -332,14 +332,6 @@ Gruvin9xFuncSwData::operator FuncSwData ()
return c9x; return c9x;
} }
t_Gruvin9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = gruvin9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData() t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData()
{ {
memset(this, 0, sizeof(t_Gruvin9xSwashRingData)); memset(this, 0, sizeof(t_Gruvin9xSwashRingData));
@ -381,7 +373,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
return c9x; return c9x;
} }
extern TimerMode getEr9xTimerMode(int mode); extern RawSwitch getEr9xTimerMode(int mode);
t_Gruvin9xTimerData::operator TimerData () t_Gruvin9xTimerData::operator TimerData ()
{ {
@ -489,8 +481,8 @@ t_Gruvin9xModelData_v102::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++) for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
return c9x; return c9x;
@ -560,8 +552,8 @@ t_Gruvin9xModelData_v103::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++) for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
return c9x; return c9x;
@ -650,8 +642,8 @@ t_Gruvin9xModelData_v105::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++) for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
@ -734,8 +726,8 @@ t_Gruvin9xModelData_v106::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++) for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;

View file

@ -186,20 +186,19 @@ PACK(typedef struct t_Gruvin9xMixData {
t_Gruvin9xMixData(); t_Gruvin9xMixData();
}) Gruvin9xMixData; }) Gruvin9xMixData;
PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data PACK(typedef struct t_Gruvin9xLogicalSwitchData { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); } t_Gruvin9xLogicalSwitchData() { memset(this, 0, sizeof(t_Gruvin9xLogicalSwitchData)); }
}) Gruvin9xCustomSwData; }) Gruvin9xLogicalSwitchData;
PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); } t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
}) Gruvin9xSafetySwData; }) Gruvin9xSafetySwData;
@ -310,7 +309,7 @@ PACK(typedef struct t_Gruvin9xModelData_v102 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9]; int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR; Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
@ -342,7 +341,7 @@ PACK(typedef struct t_Gruvin9xModelData_v103 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9]; int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR; Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
@ -374,7 +373,7 @@ PACK(typedef struct t_Gruvin9xModelData_v105 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9]; int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR; Gruvin9xSwashRingData swashR;
@ -406,7 +405,7 @@ PACK(typedef struct t_Gruvin9xModelData_v106 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9]; int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR; Gruvin9xSwashRingData swashR;

View file

@ -237,7 +237,7 @@ int Gruvin9xInterface::getCapability(const Capability capability)
return 9; return 9;
case CustomFunctions: case CustomFunctions:
return 12; return 12;
case CustomSwitches: case LogicalSwitches:
return 12; return 12;
case CSFunc: case CSFunc:
return 13; return 13;

View file

@ -293,22 +293,22 @@ RawSource open9xV4209ToSource(int8_t value)
} }
} }
Open9xGruvin9xCustomSwData_v207::operator CustomSwData () Open9xGruvin9xLogicalSwitchData_v207::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xV4207ToSource(v1).toValue(); c9x.val1 = open9xV4207ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xV4207ToSource(v2).toValue(); c9x.val2 = open9xV4207ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue();
} }
@ -316,22 +316,22 @@ Open9xGruvin9xCustomSwData_v207::operator CustomSwData ()
return c9x; return c9x;
} }
Open9xGruvin9xCustomSwData_v209::operator CustomSwData () Open9xGruvin9xLogicalSwitchData_v209::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xV4209ToSource(v1).toValue(); c9x.val1 = open9xV4209ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xV4209ToSource(v2).toValue(); c9x.val2 = open9xV4209ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue();
} }

View file

@ -110,27 +110,27 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); } t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); }
}) Open9xGruvin9xMixData_v211; }) Open9xGruvin9xMixData_v211;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v207 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); } t_Open9xGruvin9xLogicalSwitchData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v207)); }
int8_t fromSource(RawSource source); int8_t fromSource(RawSource source);
RawSource toSource(int8_t value); RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v207; }) Open9xGruvin9xLogicalSwitchData_v207;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); } t_Open9xGruvin9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v209)); }
int8_t fromSource(RawSource source); int8_t fromSource(RawSource source);
RawSource toSource(int8_t value); RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v209; }) Open9xGruvin9xLogicalSwitchData_v209;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
int8_t swtch; // input int8_t swtch; // input
@ -194,7 +194,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES]; Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES];
@ -228,7 +228,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@ -267,7 +267,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@ -307,7 +307,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES]; int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS]; int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@ -345,7 +345,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES]; int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS]; int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];

View file

@ -19,13 +19,13 @@ RawSwitch open9xArmToSwitch(int8_t sw)
else if (sw == 42) else if (sw == 42)
return RawSwitch(SWITCH_TYPE_ON); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 84) else if (sw == 84)
return RawSwitch(SWITCH_TYPE_ONM); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -42) else if (sw == -42)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 42+9) else if (swa <= 42+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-42 : sw+42); return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-42 : sw+42);
else else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9); return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9);
} }
RawSource open9xArm208ToSource(int8_t value) RawSource open9xArm208ToSource(int8_t value)
@ -124,9 +124,9 @@ RawSource open9xArm210ToSource(int8_t value)
t_Open9xArmTimerData_v202::operator TimerData () t_Open9xArmTimerData_v202::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
/*
if (mode <= -42) if (mode <= -42)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
else if (mode <= -1) else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5) else if (mode < 5)
@ -134,8 +134,8 @@ t_Open9xArmTimerData_v202::operator TimerData ()
else if (mode < 5+41) else if (mode < 5+41)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val; c9x.val = val;
c9x.persistent = false; c9x.persistent = false;
c9x.dir = (val == 0); c9x.dir = (val == 0);
@ -501,22 +501,22 @@ t_Open9xArmMixData_v212::operator MixData ()
return c9x; return c9x;
} }
t_Open9xArmCustomSwData_v208::operator CustomSwData () t_Open9xArmLogicalSwitchData_v208::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm208ToSource(v1).toValue(); c9x.val1 = open9xArm208ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xArm208ToSource(v2).toValue(); c9x.val2 = open9xArm208ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue();
} }
@ -524,22 +524,22 @@ t_Open9xArmCustomSwData_v208::operator CustomSwData ()
return c9x; return c9x;
} }
t_Open9xArmCustomSwData_v209::operator CustomSwData () t_Open9xArmLogicalSwitchData_v209::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm209ToSource(v1).toValue(); c9x.val1 = open9xArm209ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xArm209ToSource(v2).toValue(); c9x.val2 = open9xArm209ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue();
} }
@ -547,24 +547,24 @@ t_Open9xArmCustomSwData_v209::operator CustomSwData ()
return c9x; return c9x;
} }
t_Open9xArmCustomSwData_v210::operator CustomSwData () t_Open9xArmLogicalSwitchData_v210::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
c9x.delay = delay; c9x.delay = delay;
c9x.duration = duration; c9x.duration = duration;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm210ToSource(v1).toValue(); c9x.val1 = open9xArm210ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xArm210ToSource(v2).toValue(); c9x.val2 = open9xArm210ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue();
} }
@ -577,7 +577,7 @@ t_Open9xArmFuncSwData_v208::operator FuncSwData ()
FuncSwData c9x; FuncSwData c9x;
c9x.swtch = open9xArmToSwitch(swtch); c9x.swtch = open9xArmToSwitch(swtch);
c9x.func = (AssignFunc)(func); c9x.func = (AssignFunc)(func);
if (c9x.func <= FuncSafetyCh16) { if (c9x.func <= FuncSafetyCh32) {
c9x.enabled=param & 0x01; c9x.enabled=param & 0x01;
c9x.param = (param>>1)<<1; c9x.param = (param>>1)<<1;
} }

View file

@ -190,34 +190,34 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 {
t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); } t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); }
}) Open9xArmPhaseData_v212; }) Open9xArmPhaseData_v212;
PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data PACK(typedef struct t_Open9xArmLogicalSwitchData_v208 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); } t_Open9xArmLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v208)); }
}) Open9xArmCustomSwData_v208; }) Open9xArmLogicalSwitchData_v208;
PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data PACK(typedef struct t_Open9xArmLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); } t_Open9xArmLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v209)); }
}) Open9xArmCustomSwData_v209; }) Open9xArmLogicalSwitchData_v209;
PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data PACK(typedef struct t_Open9xArmLogicalSwitchData_v210 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
uint8_t delay; uint8_t delay;
uint8_t duration; uint8_t duration;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); } t_Open9xArmLogicalSwitchData_v210() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v210)); }
}) Open9xArmCustomSwData_v210; }) Open9xArmLogicalSwitchData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
int8_t swtch; // input int8_t swtch; // input
@ -343,7 +343,7 @@ PACK(typedef struct t_Open9xArmModelData_v208 {
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v208 customSw[O9X_ARM_NUM_CSW]; Open9xArmLogicalSwitchData_v208 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v208 swashR; Open9xArmSwashRingData_v208 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@ -382,7 +382,7 @@ PACK(typedef struct t_Open9xArmModelData_v209 {
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v209 customSw[O9X_ARM_NUM_CSW]; Open9xArmLogicalSwitchData_v209 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR; Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@ -422,7 +422,7 @@ PACK(typedef struct t_Open9xArmModelData_v210 {
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW]; Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR; Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@ -461,7 +461,7 @@ PACK(typedef struct t_Open9xArmModelData_v211 {
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES]; int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS]; int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR; Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@ -499,7 +499,7 @@ PACK(typedef struct t_Open9xArmModelData_v212 {
Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS]; Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES]; int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS]; int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v210 swashR; Open9xArmSwashRingData_v210 swashR;
Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES]; Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES];

View file

@ -74,13 +74,13 @@ RawSwitch open9xStockToSwitch(int8_t sw)
else if (sw == 22) else if (sw == 22)
return RawSwitch(SWITCH_TYPE_ON); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 44) else if (sw == 44)
return RawSwitch(SWITCH_TYPE_ONM); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -22) else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9) else if (swa <= 22+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22); return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22);
else else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9); return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
} }
t_Open9xExpoData_v201::operator ExpoData () t_Open9xExpoData_v201::operator ExpoData ()
@ -518,22 +518,22 @@ RawSource open9xStock209ToSource(int8_t value)
} }
} }
Open9xCustomSwData_v208::operator CustomSwData () Open9xLogicalSwitchData_v208::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9x208ToSource(v1).toValue(); c9x.val1 = open9x208ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9x208ToSource(v2).toValue(); c9x.val2 = open9x208ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue();
} }
@ -541,22 +541,22 @@ Open9xCustomSwData_v208::operator CustomSwData ()
return c9x; return c9x;
} }
Open9xCustomSwData_v209::operator CustomSwData () Open9xLogicalSwitchData_v209::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = func; c9x.func = func;
c9x.val1 = v1; c9x.val1 = v1;
c9x.val2 = v2; c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xStock209ToSource(v1).toValue(); c9x.val1 = open9xStock209ToSource(v1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xStock209ToSource(v2).toValue(); c9x.val2 = open9xStock209ToSource(v2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue();
} }
@ -662,14 +662,6 @@ t_Open9xFuncSwData_v210::operator FuncSwData ()
return c9x; return c9x;
} }
t_Open9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = open9xStockToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Open9xSwashRingData_v208::operator SwashRingData () t_Open9xSwashRingData_v208::operator SwashRingData ()
{ {
SwashRingData c9x; SwashRingData c9x;
@ -709,7 +701,7 @@ t_Open9xPhaseData_v201::operator PhaseData ()
t_Open9xTimerData_v201::operator TimerData () t_Open9xTimerData_v201::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
c9x.mode = TMRMODE_OFF; // c9x.mode = TMRMODE_OFF;
c9x.val = val; c9x.val = val;
c9x.persistent = persistent; c9x.persistent = persistent;
c9x.dir = dir; c9x.dir = dir;
@ -719,9 +711,9 @@ t_Open9xTimerData_v201::operator TimerData ()
t_Open9xTimerData_v202::operator TimerData () t_Open9xTimerData_v202::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
/*
if (mode <= -22) if (mode <= -22)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
else if (mode <= -1) else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5) else if (mode < 5)
@ -729,8 +721,8 @@ t_Open9xTimerData_v202::operator TimerData ()
else if (mode < 5+21) else if (mode < 5+21)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val; c9x.val = val;
c9x.persistent = false; c9x.persistent = false;
c9x.dir = (val == 0); c9x.dir = (val == 0);
@ -993,8 +985,8 @@ t_Open9xModelData_v201::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++) for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++) // for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
@ -1067,8 +1059,8 @@ t_Open9xModelData_v202::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++) for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++) // for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.moduleData[0].ppmFrameLength = ppmFrameLength;

View file

@ -221,30 +221,29 @@ PACK(typedef struct t_Open9xMixData_v211 {
t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); } t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); }
}) Open9xMixData_v211; }) Open9xMixData_v211;
PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data PACK(typedef struct t_Open9xLogicalSwitchData_v208 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xCustomSwData_v208)); } t_Open9xLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v208)); }
t_Open9xCustomSwData_v208(CustomSwData&); t_Open9xLogicalSwitchData_v208(LogicalSwitchData&);
}) Open9xCustomSwData_v208; }) Open9xLogicalSwitchData_v208;
PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data PACK(typedef struct t_Open9xLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input int8_t v1; //input
int8_t v2; //offset int8_t v2; //offset
uint8_t func; uint8_t func;
operator CustomSwData(); operator LogicalSwitchData();
t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); } t_Open9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v209)); }
}) Open9xCustomSwData_v209; }) Open9xLogicalSwitchData_v209;
PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); } t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
}) Open9xSafetySwData; }) Open9xSafetySwData;
@ -517,7 +516,7 @@ PACK(typedef struct t_Open9xModelData_v201 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12]; Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
@ -548,7 +547,7 @@ PACK(typedef struct t_Open9xModelData_v202 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12]; Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
@ -582,7 +581,7 @@ PACK(typedef struct t_Open9xModelData_v203 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -615,7 +614,7 @@ PACK(typedef struct t_Open9xModelData_v204 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -648,7 +647,7 @@ PACK(typedef struct t_Open9xModelData_v205 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -683,7 +682,7 @@ PACK(typedef struct t_Open9xModelData_v208 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR; Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -722,7 +721,7 @@ PACK(typedef struct t_Open9xModelData_v209 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9]; int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR; Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -762,7 +761,7 @@ PACK(typedef struct t_Open9xModelData_v210 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES]; int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS]; int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR; Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@ -800,7 +799,7 @@ PACK(typedef struct t_Open9xModelData_v211 {
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES]; int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS]; int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR; Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,7 @@ class Open9xGeneralDataNew: public TransformedField {
StructField internalField; StructField internalField;
GeneralSettings & generalData; GeneralSettings & generalData;
BoardEnum board; BoardEnum board;
unsigned int version;
int inputsCount; int inputsCount;
unsigned int chkSum; unsigned int chkSum;
}; };

View file

@ -57,19 +57,19 @@ const char * Open9xInterface::getName()
{ {
switch (board) { switch (board) {
case BOARD_STOCK: case BOARD_STOCK:
return "openTx for 9X board"; return "OpenTX for 9X board";
case BOARD_M128: case BOARD_M128:
return "openTx for M128 / 9X board"; return "OpenTX for M128 / 9X board";
case BOARD_GRUVIN9X: case BOARD_GRUVIN9X:
return "openTx for Gruvin9x board / 9X"; return "OpenTX for Gruvin9x board / 9X";
case BOARD_TARANIS: case BOARD_TARANIS:
return "openTx for FrSky Taranis"; return "OpenTX for FrSky Taranis";
case BOARD_TARANIS_REV4a: case BOARD_TARANIS_REV4a:
return "openTx for FrSky Taranis Rev4a"; return "OpenTX for FrSky Taranis Rev4a";
case BOARD_SKY9X: case BOARD_SKY9X:
return "openTx for Sky9x board / 9X"; return "OpenTX for Sky9x board / 9X";
default: default:
return "openTx for an unknown board"; return "OpenTX for an unknown board";
} }
} }
@ -526,7 +526,7 @@ int Open9xInterface::getCapability(const Capability capability)
return 24; return 24;
else else
return 16; return 16;
case CustomSwitches: case LogicalSwitches:
if (IS_ARM(board)) if (IS_ARM(board))
return 32; return 32;
else if (board==BOARD_GRUVIN9X||board==BOARD_M128) else if (board==BOARD_GRUVIN9X||board==BOARD_M128)
@ -535,10 +535,10 @@ int Open9xInterface::getCapability(const Capability capability)
return 12; return 12;
case CustomAndSwitches: case CustomAndSwitches:
if (IS_ARM(board)) if (IS_ARM(board))
return getCapability(CustomSwitches); return getCapability(LogicalSwitches);
else else
return 15/*4bits*/-9/*sw positions*/; return 15/*4bits*/-9/*sw positions*/;
case CustomSwitchesExt: case LogicalSwitchesExt:
return (IS_ARM(board) ? true : false); return (IS_ARM(board) ? true : false);
case RotaryEncoders: case RotaryEncoders:
if (board == BOARD_GRUVIN9X) if (board == BOARD_GRUVIN9X)
@ -1015,7 +1015,7 @@ void RegisterOpen9xFirmwares()
Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } }; Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } };
Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
/* 9x board */ /* 9x board */
open9x = new Open9xFirmware("opentx-9x", QObject::tr("openTx for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); open9x = new Open9xFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false);
open9x->addOptions(ext_options); open9x->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1052,7 +1052,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9x board with M128 chip */ /* 9x board with M128 chip */
open9x = new Open9xFirmware("opentx-9x128", QObject::tr("openTx for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x = new Open9xFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x->addOptions(ext_options); open9x->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1084,7 +1084,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board */ /* 9XR board */
open9x = new Open9xFirmware("opentx-9xr", QObject::tr("openTx for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false); open9x = new Open9xFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false);
open9x->addOptions(extr_options); open9x->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1118,7 +1118,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board with M128 chip */ /* 9XR board with M128 chip */
open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("openTx for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x->addOptions(extr_options); open9x->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1148,7 +1148,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* Gruvin9x board */ /* Gruvin9x board */
open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("openTx for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false);
open9x->setVariantBase(FRSKY_VARIANT); open9x->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1178,7 +1178,7 @@ void RegisterOpen9xFirmwares()
#ifndef __APPLE__ #ifndef __APPLE__
/* SKY9X board */ /* SKY9X board */
open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("openTx for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true); open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true);
open9x->setVariantBase(FRSKY_VARIANT); open9x->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1203,7 +1203,7 @@ void RegisterOpen9xFirmwares()
#endif #endif
/* Taranis board */ /* Taranis board */
open9x = new Open9xFirmware("opentx-taranis", QObject::tr("openTx for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true); open9x = new Open9xFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));
@ -1215,7 +1215,7 @@ void RegisterOpen9xFirmwares()
QSettings settings; QSettings settings;
int rev4a = settings.value("rev4asupport",0).toInt(); int rev4a = settings.value("rev4asupport",0).toInt();
if (rev4a) { if (rev4a) {
open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("openTx for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));

View file

@ -2,18 +2,6 @@
#include "helpers.h" #include "helpers.h"
#include "th9xeeprom.h" #include "th9xeeprom.h"
int8_t th9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 -sw.index);
default:
return 0;
}
}
RawSwitch th9xToSwitch(int8_t sw) RawSwitch th9xToSwitch(int8_t sw)
{ {
if (sw == 0) if (sw == 0)
@ -181,22 +169,22 @@ t_Th9xMixData::operator MixData ()
return c9x; return c9x;
} }
t_Th9xCustomSwData::operator CustomSwData () t_Th9xLogicalSwitchData::operator LogicalSwitchData ()
{ {
CustomSwData c9x; LogicalSwitchData c9x;
c9x.func = opCmp; c9x.func = opCmp;
c9x.val1 = val1; c9x.val1 = val1;
c9x.val2 = val2; c9x.val2 = val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = toSource(val1).toValue(); c9x.val1 = toSource(val1).toValue();
} }
if (c9x.func >= CS_FN_EQUAL) { if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = toSource(val2).toValue(); c9x.val2 = toSource(val2).toValue();
} }
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = th9xToSwitch(val1).toValue(); c9x.val1 = th9xToSwitch(val1).toValue();
c9x.val2 = th9xToSwitch(val2).toValue(); c9x.val2 = th9xToSwitch(val2).toValue();
} }
@ -204,7 +192,7 @@ t_Th9xCustomSwData::operator CustomSwData ()
return c9x; return c9x;
} }
int8_t t_Th9xCustomSwData::fromSource(RawSource source) int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source)
{ {
int v1 = 0; int v1 = 0;
if (source.type == SOURCE_TYPE_STICK) if (source.type == SOURCE_TYPE_STICK)
@ -228,7 +216,7 @@ int8_t t_Th9xCustomSwData::fromSource(RawSource source)
return v1; return v1;
} }
RawSource t_Th9xCustomSwData::toSource(int8_t value) RawSource t_Th9xLogicalSwitchData::toSource(int8_t value)
{ {
if (value == 0) { if (value == 0) {
return RawSource(SOURCE_TYPE_NONE); return RawSource(SOURCE_TYPE_NONE);
@ -266,7 +254,7 @@ t_Th9xModelData::operator ModelData ()
ModelData c9x; ModelData c9x;
c9x.used = true; c9x.used = true;
getEEPROMString(c9x.name, name, sizeof(name)); getEEPROMString(c9x.name, name, sizeof(name));
switch(tmrMode) { /*switch(tmrMode) {
case 1: case 1:
c9x.timers[0].mode = TMRMODE_ABS; c9x.timers[0].mode = TMRMODE_ABS;
break; break;
@ -279,7 +267,7 @@ t_Th9xModelData::operator ModelData ()
default: default:
c9x.timers[0].mode = TMRMODE_OFF; c9x.timers[0].mode = TMRMODE_OFF;
break; break;
} }*/
// c9x.timers[0].dir = tmrDir; // c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal; c9x.timers[0].val = tmrVal;
/*c9x.protocol = (Protocol)protocol; /*c9x.protocol = (Protocol)protocol;

View file

@ -138,18 +138,18 @@ PACK(typedef struct t_Th9xMixData {
t_Th9xMixData(); t_Th9xMixData();
}) Th9xMixData; }) Th9xMixData;
PACK(typedef struct t_Th9xCustomSwData { PACK(typedef struct t_Th9xLogicalSwitchData {
uint8_t sw:3; // 0..7 uint8_t sw:3; // 0..7
uint8_t opCmp:2; // < & | ^ uint8_t opCmp:2; // < & | ^
uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^ uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^
int8_t val1; int8_t val1;
int8_t val2; int8_t val2;
operator CustomSwData(); operator LogicalSwitchData();
t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); } t_Th9xLogicalSwitchData() { memset(this, 0, sizeof(t_Th9xLogicalSwitchData)); }
int8_t fromSource(RawSource source); int8_t fromSource(RawSource source);
RawSource toSource(int8_t value); RawSource toSource(int8_t value);
}) Th9xCustomSwData; }) Th9xLogicalSwitchData;
PACK(typedef struct t_Th9xTrimData { PACK(typedef struct t_Th9xTrimData {
int8_t itrim:6; //trim index int8_t itrim:6; //trim index
@ -173,7 +173,7 @@ PACK(typedef struct t_Th9xModelData {
int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143 int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143
int8_t curves5[TH9X_MAX_CURVES5][5]; // 10 int8_t curves5[TH9X_MAX_CURVES5][5]; // 10
int8_t curves9[TH9X_MAX_CURVES9][9]; // 18 int8_t curves9[TH9X_MAX_CURVES9][9]; // 18
Th9xCustomSwData switchTab[TH9X_MAX_SWITCHES];// Th9xLogicalSwitchData switchTab[TH9X_MAX_SWITCHES];//
Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4 Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4
operator ModelData(); operator ModelData();
t_Th9xModelData(); t_Th9xModelData();

View file

@ -157,7 +157,7 @@ int Th9xInterface::getCapability(const Capability capability)
return 9; return 9;
case CustomFunctions: case CustomFunctions:
return 0; return 0;
case CustomSwitches: case LogicalSwitches:
return TH9X_MAX_SWITCHES; return TH9X_MAX_SWITCHES;
case Outputs: case Outputs:
return 8; return 8;

View file

@ -0,0 +1,507 @@
#include "fwpreferencesdialog.h"
#include "ui_fwpreferencesdialog.h"
#include "mainwindow.h"
#include "eeprominterface.h"
#include "helpers.h"
#include <QDesktopServices>
#include <QtGui>
fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::fwPreferencesDialog),
updateLock(false)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("preferences.png"));
QCheckBox * OptionCheckBox[]= {
ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7,
ui->optionCheckBox_8, ui->optionCheckBox_9, ui->optionCheckBox_10, ui->optionCheckBox_11, ui->optionCheckBox_12, ui->optionCheckBox_13, ui->optionCheckBox_14,
ui->optionCheckBox_15,ui->optionCheckBox_16, ui->optionCheckBox_17, ui->optionCheckBox_18, ui->optionCheckBox_19, ui->optionCheckBox_20, ui->optionCheckBox_21,
ui->optionCheckBox_22, ui->optionCheckBox_23, ui->optionCheckBox_24, ui->optionCheckBox_25, ui->optionCheckBox_26, ui->optionCheckBox_27, ui->optionCheckBox_28,
ui->optionCheckBox_29, ui->optionCheckBox_30, ui->optionCheckBox_31, ui->optionCheckBox_32, ui->optionCheckBox_33, ui->optionCheckBox_34, ui->optionCheckBox_35,
ui->optionCheckBox_36, ui->optionCheckBox_37, ui->optionCheckBox_38, ui->optionCheckBox_39, ui->optionCheckBox_40, ui->optionCheckBox_41, ui->optionCheckBox_42,
NULL };
voice=NULL;
connect(ui->langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged()));
connect(ui->voiceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged()));
for (int i=0; OptionCheckBox[i]; i++) {
optionsCheckBoxes.push_back(OptionCheckBox[i]);
connect(OptionCheckBox[i], SIGNAL(toggled(bool)), this, SLOT(firmwareOptionChanged(bool)));
}
initSettings();
connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged()));
connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
resize(0,0);
}
fwPreferencesDialog::~fwPreferencesDialog()
{
delete ui;
}
void fwPreferencesDialog::baseFirmwareChanged()
{
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
voice=NULL;
foreach(FirmwareInfo * firmware, firmwares) {
if (firmware->id == selected_firmware) {
if (firmware->voice) {
ui->voiceLabel->show();
ui->voiceCombo->show();
ui->voice_dnld->show();
ui->sdPathButton->show();
ui->sdPath->show();
ui->sdPathLabel->show();
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->hide();
ui->voiceCombo->hide();
ui->voice_dnld->hide();
ui->sdPathButton->hide();
ui->sdPath->hide();
ui->sdPathLabel->hide();
}
populateFirmwareOptions(firmware);
break;
}
}
firmwareChanged();
}
FirmwareVariant fwPreferencesDialog::getFirmwareVariant()
{
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
bool voice=false;
foreach(FirmwareInfo * firmware, firmwares) {
if (firmware->id == selected_firmware) {
QString id = firmware->id;
foreach(QCheckBox *cb, optionsCheckBoxes) {
if (cb->isChecked()) {
if (cb->text()=="voice" && cb->isChecked())
voice=true;
id += QString("-") + cb->text();
}
}
if (! firmware->eepromInterface->getCapability(MultiLangVoice)) {
if (ui->voiceCombo->count() && (voice || firmware->voice))
id += QString("-tts") + ui->voiceCombo->currentText();
}
if (ui->langCombo->count())
id += QString("-") + ui->langCombo->currentText();
return GetFirmwareVariant(id);
}
}
// Should never occur...
return default_firmware_variant;
}
void fwPreferencesDialog::firmwareLangChanged()
{
firmwareChanged();
}
void fwPreferencesDialog::firmwareOptionChanged(bool state)
{
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
FirmwareInfo * firmware=NULL;
if (cb && state) {
QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex());
foreach(firmware, firmwares) {
if (firmware->id == selected_firmware) {
foreach(QList<Option> opts, firmware->opts) {
foreach(Option opt, opts) {
if (cb->text() == opt.name) {
foreach(Option other, opts) {
if (other.name != opt.name) {
foreach(QCheckBox *ocb, optionsCheckBoxes) {
if (ocb->text() == other.name)
ocb->setChecked(false);
}
}
}
if (voice) {
if (voice->isChecked()) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
}
return firmwareChanged();
}
}
}
}
}
} else if (cb && !state) {
if (cb->text()=="voice") {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
}
}
if (voice ) {
if (voice->isChecked()) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
} else if (firmware) {
if (firmware->voice) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
}
}
return firmwareChanged();
}
void fwPreferencesDialog::firmwareChanged()
{
if (updateLock)
return;
FirmwareVariant variant = getFirmwareVariant();
QString stamp;
stamp.append(variant.firmware->stamp);
ui->fw_dnld->setEnabled(!variant.firmware->getUrl(variant.id).isNull());
QString url=variant.firmware->getUrl(variant.id);
// B-Plan
if (false) {
ui->CPU_ID_LE->show();
ui->CPU_ID_LABEL->show();
} else {
ui->CPU_ID_LE->hide();
ui->CPU_ID_LABEL->hide();
}
QSettings settings;
settings.beginGroup("FwRevisions");
int fwrev = settings.value(variant.id, -1).toInt();
settings.endGroup();
if (fwrev != -1) {
ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev));
if (!stamp.isEmpty()) {
ui->checkFWUpdates->show();
} else {
ui->checkFWUpdates->hide();
}
}
else {
if (ui->fw_dnld->isEnabled()) {
ui->FwInfo->setText(tr("The selected firmware has never been downloaded by Companion."));
ui->checkFWUpdates->hide();
}
else {
ui->FwInfo->setText(tr("The selected firmware cannot be downloaded by Companion."));
ui->checkFWUpdates->hide();
}
}
}
void fwPreferencesDialog::writeValues()
{
QSettings settings;
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("cpu_id", ui->CPU_ID_LE->text());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
settings.setValue("profileId", ui->ProfSlot_SB->value());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
if (!ui->SplashFileName->text().isEmpty())
settings.setValue("SplashImage", "");
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
}
void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
{
const FirmwareInfo * parent = firmware->parent ? firmware->parent : firmware;
updateLock = true;
ui->langCombo->clear();
foreach(const char *lang, parent->languages) {
ui->langCombo->addItem(lang);
if (current_firmware_variant.id.endsWith(lang))
ui->langCombo->setCurrentIndex(ui->langCombo->count() - 1);
}
ui->voiceCombo->clear();
foreach(const char *lang, parent->ttslanguages) {
ui->voiceCombo->addItem(lang);
if (current_firmware_variant.id.contains(QString("-tts%1").arg(lang)))
ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1);
}
if (ui->langCombo->count()) {
ui->langCombo->show();
ui->langLabel->show();
}
else {
ui->langCombo->hide();
ui->langLabel->hide();
}
int index = 0;
foreach(QList<Option> opts, parent->opts) {
foreach(Option opt, opts) {
if (index >= optionsCheckBoxes.size()) {
qDebug() << "This firmware needs more options checkboxes!";
}
else {
QCheckBox *cb = optionsCheckBoxes.at(index++);
if (cb) {
cb->show();
cb->setText(opt.name);
cb->setToolTip(opt.tooltip);
cb->setCheckState(current_firmware_variant.id.contains(opt.name) ? Qt::Checked : Qt::Unchecked);
if (opt.name==QString("voice")) {
voice=cb;
ui->voiceLabel->show();
ui->voiceCombo->show();
ui->voice_dnld->show();
ui->sdPathButton->show();
ui->sdPath->show();
ui->sdPathLabel->show();
if (current_firmware_variant.id.contains(opt.name) ||firmware->voice) {
ui->voiceLabel->setEnabled(true);
ui->voiceCombo->setEnabled(true);
ui->voice_dnld->setEnabled(true);
ui->sdPathButton->setEnabled(true);
ui->sdPath->setEnabled(true);
} else {
ui->voiceLabel->setDisabled(true);
ui->voiceCombo->setDisabled(true);
ui->voice_dnld->setDisabled(true);
ui->sdPathButton->setDisabled(true);
ui->sdPath->setDisabled(true);
}
}
}
}
}
}
for (; index<optionsCheckBoxes.size(); index++) {
QCheckBox *cb = optionsCheckBoxes.at(index);
cb->hide();
cb->setCheckState(Qt::Unchecked);
}
updateLock = false;
QTimer::singleShot(0, this, SLOT(shrink()));
}
void fwPreferencesDialog::initSettings()
{
QSettings settings;
ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt());
ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt());
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool());
ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool());
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
QString Path=settings.value("sdPath", "").toString();
if (QDir(Path).exists()) {
ui->sdPath->setText(Path);
}
FirmwareInfo * current_firmware = GetCurrentFirmware();
foreach(FirmwareInfo * firmware, firmwares) {
ui->downloadVerCB->addItem(firmware->name, firmware->id);
if (current_firmware == firmware) {
ui->downloadVerCB->setCurrentIndex(ui->downloadVerCB->count() - 1);
}
}
baseFirmwareChanged();
ui->ProfSlot_SB->setValue(settings.value("profileId", 1).toInt());
on_ProfSlot_SB_valueChanged();
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.exists()){
ui->SplashFileName->setText(fileName);
}
}
firmwareChanged();
}
void fwPreferencesDialog::on_fw_dnld_clicked()
{
MainWindow * mw = (MainWindow *)this->parent();
FirmwareVariant variant = getFirmwareVariant();
writeValues();
if (!variant.firmware->getUrl(variant.id).isNull()) {
if (ui->burnFirmware->isChecked()) {
QSettings settings;
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
}
mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id);
}
firmwareChanged();
}
void fwPreferencesDialog::on_voice_dnld_clicked()
{
ui->ProfSave_PB->setEnabled(true);
QString url="http://fw.opentx.it/voices/";
FirmwareVariant variant = getFirmwareVariant();
url.append(QString("%1/%2/").arg(variant.firmware->id).arg(ui->voiceCombo->currentText()));
QDesktopServices::openUrl(url);
}
void fwPreferencesDialog::on_sdPathButton_clicked()
{
QSettings settings;
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString());
if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName);
}
ui->ProfSave_PB->setEnabled(true);
}
void fwPreferencesDialog::on_ProfSlot_SB_valueChanged()
{
QSettings settings;
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
ui->ProfName_LE->setText(name);
/* if (!(name.isEmpty())) {
QString firmwarename=settings.value("firmware", default_firmware_id).toString();
FirmwareInfo * fw = getFirmware(firmwarename);
int i=0;
foreach(FirmwareInfo * firmware, firmwares) {
if (fw == firmware) {
qDebug() << fw->id;
qDebug() << firmware->id;
qDebug() << i;
ui->downloadVerCB->setCurrentIndex(i);
break;
}
i++;
}
baseFirmwareChanged();
populateFirmwareOptions(fw);
}*/
settings.endGroup();
settings.endGroup();
}
void fwPreferencesDialog::on_ProfSave_PB_clicked()
{
QSettings settings;
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString name=ui->ProfName_LE->text();
if (name.isEmpty()) {
int ret = QMessageBox::question(this, "Companion",
tr("Profile name is empty, profile slot %1 will be deleted.<br>Are you sure ?").arg(ui->ProfSlot_SB->value()) ,
QMessageBox::Yes | QMessageBox::No);
if (ret==QMessageBox::Yes) {
settings.remove(profile);
} else {
settings.beginGroup(profile);
ui->ProfName_LE->setText(settings.value("Name","").toString());
}
} else {
settings.beginGroup(profile);
settings.setValue("Name",name);
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
settings.endGroup();
settings.endGroup();
}
}
void fwPreferencesDialog::on_SplashSelect_clicked()
{
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats));
if (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
QImage image(fileName);
if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
return;
}
ui->SplashFileName->setText(fileName);
}
}
void fwPreferencesDialog::on_clearImageButton_clicked() {
ui->SplashFileName->clear();
}
void fwPreferencesDialog::on_checkFWUpdates_clicked()
{
FirmwareVariant variant = getFirmwareVariant();
if (ui->burnFirmware->isChecked()) {
QSettings settings;
current_firmware_variant = variant;
settings.setValue("firmware", variant.id);
}
MainWindow * mw = (MainWindow *)this->parent();
mw->checkForUpdates(true, variant.id);
firmwareChanged();
}
void fwPreferencesDialog::shrink()
{
resize(0,0);
}

View file

@ -0,0 +1,50 @@
#ifndef FWPREFERENCESDIALOG_H
#define FWPREFERENCESDIALOG_H
#include <QDialog>
#include <QCheckBox>
#include "eeprominterface.h"
namespace Ui {
class fwPreferencesDialog;
}
class Joystick;
class fwPreferencesDialog : public QDialog
{
Q_OBJECT
public:
explicit fwPreferencesDialog(QWidget *parent = 0);
~fwPreferencesDialog();
private:
Ui::fwPreferencesDialog *ui;
QList<QCheckBox *> optionsCheckBoxes;
bool updateLock;
void populateLocale();
void populateFirmwareOptions(const FirmwareInfo *);
FirmwareVariant getFirmwareVariant();
void initSettings();
QCheckBox * voice;
private slots:
void shrink();
void writeValues();
void firmwareLangChanged();
void baseFirmwareChanged();
void firmwareOptionChanged(bool state);
void firmwareChanged();
void on_fw_dnld_clicked();
void on_voice_dnld_clicked();
void on_sdPathButton_clicked();
void on_checkFWUpdates_clicked();
void on_ProfSlot_SB_valueChanged();
void on_ProfSave_PB_clicked();
void on_SplashSelect_clicked();
void on_clearImageButton_clicked();
};
#endif // FWPREFERENCESDIALOG_H

File diff suppressed because it is too large Load diff

View file

@ -117,165 +117,6 @@ void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last=fal
b->setMaxVisibleItems(10); b->setMaxVisibleItems(10);
} }
QString getRepeatString(unsigned int val)
{
if (val==0) {
return QObject::tr("No repeat");
} else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*val);
}
}
QString getFuncName(unsigned int val)
{
if (val < NUM_SAFETY_CHNOUT) {
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, val).toString());
}
else if (val == FuncTrainer)
return QObject::tr("Trainer");
else if (val == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (val == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (val == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (val == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (val == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (val == FuncPlaySound)
return QObject::tr("Play Sound");
else if (val == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (val == FuncReset)
return QObject::tr("Reset");
else if (val == FuncVario)
return QObject::tr("Vario");
else if (val == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (val == FuncPlayBoth)
return QObject::tr("Play Both");
else if (val == FuncPlayValue)
return QObject::tr("Play Value");
else if (val == FuncLogs)
return QObject::tr("Start Logs");
else if (val == FuncVolume)
return QObject::tr("Volume");
else if (val == FuncBacklight)
return QObject::tr("Backlight");
else if (val == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (val == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
// TODO should be a toString() method in CustoSwData ...
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model)
{
QString result = "";
if (!customSw->func)
return result;
if (customSw->andsw!=0) {
result +="( ";
}
switch (getCSFunctionFamily(customSw->func)) {
case CS_FAMILY_TIMERS:
result = QString("TIM(%1 , %2)").arg(ValToTim(customSw->val1)).arg(ValToTim(customSw->val2));
break;
case CS_FAMILY_VOFS: {
RawSource source = RawSource(customSw->val1, &model);
RawSourceRange range = source.getRange();
if (customSw->val1)
result += source.toString();
else
result += "0";
result.remove(" ");
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_ANEG)
result = "|" + result + "|";
else if (customSw->func == CS_FN_DAPOS)
result = "|d(" + result + ")|";
else if (customSw->func == CS_FN_DPOS) result = "d(" + result + ")";
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_VPOS || customSw->func == CS_FN_DAPOS || customSw->func == CS_FN_DPOS)
result += " &gt; ";
else if (customSw->func == CS_FN_ANEG || customSw->func == CS_FN_VNEG)
result += " &lt; ";
result += QString::number(range.step * (customSw->val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
break;
}
case CS_FAMILY_VBOOL:
result = RawSwitch(customSw->val1).toString();
switch (customSw->func) {
case CS_FN_AND:
result += " AND ";
break;
case CS_FN_OR:
result += " OR ";
break;
case CS_FN_XOR:
result += " XOR ";
break;
default:
break;
}
result += RawSwitch(customSw->val2).toString();
break;
case CS_FAMILY_VCOMP:
if (customSw->val1)
result += RawSource(customSw->val1).toString();
else
result += "0";
switch (customSw->func) {
case CS_FN_EQUAL:
result += " = ";
break;
case CS_FN_NEQUAL:
result += " != ";
break;
case CS_FN_GREATER:
result += " &gt; ";
break;
case CS_FN_LESS:
result += " &lt; ";
break;
case CS_FN_EGREATER:
result += " &gt;= ";
break;
case CS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (customSw->val2)
result += RawSource(customSw->val2).toString();
else
result += "0";
break;
}
if (customSw->andsw!=0) {
result +=" ) AND ";
result += RawSwitch(customSw->andsw).toString();
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (customSw->delay)
result += QObject::tr(" Delay %1 sec").arg(customSw->delay/2.0);
if (customSw->duration)
result += QObject::tr(" Duration %1 sec").arg(customSw->duration/2.0);
}
return result;
}
QString getProtocolStr(const int proto) QString getProtocolStr(const int proto)
{ {
static const char *strings[] = { "OFF", static const char *strings[] = { "OFF",
@ -290,186 +131,6 @@ QString getProtocolStr(const int proto)
return CHECK_IN_ARRAY(strings, proto); return CHECK_IN_ARRAY(strings, proto);
} }
void populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i = 0; i < FuncCount; i++) {
b->addItem(getFuncName(i));
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
QString FuncParam(uint function, int value, QString paramT,unsigned int adjustmode)
{
QStringList qs;
if (function <= FuncInstantTrim) {
return QString("%1").arg(value);
}
else if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((function==FuncVolume)|| (function==FuncPlayValue)) {
RawSource item(value);
return item.toString();
}
else if ((function==FuncPlayPrompt) || (function==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
return QString("%1").arg(value);
} else {
return paramT;
}
} else if ((function>FuncBackgroundMusicPause) && (function<FuncCount)) {
switch (adjustmode) {
case 0:
return QObject::tr("Value ")+QString("%1").arg(value);
break;
case 1:
return RawSource(value).toString();
break;
case 2:
return RawSource(value).toString();
break;
case 3:
if (value==0) {
return QObject::tr("Decr:")+QString(" -1");
} else {
return QObject::tr("Incr:")+QString(" +1");
}
break;
default:
return "";
}
}
return "";
}
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList)
{
b->clear();
b->addItem("----");
QString currentvalue(value);
foreach ( QString entry, paramsList ) {
b->addItem(entry);
if (entry==currentvalue) {
b->setCurrentIndex(b->count()-1);
}
}
}
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}
else if (reCount == 2) {
qs.append( QObject::tr("REa"));
qs.append( QObject::tr("REb"));
}
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
b->addItem("-1", 0);
b->addItem("+1", 1);
b->setCurrentIndex(value);
break;
}
}
else {
b->hide();
}
}
void populateGVmodeCB(QComboBox *b, unsigned int value)
{
b->clear();
b->addItem(QObject::tr("Value"));
b->addItem(QObject::tr("Source"));
b->addItem(QObject::tr("GVAR"));
b->addItem(QObject::tr("Increment"));
b->setCurrentIndex(value);
}
void populatePhasesCB(QComboBox *b, int value) void populatePhasesCB(QComboBox *b, int value)
{ {
for (int i=-GetEepromInterface()->getCapability(FlightPhases); i<=GetEepromInterface()->getCapability(FlightPhases); i++) { for (int i=-GetEepromInterface()->getCapability(FlightPhases); i<=GetEepromInterface()->getCapability(FlightPhases); i++) {
@ -684,19 +345,6 @@ void CurveGroup::valuesChanged()
} }
} }
void populateTrimUseCB(QComboBox *b, unsigned int phase)
{
b->addItem(QObject::tr("Own trim"));
unsigned int num_phases = GetEepromInterface()->getCapability(FlightPhases);
if (num_phases>0) {
for (unsigned int i = 0; i < num_phases; i++) {
if (i != phase) {
b->addItem(QObject::tr("Flight mode %1 trim").arg(i));
}
}
}
}
void populateGvarUseCB(QComboBox *b, unsigned int phase) void populateGvarUseCB(QComboBox *b, unsigned int phase)
{ {
b->addItem(QObject::tr("Own value")); b->addItem(QObject::tr("Own value"));
@ -707,88 +355,6 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase)
} }
} }
void populateTimerSwitchCB(QComboBox *b, int value)
{
b->clear();
uint8_t count=0;
for (int i=-128; i<128; i++) {
QString timerMode = getTimerMode(i);
if (!timerMode.isEmpty()) {
b->addItem(getTimerMode(i), i);
if (i==value)
b->setCurrentIndex(b->count()-1);
count++;
}
}
b->setMaxVisibleItems(10);
}
QString getTimerMode(int tm) {
QString stt = "OFFABSTHsTH%THt";
QString s;
if (tm >= 0 && tm <= TMRMODE_THt) {
return stt.mid(abs(tm)*3, 3);
}
int tma = abs(tm);
if (tma >= TMRMODE_FIRST_SWITCH && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) {
s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_SWITCH + 1).toString();
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) {
s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString();
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_MOMENT_SWITCH && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) {
s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_MOMENT_SWITCH + 1).toString()+"t";
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) {
s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_MOMENT_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString()+"t";
if (tm < 0) s.prepend("!");
return s;
}
if (tma >=TMRMODE_FIRST_CHPERC && tma <TMRMODE_FIRST_CHPERC+16) {
s = QString("CH%1%").arg(tma-TMRMODE_FIRST_CHPERC+1);
return s;
}
return "";
}
QString getTimerModeB(int tm) {
QString stt = "---THRRUDELEIDOID1ID2AILGEATRN";
QString s;
int tma = abs(tm);
if (tma>33) {
tma-=32;
}
if (tma < 10) {
s=stt.mid(abs(tma)*3, 3);
} else if (tma <19) {
s=QString("SW%1").arg(tma-9);
} else {
s=QString("SW")+QChar('A'+tma-19);
}
if (tm<0) {
s.prepend("!");
} else if (tm>33) {
s.append("m");
}
return s;
}
void populateBacklightCB(QComboBox *b, const uint8_t value) void populateBacklightCB(QComboBox *b, const uint8_t value)
{ {
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL }; QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
@ -801,119 +367,117 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
} }
} }
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context) void populateAndSwitchCB(QComboBox *b, const RawSwitch & value)
{
if (IS_ARM(GetEepromInterface()->getBoard())) {
populateSwitchCB(b, value);
}
else {
RawSwitch item;
b->clear();
item = RawSwitch(SWITCH_TYPE_NONE);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=6; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr)
{ {
RawSwitch item; RawSwitch item;
b->clear(); b->clear();
if (attr & POPULATE_AND_SWITCHES) {
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
return;
}
#if 0
// TODO check ... I removed negative toggle switches in the FW, no?
if (attr & POPULATE_MSWITCHES) {
if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_ONM, 1);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
#endif
if (attr & POPULATE_ONOFF) { if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_OFF); item = RawSwitch(SWITCH_TYPE_OFF);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
if (item == value) b->setCurrentIndex(b->count()-1);
}
} }
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) { for (int i=-GetEepromInterface()->getCapability(LogicalSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
if (item == value) b->setCurrentIndex(b->count()-1); }
}
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-8; i<0; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
} }
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) { for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i); item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_TIMER_MODES) {
for (int i=0; i<5; i++) {
item = RawSwitch(SWITCH_TYPE_TIMER_MODE, i);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
} }
else {
item = RawSwitch(SWITCH_TYPE_NONE); item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i); item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
if (IS_TARANIS(GetEepromInterface()->getBoard())) { for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) { item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i); b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
if (item == value) b->setCurrentIndex(b->count()-1); }
}
for (int i=1; i<=8; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(RotaryEncoders); i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(LogicalSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
} }
if (attr & POPULATE_ONOFF) { if (attr & POPULATE_ONOFF) {
@ -922,52 +486,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
if (attr & POPULATE_MSWITCHES) {
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
if (attr & POPULATE_MSWITCHES) {
if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_ONM);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (IS_ARM(GetEepromInterface()->getBoard())) {
item = RawSwitch(SWITCH_TYPE_TRN,0);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
item = RawSwitch(SWITCH_TYPE_TRN,1);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
if (GetEepromInterface()->getBoard()==BOARD_SKY9X) {
item = RawSwitch(SWITCH_TYPE_REA,0);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
item = RawSwitch(SWITCH_TYPE_REA,1);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
b->setMaxVisibleItems(10); b->setMaxVisibleItems(10);
} }
@ -1064,7 +582,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
if (item == source) b->setCurrentIndex(b->count()-1); if (item == source) b->setCurrentIndex(b->count()-1);
} }
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i); item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1); if (item == source) b->setCurrentIndex(b->count()-1);
@ -1117,35 +635,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
b->setMaxVisibleItems(10); b->setMaxVisibleItems(10);
} }
#define CSWITCH_STR "---- a~x a>x a<x |a|>x |a|<x AND OR XOR a=b a!=b a>b a<b a>=b a<=b d>=x |d|>=xTIM "
#define CSW_NUM_FUNC 18 // TODO enum
#define CSW_LEN_FUNC 6
int csw_values[]={
CS_FN_OFF,
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
CS_FN_VPOS,
CS_FN_VNEG,
CS_FN_APOS,
CS_FN_ANEG,
CS_FN_AND,
CS_FN_OR,
CS_FN_XOR,
CS_FN_EQUAL,
CS_FN_NEQUAL,
CS_FN_GREATER,
CS_FN_LESS,
CS_FN_EGREATER,
CS_FN_ELESS,
CS_FN_DPOS,
CS_FN_DAPOS,
CS_FN_TIM
};
QString getCSWFunc(int val)
{
return QString(CSWITCH_STR).mid(val*CSW_LEN_FUNC, CSW_LEN_FUNC);
}
float ValToTim(int value) float ValToTim(int value)
{ {
return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0); return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0);
@ -1166,14 +655,39 @@ int TimToVal(float value)
void populateCSWCB(QComboBox *b, int value) void populateCSWCB(QComboBox *b, int value)
{ {
int order[] = {
LS_FN_OFF,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_VPOS,
LS_FN_VNEG,
// LS_FN_RANGE,
LS_FN_APOS,
LS_FN_ANEG,
LS_FN_AND,
LS_FN_OR,
LS_FN_XOR,
LS_FN_STAY,
LS_FN_EQUAL,
LS_FN_NEQUAL,
LS_FN_GREATER,
LS_FN_LESS,
LS_FN_EGREATER,
LS_FN_ELESS,
LS_FN_DPOS,
LS_FN_DAPOS,
LS_FN_TIMER,
LS_FN_STICKY
};
b->clear(); b->clear();
for (int i = 0; i < CSW_NUM_FUNC; i++) { for (int i=0; i<LS_FN_MAX; i++) {
b->addItem(getCSWFunc(i),csw_values[i]); int func = order[i];
if (i>GetEepromInterface()->getCapability(CSFunc)) { b->addItem(LogicalSwitchData(func).funcToString(), func);
QModelIndex index = b->model()->index(i, 0); // if (i>GetEepromInterface()->getCapability(CSFunc)) {
QVariant v(0); // QModelIndex index = b->model()->index(i, 0);
} // QVariant v(0);
if (value == csw_values[i]) { // }
if (value == func) {
b->setCurrentIndex(b->count()-1); b->setCurrentIndex(b->count()-1);
} }
} }
@ -1341,7 +855,7 @@ QString getTrimInc(ModelData * g_model)
QString getTimerStr(TimerData & timer) QString getTimerStr(TimerData & timer)
{ {
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down")); QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down"));
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + getTimerMode(timer.mode) + str; return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + timer.mode.toString() + str;
} }
QString getProtocol(ModelData * g_model) QString getProtocol(ModelData * g_model)
@ -1382,13 +896,6 @@ QString getPhasesStr(unsigned int phases, ModelData & model)
} }
} }
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
QString getCenterBeep(ModelData * g_model) QString getCenterBeep(ModelData * g_model)
{ {
//RETA123 //RETA123

View file

@ -4,7 +4,7 @@
#include <QtGui> #include <QtGui>
#include "eeprominterface.h" #include "eeprominterface.h"
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1) #define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(LogicalSwitches)-1)
//convert from mode 1 to mode generalSettings.stickMode //convert from mode 1 to mode generalSettings.stickMode
//NOTICE! => 1..4 -> 1..4 //NOTICE! => 1..4 -> 1..4
@ -23,6 +23,8 @@
#define TRIM_OFF 1 #define TRIM_OFF 1
#define TRIM_OFFSET 2 #define TRIM_OFFSET 2
#define TRIM_MODE_NONE 0x1F // 0b11111
void populateGvSourceCB(QComboBox *b, int value); void populateGvSourceCB(QComboBox *b, int value);
void populateVoiceLangCB(QComboBox *b, QString language); void populateVoiceLangCB(QComboBox *b, QString language);
void populateTTraceCB(QComboBox *b, int value); void populateTTraceCB(QComboBox *b, int value);
@ -80,20 +82,13 @@ class CurveGroup : public QObject {
}; };
#define POPULATE_ONOFF 0x01 #define POPULATE_ONOFF 0x01
#define POPULATE_MSWITCHES 0x02 #define POPULATE_TIMER_MODES 0x02
#define POPULATE_AND_SWITCHES 0x04 void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0);
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList);
void populatePhasesCB(QComboBox *b, int value); void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase);
void populateGvarUseCB(QComboBox *b, unsigned int phase); void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto); void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateTimerSwitchCB(QComboBox *b, int value);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto); QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model); QString getPhasesStr(unsigned int phases, ModelData & model);
@ -112,13 +107,8 @@ QString getPhasesStr(unsigned int phases, ModelData & model);
void populateGVCB(QComboBox *b, int value); void populateGVCB(QComboBox *b, int value);
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags); void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
void populateCSWCB(QComboBox *b, int value); void populateCSWCB(QComboBox *b, int value);
QString getTimerMode(int tm);
QString getTimerModeB(int tm);
QString getPhaseName(int val, char * phasename=NULL); QString getPhaseName(int val, char * phasename=NULL);
QString getInputStr(ModelData & model, int index); QString getInputStr(ModelData & model, int index);
QString getCSWFunc(int val);
QString getFuncName(unsigned int val);
QString getRepeatString(unsigned int val);
QString getSignedStr(int value); QString getSignedStr(int value);
QString getGVarString(int16_t val, bool sign=false); QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image); QString image2qstring(QImage image);
@ -138,7 +128,6 @@ QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units); QString getFrSkyMeasure(int units);
QString getFrSkySrc(int index); QString getFrSkySrc(int index);
float c9xexpou(float point, float coeff);
float ValToTim(int value); float ValToTim(int value);
int TimToVal(float value); int TimToVal(float value);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 477 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 852 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 B

After

Width:  |  Height:  |  Size: 9.6 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 731 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Before After
Before After

View file

@ -0,0 +1,481 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>preferencesDialog</class>
<widget class="QDialog" name="preferencesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>418</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>685</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Preferences</string>
</property>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="margin">
<number>4</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="1">
<widget class="QLineEdit" name="snapshotPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Simu BackLight</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Simulator capture folder</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Joystick</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Remember simulator switches</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="simuSW">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="joystickCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="joystickChkB">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="snapshotClipboardCKB">
<property name="text">
<string>Use clipboard only</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="joystickcalButton">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="backLightColor">
<item>
<property name="text">
<string>Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Green</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="snapshotPathButton">
<property name="text">
<string>Open Folder</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_7">
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Personal splash library</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="libraryPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="libraryPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QComboBox" name="splashincludeCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Include companion splashes</string>
</property>
</item>
<item>
<property name="text">
<string>Only user defined splashes</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Splash library behaviour</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Custom TX splash screen</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="SplashSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Open Image</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QToolButton" name="splashLibraryButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="clearImageButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="InvertPixels">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Invert Pixels</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="companion.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>preferencesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>370</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>preferencesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>390</x>
<y>55</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -42,6 +42,7 @@
#include <QtGui> #include <QtGui>
#include <QNetworkProxyFactory> #include <QNetworkProxyFactory>
#include <QFileInfo> #include <QFileInfo>
#include <QDesktopServices>
#include "mainwindow.h" #include "mainwindow.h"
#include "mdichild.h" #include "mdichild.h"
#include "burnconfigdialog.h" #include "burnconfigdialog.h"
@ -49,6 +50,8 @@
#include "comparedialog.h" #include "comparedialog.h"
#include "logsdialog.h" #include "logsdialog.h"
#include "preferencesdialog.h" #include "preferencesdialog.h"
#include "apppreferencesdialog.h"
#include "fwpreferencesdialog.h"
#include "flashinterface.h" #include "flashinterface.h"
#include "fusesdialog.h" #include "fusesdialog.h"
#include "downloaddialog.h" #include "downloaddialog.h"
@ -641,6 +644,42 @@ void MainWindow::closeEvent(QCloseEvent *event)
} }
} }
void MainWindow::setLanguage(QString langString)
{
QSettings settings;
settings.setValue("locale", langString );
QMessageBox msgBox;
msgBox.setText(tr("The selected language will be used the next time you start Companion."));
msgBox.setIcon(QMessageBox::Information);
msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
msgBox.exec();
}
void MainWindow::setTheme(int index)
{
QSettings settings;
settings.setValue("theme", index );
QMessageBox msgBox;
msgBox.setText(tr("The new theme will be loaded the next time you start Companion."));
msgBox.setIcon(QMessageBox::Information);
msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
msgBox.exec();
}
void MainWindow::setIconThemeSize(int index)
{
QSettings settings;
settings.setValue("icon_size", index );
QMessageBox msgBox;
msgBox.setText(tr("The icon size will be used the next time you start Companion."));
msgBox.setIcon(QMessageBox::Information);
msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
msgBox.exec();
}
void MainWindow::newFile() void MainWindow::newFile()
{ {
MdiChild *child = createMdiChild(); MdiChild *child = createMdiChild();
@ -648,6 +687,12 @@ void MainWindow::newFile()
child->show(); child->show();
} }
void MainWindow::openDocumentURL()
{
QString link = "http://www.open-tx.org/documents.html";
QDesktopServices::openUrl(QUrl(link));
}
void MainWindow::openFile() void MainWindow::openFile()
{ {
QSettings settings; QSettings settings;
@ -782,6 +827,32 @@ void MainWindow::preferences()
updateMenus(); updateMenus();
} }
void MainWindow::appPreferences()
{
appPreferencesDialog *pd = new appPreferencesDialog(this);
pd->exec();
updateMenus();
}
void MainWindow::fwPreferences()
{
fwPreferencesDialog *pd = new fwPreferencesDialog(this);
pd->exec();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
}
else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
}
updateMenus();
}
void MainWindow::contributors() void MainWindow::contributors()
{ {
contributorsDialog *cd = new contributorsDialog(this,0); contributorsDialog *cd = new contributorsDialog(this,0);
@ -1630,10 +1701,18 @@ void MainWindow::createActions()
logsAct->setStatusTip(tr("Open log file")); logsAct->setStatusTip(tr("Open log file"));
connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile())); connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile()));
preferencesAct = new QAction(CompanionIcon("preferences.png"), tr("&Preferences..."), this); preferencesAct = new QAction(tr("&Old Preferences Dialog..."), this);
preferencesAct->setStatusTip(tr("Edit general preferences")); preferencesAct->setStatusTip(tr("Used the old Preferences Dialog"));
connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences())); connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences()));
appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Application Preferences..."), this);
appPreferencesAct->setStatusTip(tr("Edit application preferences"));
connect(appPreferencesAct, SIGNAL(triggered()), this, SLOT(appPreferences()));
fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads and Profiles..."), this);
fwPreferencesAct->setStatusTip(tr("Firmware and voice file downloads as well as profile definition."));
connect(fwPreferencesAct, SIGNAL(triggered()), this, SLOT(fwPreferences()));
checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this); checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this);
checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion")); checkForUpdatesAct->setStatusTip(tr("Check for new version of Companion"));
connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates())); connect(checkForUpdatesAct, SIGNAL(triggered()), this, SLOT(doUpdates()));
@ -1655,7 +1734,7 @@ void MainWindow::createActions()
compareAct->setEnabled(false); compareAct->setEnabled(false);
connect(compareAct, SIGNAL(triggered()), this, SLOT(compare())); connect(compareAct, SIGNAL(triggered()), this, SLOT(compare()));
customizeSplashAct = new QAction(CompanionIcon("paintbrush.png"), tr("Customize your &TX..."), this); customizeSplashAct = new QAction(CompanionIcon("paintbrush.png"), tr("Configure transmitter start screen..."), this);
customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX")); customizeSplashAct->setStatusTip(tr("Customize the splash screen of your TX"));
connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash())); connect(customizeSplashAct, SIGNAL(triggered()), this, SLOT(customizeSplash()));
@ -1708,7 +1787,7 @@ void MainWindow::createActions()
burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter")); burnFromFlashAct->setStatusTip(tr("Read firmware from transmitter"));
connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash())); connect(burnFromFlashAct,SIGNAL(triggered()),this,SLOT(burnFromFlash()));
burnConfigAct = new QAction(CompanionIcon("configure.png"), tr("&Configure..."), this); burnConfigAct = new QAction(CompanionIcon("configure.png"), tr("&Configure connection software..."), this);
burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter")); burnConfigAct->setStatusTip(tr("Configure software for reading from and writing to the transmitter"));
connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig())); connect(burnConfigAct,SIGNAL(triggered()),this,SLOT(burnConfig()));
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
@ -1754,6 +1833,84 @@ void MainWindow::createActions()
connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile()));
} }
updateProfilesActions(); updateProfilesActions();
classicThemeAct = new QAction(tr("Classic"), this);
classicThemeAct->setStatusTip(tr("The multicolor classical Companion icon theme"));
connect(classicThemeAct, SIGNAL(triggered()), this, SLOT(setClassicTheme()));
monoThemeAct = new QAction("Monochrome",this);
monoThemeAct->setStatusTip(tr("A monochrome black icon theme"));
connect(monoThemeAct, SIGNAL(triggered()), this, SLOT(setMonochromeTheme()));
monoWhiteThemeAct = new QAction("MonoWhite",this);
monoWhiteThemeAct->setStatusTip(tr("A monochrome white icon theme"));
connect(monoWhiteThemeAct, SIGNAL(triggered()), this, SLOT(setMonoWhiteTheme()));
monoBlueThemeAct = new QAction("MonoBlue",this);
monoBlueThemeAct->setStatusTip(tr("A monochrome blue icon theme"));
connect(monoBlueThemeAct, SIGNAL(triggered()), this, SLOT(setMonoBlueTheme()));
smallIconAct = new QAction(tr("Small"),this);
smallIconAct->setStatusTip(tr("Use small toolbar icons"));
connect(smallIconAct, SIGNAL(triggered()), this, SLOT(setSmallIconThemeSize()));
normalIconAct = new QAction(this);
normalIconAct->setStatusTip(tr("Use normal size toolbar icons"));
normalIconAct->setText(tr("Normal"));
connect(normalIconAct, SIGNAL(triggered()), this, SLOT(setNormalIconThemeSize()));
bigIconAct = new QAction(this);
bigIconAct->setStatusTip(tr("Use big toolbar icons"));
bigIconAct->setText(tr("Big"));
connect(bigIconAct, SIGNAL(triggered()), this, SLOT(setBigIconThemeSize()));
hugeIconAct = new QAction(this);
hugeIconAct->setStatusTip(tr("Use huge toolbar icons"));
hugeIconAct->setText(tr("Huge"));
connect(hugeIconAct, SIGNAL(triggered()), this, SLOT(setHugeIconThemeSize()));
defaultLanguageAct = new QAction(tr("System default language"),this);
defaultLanguageAct->setStatusTip(tr("Use system default language in menus"));
connect(defaultLanguageAct, SIGNAL(triggered()), this, SLOT(setDefaultLanguage()));
czechLanguageAct = new QAction(tr("Czech"),this);
czechLanguageAct->setStatusTip(tr("Use Czech in menus"));
connect(czechLanguageAct, SIGNAL(triggered()), this, SLOT(setCZLanguage()));
germanLanguageAct = new QAction(tr("German"),this);
germanLanguageAct->setStatusTip(tr("Use German in menus"));
connect(germanLanguageAct, SIGNAL(triggered()), this, SLOT(setDELanguage()));
englishLanguageAct = new QAction(tr("English"),this);
englishLanguageAct->setStatusTip(tr("Use English in menus"));
connect(englishLanguageAct, SIGNAL(triggered()), this, SLOT(setENLanguage()));
frenchLanguageAct = new QAction(tr("French"),this);
frenchLanguageAct->setStatusTip(tr("Use French in menus"));
connect(frenchLanguageAct, SIGNAL(triggered()), this, SLOT(setFRLanguage()));
italianLanguageAct = new QAction(tr("Italian"),this);
italianLanguageAct->setStatusTip(tr("Use Italian in menus"));
connect(italianLanguageAct, SIGNAL(triggered()), this, SLOT(setITLanguage()));
hebrewLanguageAct = new QAction(tr("Hebrew"),this);
hebrewLanguageAct->setStatusTip(tr("Use Hebrew in menus"));
connect(hebrewLanguageAct, SIGNAL(triggered()), this, SLOT(setHELanguage()));
polishLanguageAct = new QAction(tr("Polish"),this);
polishLanguageAct->setStatusTip(tr("Use Polish in menus"));
connect(polishLanguageAct, SIGNAL(triggered()), this, SLOT(setPLLanguage()));
portugueseLanguageAct = new QAction(tr("Portuguese"),this);
portugueseLanguageAct->setStatusTip(tr("Use Portuguese in menus"));
connect(portugueseLanguageAct, SIGNAL(triggered()), this, SLOT(setPTLanguage()));
swedishLanguageAct = new QAction(tr("Swedish"),this);
swedishLanguageAct->setStatusTip(tr("Use Swedish in menus"));
connect(swedishLanguageAct, SIGNAL(triggered()), this, SLOT(setSELanguage()));
russianLanguageAct = new QAction(tr("Russian"),this);
russianLanguageAct->setStatusTip(tr("Use Russian in menus"));
connect(russianLanguageAct, SIGNAL(triggered()), this, SLOT(setRULanguage()));
openDocumentURLAct = new QAction(tr("Manuals and other Documents"),this);
openDocumentURLAct->setStatusTip(tr("Open the OpenTX document page in a web browser"));
connect(openDocumentURLAct, SIGNAL(triggered()), this, SLOT(openDocumentURL()));
} }
void MainWindow::createMenus() void MainWindow::createMenus()
@ -1761,6 +1918,9 @@ void MainWindow::createMenus()
{ {
QMenu *recentFileMenu=new QMenu(tr("Recent Files")); QMenu *recentFileMenu=new QMenu(tr("Recent Files"));
QMenu *profilesMenu=new QMenu(tr("Firmware Profiles")); QMenu *profilesMenu=new QMenu(tr("Firmware Profiles"));
QMenu *languageMenu=new QMenu(tr("Set Menu Language"));
QMenu *themeMenu=new QMenu(tr("Set Icon Theme"));
QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size"));
fileMenu = menuBar()->addMenu(tr("&File")); fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct); fileMenu->addAction(newAct);
@ -1778,7 +1938,7 @@ void MainWindow::createMenus()
fileMenu->addAction(printAct); fileMenu->addAction(printAct);
fileMenu->addAction(compareAct); fileMenu->addAction(compareAct);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(preferencesAct); fileMenu->addAction(fwPreferencesAct);
fileMenu->addMenu(profilesMenu); fileMenu->addMenu(profilesMenu);
profilesMenu->setIcon(CompanionIcon("profiles.png")); profilesMenu->setIcon(CompanionIcon("profiles.png"));
@ -1791,6 +1951,35 @@ void MainWindow::createMenus()
editMenu->addAction(copyAct); editMenu->addAction(copyAct);
editMenu->addAction(pasteAct); editMenu->addAction(pasteAct);
settingsMenu = menuBar()->addMenu(tr("&Settings"));
settingsMenu->addMenu(languageMenu);
languageMenu->addAction(defaultLanguageAct);
languageMenu->addAction(englishLanguageAct);
languageMenu->addAction(czechLanguageAct);
languageMenu->addAction(germanLanguageAct);
languageMenu->addAction(frenchLanguageAct);
languageMenu->addAction(hebrewLanguageAct);
languageMenu->addAction(italianLanguageAct);
languageMenu->addAction(polishLanguageAct);
languageMenu->addAction(portugueseLanguageAct);
languageMenu->addAction(swedishLanguageAct);
languageMenu->addAction(russianLanguageAct);
settingsMenu->addMenu(themeMenu);
themeMenu->addAction(classicThemeAct);
themeMenu->addAction(monoThemeAct);
themeMenu->addAction(monoBlueThemeAct);
themeMenu->addAction(monoWhiteThemeAct);
settingsMenu->addMenu(iconThemeSizeMenu);
iconThemeSizeMenu->addAction(smallIconAct);
iconThemeSizeMenu->addAction(normalIconAct);
iconThemeSizeMenu->addAction(bigIconAct);
iconThemeSizeMenu->addAction(hugeIconAct);
settingsMenu->addSeparator();
settingsMenu->addAction(appPreferencesAct);
settingsMenu->addAction(customizeSplashAct);
settingsMenu->addAction(preferencesAct);
settingsMenu->addAction(burnConfigAct);
burnMenu = menuBar()->addMenu(tr("&Read/Write")); burnMenu = menuBar()->addMenu(tr("&Read/Write"));
burnMenu->addAction(burnToAct); burnMenu->addAction(burnToAct);
burnMenu->addAction(burnFromAct); burnMenu->addAction(burnFromAct);
@ -1801,9 +1990,7 @@ void MainWindow::createMenus()
burnMenu->addAction(burnToFlashAct); burnMenu->addAction(burnToFlashAct);
burnMenu->addAction(burnFromFlashAct); burnMenu->addAction(burnFromFlashAct);
burnMenu->addSeparator(); burnMenu->addSeparator();
burnMenu->addAction(customizeSplashAct);
burnMenu->addSeparator(); burnMenu->addSeparator();
burnMenu->addAction(burnConfigAct);
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
if (!IS_ARM(eepromInterface->getBoard())) { if (!IS_ARM(eepromInterface->getBoard())) {
burnMenu->addAction(burnFusesAct); burnMenu->addAction(burnFusesAct);
@ -1816,6 +2003,7 @@ void MainWindow::createMenus()
helpMenu->addAction(checkForUpdatesAct); helpMenu->addAction(checkForUpdatesAct);
helpMenu->addSeparator(); helpMenu->addSeparator();
helpMenu->addAction(aboutAct); helpMenu->addAction(aboutAct);
helpMenu->addAction(openDocumentURLAct);
helpMenu->addSeparator(); helpMenu->addSeparator();
helpMenu->addAction(changelogAct); helpMenu->addAction(changelogAct);
helpMenu->addAction(fwchangelogAct); helpMenu->addAction(fwchangelogAct);
@ -1872,7 +2060,9 @@ void MainWindow::createToolBars()
fileToolBar->addAction(saveAct); fileToolBar->addAction(saveAct);
fileToolBar->addAction(logsAct); fileToolBar->addAction(logsAct);
fileToolBar->addSeparator(); fileToolBar->addSeparator();
fileToolBar->addAction(preferencesAct); fileToolBar->addAction(appPreferencesAct);
fileToolBar->addAction(fwPreferencesAct);
fileToolBar->addAction(customizeSplashAct);
profileButton = new QToolButton; profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup); profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu()); profileButton->setMenu(createProfilesMenu());
@ -1968,14 +2158,6 @@ QMdiSubWindow *MainWindow::findMdiChild(const QString &fileName)
return 0; return 0;
} }
void MainWindow::switchLayoutDirection()
{
if (layoutDirection() == Qt::LeftToRight)
qApp->setLayoutDirection(Qt::RightToLeft);
else
qApp->setLayoutDirection(Qt::LeftToRight);
}
void MainWindow::setActiveSubWindow(QWidget *window) void MainWindow::setActiveSubWindow(QWidget *window)
{ {
if (!window) if (!window)
@ -2143,3 +2325,5 @@ void MainWindow::autoClose()
{ {
this->close(); this->close();
} }

View file

@ -64,6 +64,7 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
friend class preferencesDialog; friend class preferencesDialog;
friend class fwPreferencesDialog;
friend class MdiChild; // TODO GetAvrdudeArgs could be external to this class friend class MdiChild; // TODO GetAvrdudeArgs could be external to this class
Q_OBJECT Q_OBJECT
@ -82,6 +83,33 @@ public slots:
void unloadProfile(); void unloadProfile();
private slots: private slots:
void openDocumentURL();
void setLanguage(QString langString);
void setDefaultLanguage() {setLanguage("");};
void setCZLanguage() {setLanguage("cs_CZ");};
void setDELanguage() {setLanguage("de_DE");};
void setENLanguage() {setLanguage("en");};
void setFRLanguage() {setLanguage("fr_FR");};
void setITLanguage() {setLanguage("it_IT");};
void setHELanguage() {setLanguage("he_IL");};
void setPLLanguage() {setLanguage("pl_PL");};
void setPTLanguage() {setLanguage("pt_PT");};
void setRULanguage() {setLanguage("ru_RU");};
void setSELanguage() {setLanguage("sv_SE");};
void setTheme(int index);
void setClassicTheme() {setTheme(0);};
void setMonochromeTheme(){setTheme(1);};
void setMonoWhiteTheme() {setTheme(2);};
void setMonoBlueTheme() {setTheme(3);};
void setIconThemeSize(int index);
void setSmallIconThemeSize() {setIconThemeSize(0);};
void setNormalIconThemeSize() {setIconThemeSize(1);};
void setBigIconThemeSize() {setIconThemeSize(2);};
void setHugeIconThemeSize() {setIconThemeSize(3);};
void checkForUpdates(bool ignoreSettings, QString & fwId); void checkForUpdates(bool ignoreSettings, QString & fwId);
void checkForUpdateFinished(QNetworkReply * reply); void checkForUpdateFinished(QNetworkReply * reply);
void displayWarnings(); void displayWarnings();
@ -119,9 +147,10 @@ private slots:
void print(); void print();
void loadBackup(); void loadBackup();
void preferences(); void preferences();
void appPreferences();
void fwPreferences();
void updateMenus(); void updateMenus();
MdiChild *createMdiChild(); MdiChild *createMdiChild();
void switchLayoutDirection();
void setActiveSubWindow(QWidget *window); void setActiveSubWindow(QWidget *window);
QMenu * createRecentFileMenu(); QMenu * createRecentFileMenu();
QMenu * createProfilesMenu(); QMenu * createProfilesMenu();
@ -153,7 +182,6 @@ private:
QStringList GetSendFlashCommand(const QString &filename); QStringList GetSendFlashCommand(const QString &filename);
int getEpromVersion(QString fileName); int getEpromVersion(QString fileName);
bool convertEEPROM(QString backupFile, QString restoreFile, QString flashFile); bool convertEEPROM(QString backupFile, QString restoreFile, QString flashFile);
bool isValidEEPROM(QString eepromfile); bool isValidEEPROM(QString eepromfile);
@ -183,6 +211,7 @@ private:
QMenu *fileMenu; QMenu *fileMenu;
QMenu *editMenu; QMenu *editMenu;
QMenu *settingsMenu;
QMenu *burnMenu; QMenu *burnMenu;
QMenu *helpMenu; QMenu *helpMenu;
QToolBar *fileToolBar; QToolBar *fileToolBar;
@ -196,6 +225,8 @@ private:
QAction *saveAsAct; QAction *saveAsAct;
QAction *exitAct; QAction *exitAct;
QAction *preferencesAct; QAction *preferencesAct;
QAction *appPreferencesAct;
QAction *fwPreferencesAct;
QAction *checkForUpdatesAct; QAction *checkForUpdatesAct;
QAction *contributorsAct; QAction *contributorsAct;
QAction *changelogAct; QAction *changelogAct;
@ -222,6 +253,26 @@ private:
QAction *logsAct; QAction *logsAct;
QAction *recentFileActs[MAX_RECENT]; QAction *recentFileActs[MAX_RECENT];
QAction *profileActs[MAX_PROFILES]; QAction *profileActs[MAX_PROFILES];
QAction *classicThemeAct;
QAction *monoThemeAct;
QAction *monoBlueThemeAct;
QAction *monoWhiteThemeAct;
QAction *smallIconAct;
QAction *normalIconAct;
QAction *bigIconAct;
QAction *hugeIconAct;
QAction *defaultLanguageAct;
QAction *englishLanguageAct;
QAction *czechLanguageAct;
QAction *germanLanguageAct;
QAction *frenchLanguageAct;
QAction *italianLanguageAct;
QAction *hebrewLanguageAct;
QAction *polishLanguageAct;
QAction *portugueseLanguageAct;
QAction *swedishLanguageAct;
QAction *russianLanguageAct;
QAction *openDocumentURLAct;
QString fwToUpdate; QString fwToUpdate;
QToolButton * profileButton; QToolButton * profileButton;
}; };

View file

@ -495,6 +495,13 @@ void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
} }
} }
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
void ModelEdit::on_ca_apply_PB_clicked() void ModelEdit::on_ca_apply_PB_clicked()
{ {
int index=ui->ca_ctype_CB->currentIndex(); int index=ui->ca_ctype_CB->currentIndex();

View file

@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index)
emit modified(); emit modified();
} }
void RepeatComboBox::update()
{
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
int value = repeatParam/step;
if (step == 1) {
value++;
}
setCurrentIndex(value);
}
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings): CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model), ModelPanel(parent, model),
generalSettings(generalSettings), generalSettings(generalSettings),
@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
lock = true; lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
QStringList paramarmList;
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) { for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) { if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
@ -90,12 +99,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
for (int i=0; i<num_fsw; i++) { for (int i=0; i<num_fsw; i++) {
AssignFunc func = model.funcSw[i].func; AssignFunc func = model.funcSw[i].func;
// The label
QLabel * label = new QLabel(this);
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
label->setProperty("index", i);
label->setText(tr("CF%1").arg(i+1));
gridLayout->addWidget(label, i+1, 0);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
// The switch // The switch
fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setProperty("index", i);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1); gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
// The function // The function
fswtchFunc[i] = new QComboBox(this); fswtchFunc[i] = new QComboBox(this);
@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i); fswtchParamArmT[i]->setProperty("index", i);
populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList); populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
fswtchParamArmT[i]->setEditable(true); fswtchParamArmT[i]->setEditable(true);
paramLayout->addWidget(fswtchParamArmT[i]); paramLayout->addWidget(fswtchParamArmT[i]);
@ -286,7 +304,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
int index = fswtchFunc[i]->currentIndex(); int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) { if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
fswtchParam[i]->setDecimals(0); fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125); fswtchParam[i]->setMinimum(-125);
@ -329,6 +347,15 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
} }
else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) {
if (modified) model.funcSw[i].param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(0);
fswtchParam[i]->setMaximum(59*60+59);
fswtchParam[i]->setValue(model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
}
else if (index==FuncVolume) { else if (index==FuncVolume) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
@ -337,6 +364,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) { if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT; widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
} }
if (index==FuncPlayValue) { if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
@ -381,14 +409,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) { if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength); int vml = GetEepromInterface()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") { if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY; widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) { for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
} }
} }
} }
else {
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
}
} }
} }
else if (index==FuncBackgroundMusic) { else if (index==FuncBackgroundMusic) {
@ -453,13 +487,13 @@ void CustomFunctionsPanel::fswPaste()
const QMimeData *mimeData = clipboard->mimeData(); const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-fsw")) { if (mimeData->hasFormat("application/x-companion-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion-fsw"); QByteArray fswData = mimeData->data("application/x-companion-fsw");
FuncSwData *fsw = &model.funcSw[selectedFunction]; FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
// TODO update switch and func lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction); refreshCustomFunction(selectedFunction);
lock = false;
emit modified(); emit modified();
} }
} }
@ -468,7 +502,7 @@ void CustomFunctionsPanel::fswDelete()
{ {
model.funcSw[selectedFunction].clear(); model.funcSw[selectedFunction].clear();
// TODO update switch and func // TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction); refreshCustomFunction(selectedFunction);
emit modified(); emit modified();
@ -476,17 +510,17 @@ void CustomFunctionsPanel::fswDelete()
void CustomFunctionsPanel::fswCopy() void CustomFunctionsPanel::fswCopy()
{ {
QByteArray fswData; QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData)); fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData; QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData); mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
} }
void CustomFunctionsPanel::fswCut() void CustomFunctionsPanel::fswCut()
{ {
fswCopy(); fswCopy();
fswDelete(); fswDelete();
} }
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
@ -508,3 +542,124 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
contextMenu.exec(globalPos); contextMenu.exec(globalPos);
} }
void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
{
b->clear();
b->addItem(QObject::tr("Value"));
b->addItem(QObject::tr("Source"));
b->addItem(QObject::tr("GVAR"));
b->addItem(QObject::tr("Increment"));
b->setCurrentIndex(value);
}
void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList)
{
b->clear();
b->addItem("----");
bool added = false;
QString currentvalue(value);
foreach ( QString entry, paramsList ) {
b->addItem(entry);
if (entry==currentvalue) {
b->setCurrentIndex(b->count()-1);
added = true;
}
}
if (!added && strlen(value)) {
b->addItem(value);
b->setCurrentIndex(b->count()-1);
}
}
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}
else if (reCount == 2) {
qs.append( QObject::tr("REa"));
qs.append( QObject::tr("REb"));
}
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
b->addItem("-1", 0);
b->addItem("+1", 1);
b->setCurrentIndex(value);
break;
}
}
else {
b->hide();
}
}

View file

@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox
public: public:
RepeatComboBox(QWidget *parent, int & repeatParam); RepeatComboBox(QWidget *parent, int & repeatParam);
void update();
signals: signals:
void modified(); void modified();
@ -55,7 +56,13 @@ class CustomFunctionsPanel : public ModelPanel
void fswCut(); void fswCut();
private: private:
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
GeneralSettings & generalSettings; GeneralSettings & generalSettings;
QStringList paramarmList;
bool phononLock; bool phononLock;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
@ -65,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS]; QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS]; RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON #ifdef PHONON
Phonon::MediaObject *clickObject; Phonon::MediaObject *clickObject;

View file

@ -7,7 +7,7 @@
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include "helpers.h" #include "helpers.h"
CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
ModelPanel(parent, model), ModelPanel(parent, model),
selectedSwitch(0) selectedSwitch(0)
{ {
@ -18,13 +18,13 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
addLabel(gridLayout, tr("V1"), col++); addLabel(gridLayout, tr("V1"), col++);
addLabel(gridLayout, tr("V2"), col++); addLabel(gridLayout, tr("V2"), col++);
addLabel(gridLayout, tr("AND"), col++); addLabel(gridLayout, tr("AND"), col++);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
addLabel(gridLayout, tr("Duration"), col++); addLabel(gridLayout, tr("Duration"), col++);
addLabel(gridLayout, tr("Delay"), col++); addLabel(gridLayout, tr("Delay"), col++);
} }
lock = true; lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
// The label // The label
QLabel * label = new QLabel(this); QLabel * label = new QLabel(this);
label->setProperty("index", i); label->setProperty("index", i);
@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V1 // V1
cswitchSource1[i] = new QComboBox(this); cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i); cswitchSource1[i]->setProperty("index",i);
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
gridLayout->addWidget(cswitchSource1[i], i+1, 2); gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false); cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this); cswitchValue[i] = new QDoubleSpinBox(this);
@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V2 // V2
cswitchSource2[i] = new QComboBox(this); cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i); cswitchSource2[i]->setProperty("index", i);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
gridLayout->addWidget(cswitchSource2[i], i+1, 3); gridLayout->addWidget(cswitchSource2[i], i+1, 3);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this); cswitchOffset[i] = new QDoubleSpinBox(this);
@ -78,11 +78,10 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// AND // AND
cswitchAnd[i] = new QComboBox(this); cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i); cswitchAnd[i]->setProperty("index", i);
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
gridLayout->addWidget(cswitchAnd[i], i+1, 4); gridLayout->addWidget(cswitchAnd[i], i+1, 4);
cswitchAnd[i]->setVisible(false);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
// Duration // Duration
cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i] = new QDoubleSpinBox(this);
cswitchDuration[i]->setProperty("index", i); cswitchDuration[i]->setProperty("index", i);
@ -91,9 +90,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setMinimum(0);
cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1); cswitchDuration[i]->setDecimals(1);
connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited())); connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
gridLayout->addWidget(cswitchDuration[i], i+1, 5); gridLayout->addWidget(cswitchDuration[i], i+1, 5);
cswitchDuration[i]->setVisible(false);
// Delay // Delay
cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i] = new QDoubleSpinBox(this);
@ -103,75 +101,114 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setMinimum(0);
cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1); cswitchDelay[i]->setDecimals(1);
connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited())); connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
gridLayout->addWidget(cswitchDelay[i], i+1, 6); gridLayout->addWidget(cswitchDelay[i], i+1, 6);
cswitchDelay[i]->setVisible(false);
} }
} }
lock = false; lock = false;
} }
CustomSwitchesPanel::~CustomSwitchesPanel() LogicalSwitchesPanel::~LogicalSwitchesPanel()
{ {
} }
void CustomSwitchesPanel::edited() void LogicalSwitchesPanel::v1Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model.customSw[i].val1, &model);
if (source.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
emit modified();
}
}
void LogicalSwitchesPanel::v2Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::andEdited(int value)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::durationEdited(double duration)
{
int index = sender()->property("index").toInt();
model.customSw[index].duration = (uint8_t)round(duration*2);
emit modified();
}
void LogicalSwitchesPanel::delayEdited(double delay)
{
int index = sender()->property("index").toInt();
model.customSw[index].delay = (uint8_t)round(delay*2);
emit modified();
}
void LogicalSwitchesPanel::edited()
{ {
if (!lock) { if (!lock) {
lock = true; lock = true;
int i = sender()->property("index").toInt(); int i = sender()->property("index").toInt();
bool chAr; int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt();
float value, step; bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily());
int newval; model.customSw[i].func = newFunc;
chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt())); if (chAr) {
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) {
if(chAr) {
if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) {
model.customSw[i].val1 = -119; model.customSw[i].val1 = -119;
model.customSw[i].val2 = -119; model.customSw[i].val2 = -119;
} else { }
else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = -129;
model.customSw[i].val3 = 0;
}
else {
model.customSw[i].val1 = 0; model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0; model.customSw[i].val2 = 0;
} }
model.customSw[i].andsw = 0; model.customSw[i].andsw = 0;
setSwitchWidgetVisibility(i); setSwitchWidgetVisibility(i);
} }
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2);
model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2);
}
RawSource source; RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func)) switch (model.customSw[i].getFunctionFamily())
{ {
case (CS_FAMILY_VOFS): case LS_FAMILY_VOFS:
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) { {
source = RawSource(model.customSw[i].val1, &model);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
RawSource newSource = RawSource(model.customSw[i].val1, &model);
if (newSource.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
else {
source = RawSource(model.customSw[i].val1, &model); source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) { if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step); cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
} }
@ -181,84 +218,50 @@ void CustomSwitchesPanel::edited()
} }
} }
break; break;
case (CS_FAMILY_TIMERS): { case LS_FAMILY_TIMER:
value = cswitchOffset[i]->value(); model.customSw[i].val1 = TimToVal(cswitchValue[i]->value());
newval=TimToVal(value); model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
if (newval>model.customSw[i].val2) { updateTimerParam(cswitchValue[i], model.customSw[i].val1);
if (value >=60) { updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val2=TimToVal(value);
value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setValue(value);
cswitchOffset[i]->setSingleStep(step);
value=cswitchValue[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val1) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val1=TimToVal(value);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setValue(value);
cswitchValue[i]->setSingleStep(step);
break; break;
} case LS_FAMILY_STAY:
case (CS_FAMILY_VBOOL): model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
case (CS_FAMILY_VCOMP): updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); break;
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); default:
break; break;
} }
model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt();
emit modified(); emit modified();
lock = false; lock = false;
} }
} }
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero)
{ {
sb->setVisible(true);
sb->setDecimals(1);
sb->setMinimum(allowZero ? 0.0 : 0.1);
sb->setMaximum(175);
float value = ValToTim(timer);
if (value>60)
sb->setSingleStep(1);
else if (value>2)
sb->setSingleStep(0.5);
else
sb->setSingleStep(0.1);
sb->setValue(value);
}
void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{
lock = true;
RawSource source = RawSource(model.customSw[i].val1, &model); RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange();
switch (getCSFunctionFamily(model.customSw[i].func)) switch (model.customSw[i].getFunctionFamily())
{ {
case CS_FAMILY_VOFS: case LS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false); cswitchValue[i]->setVisible(false);
@ -266,17 +269,19 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step); cswitchOffset[i]->setSingleStep(range.step);
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) { if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
cswitchOffset[i]->setMinimum(range.step*-127); cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127); cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2); cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
} else { }
else {
cswitchOffset[i]->setMinimum(range.min); cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max); cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset); cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
} }
break; break;
case CS_FAMILY_VBOOL: case LS_FAMILY_VBOOL:
case LS_FAMILY_STICKY:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true); cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false); cswitchValue[i]->setVisible(false);
@ -284,7 +289,14 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break; break;
case CS_FAMILY_VCOMP: case LS_FAMILY_STAY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
break;
case LS_FAMILY_VCOMP:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true); cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false); cswitchValue[i]->setVisible(false);
@ -292,87 +304,65 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break; break;
case CS_FAMILY_TIMERS: case LS_FAMILY_TIMER:
cswitchSource1[i]->setVisible(false); cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(true); updateTimerParam(cswitchValue[i], model.customSw[i].val1);
cswitchOffset[i]->setVisible(true); updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
cswitchOffset[i]->setDecimals(1);
cswitchOffset[i]->setMinimum(0.1);
cswitchOffset[i]->setMaximum(175);
float value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setSingleStep(0.1);
if (value>60) {
cswitchOffset[i]->setSingleStep(1);
} else if (value>2) {
cswitchOffset[i]->setSingleStep(0.5);
}
cswitchOffset[i]->setValue(value);
cswitchValue[i]->setDecimals(1);
cswitchValue[i]->setMinimum(0.1);
cswitchValue[i]->setMaximum(175);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setSingleStep(0.1);
if (value>60) {
cswitchValue[i]->setSingleStep(1);
} else if (value>2) {
cswitchValue[i]->setSingleStep(0.5);
}
cswitchValue[i]->setValue(value);
break; break;
} }
cswitchAnd[i]->setVisible(true);
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES); lock = false;
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { }
cswitchDuration[i]->setVisible(true);
void LogicalSwitchesPanel::update()
{
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
lock = true;
populateCSWCB(csw[i], model.customSw[i].func);
lock = false;
setSwitchWidgetVisibility(i);
lock = true;
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
cswitchDelay[i]->setVisible(true);
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
} }
} lock = false;
void CustomSwitchesPanel::update()
{
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
populateCSWCB(csw[i], model.customSw[i].func);
setSwitchWidgetVisibility(i);
} }
lock = false;
} }
void CustomSwitchesPanel::cswPaste() void LogicalSwitchesPanel::cswPaste()
{ {
const QClipboard *clipboard = QApplication::clipboard(); const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData(); const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-csw")) { if (mimeData->hasFormat("application/x-companion-csw")) {
QByteArray cswData = mimeData->data("application/x-companion-csw"); QByteArray cswData = mimeData->data("application/x-companion-csw");
CustomSwData *csw = &model.customSw[selectedSwitch]; LogicalSwitchData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData)); memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
emit modified(); emit modified();
updateSelectedSwitch(); updateSelectedSwitch();
} }
} }
void CustomSwitchesPanel::cswDelete() void LogicalSwitchesPanel::cswDelete()
{ {
model.customSw[selectedSwitch].clear(); model.customSw[selectedSwitch].clear();
emit modified(); emit modified();
updateSelectedSwitch(); updateSelectedSwitch();
} }
void CustomSwitchesPanel::cswCopy() void LogicalSwitchesPanel::cswCopy()
{ {
QByteArray cswData; QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData)); cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData; QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData); mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
} }
void CustomSwitchesPanel::updateSelectedSwitch() void LogicalSwitchesPanel::updateSelectedSwitch()
{ {
lock = true; lock = true;
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func); populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
@ -380,14 +370,14 @@ void CustomSwitchesPanel::updateSelectedSwitch()
lock = false; lock = false;
} }
void CustomSwitchesPanel::cswCut() void LogicalSwitchesPanel::cswCut()
{ {
cswCopy(); cswCopy();
cswDelete(); cswDelete();
} }
// TODO make something generic here! // TODO make something generic here!
void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
{ {
QLabel *label = (QLabel *)sender(); QLabel *label = (QLabel *)sender();
selectedSwitch = label->property("index").toInt(); selectedSwitch = label->property("index").toInt();

View file

@ -5,18 +5,23 @@
#include <QComboBox> #include <QComboBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
class CustomSwitchesPanel : public ModelPanel class LogicalSwitchesPanel : public ModelPanel
{ {
Q_OBJECT Q_OBJECT
public: public:
CustomSwitchesPanel(QWidget *parent, ModelData & model); LogicalSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~CustomSwitchesPanel(); virtual ~LogicalSwitchesPanel();
virtual void update(); virtual void update();
private slots: private slots:
void edited(); void edited();
void v1Edited(int value);
void v2Edited(int value);
void andEdited(int value);
void durationEdited(double duration);
void delayEdited(double delay);
void csw_customContextMenuRequested(QPoint pos); void csw_customContextMenuRequested(QPoint pos);
void cswDelete(); void cswDelete();
void cswCopy(); void cswCopy();
@ -36,6 +41,8 @@ class CustomSwitchesPanel : public ModelPanel
int selectedSwitch; int selectedSwitch;
void updateSelectedSwitch(); void updateSelectedSwitch();
void updateV2(int index);
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
}; };

View file

@ -17,9 +17,11 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
{ {
ui->setupUi(this); ui->setupUi(this);
int modesCount = GetEepromInterface()->getCapability(FlightPhases);
// Phase name // Phase name
QRegExp rx(CHAR_FOR_NAMES_REGEX); QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (GetEepromInterface()->getCapability(FlightPhases)) { if (modesCount) {
ui->name->setValidator(new QRegExpValidator(rx, this)); ui->name->setValidator(new QRegExpValidator(rx, this));
ui->name->setMaxLength(GetEepromInterface()->getCapability(FlightModesName)); ui->name->setMaxLength(GetEepromInterface()->getCapability(FlightModesName));
connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished())); connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished()));
@ -66,14 +68,19 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]); trimsLabel[i]->setText(labels[CONVERT_MODE(i+1)-1]);
if (phaseIdx > 0) { QComboBox * cb = trimsUse[i];
trimsUse[i]->setProperty("index", i); cb->setProperty("index", i);
populateTrimUseCB(trimsUse[i], phaseIdx); cb->addItem(QObject::tr("Trim disabled"), -1);
connect(trimsUse[i], SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int))); for (int m=0; m<modesCount; m++) {
} if (m == phaseIdx) {
else { cb->addItem(QObject::tr("Own Trim"), m*2);
trimsUse[i]->hide(); }
else if (phaseIdx > 0) {
cb->addItem(QObject::tr("Use Trim from Flight mode %1").arg(m), m*2);
cb->addItem(QObject::tr("Use Trim from Flight mode %1 + Own Trim as an offset").arg(m), m*2+1);
}
} }
connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseTrimUse_currentIndexChanged(int)));
trimsValue[i]->setProperty("index", i); trimsValue[i]->setProperty("index", i);
connect(trimsValue[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrim_valueChanged())); connect(trimsValue[i], SIGNAL(valueChanged(int)), this, SLOT(phaseTrim_valueChanged()));
@ -123,17 +130,6 @@ FlightMode::FlightMode(QWidget * parent, ModelData & model, int phaseIdx, Genera
QLabel *label = new QLabel(ui->gvGB); QLabel *label = new QLabel(ui->gvGB);
label->setText(tr("GVAR%1").arg(i+1)); label->setText(tr("GVAR%1").arg(i+1));
gvLayout->addWidget(label, i, col++, 1, 1); gvLayout->addWidget(label, i, col++, 1, 1);
#if 0
// TODO remove this capability?
// GVar source (er9x/ersky9x)
if (GetEepromInterface()->getCapability(GvarsHaveSources)) {
QComboBox *source = new QComboBox(ui->gvGB);
source->setProperty("index", i);
populateGvSourceCB(source, model.gvsource[i]);
// connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseGVSource_currentIndexChanged(int)));
gvLayout->addWidget(source, i, col++, 1, 1);
}
#endif
// GVar name // GVar name
int nameLen = GetEepromInterface()->getCapability(GvarsName); int nameLen = GetEepromInterface()->getCapability(GvarsName);
if (nameLen > 0) { if (nameLen > 0) {
@ -193,7 +189,6 @@ void FlightMode::update()
int chn = CONVERT_MODE(i+1)-1; int chn = CONVERT_MODE(i+1)-1;
if (chn == 2/*TODO constant*/ && model.throttleReversed) if (chn == 2/*TODO constant*/ && model.throttleReversed)
trimsSlider[i]->setInvertedAppearance(true); trimsSlider[i]->setInvertedAppearance(true);
trimUpdate(i); trimUpdate(i);
} }
@ -262,23 +257,22 @@ void FlightMode::phaseFadeOut_editingFinished()
void FlightMode::trimUpdate(unsigned int trim) void FlightMode::trimUpdate(unsigned int trim)
{ {
lock = true; lock = true;
int chn = CONVERT_MODE(trim+1)-1; int chn = CONVERT_MODE(trim+1)-1;
int value = phase.trim[chn]; int value = model.getTrimValue(phaseIdx, chn);
if (phaseIdx > 0 && phase.trimRef[chn] >= 0) { trimsSlider[trim]->setValue(value);
trimsUse[trim]->setCurrentIndex(1 + phase.trimRef[chn] - (phase.trimRef[chn] >= phaseIdx ? 1 : 0)); trimsValue[trim]->setValue(value);
value = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn]; if (phase.trimMode[chn] < 0) {
trimsValue[trim]->setEnabled(false); trimsUse[trim]->setCurrentIndex(0);
trimsSlider[trim]->setEnabled(false); trimsValue[trim]->setEnabled(false);
} trimsSlider[trim]->setEnabled(false);
else { }
if (phaseIdx > 0) trimsUse[trim]->setCurrentIndex(0); else {
trimsValue[trim]->setEnabled(true); trimsUse[trim]->setCurrentIndex(1 + 2*phase.trimRef[chn] + phase.trimMode[chn] - (phase.trimRef[chn] > phaseIdx ? 1 : 0));
trimsSlider[trim]->setEnabled(true); trimsValue[trim]->setEnabled(true);
} trimsSlider[trim]->setEnabled(true);
trimsSlider[trim]->setValue(value); }
trimsValue[trim]->setValue(value); lock = false;
lock = false;
} }
void FlightMode::phaseGVValue_editingFinished() void FlightMode::phaseGVValue_editingFinished()
@ -380,15 +374,17 @@ void FlightMode::phaseTrimUse_currentIndexChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox*>(sender()); QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int trim = comboBox->property("index").toInt(); int trim = comboBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1; int chn = CONVERT_MODE(trim+1)-1;
if (index == 0) { int data = comboBox->itemData(index).toInt();
phase.trim[chn] = model.phaseData[model.getTrimFlightPhase(chn, phaseIdx)].trim[chn]; if (data < 0) {
phase.trimRef[chn] = -1; phase.trimMode[chn] = -1;
phase.trimRef[chn] = 0;
phase.trim[chn] = 0;
} }
else { else {
phase.trimMode[chn] = data % 2;
phase.trimRef[chn] = data / 2;
phase.trim[chn] = 0; phase.trim[chn] = 0;
phase.trimRef[chn] = index - 1 + (index > (int)phaseIdx ? 1 : 0);
} }
trimUpdate(trim); trimUpdate(trim);
emit modified(); emit modified();
} }
@ -401,7 +397,7 @@ void FlightMode::phaseTrim_valueChanged()
int trim = spinBox->property("index").toInt(); int trim = spinBox->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1; int chn = CONVERT_MODE(trim+1)-1;
int value = spinBox->value(); int value = spinBox->value();
phase.trim[chn] = value; model.setTrimValue(phaseIdx, chn, value);
lock = true; lock = true;
trimsSlider[trim]->setValue(value); trimsSlider[trim]->setValue(value);
lock = false; lock = false;
@ -416,7 +412,7 @@ void FlightMode::phaseTrimSlider_valueChanged()
int trim = slider->property("index").toInt(); int trim = slider->property("index").toInt();
int chn = CONVERT_MODE(trim+1)-1; int chn = CONVERT_MODE(trim+1)-1;
int value = slider->value(); int value = slider->value();
phase.trim[chn] = value; model.setTrimValue(phaseIdx, chn, value);
lock = true; lock = true;
trimsValue[trim]->setValue(value); trimsValue[trim]->setValue(value);
lock = false; lock = false;

View file

@ -30,7 +30,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs")); addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs"));
addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes")); addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes"));
addTab(new Channels(this, model), tr("Channels")); addTab(new Channels(this, model), tr("Channels"));
addTab(new CustomSwitchesPanel(this, model), tr("Logical Switches")); addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches"));
if (GetEepromInterface()->getCapability(CustomFunctions)) if (GetEepromInterface()->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment")); addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment"));
addTab(new Curves(this, model), tr("Curves")); addTab(new Curves(this, model), tr("Curves"));

View file

@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
{ {
ui->setupUi(this); ui->setupUi(this);
lock = true;
// Mode // Mode
populateTimerSwitchCB(ui->mode, timer.mode); populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES);
if (!GetEepromInterface()->getCapability(PermTimers)) { if (!GetEepromInterface()->getCapability(PermTimers)) {
ui->persistent->hide(); ui->persistent->hide();
@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
ui->countdownBeep->addItem(tr("Beeps")); ui->countdownBeep->addItem(tr("Beeps"));
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard())) if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
ui->countdownBeep->addItem(tr("Countdown")); ui->countdownBeep->addItem(tr("Countdown"));
lock = false;
} }
TimerPanel::~TimerPanel() TimerPanel::~TimerPanel()
@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished()
void TimerPanel::on_mode_currentIndexChanged(int index) void TimerPanel::on_mode_currentIndexChanged(int index)
{ {
timer.mode = TimerMode(ui->mode->itemData(index).toInt()); if (!lock) {
emit modified(); timer.mode = RawSwitch(ui->mode->itemData(index).toInt());
emit modified();
}
} }
void TimerPanel::on_persistent_toggled(bool checked) void TimerPanel::on_persistent_toggled(bool checked)
@ -123,20 +129,20 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
if (GetEepromInterface()->getCapability(HasFailsafe)) { if (GetEepromInterface()->getCapability(HasFailsafe)) {
for (int i=0; i<16; i++) { for (int i=0; i<16; i++) {
QSlider * slider = new QSlider(this); QLabel * label = new QLabel(this);
slider->setMinimumSize(QSize(30, 50)); label->setText(QString::number(i+1));
slider->setRange(-100, 100); QDoubleSpinBox * spinbox = new QDoubleSpinBox(this);
QSpinBox * spinbox = new QSpinBox(this);
spinbox->setMinimumSize(QSize(20, 0)); spinbox->setMinimumSize(QSize(20, 0));
spinbox->setRange(-100, 100); spinbox->setRange(-100, 100);
slider->setProperty("index", i); spinbox->setSingleStep(0.1);
spinbox->setDecimals(1);
spinbox->setValue(((double)module.failsafeChannels[i]*100)/1024);
label->setProperty("index", i);
spinbox->setProperty("index", i); spinbox->setProperty("index", i);
failsafeSliders << slider;
failsafeSpins << spinbox; failsafeSpins << spinbox;
ui->failsafesLayout->addWidget(slider, 2*(i/8), i%8, Qt::AlignHCenter); ui->failsafesLayout->addWidget(label, 2*(i/8), i%8, Qt::AlignHCenter);
ui->failsafesLayout->addWidget(spinbox, 1+2*(i/8), i%8, Qt::AlignHCenter); ui->failsafesLayout->addWidget(spinbox, 1+2*(i/8), i%8, Qt::AlignHCenter);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int))); connect(spinbox, SIGNAL(valueChanged(double)), this, SLOT(onFailsafeSpinChanged(double)));
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
} }
} }
@ -217,10 +223,6 @@ void ModulePanel::update()
ui->failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setVisible(mask & MASK_FAILSAFES);
ui->failsafeMode->setCurrentIndex(module.failsafeMode); ui->failsafeMode->setCurrentIndex(module.failsafeMode);
ui->failsafesFrame->setEnabled(module.failsafeMode == 1); ui->failsafesFrame->setEnabled(module.failsafeMode == 1);
for (int i=0; i<failsafeSliders.size(); i++) {
failsafeSliders[i]->setValue(module.failsafeChannels[i]);
failsafeSpins[i]->setValue(module.failsafeChannels[i]);
}
} }
else { else {
mask = 0; mask = 0;
@ -302,16 +304,12 @@ void ModulePanel::on_failsafeMode_currentIndexChanged(int value)
} }
} }
void ModulePanel::onFailsafeChannelChanged(int value) void ModulePanel::onFailsafeSpinChanged(double value)
{ {
if (!lock) { if (!lock) {
lock = true;
int index = sender()->property("index").toInt(); int index = sender()->property("index").toInt();
module.failsafeChannels[index] = value; module.failsafeChannels[index] = (value*1024)/100;
failsafeSpins[index]->setValue(value);
failsafeSliders[index]->setValue(value);
emit modified(); emit modified();
lock = false;
} }
} }

View file

@ -56,14 +56,13 @@ class ModulePanel : public ModelPanel
void on_ppmFrameLength_editingFinished(); void on_ppmFrameLength_editingFinished();
void on_rxNumber_editingFinished(); void on_rxNumber_editingFinished();
void on_failsafeMode_currentIndexChanged(int value); void on_failsafeMode_currentIndexChanged(int value);
void onFailsafeChannelChanged(int value); void onFailsafeSpinChanged(double value);
private: private:
ModuleData & module; ModuleData & module;
int moduleIdx; int moduleIdx;
Ui::Module *ui; Ui::Module *ui;
QVector<QSpinBox *> failsafeSpins; QVector<QDoubleSpinBox *> failsafeSpins;
QVector<QSlider *> failsafeSliders;
}; };
class Setup : public ModelPanel class Setup : public ModelPanel

View file

@ -352,7 +352,7 @@ void TelemetryCustomScreen::updateBar(int line)
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
RawSourceRange range = source.getRange(true); RawSourceRange range = source.getRange(true);
int max = round((range.max - range.min) / range.step); int max = round((range.max - range.min) / range.step);
if (255-screen.body.bars[line].barMax > max) if (int(255-screen.body.bars[line].barMax) > max)
screen.body.bars[line].barMax = 255 - max; screen.body.bars[line].barMax = 255 - max;
minSB[line]->setEnabled(true); minSB[line]->setEnabled(true);
minSB[line]->setDecimals(range.decimals); minSB[line]->setDecimals(range.decimals);

View file

@ -584,8 +584,8 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch();
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP;
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
updateSwitchesTab(); updateSwitchesTab();
} }
@ -841,9 +841,9 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch();
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP;
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP;
setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
// redraw switches tab // redraw switches tab
updateSwitchesTab(); updateSwitchesTab();

View file

@ -40,7 +40,6 @@ preferencesDialog::preferencesDialog(QWidget *parent) :
connect(OptionCheckBox[i], SIGNAL(toggled(bool)), this, SLOT(firmwareOptionChanged(bool))); connect(OptionCheckBox[i], SIGNAL(toggled(bool)), this, SLOT(firmwareOptionChanged(bool)));
} }
populateLocale();
initSettings(); initSettings();
connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged())); connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged()));
connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));
@ -254,11 +253,6 @@ void preferencesDialog::firmwareChanged()
void preferencesDialog::writeValues() void preferencesDialog::writeValues()
{ {
QSettings settings; QSettings settings;
if (ui->locale_QB->currentIndex() > 0)
settings.setValue("locale", ui->locale_QB->itemData(ui->locale_QB->currentIndex()));
else
settings.remove("locale");
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); settings.setValue("default_channel_order", ui->channelorderCB->currentIndex());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("cpu_id", ui->CPU_ID_LE->text()); settings.setValue("cpu_id", ui->CPU_ID_LE->text());
@ -267,8 +261,6 @@ void preferencesDialog::writeValues()
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked()); settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked());
settings.setValue("show_splash", ui->showSplash->isChecked()); settings.setValue("show_splash", ui->showSplash->isChecked());
settings.setValue("theme", ui->theme_CB->currentIndex());
settings.setValue("icon_size", ui->iconSize_CB->currentIndex());
settings.setValue("simuSW", ui->simuSW->isChecked()); settings.setValue("simuSW", ui->simuSW->isChecked());
settings.setValue("history_size", ui->historySize->value()); settings.setValue("history_size", ui->historySize->value());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
@ -387,9 +379,6 @@ void preferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
void preferencesDialog::initSettings() void preferencesDialog::initSettings()
{ {
QSettings settings; QSettings settings;
int i = ui->locale_QB->findData(settings.value("locale"));
if (i < 0) i = 0;
ui->locale_QB->setCurrentIndex(i);
ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool()); ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool());
if (ui->snapshotClipboardCKB->isChecked()) { if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
@ -408,8 +397,6 @@ void preferencesDialog::initSettings()
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool()); ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool());
ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool()); ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool());
ui->showSplash->setChecked(settings.value("show_splash", true).toBool()); ui->showSplash->setChecked(settings.value("show_splash", true).toBool());
ui->theme_CB->setCurrentIndex(settings.value("theme", 1).toInt());
ui->iconSize_CB->setCurrentIndex(settings.value("icon_size", 2).toInt());
ui->historySize->setValue(settings.value("history_size", 10).toInt()); ui->historySize->setValue(settings.value("history_size", 10).toInt());
ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt()); ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt());
ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool()); ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool());
@ -501,25 +488,6 @@ void preferencesDialog::initSettings()
firmwareChanged(); firmwareChanged();
} }
void preferencesDialog::populateLocale()
{
ui->ProfSave_PB->setEnabled(true);
ui->locale_QB->clear();
ui->locale_QB->addItem("System default language", "");
ui->locale_QB->addItem("English", "en");
QStringList strl = QApplication::arguments();
if (!strl.count()) return;
QDir directory = QDir(":/");
QStringList files = directory.entryList(QStringList("companion_*.qm"), QDir::Files | QDir::NoSymLinks);
foreach(QString file, files) {
QLocale loc(file.mid(10, 2));
ui->locale_QB->addItem(QLocale::languageToString(loc.language()), loc.name());
}
}
void preferencesDialog::on_fw_dnld_clicked() void preferencesDialog::on_fw_dnld_clicked()
{ {
MainWindow * mw = (MainWindow *)this->parent(); MainWindow * mw = (MainWindow *)this->parent();

View file

@ -25,7 +25,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Preferences</string> <string>Preferences</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,0,0,1,0"> <layout class="QGridLayout" name="gridLayout_4" columnstretch="1,0,0,0,0">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetMinimumSize</enum>
</property> </property>
@ -35,7 +35,84 @@
<property name="margin"> <property name="margin">
<number>4</number> <number>4</number>
</property> </property>
<item row="3" column="1" colspan="4"> <item row="31" column="1" colspan="2">
<widget class="QComboBox" name="stickmodeCB">
<property name="whatsThis">
<string>Mode selection:
Mode 1:
Left stick: Elevator, Rudder
Right stick: Throttle, Aileron
Mode 2:
Left stick: Throttle, Rudder
Right stick: Elevator, Aileron
Mode 3:
Left stick: Elevator, Aileron
Right stick: Throttle, Rudder
Mode 4:
Left stick: Throttle, Aileron
Right stick: Elevator, Rudder
</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Mode 1 (RUD ELE THR AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 2 (RUD THR ELE AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 3 (AIL ELE THR RUD)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 4 (AIL THR ELE RUD)</string>
</property>
</item>
</widget>
</item>
<item row="14" column="1">
<widget class="QComboBox" name="backLightColor">
<item>
<property name="text">
<string>Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Green</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<item> <item>
<widget class="QLineEdit" name="backupPath"> <widget class="QLineEdit" name="backupPath">
@ -60,7 +137,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Automatic Backup Folder</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -73,7 +157,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="16" column="1" colspan="4"> <item row="15" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QCheckBox" name="joystickChkB"> <widget class="QCheckBox" name="joystickChkB">
@ -101,14 +185,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0"> <item row="1" column="1" colspan="4">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Automatic Backup Folder</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QSpinBox" name="historySize"> <widget class="QSpinBox" name="historySize">
@ -151,14 +228,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="6" column="0" colspan="5"> <item row="5" column="0" colspan="5">
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="0"> <item row="14" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -174,7 +251,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="4" rowspan="7"> <item row="6" column="4" rowspan="7">
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0"> <layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QLabel" name="imageLabel"> <widget class="QLabel" name="imageLabel">
@ -229,43 +306,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="15" column="2" colspan="2"> <item row="14" column="2" colspan="2">
<widget class="QCheckBox" name="simuSW"> <widget class="QCheckBox" name="simuSW">
<property name="text"> <property name="text">
<string>Remember switches in simulator</string> <string>Remember switches in simulator</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="1"> <item row="6" column="1" colspan="3">
<widget class="QComboBox" name="backLightColor">
<item>
<property name="text">
<string>Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Green</string>
</property>
</item>
<item>
<property name="text">
<string>Red</string>
</property>
</item>
<item>
<property name="text">
<string>Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Yellow</string>
</property>
</item>
</widget>
</item>
<item row="7" column="1" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
@ -302,27 +350,21 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="17" column="0"> <item row="16" column="0">
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_19">
<property name="text"> <property name="text">
<string>Simulator capture folder</string> <string>Simulator capture folder</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="17" column="0" colspan="5">
<widget class="QLabel" name="label"> <widget class="Line" name="line_2">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Language (requires restart)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="32" column="4"> <item row="31" column="4">
<widget class="QComboBox" name="channelorderCB"> <widget class="QComboBox" name="channelorderCB">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -466,7 +508,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -479,7 +521,7 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="1" colspan="3"> <item row="12" column="1" colspan="3">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>1</number> <number>1</number>
@ -503,7 +545,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="25" column="1" colspan="4"> <item row="24" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QLabel" name="FwInfo"> <widget class="QLabel" name="FwInfo">
@ -527,7 +569,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="13" column="0"> <item row="12" column="0">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -540,7 +582,7 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="38" column="0" colspan="5"> <item row="37" column="0" colspan="5">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
@ -583,7 +625,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="27" column="1" colspan="4"> <item row="26" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0"> <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0">
<item> <item>
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
@ -610,7 +652,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="33" column="1" colspan="4"> <item row="32" column="1" colspan="4">
<layout class="QGridLayout" name="gridLayout_6" columnstretch="0,0,1,0,0"> <layout class="QGridLayout" name="gridLayout_6" columnstretch="0,0,1,0,0">
<item row="1" column="4"> <item row="1" column="4">
<widget class="QPushButton" name="export_PB"> <widget class="QPushButton" name="export_PB">
@ -658,7 +700,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="17" column="1" colspan="4"> <item row="16" column="1" colspan="4">
<layout class="QGridLayout" name="gridLayout_8"> <layout class="QGridLayout" name="gridLayout_8">
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>1</number> <number>1</number>
@ -689,7 +731,7 @@ This is used by the templated to determine which channel goes to what number out
</item> </item>
</layout> </layout>
</item> </item>
<item row="32" column="0"> <item row="31" column="0">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="label_14">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -702,7 +744,7 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="32" column="3"> <item row="31" column="3">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -718,62 +760,14 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="32" column="1" colspan="2"> <item row="32" column="0">
<widget class="QComboBox" name="stickmodeCB">
<property name="whatsThis">
<string>Mode selection:
Mode 1:
Left stick: Elevator, Rudder
Right stick: Throttle, Aileron
Mode 2:
Left stick: Throttle, Rudder
Right stick: Elevator, Aileron
Mode 3:
Left stick: Elevator, Aileron
Right stick: Throttle, Rudder
Mode 4:
Left stick: Throttle, Aileron
Right stick: Elevator, Rudder
</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Mode 1 (RUD ELE THR AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 2 (RUD THR ELE AIL)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 3 (AIL ELE THR RUD)</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 4 (AIL THR ELE RUD)</string>
</property>
</item>
</widget>
</item>
<item row="33" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="text"> <property name="text">
<string>Profile slot</string> <string>Profile slot</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="28" column="1" colspan="4"> <item row="27" column="1" colspan="4">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -789,7 +783,7 @@ Mode 4:
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="26" column="1" colspan="4"> <item row="25" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="1,0"> <layout class="QHBoxLayout" name="horizontalLayout_11" stretch="1,0">
<item> <item>
<widget class="QLabel" name="label_18"> <widget class="QLabel" name="label_18">
@ -816,7 +810,7 @@ Mode 4:
</item> </item>
</layout> </layout>
</item> </item>
<item row="22" column="1" colspan="4"> <item row="21" column="1" colspan="4">
<layout class="QGridLayout" name="gridLayout_5" columnstretch="1,0,0,0,0"> <layout class="QGridLayout" name="gridLayout_5" columnstretch="1,0,0,0,0">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum> <enum>QLayout::SetMaximumSize</enum>
@ -907,7 +901,7 @@ May be different from firmware language</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="22" column="0"> <item row="21" column="0">
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
@ -947,7 +941,7 @@ May be different from firmware language</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -960,14 +954,7 @@ May be different from firmware language</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="18" column="0" colspan="5"> <item row="23" column="1" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="24" column="1" colspan="4">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum> <enum>QLayout::SetMaximumSize</enum>
@ -1520,7 +1507,7 @@ May be different from firmware language</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="10" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="label_10">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -1533,7 +1520,7 @@ May be different from firmware language</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1" colspan="3"> <item row="9" column="1" colspan="3">
<widget class="QComboBox" name="splashincludeCB"> <widget class="QComboBox" name="splashincludeCB">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -1554,116 +1541,6 @@ May be different from firmware language</string>
</widget> </widget>
</item> </item>
<item row="0" column="1" colspan="4"> <item row="0" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QComboBox" name="locale_QB"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Theme</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="theme_CB">
<property name="toolTip">
<string>Requires restart</string>
</property>
<item>
<property name="text">
<string>Classic</string>
</property>
</item>
<item>
<property name="text">
<string>Monochrome</string>
</property>
</item>
<item>
<property name="text">
<string>MonoWhite</string>
</property>
</item>
<item>
<property name="text">
<string>MonoBlue</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Icon size</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="iconSize_CB">
<property name="toolTip">
<string>Requires restart</string>
</property>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Big</string>
</property>
</item>
<item>
<property name="text">
<string>Huge</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="1" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0,0,0">
<item> <item>
<widget class="QCheckBox" name="showSplash"> <widget class="QCheckBox" name="showSplash">
@ -1710,7 +1587,7 @@ May be different from firmware language</string>
</item> </item>
</layout> </layout>
</item> </item>
<item row="16" column="0"> <item row="15" column="0">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_11">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
@ -1723,14 +1600,14 @@ May be different from firmware language</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="3" column="0">
<widget class="QLabel" name="ge_label"> <widget class="QLabel" name="ge_label">
<property name="text"> <property name="text">
<string>Google Earth Executable</string> <string>Google Earth Executable</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="4"> <item row="3" column="1" colspan="4">
<layout class="QHBoxLayout" name="ge_layout"> <layout class="QHBoxLayout" name="ge_layout">
<item> <item>
<widget class="QLineEdit" name="ge_lineedit"> <widget class="QLineEdit" name="ge_lineedit">

View file

@ -54,7 +54,6 @@ printDialog::printDialog(QWidget *parent, GeneralSettings *gg, ModelData *gm, QS
printCurves(); printCurves();
printGvars(); printGvars();
printSwitches(); printSwitches();
printSafetySwitches();
printFSwitches(); printFSwitches();
printFrSky(); printFrSky();
@ -643,7 +642,7 @@ void printDialog::printSwitches()
str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>"); str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3>"); str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3>");
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
if (g_model->customSw[i].func) { if (g_model->customSw[i].func) {
str.append("<tr>"); str.append("<tr>");
if (i<9) { if (i<9) {
@ -651,7 +650,7 @@ void printDialog::printSwitches()
} else { } else {
str.append("<td width=\"60\" align=\"center\"><b>"+tr("LS")+('A'+(i-9))+"</b></td>"); str.append("<td width=\"60\" align=\"center\"><b>"+tr("LS")+('A'+(i-9))+"</b></td>");
} }
QString tstr = getCustomSwitchStr(&g_model->customSw[i], *g_model); QString tstr = g_model->customSw[i].toString(*g_model);
str.append(doTC(tstr,"green")); str.append(doTC(tstr,"green"));
str.append("</tr>"); str.append("</tr>");
sc++; sc++;
@ -693,33 +692,6 @@ void printDialog::printGvars()
} }
} }
void printDialog::printSafetySwitches()
{
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3><tr>");
str.append("<td width=\"60\">&nbsp;</td>");
str.append(doTC(tr("Switch"), "", true));
str.append(doTL(tr("Value"), "", true));
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if (g_model->safetySw[i].swtch.type) {
str.append("<tr>");
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
str.append(doTC(g_model->safetySw[i].swtch.toString(),"green"));
str.append(doTC(QString::number(g_model->safetySw[i].val),"green"));
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void printDialog::printFSwitches() void printDialog::printFSwitches()
{ {
int sc=0; int sc=0;
@ -736,8 +708,8 @@ void printDialog::printFSwitches()
if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
str.append("<tr>"); str.append("<tr>");
str.append(doTC(g_model->funcSw[i].swtch.toString(),"green")); str.append(doTC(g_model->funcSw[i].swtch.toString(),"green"));
str.append(doTC(getFuncName(g_model->funcSw[i].func),"green")); str.append(doTC(g_model->funcSw[i].funcToString(),"green"));
str.append(doTC(FuncParam(g_model->funcSw[i].func,g_model->funcSw[i].param,g_model->funcSw[i].paramarm, g_model->funcSw[i].adjustMode),"green")); str.append(doTC(g_model->funcSw[i].paramToString(),"green"));
int index=g_model->funcSw[i].func; int index=g_model->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green")); str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green"));

View file

@ -356,7 +356,7 @@ void simulatorDialog::loadParams(RadioData &radioData, const int model_idx)
beepVal = 0; beepVal = 0;
beepShow = 0; beepShow = 0;
switches=txInterface->getCapability(CustomSwitches); switches=txInterface->getCapability(LogicalSwitches);
if ( switches < 13) { if ( switches < 13) {
ui->cswitch_13->hide(); ui->cswitch_13->hide();
ui->labelCSW_13->hide(); ui->labelCSW_13->hide();
@ -497,6 +497,8 @@ void simulatorDialog::setValues()
{ {
TxOutputs outputs; TxOutputs outputs;
simulator->getValues(outputs); simulator->getValues(outputs);
Trims trims;
simulator->getTrims(trims);
ui->chnout_1->setValue(chVal(outputs.chans[0])); ui->chnout_1->setValue(chVal(outputs.chans[0]));
ui->chnout_2->setValue(chVal(outputs.chans[1])); ui->chnout_2->setValue(chVal(outputs.chans[1]));
@ -536,11 +538,11 @@ void simulatorDialog::setValues()
ui->chnoutV_16->setText(QString("%1").arg((qreal)outputs.chans[15]*100/1024, 0, 'f', 1)); ui->chnoutV_16->setText(QString("%1").arg((qreal)outputs.chans[15]*100/1024, 0, 'f', 1));
} }
ui->leftXPerc->setText(QString("X %1%").arg((qreal)nodeLeft->getX()*100, 2, 'f', 0)); ui->leftXPerc->setText(QString("X %1%").arg((qreal)nodeLeft->getX()*100+trims.values[0]/5, 2, 'f', 0));
ui->leftYPerc->setText(QString("Y %1%").arg((qreal)nodeLeft->getY()*-100, 2, 'f', 0)); ui->leftYPerc->setText(QString("Y %1%").arg((qreal)nodeLeft->getY()*-100+trims.values[1]/5, 2, 'f', 0));
ui->rightXPerc->setText(QString("X %1%").arg((qreal)nodeRight->getX()*100, 2, 'f', 0)); ui->rightXPerc->setText(QString("X %1%").arg((qreal)nodeRight->getX()*100+trims.values[2]/5, 2, 'f', 0));
ui->rightYPerc->setText(QString("Y %1%").arg((qreal)nodeRight->getY()*-100, 2, 'f', 0)); ui->rightYPerc->setText(QString("Y %1%").arg((qreal)nodeRight->getY()*-100+trims.values[3]/5, 2, 'f', 0));
#define CSWITCH_ON "QLabel { background-color: #4CC417 }" #define CSWITCH_ON "QLabel { background-color: #4CC417 }"
#define CSWITCH_OFF "QLabel { }" #define CSWITCH_OFF "QLabel { }"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 876 B

After

Width:  |  Height:  |  Size: 463 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 733 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 999 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

After

Width:  |  Height:  |  Size: 309 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

After

Width:  |  Height:  |  Size: 668 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 947 B

After

Width:  |  Height:  |  Size: 511 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 736 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

After

Width:  |  Height:  |  Size: 912 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 998 B

After

Width:  |  Height:  |  Size: 500 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 B

After

Width:  |  Height:  |  Size: 492 B

Before After
Before After

Some files were not shown because too many files have changed in this diff Show more