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

Merge branch 'origin/next'

Conflicts:
	companion/src/CMakeLists.txt
	companion/src/apppreferencesdialog.ui
	companion/src/companion.qrc
	companion/src/mdichild.cpp
This commit is contained in:
Kjell Kernen 2014-03-31 10:22:23 +02:00
commit 8059daccaf
236 changed files with 25514 additions and 16461 deletions

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
/.*project
/.settings
/.autotools
radio/src/bootloader/.dep/
radio/src/bootloader/bootloader_ramBoot*
*.lbm

View file

@ -332,3 +332,31 @@ Steve Coley
Sean Cull
Roberto Orsello
David Finger
FrSky - www.frsky-rc.com
Jean-Marie Oddo
Mike Matheny
Glen Roe (Showmaster)
Arron Bates
Tim Spurr
Daniel Morgan
Trent Ready
Mark Maskiell
Robert Crockford
Mark Illum
David McGuire
Martyn Coles
Jose Sobral
Heung Jin Choi
Tomasz Janiak
Fabien Gagné
Joe Street
Micha Ronen
Albert Blondin
Klaus Schuebel
Evening Shade Pottery
Thomas Kilduff
Sven Assmus
Markus Eberl
Dietmar Drees
Nicholas Field
Harald Wilczak

View file

@ -1,3 +1,10 @@
<h2>Version 1.52</h2>
<ul>
<li>Fix crash when writing certain EEPROMS</li>
<li>Google Earth export of logs containing GPS positions</li>
<li>DSM2 added for Taranis</li>
</ul>
<h2>Version 1.51</h2>
<ul>
<li>Wrong DFU-Util default path (MAC)</li>

View file

@ -1,7 +1,7 @@
PROJECT( companion )
SET( C9X_VERSION_MAJOR "1" )
SET( C9X_VERSION_MINOR "52" )
SET( C9X_VERSION_MINOR "99" )
SET( C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR} )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
@ -36,7 +36,7 @@ ELSE()
MESSAGE( "SDL not found! Joysticks support will be disabled" )
ENDIF()
FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE(Qt4 4.8.4 REQUIRED)
SET( QT_USE_QTNETWORK True )
SET( QT_USE_QTXML True )
INCLUDE( ${QT_USE_FILE} )
@ -90,6 +90,13 @@ add_custom_command(
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)
add_custom_command(
OUTPUT ${RADIO_SRC_DIRECTORY}/stamp-opentx.h
COMMAND make stamp_header
DEPENDS ${RADIO_SRC_DIRECTORY}/Makefile
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/../..
@ -128,6 +135,7 @@ set(companion_SRCS
firmwares/opentx/opentxsimulator.cpp
firmwares/ersky9x/ersky9xeeprom.cpp
firmwares/ersky9x/ersky9xinterface.cpp
${RADIO_SRC_DIRECTORY}/stamp-opentx.h
${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm
${RADIO_SRC_DIRECTORY}/translations/en.h
appdata.cpp
@ -151,6 +159,8 @@ set(companion_SRCS
splashlibrary.cpp
mainwindow.cpp
companion.cpp
modelconfigdialog.cpp
taranisnotfound.cpp
qcustomplot.cpp
wizarddata.cpp
wizarddialog.cpp
@ -175,6 +185,8 @@ set(companion_MOC_HDRS
modelslist.h
mdichild.h
mainwindow.h
modelconfigdialog.h
taranisnotfound.h
qcustomplot.h
helpers.h
wizarddialog.h
@ -196,6 +208,8 @@ set(companion_UIS
customizesplashdialog.ui
splashlibrary.ui
burndialog.ui
modelconfigdialog.ui
taranisnotfound.ui
)
set(companion_RCS
@ -387,7 +401,7 @@ IF( WIN32 )
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/companionInstall.exe
COMMAND "${NSIS_EXE}" ARGS companion.nsi
DEPENDS ${PROJECT_NAME} ${PROJECT_BINARY_DIR}/companion.nsi
DEPENDS ${PROJECT_NAME} simulator ${PROJECT_BINARY_DIR}/companion.nsi
COMMENT "Windows NSIS Installer")
ADD_CUSTOM_TARGET( installer

View file

@ -307,6 +307,7 @@ QString Profile::display() const { return _display; }
QString Profile::haptic() const { return _haptic; }
QString Profile::speaker() const { return _speaker; }
QString Profile::stickPotCalib() const { return _stickPotCalib; }
QString Profile::timeStamp() const { return _timeStamp; }
QString Profile::trainerCalib() const { return _trainerCalib; }
int Profile::currentCalib() const { return _currentCalib; }
int Profile::gsStickMode() const { return _gsStickMode; }
@ -331,6 +332,7 @@ void Profile::display (const QString x) { store(x, _display, "Displa
void Profile::haptic (const QString x) { store(x, _haptic, "Haptic" ,"Profiles", QString("profile%1").arg(index));}
void Profile::speaker (const QString x) { store(x, _speaker, "Speaker" ,"Profiles", QString("profile%1").arg(index));}
void Profile::stickPotCalib (const QString x) { store(x, _stickPotCalib, "StickPotCalib" ,"Profiles", QString("profile%1").arg(index));}
void Profile::timeStamp (const QString x) { store(x, _timeStamp, "TimeStamp" ,"Profiles", QString("profile%1").arg(index));}
void Profile::trainerCalib (const QString x) { store(x, _trainerCalib, "TrainerCalib" ,"Profiles", QString("profile%1").arg(index));}
void Profile::currentCalib (const int x) { store(x, _currentCalib, "currentCalib" ,"Profiles", QString("profile%1").arg(index));}
void Profile::gsStickMode (const int x) { store(x, _gsStickMode, "GSStickMode" ,"Profiles", QString("profile%1").arg(index));}
@ -396,6 +398,24 @@ bool Profile::existsOnDisk()
return (keyList.length() > 0);
}
void Profile::initFwVariables()
{
_beeper = "";
_countryCode = "";
_display = "";
_haptic = "";
_speaker = "";
_stickPotCalib = "";
_timeStamp = "";
_trainerCalib = "";
_currentCalib = 0;
_gsStickMode = 0;
_ppmMultiplier = 0;
_vBatCalib = 0;
_vBatWarn = 0;
}
void Profile::init(int newIndex)
{
index = newIndex;
@ -410,19 +430,7 @@ void Profile::init(int newIndex)
_channelOrder = 0;
_defaultMode = 1;
_beeper = "";
_countryCode = "";
_display = "";
_haptic = "";
_speaker = "";
_stickPotCalib = "";
_trainerCalib = "";
_currentCalib = 0;
_gsStickMode = 0;
_ppmMultiplier = 0;
_vBatCalib = 0;
_vBatWarn = 0;
initFwVariables();
// Do not write empty profiles to disk except the default (0) profile.
if ( index > 0 && !existsOnDisk())
@ -450,6 +458,7 @@ void Profile::flush()
getset( _haptic, "Haptic" ,"" ,"Profiles", QString("profile%1").arg(index));
getset( _speaker, "Speaker" ,"" ,"Profiles", QString("profile%1").arg(index));
getset( _stickPotCalib, "StickPotCalib" ,"" ,"Profiles", QString("profile%1").arg(index));
getset( _timeStamp, "TimeStamp" ,"" ,"Profiles", QString("profile%1").arg(index));
getset( _trainerCalib, "TrainerCalib" ,"" ,"Profiles", QString("profile%1").arg(index));
getset( _currentCalib, "currentCalib" ,0 ,"Profiles", QString("profile%1").arg(index));
getset( _gsStickMode, "GSStickMode" ,0 ,"Profiles", QString("profile%1").arg(index));

View file

@ -120,6 +120,7 @@ class Profile: protected CompStoreObj
QString _haptic;
QString _speaker;
QString _stickPotCalib;
QString _timeStamp;
QString _trainerCalib;
int _currentCalib;
int _gsStickMode;
@ -145,6 +146,7 @@ class Profile: protected CompStoreObj
QString haptic() const;
QString speaker() const;
QString stickPotCalib() const;
QString timeStamp() const;
QString trainerCalib() const;
int currentCalib() const;
int gsStickMode() const;
@ -169,6 +171,7 @@ class Profile: protected CompStoreObj
void haptic (const QString);
void speaker (const QString);
void stickPotCalib (const QString);
void timeStamp (const QString);
void trainerCalib (const QString);
void currentCalib (const int);
void gsStickMode (const int);
@ -181,6 +184,7 @@ class Profile: protected CompStoreObj
void remove();
bool existsOnDisk();
void init(int newIndex);
void initFwVariables();
void flush();
};

View file

@ -68,12 +68,13 @@ void appPreferencesDialog::writeValues()
else
g.profile[g.id()].name(ui->profileNameLE->text());
// If a new radio type has been choosen, several things need to change
// If a new radio type has been choosen, several things need to reset
if ( initialRadioType != ui->radioCB->currentIndex())
{
g.profile[g.id()].fwName("");
g.profile[g.id()].fwType(getDefaultFwType(ui->radioCB->currentIndex()));
current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].fwType());
current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].fwType());
g.profile[g.id()].initFwVariables();
}
}
@ -154,11 +155,23 @@ void appPreferencesDialog::initSettings()
ui->sdPath->setText(g.profile[g.id()].sdPath());
ui->profileNameLE->setText(g.profile[g.id()].name());
ui->SplashFileName->setText(g.profile[g.id()].splashFile());
initialRadioType = getRadioType(g.profile[g.id()].fwType());
ui->radioCB->setCurrentIndex(initialRadioType);
displayImage( g.profile[g.id()].splashFile() );
QString hwSettings;
if (g.profile[g.id()].stickPotCalib() == "" ) {
hwSettings = QString(tr("EMPTY: No radio settings stored in profile"));
}
else {
QString str = g.profile[g.id()].timeStamp();
if (str.isEmpty())
hwSettings = QString(tr("AVAILABLE: Radio settings of unknown age"));
else
hwSettings = QString(tr("AVAILABLE: Radio settings stored %1").arg(str));
}
ui->lblGeneralSettings->setText(hwSettings);
}
void appPreferencesDialog::on_libraryPathButton_clicked()

View file

@ -51,18 +51,20 @@ avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg,
ui->progressBar->setMaximum(127);
QTimer::singleShot(500, this, SLOT(doCopy()));
}
} else {
if(wTitle.isEmpty())
setWindowTitle(getProgrammer() + " " + tr("result"));
}
else {
if (wTitle.isEmpty())
setWindowTitle(getProgrammer() + " " + tr("result"));
else
setWindowTitle(getProgrammer() + " - " + wTitle);
setWindowTitle(getProgrammer() + " - " + wTitle);
QFile exec;
winTitle=wTitle;
if (!(exec.exists(prog))) {
QMessageBox::critical(this, "Companion", getProgrammer() + " " + tr("executable not found"));
closeOpt = AVR_DIALOG_FORCE_CLOSE;
QTimer::singleShot(0, this, SLOT(forceClose()));
} else {
}
else {
foreach(QString str, arg) cmdLine.append(" " + str);
lfuse = 0;
hfuse = 0;
@ -70,10 +72,11 @@ avrOutputDialog::avrOutputDialog(QWidget *parent, QString prog, QStringList arg,
phase=0;
currLine.clear();
if (!displayDetails) {
ui->plainTextEdit->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
} else {
ui->checkBox->setChecked(true);
ui->plainTextEdit->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
}
else {
ui->checkBox->setChecked(true);
}
process = new QProcess(this);
connect(process,SIGNAL(readyReadStandardError()), this, SLOT(doAddTextStdErr()));
@ -241,10 +244,8 @@ void avrOutputDialog::doAddTextStdOut()
if (text.contains("Complete ")) {
#if !__GNUC__
if (kill_timer) {
delete kill_timer;
kill_timer = NULL;
}
delete kill_timer;
kill_timer = NULL;
#endif
int start = text.indexOf("Complete ");
int end = text.indexOf("%");

View file

@ -15,6 +15,7 @@ burnConfigDialog::burnConfigDialog(QWidget *parent) :
ui(new Ui::burnConfigDialog)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("configure.png"));
ui->avrdude_programmer->model()->sort(0);
getSettings();

View file

@ -501,6 +501,61 @@ Please only use this if you know what you are doing. There are no error checks
<string notr="true">com4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com5</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com6</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com7</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com8</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com9</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com10</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com11</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com12</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com13</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com14</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">com15</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">lpt1</string>

View file

@ -18,12 +18,13 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexType(Type)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("write_flash.png"));
if(!g.profile[g.id()].splashFile().isEmpty()){
if (!g.profile[g.id()].splashFile().isEmpty()){
imageSource=PROFILE;
imageFile=g.profile[g.id()].splashFile();
}
else{
else {
ui->useProfileImageCB->setDisabled(true);
imageSource=FIRMWARE;
imageFile="";
@ -51,7 +52,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->BurnFlashButton->setDisabled(true);
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
ui->versionField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
@ -131,7 +132,7 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->BurnFlashButton->setDisabled(true);
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
ui->versionField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
@ -145,7 +146,7 @@ void burnDialog::on_FlashLoadButton_clicked()
checkFw(fileName);
}
else {
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), g.eepromDir(), tr(EEPE_FILES_FILTER));
if (checkeEprom(fileName)) {
if (burnraw==false) {
ui->BurnFlashButton->setEnabled(true);
@ -191,8 +192,8 @@ void burnDialog::checkFw(QString fileName)
if (flash.isValid()) {
ui->FramFWInfo->show();
ui->DateField->setText(flash.getDate() + " " + flash.getTime());
ui->SVNField->setText(flash.getSvn());
ui->ModField->setText(flash.getBuild());
ui->versionField->setText(flash.getVersion().isEmpty() ? flash.getSvn() : flash.getVersion());
ui->ModField->setText(flash.getEEprom());
ui->SplashFrame->hide();
if (flash.hasSplash()) {
@ -305,7 +306,7 @@ void burnDialog::displaySplash()
FlashInterface flash(ui->FWFileName->text());
image = flash.getSplash();
}
else{
else {
image.load(imageFile);
}
if (image.isNull()) {
@ -425,15 +426,18 @@ void burnDialog::on_BurnFlashButton_clicked()
hexfileName->clear();
QMessageBox::critical(this, tr("Warning"), tr("Cannot save customized firmware"));
}
} else {
}
else {
hexfileName->clear();
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
}
} else {
hexfileName->clear();
hexfileName->append(fileName);
}
} else {
else {
hexfileName->clear();
hexfileName->append(fileName);
}
}
else {
QMessageBox::critical(this, tr("Warning"), tr("No firmware selected"));
hexfileName->clear();
}

View file

@ -7,12 +7,9 @@
#include "flashinterface.h"
#include "xmlinterface.h"
#define XML_FILES_FILTER "XML files (*.xml);;"
#define HEX_FILES_FILTER "HEX files (*.hex);;"
#define BIN_FILES_FILTER "BIN files (*.bin);;"
#define EEPE_FILES_FILTER "EEPE EEPROM files (*.eepe);;"
#define EEPM_FILES_FILTER "EEPE MODEL files (*.eepm);;"
// #define EEPROM_FILES_FILTER "EEPE files (*.xml *.eepe *.eepm *.bin *.hex);;" XML_FILES_FILTER EEPE_FILES_FILTER EEPM_FILES_FILTER BIN_FILES_FILTER HEX_FILES_FILTER
#define EEPROM_FILES_FILTER "EEPE files (*.eepe *.bin *.hex);;" EEPE_FILES_FILTER BIN_FILES_FILTER HEX_FILES_FILTER
#define FLASH_FILES_FILTER "FLASH files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER
#define EXTERNAL_EEPROM_FILES_FILTER "EEPROM files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>423</height>
<width>399</width>
<height>564</height>
</rect>
</property>
<property name="sizePolicy">
@ -18,7 +18,7 @@
</property>
<property name="minimumSize">
<size>
<width>440</width>
<width>0</width>
<height>0</height>
</size>
</property>
@ -113,8 +113,15 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="3" column="0">
<widget class="QLabel" name="dateLabel">
<property name="text">
<string>Date &amp; Time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="SVNField">
<widget class="QLineEdit" name="versionField">
<property name="readOnly">
<bool>true</bool>
</property>
@ -135,20 +142,13 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="svnLabel">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>SVN</string>
<string>Version</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="dateLabel">
<property name="text">
<string>Date &amp; Time</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="3" column="1">
<widget class="QLineEdit" name="DateField">
<property name="readOnly">
<bool>true</bool>
@ -171,6 +171,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
@ -254,8 +260,8 @@
<item row="0" column="0">
<layout class="QGridLayout" name="SplashLayout" rowstretch="0,0,0,0,0,0,0">
<item row="0" column="1" rowspan="7">
<layout class="QGridLayout" name="gridLayout_2" rowstretch="1">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0">
<item row="0" column="0">
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -271,8 +277,8 @@
</property>
<property name="maximumSize">
<size>
<width>212</width>
<height>64</height>
<width>214</width>
<height>66</height>
</size>
</property>
<property name="frameShape">
@ -281,6 +287,9 @@
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
@ -289,32 +298,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<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 row="0" column="0">
<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="2" column="0">
@ -377,8 +360,7 @@
<tabstop>BurnFlashButton</tabstop>
<tabstop>FWFileName</tabstop>
<tabstop>FlashLoadButton</tabstop>
<tabstop>DateField</tabstop>
<tabstop>SVNField</tabstop>
<tabstop>versionField</tabstop>
<tabstop>ModField</tabstop>
<tabstop>useProfileImageCB</tabstop>
<tabstop>useFwImageCB</tabstop>

View file

@ -57,6 +57,7 @@
<file>images/x9r3.png</file>
<file>images/x9s0.png</file>
<file>images/x9t0.png</file>
<file>images/taranison.png</file>
<file>images/wizard/ailerons.png</file>
<file>images/wizard/airbrakes.png</file>
<file>images/wizard/bank.png</file>

View file

@ -1069,7 +1069,7 @@ void compareDialog::printFSwitches()
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("Switch Assignment")+"</h2></td></tr>");
str.append("<tr><td><h2>"+tr("Special Functions")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\"><tr>");
str.append("<td width=\"7%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"12%\" align=\"center\"><b>"+tr("Function")+"</b></td>");
@ -1112,7 +1112,7 @@ void compareDialog::printFSwitches()
} else {
str.append("<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>");
}
str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true));
str.append(doTC(tr("SF")+QString("%1").arg(i+1),"",true));
if (g_model2->funcSw[i].swtch.type) {
str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2));
str.append(doTC(g_model2->funcSw[i].funcToString(),color2));

View file

@ -142,7 +142,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
ui(new Ui::customizeSplashDialog)
{
ui->setupUi(this);
this->setWindowIcon(CompanionIcon("paint.png"));
setWindowIcon(CompanionIcon("paintbrush.png"));
ui->leftLibraryButton->setIcon(CompanionIcon("library.png"));
ui->rightLibraryButton->setIcon(CompanionIcon("library.png"));

View file

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>1087</width>
<height>285</height>
<height>298</height>
</rect>
</property>
<property name="sizePolicy">
@ -165,6 +165,9 @@
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
@ -470,6 +473,9 @@
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>

View file

@ -2,6 +2,7 @@
#include "ui_downloaddialog.h"
#include <QMessageBox>
#include <QtGui>
#include <QTime>
#include "helpers.h"
downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) :
@ -87,3 +88,14 @@ void downloadDialog::fileError()
file = 0;
reject();
}
void downloadDialog::closeEvent( QCloseEvent * event)
{
// Delay closing 2 seconds to avoid unpleasant flashing download dialogs
QTime closeTime= QTime::currentTime().addSecs(2);
while( QTime::currentTime() < closeTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
event->accept();
}

View file

@ -27,6 +27,7 @@ private slots:
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
private:
void closeEvent( QCloseEvent * event);
Ui::downloadDialog *ui;
QNetworkAccessManager qnam;

View file

@ -638,41 +638,45 @@ class ConversionField: public TransformedField {
virtual void beforeExport()
{
int val = field;
_field = field;
if (scale) {
val /= scale;
_field /= scale;
}
if (table) {
if (table->exportValue(val, _field))
if (table->exportValue(_field, _field))
return;
if (!error.isEmpty())
EEPROMWarnings += error + "\n";
}
if (shift) {
if (val < min) _field = min + shift;
else if (val > max) _field = max + shift;
else _field = val + shift;
if (_field < min) _field = min + shift;
else if (_field > max) _field = max + shift;
else _field += shift;
}
if (exportFunc) {
_field = exportFunc(val);
_field = exportFunc(_field);
}
}
virtual void afterImport()
{
field = _field;
if (table) {
if (table->importValue(_field, field))
if (table->importValue(field, field))
return;
}
field = _field - shift;
if (shift) {
field -= shift;
}
if (importFunc) {
field = importFunc(_field);
field = importFunc(field);
}
if (scale) {

View file

@ -127,11 +127,14 @@ RawSourceRange RawSource::getRange(bool singleprec)
result.max = singleprec ? 1540 : 3000;
break;
case TELEMETRY_SOURCE_T1:
case TELEMETRY_SOURCE_T1_MAX:
case TELEMETRY_SOURCE_T2:
case TELEMETRY_SOURCE_T2_MAX:
result.min = -30;
result.max = 225;
break;
case TELEMETRY_SOURCE_RPM:
case TELEMETRY_SOURCE_RPM_MAX:
result.step = singleprec ? 50 : 1;
result.max = singleprec ? 12750 : 20000;
break;
@ -139,6 +142,7 @@ RawSourceRange RawSource::getRange(bool singleprec)
result.max = 100;
break;
case TELEMETRY_SOURCE_SPEED:
case TELEMETRY_SOURCE_SPEED_MAX:
result.step = singleprec ? 4 : 1;
result.max = singleprec ? 944 : 2000;
if (model && !model->frsky.imperial) {
@ -147,21 +151,26 @@ RawSourceRange RawSource::getRange(bool singleprec)
}
break;
case TELEMETRY_SOURCE_DIST:
case TELEMETRY_SOURCE_DIST_MAX:
result.step = singleprec ? 8 : 1;
result.max = singleprec ? 2040 : 10000;
break;
case TELEMETRY_SOURCE_CELL:
case TELEMETRY_SOURCE_CELL_MIN:
result.step = singleprec ? 0.02 : 0.01;
result.max = 5.1;
result.decimals = 2;
break;
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_CELLS_MIN:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_VFAS_MIN:
result.step = 0.1;
result.max = 25.5;
result.decimals = 1;
break;
case TELEMETRY_SOURCE_CURRENT:
case TELEMETRY_SOURCE_CURRENT_MAX:
result.step = singleprec ? 0.5 : 0.1;
result.max = singleprec ? 127.5 : 200.0;
result.decimals = 1;
@ -171,6 +180,7 @@ RawSourceRange RawSource::getRange(bool singleprec)
result.max = singleprec ? 5100 : 10000;
break;
case TELEMETRY_SOURCE_POWER:
case TELEMETRY_SOURCE_POWER_MAX:
result.step = singleprec ? 5 : 1;
result.max = singleprec ? 1275 : 2000;
break;
@ -222,20 +232,20 @@ QString RawSource::toString()
QObject::tr("A1"), QObject::tr("A2"), QObject::tr("A3"), QObject::tr("A4"),
QObject::tr("Alt"), QObject::tr("Rpm"), QObject::tr("Fuel"), QObject::tr("T1"), QObject::tr("T2"),
QObject::tr("Speed"), QObject::tr("Dist"), QObject::tr("GPS Alt"),
QObject::tr("Cell"), QObject::tr("Cels"), QObject::tr("Vfas"), QObject::tr("Curr"), QObject::tr("Cnsp"), QObject::tr("Powr"),
QObject::tr("Cell"), QObject::tr("Cells"), QObject::tr("Vfas"), QObject::tr("Curr"), QObject::tr("Cnsp"), QObject::tr("Powr"),
QObject::tr("AccX"), QObject::tr("AccY"), QObject::tr("AccZ"),
QObject::tr("HDG "), QObject::tr("VSpd"), QObject::tr("ASpd"), QObject::tr("dTE"),
QObject::tr("A1-"), QObject::tr("A2-"), QObject::tr("A3-"), QObject::tr("A4-"),
QObject::tr("Alt-"), QObject::tr("Alt+"), QObject::tr("Rpm+"), QObject::tr("T1+"), QObject::tr("T2+"), QObject::tr("Spd+"), QObject::tr("Dst+"),
QObject::tr("Cel-"), QObject::tr("Cels-"), QObject::tr("Vfs-"), QObject::tr("Cur+"), QObject::tr("Pwr+"),
QObject::tr("Alt-"), QObject::tr("Alt+"), QObject::tr("Rpm+"), QObject::tr("T1+"), QObject::tr("T2+"), QObject::tr("Speed+"), QObject::tr("Dist+"),
QObject::tr("Cell-"), QObject::tr("Cells-"), QObject::tr("Vfas-"), QObject::tr("Curr+"), QObject::tr("Powr+"),
QObject::tr("ACC"), QObject::tr("Time"),
};
static const QString virtualSwitches[] = {
QObject::tr("LS1"), QObject::tr("LS2"), QObject::tr("LS3"), QObject::tr("LS4"), QObject::tr("LS5"), QObject::tr("LS6"), QObject::tr("LS7"), QObject::tr("LS8"), QObject::tr("LS9"), QObject::tr("LSA"),
QObject::tr("LSB"), QObject::tr("LSC"), QObject::tr("LSD"), QObject::tr("LSE"), QObject::tr("LSF"), QObject::tr("LSG"), QObject::tr("LSH"), QObject::tr("LSI"), QObject::tr("LSJ"), QObject::tr("LSK"),
QObject::tr("LSL"), QObject::tr("LSM"), QObject::tr("LSN"), QObject::tr("LSO"), QObject::tr("LSP"), QObject::tr("LSQ"), QObject::tr("LSR"), QObject::tr("LSS"), QObject::tr("LST"), QObject::tr("LSU"),
QObject::tr("LSV"), QObject::tr("LSW")
QObject::tr("L1"), QObject::tr("L2"), QObject::tr("L3"), QObject::tr("L4"), QObject::tr("L5"), QObject::tr("L6"), QObject::tr("L7"), QObject::tr("L8"), QObject::tr("L9"), QObject::tr("L10"),
QObject::tr("L11"), QObject::tr("L12"), QObject::tr("L13"), QObject::tr("L14"), QObject::tr("L15"), QObject::tr("L16"), QObject::tr("L17"), QObject::tr("L18"), QObject::tr("L19"), QObject::tr("L20"),
QObject::tr("L21"), QObject::tr("L22"), QObject::tr("L23"), QObject::tr("L24"), QObject::tr("L25"), QObject::tr("L26"), QObject::tr("L27"), QObject::tr("L28"), QObject::tr("L29"), QObject::tr("L30"),
QObject::tr("L31"), QObject::tr("L32")
};
if (index<0) {
@ -265,7 +275,7 @@ QString RawSource::toString()
case SOURCE_TYPE_CYC:
return QObject::tr("CYC%1").arg(index+1);
case SOURCE_TYPE_PPM:
return QObject::tr("PPM%1").arg(index+1);
return QObject::tr("TR%1").arg(index+1);
case SOURCE_TYPE_CH:
if (index < GetEepromInterface()->getCapability(Outputs))
return QObject::tr("CH%1%2").arg((index+1)/10).arg((index+1)%10);
@ -312,10 +322,10 @@ QString RawSwitch::toString()
};
static const QString virtualSwitches[] = {
QObject::tr("LS1"), QObject::tr("LS2"), QObject::tr("LS3"), QObject::tr("LS4"), QObject::tr("LS5"), QObject::tr("LS6"), QObject::tr("LS7"), QObject::tr("LS8"), QObject::tr("LS9"), QObject::tr("LSA"),
QObject::tr("LSB"), QObject::tr("LSC"), QObject::tr("LSD"), QObject::tr("LSE"), QObject::tr("LSF"), QObject::tr("LSG"), QObject::tr("LSH"), QObject::tr("LSI"), QObject::tr("LSJ"), QObject::tr("LSK"),
QObject::tr("LSL"), QObject::tr("LSM"), QObject::tr("LSN"), QObject::tr("LSO"), QObject::tr("LSP"), QObject::tr("LSQ"), QObject::tr("LSR"), QObject::tr("LSS"), QObject::tr("LST"), QObject::tr("LSU"),
QObject::tr("LSV"), QObject::tr("LSW")
QObject::tr("L1"), QObject::tr("L2"), QObject::tr("L3"), QObject::tr("L4"), QObject::tr("L5"), QObject::tr("L6"), QObject::tr("L7"), QObject::tr("L8"), QObject::tr("L9"), QObject::tr("L10"),
QObject::tr("L11"), QObject::tr("L12"), QObject::tr("L13"), QObject::tr("L14"), QObject::tr("L15"), QObject::tr("L16"), QObject::tr("L17"), QObject::tr("L18"), QObject::tr("L19"), QObject::tr("L20"),
QObject::tr("L21"), QObject::tr("L22"), QObject::tr("L23"), QObject::tr("L24"), QObject::tr("L25"), QObject::tr("L26"), QObject::tr("L27"), QObject::tr("L28"), QObject::tr("L29"), QObject::tr("L30"),
QObject::tr("L31"), QObject::tr("L32")
};
static const QString multiposPots[] = {
@ -451,7 +461,7 @@ QString LogicalSwitchData::funcToString()
case LS_FN_STICKY:
return QObject::tr("Sticky");
case LS_FN_STAY:
return QObject::tr("Stay");
return QObject::tr("Edge");
default:
return QObject::tr("Unknown");
}
@ -782,115 +792,122 @@ QString FuncSwData::repeatToString()
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
contrast = 25;
vBatWarn = 90;
for (int i=0; i<(NUM_STICKS+C9X_NUM_POTS ); ++i) {
for (int i=0; i<NUM_STICKS+C9X_NUM_POTS; ++i) {
calibMid[i] = 0x200;
calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180;
}
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
potsType[0] = 1;
potsType[1] = 1;
}
templateSetup = g.profile[g.id()].channelOrder();
stickMode = g.profile[g.id()].defaultMode();
QString t_calib=g.profile[g.id()].stickPotCalib();
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
return;
}
else {
QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier();
uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode();
uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=g.profile[g.id()].display();
QString t_BeeperSet=g.profile[g.id()].beeper();
QString t_HapticSet=g.profile[g.id()].haptic();
QString t_SpeakerSet=g.profile[g.id()].speaker();
QString t_CountrySet=g.profile[g.id()].countryCode();
QString t_calib=g.profile[g.id()].stickPotCalib();
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
return;
}
else {
QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier();
uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode();
uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=g.profile[g.id()].display();
QString t_BeeperSet=g.profile[g.id()].beeper();
QString t_HapticSet=g.profile[g.id()].haptic();
QString t_SpeakerSet=g.profile[g.id()].speaker();
QString t_CountrySet=g.profile[g.id()].countryCode();
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=t_calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibMid[i]=byte16;
Byte=t_calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanNeg[i]=byte16;
Byte=t_calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanPos[i]=byte16;
}
for (int i=0; i<4; i++) {
Byte=t_trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
trainer.calib[i]=byte16;
}
currentCalib=t_currentCalib;
vBatCalib=t_vBatCalib;
vBatWarn=t_vBatWarn;
PPM_Multiplier=t_PPM_Multiplier;
stickMode = t_stickMode;
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=t_calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibMid[i]=byte16;
Byte=t_calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanNeg[i]=byte16;
Byte=t_calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanPos[i]=byte16;
}
if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) {
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16);
for (int i=0; i<4; i++) {
Byte=t_trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16);
trainer.calib[i]=byte16;
}
currentCalib=t_currentCalib;
vBatCalib=t_vBatCalib;
vBatWarn=t_vBatWarn;
PPM_Multiplier=t_PPM_Multiplier;
stickMode = t_stickMode;
}
if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) {
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16);
if (ok)
optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16);
if (ok)
contrast=byte8u;
byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16);
if (ok)
backlightBright=byte8u;
byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
beeperMode=(BeeperMode)byte8;
byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
beeperLength=byte8;
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
hapticStrength=byte8u;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;
byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
speakerMode=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
speakerPitch=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
speakerVolume=byte8u;
if (t_CountrySet.length()==6) {
byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
contrast=byte8u;
byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16);
countryCode=byte8u;
byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
backlightBright=byte8u;
byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
beeperMode=(BeeperMode)byte8;
byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
beeperLength=byte8;
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
hapticStrength=byte8u;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;
byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
speakerMode=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
speakerPitch=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
speakerVolume=byte8u;
if (t_CountrySet.length()==6) {
byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
countryCode=byte8u;
byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
imperial=byte8u;
QString chars=t_CountrySet.mid(4,2);
ttsLanguage[0]=chars[0].toAscii();
ttsLanguage[1]=chars[1].toAscii();
}
imperial=byte8u;
QString chars=t_CountrySet.mid(4,2);
ttsLanguage[0]=chars[0].toAscii();
ttsLanguage[1]=chars[1].toAscii();
}
}
}
}
RawSource GeneralSettings::getDefaultSource(unsigned int channel) const
@ -899,6 +916,15 @@ RawSource GeneralSettings::getDefaultSource(unsigned int channel) const
return RawSource(SOURCE_TYPE_STICK, stick_index);
}
void FrSkyData::clear()
{
memset(this, 0, sizeof(FrSkyData));
rssiAlarms[0].clear(2, 45);
rssiAlarms[1].clear(3, 42);
varioSource = 2/*VARIO*/;
blades = 2;
}
ModelData::ModelData()
{
clear();

View file

@ -170,6 +170,19 @@ enum HeliSwashTypes {
extern const char * switches9X[];
extern const char * switchesX9D[];
enum ThrottleSource {
THROTTLE_SOURCE_THR,
THROTTLE_SOURCE_P1,
THROTTLE_SOURCE_P2,
THROTTLE_SOURCE_P3,
THROTTLE_SOURCE_S1 = THROTTLE_SOURCE_P1,
THROTTLE_SOURCE_S2,
THROTTLE_SOURCE_S3,
THROTTLE_SOURCE_LS,
THROTTLE_SOURCE_RS,
THROTTLE_SOURCE_FIRST_CHANNEL,
};
enum TelemetrySource {
TELEMETRY_SOURCE_TX_BATT,
TELEMETRY_SOURCE_TIMER1,
@ -217,6 +230,7 @@ enum TelemetrySource {
TELEMETRY_SOURCE_CELL_MIN,
TELEMETRY_SOURCE_CELLS_MIN,
TELEMETRY_SOURCE_VFAS_MIN,
TELEMETRY_SOURCE_CURRENT_MAX,
TELEMETRY_SOURCE_POWER_MAX,
TELEMETRY_SOURCE_ACC,
TELEMETRY_SOURCE_GPS_TIME,
@ -579,7 +593,6 @@ class MixData {
MixData() { clear(); }
unsigned int destCh; // 1..C9X_NUM_CHNOUT
RawSource srcRaw;
unsigned int srcVariant;
int weight;
RawSwitch swtch;
CurveReference curve; //0=symmetrisch
@ -804,7 +817,7 @@ class FrSkyData {
FrSkyChannelData channels[2];
unsigned int usrProto;
unsigned int imperial;
unsigned int blades;
int blades;
unsigned int voltsSource;
bool altitudeDisplayed;
unsigned int currentSource;
@ -820,7 +833,7 @@ class FrSkyData {
unsigned int storedMah;
int fasOffset;
void clear() { memset(this, 0, sizeof(FrSkyData)); rssiAlarms[0].clear(2, 45); rssiAlarms[1].clear(3, 42); varioSource = 2/*VARIO*/; }
void clear();
};
class MavlinkData {
@ -975,7 +988,6 @@ class RadioData {
// TODO rename FlightPhase to FlightMode
enum Capability {
OwnerName,
FlightPhases,
FlightModesName,
FlightPhasesHaveFades,
@ -1002,7 +1014,6 @@ enum Capability {
ExtraChannels,
ExtraInputs,
ExtendedTrims,
HasInputFilter,
NumCurves,
NumCurvePoints,
OffsetWeight,
@ -1015,11 +1026,7 @@ enum Capability {
Haptic,
HapticLength,
HapticMode,
HasBlInvert,
HasBeeper,
BandgapMeasure,
PotScrolling,
TrainerSwitch,
ModelTrainerEnable,
Timer2ThrTrig,
HasExpoNames,
@ -1034,8 +1041,6 @@ enum Capability {
OptrexDisplay,
PPMExtCtrl,
PPMFrameLength,
gsSwitchMask,
BLonStickMove,
DSM2Indexes,
Telemetry,
TelemetryUnits,
@ -1050,8 +1055,6 @@ enum Capability {
TelemetryCustomScreens,
TelemetryCustomScreensFieldsPerLine,
TelemetryRSSIModel,
TelemetryAlarm,
TelemetryInternalAlarm,
TelemetryTimeshift,
TelemetryMaxMultiplier,
HasAltitudeSel,
@ -1059,9 +1062,6 @@ enum Capability {
HasVarioSink,
HasVariants,
HasFailsafe,
HasPPMSim,
HasCrossTrims,
HasStickScroll,
HasSoundMixer,
NumModules,
PPMCenter,
@ -1084,7 +1084,6 @@ enum Capability {
LuaInputs,
LimitsPer1000,
EnhancedCurves,
TelemetryInternalAlarms,
HasFasOffset,
HasMahPersistent,
MultiposPots,
@ -1373,6 +1372,11 @@ inline unsigned int GetCurrentFirmwareVariant()
return current_firmware_variant.variant;
}
inline int divRoundClosest(const int n, const int d)
{
return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d);
}
#define CHECK_IN_ARRAY(T, index) ((unsigned int)index < (unsigned int)(sizeof(T)/sizeof(T[0])) ? T[(unsigned int)index] : "???")
#endif

View file

@ -213,22 +213,14 @@ int Er9xInterface::getCapability(const Capability capability)
return 1;
case Timer2ThrTrig:
return 1;
case TrainerSwitch:
return 1;
case OffsetWeight:
return 125;
case BandgapMeasure:
return 1;
case PotScrolling:
return 1;
case SoundMod:
return 1;
case SoundPitch:
return 1;
case Haptic:
return 1;
case OwnerName:
return 10;
case Timers:
return 1;
case Pots:
@ -251,10 +243,6 @@ int Er9xInterface::getCapability(const Capability capability)
return 0;
case Simulation:
return 1;
case gsSwitchMask:
return 1;
case BLonStickMove:
return 1;
case Telemetry:
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryUnits:
@ -270,14 +258,9 @@ int Er9xInterface::getCapability(const Capability capability)
case LCDWidth:
return 128;
case VoicesAsNumbers:
case TelemetryInternalAlarm:
case HasPPMSim:
case HasCrossTrims:
case HasStickScroll:
case HasAltitudeSel:
case HasContrast:
case HasVolume:
case HasBlInvert:
case ModelVoice:
case Gvars:
return 7;

View file

@ -255,22 +255,12 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 1;
case Timer2ThrTrig:
return 1;
case TrainerSwitch:
return 1;
case BandgapMeasure:
return 1;
case PotScrolling:
return 1;
case SoundMod:
return 1;
case SoundPitch:
return 1;
case Haptic:
return 1;
case OwnerName:
return 10;
case HasInputFilter:
return 0;
case ModelVoice:
return 1;
case Timers:
@ -297,10 +287,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 0;
case Simulation:
return 1;
case gsSwitchMask:
return 1;
case BLonStickMove:
return 1;
case Telemetry:
return TM_HASTELEMETRY|TM_HASWSHH;
case TelemetryUnits:

View file

@ -219,8 +219,6 @@ int Gruvin9xInterface::getSize(GeneralSettings &settings)
int Gruvin9xInterface::getCapability(const Capability capability)
{
switch (capability) {
case OwnerName:
return 0;
case Mixes:
return G9X_MAX_MIXERS;
case FlightPhases:

View file

@ -681,7 +681,7 @@ t_Open9xArmFrSkyData_v210::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.voltsSource = voltsSource;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.currentSource=currentSource;
c9x.screens[0].type = 1;
for (int i=0; i<4; i++) {
@ -709,7 +709,7 @@ t_Open9xArmFrSkyData_v211::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.voltsSource = voltsSource;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.currentSource=currentSource;
c9x.screens[0].type = 1;
for (int i=0; i<4; i++) {

View file

@ -843,7 +843,7 @@ t_Open9xFrSkyData_v204::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.imperial = imperial;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.screens[0].type = 1;
for (int i=0; i<4; i++)
c9x.screens[0].body.bars[i] = bars[i];
@ -857,7 +857,7 @@ t_Open9xFrSkyData_v205::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.imperial = imperial;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.screens[0].type = 1;
for (int i=0; i<4; i++)
c9x.screens[0].body.bars[i] = bars[i];
@ -873,7 +873,7 @@ t_Open9xFrSkyData_v208::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.voltsSource = voltsSource;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.currentSource=currentSource;
c9x.screens[0].type = 1;
for (int i=0; i<4; i++)
@ -890,7 +890,7 @@ t_Open9xFrSkyData_v210::operator FrSkyData ()
c9x.channels[1] = channels[1];
c9x.usrProto = usrProto;
c9x.voltsSource = voltsSource;
c9x.blades = blades;
c9x.blades = blades+2;
c9x.currentSource=currentSource;
int lines_screen_index = 0;

View file

@ -74,6 +74,7 @@ namespace Open9xGruvin9x {
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/fonts.cpp"
#include "radio/src/audio_avr.cpp"
#include "radio/src/buzzer.cpp"
#include "radio/src/targets/gruvin9x/somo14d.cpp"

View file

@ -73,6 +73,7 @@ namespace Open9xM128 {
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/fonts.cpp"
#include "radio/src/audio_avr.cpp"
#include "radio/src/targets/stock/voice.cpp"
#include "radio/src/telemetry/frsky.cpp"

View file

@ -54,6 +54,7 @@
#define GPS
#define FAI_CHOICE
#define NUM_POTS 3
#define EEPROM_VARIANT 3
#undef min
@ -90,6 +91,7 @@ namespace Open9xSky9x {
#include "radio/src/simpgmspace.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/fonts.cpp"
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/targets/sky9x/audio_driver.cpp"
#include "radio/src/audio_arm.cpp"

View file

@ -23,7 +23,6 @@
#define PCBTARANIS
#define CPUARM
#define HELI
#define TEMPLATES
#define SPLASH
#define FLIGHT_MODES
#define FRSKY
@ -54,6 +53,8 @@
#define LUA_MODEL_SCRIPTS
#define EEPROM_VARIANT 3
#define NUM_POTS 5
#undef min
#undef max
@ -71,7 +72,6 @@ inline int geteepromsize() {
#include "radio/src/protocols/ppm_arm.cpp"
#include "radio/src/protocols/pxx_arm.cpp"
#include "radio/src/protocols/dsm2_arm.cpp"
#include "radio/src/targets/taranis/pwr_driver.cpp"
#include "radio/src/eeprom_common.cpp"
#include "radio/src/eeprom_conversions.cpp"
#include "radio/src/eeprom_rlc.cpp"
@ -102,8 +102,8 @@ inline int geteepromsize() {
#undef SDCARD
#include "radio/src/simpgmspace.cpp"
#define SDCARD
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/fonts.cpp"
#include "radio/src/telemetry/frsky_sport.cpp"
#include "radio/src/targets/taranis/audio_driver.cpp"
#include "radio/src/audio_arm.cpp"
@ -152,9 +152,6 @@ int16_t g_anas[NUM_STICKS+5];
uint16_t anaIn(uint8_t chan)
{
if (chan == 8)
return 1800;
else
return g_anas[chan];
}

View file

@ -11,7 +11,7 @@
#define HAS_PERSISTENT_TIMERS(board) (IS_ARM(board) || board == BOARD_GRUVIN9X)
#define HAS_LARGE_LCD(board) IS_TARANIS(board)
#define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256)
#define MAX_POTS(board, version) (IS_TARANIS(board) ? (version>=216 ? 5 : 4) : 3)
#define MAX_POTS(board) (IS_TARANIS(board) ? 5 : 3)
#define MAX_SWITCHES(board) (IS_TARANIS(board) ? 8 : 7)
#define MAX_SWITCHES_POSITION(board) (IS_TARANIS(board) ? 22 : 9)
#define MAX_ROTARY_ENCODERS(board) (board==BOARD_GRUVIN9X ? 2 : (board==BOARD_SKY9X ? 1 : 0))
@ -172,8 +172,11 @@ class SourcesConversionTable: public ConversionTable {
}
}
for (int i=0; i<4+MAX_POTS(board, version); i++)
for (int i=0; i<4+MAX_POTS(board); i++) {
if (IS_TARANIS(board) && version < 216 && i==6)
continue;
addConversion(RawSource(SOURCE_TYPE_STICK, i), val++);
}
for (int i=0; i<MAX_ROTARY_ENCODERS(board); i++)
addConversion(RawSource(SOURCE_TYPE_ROTARY_ENCODER, 0), val++);
@ -291,6 +294,32 @@ class SourcesConversionTable: public ConversionTable {
}
};
ThrottleSourceConversionTable::ThrottleSourceConversionTable(BoardEnum board, unsigned int version)
{
int val=0;
addConversion(THROTTLE_SOURCE_THR, val++);
if (IS_TARANIS(board)) {
addConversion(THROTTLE_SOURCE_S1, val++);
addConversion(THROTTLE_SOURCE_S2, val++);
if (version >= 216)
addConversion(THROTTLE_SOURCE_S3, val++);
addConversion(THROTTLE_SOURCE_LS, val++);
addConversion(THROTTLE_SOURCE_RS, val++);
}
else {
addConversion(THROTTLE_SOURCE_P1, val++);
addConversion(THROTTLE_SOURCE_P2, val++);
addConversion(THROTTLE_SOURCE_P3, val++);
}
for (int i=0; i<MAX_CHANNELS(board, version); i++) {
addConversion(THROTTLE_SOURCE_FIRST_CHANNEL+i, val++);
}
}
template <int N>
class SwitchField: public ConversionField< SignedField<N> > {
public:
@ -384,8 +413,12 @@ class TelemetrySourcesConversionTable: public ConversionTable {
addConversion(1+TELEMETRY_SOURCE_T2_MAX, val++);
addConversion(1+TELEMETRY_SOURCE_SPEED_MAX, val++);
addConversion(1+TELEMETRY_SOURCE_DIST_MAX, val++);
addConversion(1+TELEMETRY_SOURCE_CELL_MIN, val++);
addConversion(1+TELEMETRY_SOURCE_VFAS_MIN, val++);
if (version >= 216) {
addConversion(1+TELEMETRY_SOURCE_CELL_MIN, val++);
addConversion(1+TELEMETRY_SOURCE_CELLS_MIN, val++);
addConversion(1+TELEMETRY_SOURCE_VFAS_MIN, val++);
}
addConversion(1+TELEMETRY_SOURCE_CURRENT_MAX, val++);
addConversion(1+TELEMETRY_SOURCE_POWER_MAX, val++);
if (IS_ARM(board) && version >= 216) {
for (int i=0; i<5; i++)
@ -697,32 +730,36 @@ void concatGvarParam(int & gvar, const int _gvar, const unsigned int _gvarParam,
}
}
void exportGvarParam(const int gvar, int & _gvar)
void exportGvarParam(const int gvar, int & _gvar, int version)
{
int GV1 = (version >= 216 ? 4096 : 512);
if (gvar < -10000) {
_gvar = 512 + gvar + 10000;
_gvar = GV1 + gvar + 10000;
}
else if (gvar > 10000) {
_gvar = 512 + gvar - 10001;
_gvar = GV1 + gvar - 10001;
}
else {
_gvar = gvar;
}
}
void importGvarParam(int & gvar, const int _gvar)
void importGvarParam(int & gvar, const int _gvar, int version)
{
if (_gvar >= 512) {
gvar = 10001 + _gvar - 512;
int GV1 = (version >= 216 ? 4096 : 512);
if (_gvar >= GV1) {
gvar = 10001 + _gvar - GV1;
}
else if (_gvar >= 512-5) {
gvar = -10000 + _gvar - 512;
else if (_gvar >= GV1-9) {
gvar = -10000 + _gvar - GV1;
}
else if (_gvar < -512) {
gvar = -10000 + _gvar + 513;
else if (_gvar < -GV1) {
gvar = -10000 + _gvar + GV1 + 1;
}
else if (_gvar < -512+5) {
gvar = 10000 + _gvar + 513;
else if (_gvar < -GV1+9) {
gvar = 10000 + _gvar + GV1 + 1;
}
else {
gvar = _gvar;
@ -744,12 +781,14 @@ class MixField: public TransformedField {
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new UnsignedField<8>((unsigned int &)mix.mltpx));
internalField.Append(new UnsignedField<2>((unsigned int &)mix.mltpx));
internalField.Append(new UnsignedField<1>((unsigned int &)mix.carryTrim));
internalField.Append(new SpareBitsField<5>());
internalField.Append(new SignedField<16>(_weight));
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
internalField.Append(new CurveReferenceField(mix.curve, board, version));
internalField.Append(new UnsignedField<4>(mix.mixWarn));
internalField.Append(new UnsignedField<4>(mix.srcVariant));
internalField.Append(new SpareBitsField<4>());
internalField.Append(new UnsignedField<8>(mix.delayUp));
internalField.Append(new UnsignedField<8>(mix.delayDown));
internalField.Append(new UnsignedField<8>(mix.speedUp));
@ -759,6 +798,26 @@ class MixField: public TransformedField {
internalField.Append(new ZCharField<8>(mix.name));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board) && version >= 216) {
internalField.Append(new UnsignedField<4>(_destCh));
internalField.Append(new UnsignedField<4>(mix.mixWarn));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new BoolField<1>(_curveMode));
internalField.Append(new BoolField<1>(mix.noExpo));
internalField.Append(new SignedField<3>(mix.carryTrim));
internalField.Append(new UnsignedField<2>((unsigned int &)mix.mltpx));
internalField.Append(new SpareBitsField<1>());
internalField.Append(new SignedField<16>(_weight));
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
internalField.Append(new SignedField<8>(_curveParam));
internalField.Append(new UnsignedField<8>(mix.delayUp));
internalField.Append(new UnsignedField<8>(mix.delayDown));
internalField.Append(new UnsignedField<8>(mix.speedUp));
internalField.Append(new UnsignedField<8>(mix.speedDown));
internalField.Append(new SourceField<8>(mix.srcRaw, board, version, FLAG_NOTELEMETRY));
internalField.Append(new SignedField<16>(_offset));
internalField.Append(new ZCharField<6>(mix.name));
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
@ -775,7 +834,7 @@ class MixField: public TransformedField {
internalField.Append(new SignedField<8>(_curveParam));
if (version >= 214) {
internalField.Append(new UnsignedField<4>(mix.mixWarn));
internalField.Append(new UnsignedField<4>(mix.srcVariant));
internalField.Append(new SpareBitsField<4>());
}
else {
internalField.Append(new UnsignedField<8>(mix.mixWarn));
@ -865,9 +924,9 @@ class MixField: public TransformedField {
}
if (IS_ARM(board)) {
exportGvarParam(mix.weight, _weight);
exportGvarParam(mix.weight, _weight, version);
if (version >= 214)
exportGvarParam(mix.sOffset, _offset);
exportGvarParam(mix.sOffset, _offset, version);
else
splitGvarParam(mix.sOffset, _offset, _offsetMode, board, version);
}
@ -879,7 +938,7 @@ class MixField: public TransformedField {
virtual void afterImport()
{
if (IS_TARANIS(board) || version < 216) {
if (IS_TARANIS(board) && version < 216) {
if (mix.srcRaw.type == SOURCE_TYPE_STICK && mix.srcRaw.index < NUM_STICKS) {
if (!mix.noExpo) {
mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, mix.srcRaw.index, model);
@ -900,9 +959,9 @@ class MixField: public TransformedField {
}
if (IS_ARM(board)) {
importGvarParam(mix.weight, _weight);
importGvarParam(mix.weight, _weight, version);
if (version >= 214)
importGvarParam(mix.sOffset, _offset);
importGvarParam(mix.sOffset, _offset, version);
else
concatGvarParam(mix.sOffset, _offset, _offsetMode, board, version);
}
@ -910,6 +969,13 @@ class MixField: public TransformedField {
concatGvarParam(mix.weight, _weight, _weightMode, board, version);
concatGvarParam(mix.sOffset, _offset, _offsetMode, board, version);
}
if (IS_TARANIS(board) && version < 216) {
if (mix.sOffset >= -500 && mix.sOffset <= 500 && mix.weight >= -500 && mix.weight <= 500) {
mix.sOffset = divRoundClosest(mix.sOffset * mix.weight, 100);
}
if (mix.carryTrim < 0) mix.carryTrim = 0;
}
}
protected:
@ -938,17 +1004,28 @@ class InputField: public TransformedField {
{
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0));
internalField.Append(new UnsignedField<16>(expo.scale));
internalField.Append(new UnsignedField<16>(expo.scale, "Scale"));
internalField.Append(new UnsignedField<8>(expo.chn, "Channel"));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
internalField.Append(new UnsignedField<16>(expo.phases));
internalField.Append(new SignedField<8>(_weight, "Weight"));
internalField.Append(new SignedField<8>(expo.carryTrim));
internalField.Append(new SignedField<6>(expo.carryTrim, "CarryTrim"));
internalField.Append(new UnsignedField<2>(expo.mode, "Mode"));
internalField.Append(new ZCharField<8>(expo.name));
internalField.Append(new SignedField<8>(expo.offset, "Offset"));
internalField.Append(new CurveReferenceField(expo.curve, board, version));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board) && version >= 216) {
internalField.Append(new UnsignedField<2>(expo.mode, "Mode"));
internalField.Append(new UnsignedField<4>(expo.chn, "Channel"));
internalField.Append(new BoolField<2>(_curveMode));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
internalField.Append(new UnsignedField<16>(expo.phases, "Phases"));
internalField.Append(new SignedField<8>(_weight, "Weight"));
internalField.Append(new ZCharField<6>(expo.name));
internalField.Append(new SignedField<8>(_curveParam));
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(expo.mode, "Mode"));
internalField.Append(new UnsignedField<8>(expo.chn, "Channel"));
@ -1008,9 +1085,11 @@ class InputField: public TransformedField {
virtual void afterImport()
{
if (IS_TARANIS(board) && version < 216) {
if (expo.mode) {
expo.srcRaw = RawSource(SOURCE_TYPE_STICK, expo.chn);
if (IS_TARANIS(board)) {
if (version < 216) {
if (expo.mode) {
expo.srcRaw = RawSource(SOURCE_TYPE_STICK, expo.chn);
}
}
}
@ -1041,7 +1120,7 @@ class LimitField: public StructField {
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
StructField("Limit")
{
if (IS_ARM(board) && version >= 216) {
if (IS_TARANIS(board) && version >= 216) {
Append(new ConversionField< SignedField<16> >(limit.min, +1000));
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
}
@ -1808,7 +1887,7 @@ class AvrCustomFunctionField: public TransformedField {
internalField.Append(new UnsignedField<5>(_union_param));
internalField.Append(new UnsignedField<1>(_active));
}
if (version >= 213) {
else if (version >= 213) {
internalField.Append(new SwitchField<8>(fn.swtch, board, version));
internalField.Append(new UnsignedField<3>(_union_param));
internalField.Append(new ConversionField< UnsignedField<5> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function")));
@ -2069,7 +2148,7 @@ class FrskyField: public StructField {
else {
Append(new UnsignedField<8>(frsky.voltsSource));
}
Append(new UnsignedField<8>(frsky.blades));
Append(new ConversionField< SignedField<8> >(frsky.blades, -2));
Append(new UnsignedField<8>(frsky.currentSource));
Append(new UnsignedField<1>(frsky.screens[0].type));
@ -2111,12 +2190,12 @@ class FrskyField: public StructField {
Append(new UnsignedField<1>(frsky.channels[i].alarms[j].greater));
Append(new UnsignedField<2>(frsky.channels[i].multiplier, 0, 3, "Multiplier"));
}
Append(new UnsignedField<2>(frsky.usrProto));
Append(new UnsignedField<2>(frsky.blades));
Append(new UnsignedField<2>(frsky.usrProto, "USR Proto"));
Append(new ConversionField< UnsignedField<2> >((unsigned int &)frsky.blades, -2));
Append(new UnsignedField<1>(frsky.screens[0].type));
Append(new UnsignedField<1>(frsky.screens[1].type));
Append(new UnsignedField<2>(frsky.voltsSource));
Append(new SignedField<4>(frsky.varioMin));
Append(new UnsignedField<2>(frsky.voltsSource, "Volts Source"));
Append(new SignedField<4>(frsky.varioMin, "Vario Min"));
Append(new SignedField<4>(frsky.varioMax));
for (int i=0; i<2; i++) {
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI level"));
@ -2165,7 +2244,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
board(board),
version(version),
variant(variant),
protocolsConversionTable(board)
protocolsConversionTable(board),
throttleSourceConversionTable(board, version)
{
sprintf(name, "Model %s", modelData.name);
@ -2275,7 +2355,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength));
}
internalField.Append(new UnsignedField<8>(modelData.thrTraceSrc));
internalField.Append(new ConversionField< UnsignedField<8> >(modelData.thrTraceSrc, &throttleSourceConversionTable, "Throttle Source"));
if (!afterrelease21March2013) {
internalField.Append(new UnsignedField<8>(modelData.modelId));
@ -2425,7 +2505,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
generalData(generalData),
board(board),
version(version),
inputsCount(4 + MAX_POTS(board, version))
inputsCount(4 + MAX_POTS(board))
{
generalData.version = version;
generalData.variant = variant;
@ -2442,12 +2522,18 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
}
}
else {
for (int i=0; i<inputsCount; i++)
internalField.Append(new SignedField<16>(generalData.calibMid[i]));
for (int i=0; i<inputsCount; i++)
internalField.Append(new SignedField<16>(generalData.calibSpanNeg[i]));
for (int i=0; i<inputsCount; i++)
internalField.Append(new SignedField<16>(generalData.calibSpanPos[i]));
for (int i=0; i<inputsCount; i++) {
if (!IS_TARANIS(board) || i!=6)
internalField.Append(new SignedField<16>(generalData.calibMid[i]));
}
for (int i=0; i<inputsCount; i++) {
if (!IS_TARANIS(board) || i!=6)
internalField.Append(new SignedField<16>(generalData.calibSpanNeg[i]));
}
for (int i=0; i<inputsCount; i++) {
if (!IS_TARANIS(board) || i!=6)
internalField.Append(new SignedField<16>(generalData.calibSpanPos[i]));
}
}
internalField.Append(new UnsignedField<16>(chkSum));
@ -2549,8 +2635,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
}
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(generalData.hw_uartMode));
for (int i=0; i<8; i++) {
internalField.Append(new UnsignedField<1>(generalData.potsType[i]));
for (int i=0; i<4; i++) {
internalField.Append(new UnsignedField<2>(potsType[i]));
}
}
}
@ -2569,6 +2655,11 @@ void OpenTxGeneralData::beforeExport()
sum += generalData.calibSpanPos[i];
if (++count == 12) break;
}
for (int i=0; i<4; i++) {
potsType[i] = generalData.potsType[i];
if (i<2 && potsType[i] == 1)
potsType[i] = 0;
}
}
else {
for (int i=0; i<inputsCount; i++)
@ -2581,4 +2672,8 @@ void OpenTxGeneralData::beforeExport()
void OpenTxGeneralData::afterImport()
{
for (int i=0; i<4; i++) {
if (i<2 && generalData.potsType[i] == 0)
generalData.potsType[i] = 1;
}
}

View file

@ -65,6 +65,7 @@ class OpenTxGeneralData: public TransformedField {
unsigned int version;
int inputsCount;
unsigned int chkSum;
unsigned int potsType[4];
};
class ProtocolsConversionTable: public ConversionTable
@ -102,6 +103,12 @@ class ProtocolsConversionTable: public ConversionTable
}
};
class ThrottleSourceConversionTable: public ConversionTable {
public:
ThrottleSourceConversionTable(BoardEnum board, unsigned int version);
};
class ChannelsConversionTable: public ConversionTable
{
public:
@ -133,6 +140,7 @@ class OpenTxModelData: public TransformedField {
char name[256];
int subprotocols[C9X_NUM_MODULES+1/*trainer*/];
ProtocolsConversionTable protocolsConversionTable;
ThrottleSourceConversionTable throttleSourceConversionTable;
ChannelsConversionTable channelsConversionTable;
};

View file

@ -451,8 +451,6 @@ int OpenTxInterface::getSize(GeneralSettings &settings)
int OpenTxInterface::getCapability(const Capability capability)
{
switch (capability) {
case OwnerName:
return 0;
case ModelImage:
if (IS_TARANIS(board))
return 1;
@ -493,6 +491,8 @@ int OpenTxInterface::getCapability(const Capability capability)
case FlightModesName:
case GvarsName:
return (IS_TARANIS(board) ? 10 : 6);
case HasChNames:
return (IS_TARANIS(board) ? 1 : 0);
case GvarsInCS:
case HasFAIMode:
return 1;
@ -594,7 +594,7 @@ int OpenTxInterface::getCapability(const Capability capability)
case MixesWithoutExpo:
return 1;
case NumCurves:
return (IS_ARM(board) ? 16 : 8);
return (IS_TARANIS(board) ? 32 : (IS_ARM(board) ? 16 : 8));
case HasMixerNames:
return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false);
case HasExpoNames:
@ -619,8 +619,6 @@ int OpenTxInterface::getCapability(const Capability capability)
return 1;
case TelemetryRSSIModel:
return 1;
case TelemetryAlarm:
return 0;
case TelemetryTimeshift:
return 1;
case TelemetryMaxMultiplier:
@ -676,8 +674,6 @@ int OpenTxInterface::getCapability(const Capability capability)
case LuaInputs:
case LimitsPer1000:
case EnhancedCurves:
case TelemetryInternalAlarms:
return IS_TARANIS(board);
case HasFasOffset:
return (IS_STOCK(board) ? false : true);
case HasMahPersistent:

View file

@ -53,6 +53,8 @@
#define EEPROM_VARIANT SIMU_STOCK_VARIANTS
#define GAUGES
#define NUM_POTS 3
#undef min
#undef max
@ -78,6 +80,7 @@ namespace Open9x {
#include "radio/src/telemetry/frsky.cpp"
#include "radio/src/templates.cpp"
#include "radio/src/translations.cpp"
#include "radio/src/fonts.cpp"
#include "radio/src/targets/stock/voice.cpp"
#include "radio/src/buzzer.cpp"
#include "radio/src/translations/tts_en.cpp"

View file

@ -145,8 +145,6 @@ int Th9xInterface::getCapability(const Capability capability)
switch (capability) {
case Mixes:
return TH9X_MAX_MIXERS;
case OwnerName:
return 0;
case Timers:
return 1;
case Pots:
@ -168,8 +166,6 @@ int Th9xInterface::getCapability(const Capability capability)
case Simulation:
return 1;
case HasContrast:
case HasInputFilter:
return 1;
case CSFunc:
return 13;
case SlowScale:

View file

@ -13,6 +13,7 @@
* GNU General Public License for more details.
*
*/
#include <QtGui>
#include "hexinterface.h"
#include "splash.h"
@ -20,192 +21,77 @@
int getFileType(const QString &fullFileName)
{
if(QFileInfo(fullFileName).suffix().toUpper()=="HEX") return FILE_TYPE_HEX;
if(QFileInfo(fullFileName).suffix().toUpper()=="BIN") return FILE_TYPE_BIN;
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPM") return FILE_TYPE_EEPM;
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPE") return FILE_TYPE_EEPE;
if(QFileInfo(fullFileName).suffix().toUpper()=="XML") return FILE_TYPE_XML;
return 0;
QString suffix = QFileInfo(fullFileName).suffix().toUpper();
if (suffix == "HEX")
return FILE_TYPE_HEX;
else if (suffix == "BIN")
return FILE_TYPE_BIN;
else if (suffix == "EEPM")
return FILE_TYPE_EEPM;
else if (suffix == "EEPE")
return FILE_TYPE_EEPE;
else if (suffix == "XML")
return FILE_TYPE_XML;
else
return 0;
}
FlashInterface::FlashInterface(QString fileName)
FlashInterface::FlashInterface(QString fileName):
flash(MAX_FSIZE, 0),
flash_size(0),
isValidFlag(false)
{
char * temp = (char *)malloc(MAX_FSIZE);
date = "";
time = "";
svn = "";
build = "";
isValidFlag = true;
QFile file(fileName);
flash_size=0;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
isValidFlag = false;
}
else {
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QTextStream inputStream(&file);
flash_size = HexInterface(inputStream).load((uint8_t *)temp, MAX_FSIZE);
flash_size = HexInterface(inputStream).load((uint8_t *)flash.data(), MAX_FSIZE);
file.close();
inputStream.reset();
if (flash_size == 0) {
QFile file(fileName);
file.open(QIODevice::ReadOnly);
char * bin_flash = (char *)malloc(MAX_FSIZE);
flash_size = file.read(bin_flash, MAX_FSIZE);
flash = QByteArray(bin_flash, flash_size);
free(bin_flash);
}
else {
flash = QByteArray(temp, flash_size);
flash_size = file.read((char *)flash.data(), MAX_FSIZE);
}
if (flash_size > 0) {
SeekSvn();
SeekDate();
SeekTime();
SeekBuild();
svn = seekLabel(SVN_MARK);
version = seekLabel(VERS_MARK);
date = seekLabel(DATE_MARK);
time = seekLabel(TIME_MARK);
eeprom = seekLabel(EEPR_MARK);
SeekSplash();
}
else {
isValidFlag = false;
isValidFlag = true;
}
}
free(temp);
}
QString FlashInterface::getDate(void)
QString FlashInterface::seekString(const QString & string)
{
return date;
}
QString result = "";
QString FlashInterface::getTime(void)
{
return time;
}
QString FlashInterface::getSvn(void)
{
return svn;
}
QString FlashInterface::getBuild(void)
{
return build;
}
int FlashInterface::getSize()
{
return flash_size;
}
void FlashInterface::SeekSvn(void)
{
int i, start = -1, end = -1;
start = flash.indexOf(QString(SVN_MARK));
int start = flash.indexOf(string);
if (start > 0) {
start += QString(SVN_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
start += string.length();
int end = -1;
for (int i=start; i<start+20; i++) {
char c = flash.at(i);
if (c == '\0' || c == '\036') {
end = i;
break;
}
}
if (end > 0) {
svn = QString(flash.mid(start, (end - start))).trimmed();
}
else {
svn = QString("");
result = flash.mid(start, (end - start)).trimmed();
}
}
return result;
}
void FlashInterface::SeekDate(void)
QString FlashInterface::seekLabel(const QString & label)
{
int i, start = -1, end = -1, startsvn=0;
startsvn = flash.indexOf(QString(SVN_MARK));
if (startsvn>0) {
start = flash.indexOf(QString(DATE_MARK),startsvn);
} else {
start = flash.indexOf(QString(DATE_MARK));
}
if (start > 0) {
start += QString(DATE_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
date = QString(flash.mid(start, (end - start))).trimmed();
}
else {
date = QString("");
}
}
}
QString result = seekString(label + "\037\033:");
if (!result.isEmpty())
return result;
void FlashInterface::SeekTime(void)
{
int i, start = -1, end = -1, startsvn=0;
startsvn = flash.indexOf(QString(SVN_MARK));
if (startsvn>0) {
start = flash.indexOf(QString(TIME_MARK),startsvn);
} else {
start = flash.indexOf(QString(TIME_MARK));
}
if (start > 0) {
start += QString(TIME_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
time = QString(flash.mid(start, (end - start))).trimmed();
}
else {
time = QString("");
}
}
}
void FlashInterface::SeekBuild(void)
{
int i, start = -1, end = -1;
start = flash.indexOf(QString(BLD_MARK));
if (start > 0) {
start += QString(BLD_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
build = QString(flash.mid(start, (end - start))).trimmed();
}
else {
build = QString("");
}
}
else {
start = flash.indexOf(QString(VAR_MARK));
if (start > 0) {
start += QString(VAR_MARK).length();
for (i = start; i < (start + 20); i++) {
if (flash.at(i) == 0) {
end = i;
break;
}
}
if (end > 0) {
build = QString(flash.mid(start, (end - start))).trimmed();
}
else {
build = QString("");
}
}
}
return seekString(label + ":");
}
void FlashInterface::SeekSplash(void)

View file

@ -14,6 +14,7 @@
#ifndef FLASHINTERFACE_H
#define FLASHINTERFACE_H
#include <QDialog>
#include <QtGui>
#include <inttypes.h>
@ -32,12 +33,12 @@
#define ERSKY9X_SPS "SPS"
#define ERSKY9X_SPE "SPE"
#define ERSKY9X_OFFSET (7)
#define VERS_MARK "VERS:"
#define SVN_MARK "SVN:"
#define DATE_MARK "DATE:"
#define TIME_MARK "TIME:"
#define BLD_MARK "BLD:"
#define VAR_MARK "EEPR:"
#define VERS_MARK "VERS"
#define SVN_MARK "SVN"
#define DATE_MARK "DATE"
#define TIME_MARK "TIME"
#define BLD_MARK "BLD"
#define EEPR_MARK "EEPR"
#define FILE_TYPE_BIN 1
#define FILE_TYPE_HEX 2
@ -49,48 +50,46 @@ int getFileType(const QString &fullFileName);
class FlashInterface
{
public:
FlashInterface(QString filename);
QString getDate();
QString getTime();
QString getSvn();
int getSize();
QString getBuild();
QImage getSplash();
bool setSplash(const QImage & newsplash);
bool hasSplash();
int getSplashWidth();
uint getSplashHeight();
uint getSplashColors();
QImage::Format getSplashFormat();
uint saveFlash(QString fileName);
bool isValid();
public:
FlashInterface(QString filename);
inline QString getDate() { return date; }
inline QString getTime() { return time; }
inline QString getSvn() { return svn; }
int getSize() { return flash_size; }
inline QString getVersion() { return version; }
inline QString getEEprom() { return eeprom; }
QImage getSplash();
bool setSplash(const QImage & newsplash);
bool hasSplash();
int getSplashWidth();
uint getSplashHeight();
uint getSplashColors();
QImage::Format getSplashFormat();
uint saveFlash(QString fileName);
bool isValid();
private:
QByteArray flash;
void SeekVer();
void SeekSvn();
void SeekDate();
void SeekTime();
void SeekBuild();
void SeekSplash();
QString filename;
QString date;
QString time;
QString svn;
QString build;
QByteArray splash;
uint splash_offset;
uint splash_type;
uint splash_size;
uint splash_width;
uint splash_height;
uint splash_colors;
QImage::Format splash_format;
uint flash_size;
protected:
bool isValidFlag;
private:
QByteArray flash;
QString seekString(const QString & string);
QString seekLabel(const QString & label);
void SeekSplash();
QString filename;
QString date;
QString time;
QString svn;
QString version;
QString eeprom;
QByteArray splash;
uint splash_offset;
uint splash_type;
uint splash_size;
uint splash_width;
uint splash_height;
uint splash_colors;
QImage::Format splash_format;
uint flash_size;
bool isValidFlag;
};
#endif /* FLASHINTERFACE_H */

View file

@ -2,6 +2,7 @@
#include "ui_generaledit.h"
#include "helpers.h"
#include "appdata.h"
#include <QDateTime>
#include <QtGui>
#define BIT_WARN_THR ( 0x01 )
@ -78,9 +79,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
}
}
}
QRegExp rx(CHAR_FOR_NAMES_REGEX);
ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this));
switchDefPosEditLock=true;
populateBacklightCB(ui->backlightswCB, g_eeGeneral.backlightMode);
bool voice = current_firmware_variant.id.contains("voice");
@ -116,18 +115,21 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->bgVolume_label->hide();
ui->wavVolume_SL->hide();
ui->wavVolume_label->hide();
ui->varioP0_label->hide();
ui->varioP0_SB->hide();
ui->varioPMax_label->hide();
ui->varioPMax_SB->hide();
ui->varioR0_label->hide();
ui->varioR0_SB->hide();
} else {
ui->beepVolume_SL->setValue(g_eeGeneral.beepVolume);
ui->varioVolume_SL->setValue(g_eeGeneral.varioVolume);
ui->bgVolume_SL->setValue(g_eeGeneral.backgroundVolume);
ui->wavVolume_SL->setValue(g_eeGeneral.wavVolume);
}
if (!GetEepromInterface()->getCapability(HasBlInvert)) {
ui->blinvert_cb->hide();
ui->blinvert_label->hide();
} else {
ui->blinvert_cb->setChecked(g_eeGeneral.blightinv);
ui->varioP0_SB->setValue(700+(g_eeGeneral.varioPitch*10));
updateVarioPitchRange();
ui->varioPMax_SB->setValue(700+(g_eeGeneral.varioPitch*10)+1000+(g_eeGeneral.varioRange*10));
ui->varioR0_SB->setValue(500+(g_eeGeneral.varioRepeat*10));
}
if (!GetEepromInterface()->getCapability(HasFAIMode)) {
ui->faimode_CB->hide();
@ -136,35 +138,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
else {
ui->faimode_CB->setChecked(g_eeGeneral.fai);
}
ui->ownerNameLE->setText(g_eeGeneral.ownerName);
if (!GetEepromInterface()->getCapability(OwnerName)) {
ui->ownerNameLE->setDisabled(true);
ui->label_ownerName->hide();
ui->ownerNameLE->hide();
ui->hideNameOnSplashChkB->setDisabled(true);
ui->hideNameOnSplashChkB->hide();
ui->label_hideOwnerName->hide();
}
if (!GetEepromInterface()->getCapability(HasInputFilter)) {
ui->inputfilterCB->hide();
ui->inputfilterLabel->hide();
}
if (!GetEepromInterface()->getCapability(HasStickScroll)) {
ui->StickScrollChkB->hide();
ui->StickScrollLB->hide();
}
if (!GetEepromInterface()->getCapability(TelemetryInternalAlarm)) {
ui->frskyintalarmChkB->hide();
ui->label_frskyintalarm->hide();
}
if (!GetEepromInterface()->getCapability(HasCrossTrims)) {
ui->crosstrimChkB->hide();
ui->crosstrimLB->hide();
}
if (!GetEepromInterface()->getCapability(HasPPMSim)) {
ui->PPMSimLB->hide();
ui->PPMSimChkB->hide();
}
if (!GetEepromInterface()->getCapability( HasPxxCountry)) {
ui->countrycode_label->hide();
ui->countrycode_CB->hide();
@ -212,9 +185,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->label_CurrentCalib->hide();
}
if (GetEepromInterface()->getCapability(TelemetryRSSIModel) ) {
ui->tabWidget->removeTab(2);
}
ui->tabWidget->setCurrentIndex(0);
if (!GetEepromInterface()->getCapability(SoundMod)) {
@ -234,14 +204,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->hapticStrengthSB->hide();
ui->label_hapticStrengthSB->hide();
}
if (GetEepromInterface()->getCapability(PerModelTimers)) {
ui->beepCountDownChkB->hide();
ui->beepFlashChkB->hide();
ui->beepMinuteChkB->hide();
ui->label_timers->hide();
}
if (!GetEepromInterface()->getCapability(HapticMode)) {
ui->hapticmodeCB->setDisabled(true);
@ -249,66 +211,6 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->label_hapticmode->hide();
}
if (!GetEepromInterface()->getCapability(BandgapMeasure)) {
ui->BandGapEnableChkB->setDisabled(true);
ui->BandGapEnableChkB->hide();
ui->label_BandGapEnable->hide();
}
if (!GetEepromInterface()->getCapability(PotScrolling)) {
ui->PotScrollEnableChkB->setDisabled(true);
ui->PotScrollEnableChkB->hide();
ui->label_PotScrollEnable->hide();
}
if (!GetEepromInterface()->getCapability(TrainerSwitch)) {
ui->label_switch->hide();
ui->swtchCB_1->setDisabled(true);
ui->swtchCB_2->setDisabled(true);
ui->swtchCB_3->setDisabled(true);
ui->swtchCB_4->setDisabled(true);
ui->swtchCB_1->hide();
ui->swtchCB_2->hide();
ui->swtchCB_3->hide();
ui->swtchCB_4->hide();
} else {
populateSwitchCB(ui->swtchCB_1,g_eeGeneral.trainer.mix[0].swtch);
populateSwitchCB(ui->swtchCB_2,g_eeGeneral.trainer.mix[1].swtch);
populateSwitchCB(ui->swtchCB_3,g_eeGeneral.trainer.mix[2].swtch);
populateSwitchCB(ui->swtchCB_4,g_eeGeneral.trainer.mix[3].swtch);
}
if (!GetEepromInterface()->getCapability(BLonStickMove)) {
ui->blOnStickMoveSB->setDisabled(true);
ui->blOnStickMoveSB->hide();
ui->label_blOnStickMove->hide();
} else {
ui->blOnStickMoveSB->setValue(g_eeGeneral.lightOnStickMove*5);
}
if (!GetEepromInterface()->getCapability(gsSwitchMask)) {
ui->swAILChkB->setDisabled(true);
ui->swELEChkB->setDisabled(true);
ui->swTHRChkB->setDisabled(true);
ui->swRUDChkB->setDisabled(true);
ui->swGEAChkB->setDisabled(true);
ui->swID0ChkB->setDisabled(true);
ui->swID1ChkB->setDisabled(true);
ui->swID2ChkB->setDisabled(true);
ui->swAILChkB->hide();
ui->swELEChkB->hide();
ui->swTHRChkB->hide();
ui->swRUDChkB->hide();
ui->swGEAChkB->hide();
ui->swID0ChkB->hide();
ui->swID1ChkB->hide();
ui->swID2ChkB->hide();
this->layout()->removeItem(ui->switchMaskLayout);
} else {
setSwitchDefPos();
}
if (!GetEepromInterface()->getCapability(TelemetryAlarm)) {
ui->telalarmsChkB->hide();
ui->label_telalarms->hide();
}
int renumber=GetEepromInterface()->getCapability(RotaryEncoders);
if (renumber==0) {
ui->re_label->hide();
@ -316,28 +218,15 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
} else {
populateRotEncCB(ui->re_CB, g_eeGeneral.reNavigation, renumber);
}
ui->telalarmsChkB->setChecked(g_eeGeneral.enableTelemetryAlarm);
ui->PotScrollEnableChkB->setChecked(!g_eeGeneral.disablePotScroll);
ui->BandGapEnableChkB->setChecked(!g_eeGeneral.disableBG);
ui->contrastSB->setValue(g_eeGeneral.contrast);
ui->battwarningDSB->setValue((double)g_eeGeneral.vBatWarn/10);
ui->backlightautoSB->setValue(g_eeGeneral.backlightDelay*5);
ui->inactimerSB->setValue(g_eeGeneral.inactivityTimer);
ui->crosstrimChkB->setChecked(g_eeGeneral.crosstrim);
ui->frskyintalarmChkB->setChecked(g_eeGeneral.frskyinternalalarm);
ui->StickScrollChkB->setChecked(g_eeGeneral.stickScroll);
ui->PPMSimChkB->setChecked(g_eeGeneral.enablePpmsim);
ui->inputfilterCB->setCurrentIndex(g_eeGeneral.filterInput);
ui->memwarnChkB->setChecked(!g_eeGeneral.disableMemoryWarning); //Default is zero=checked
ui->alarmwarnChkB->setChecked(!g_eeGeneral.disableAlarmWarning);//Default is zero=checked
ui->enableTelemetryAlarmChkB->setChecked(g_eeGeneral.enableTelemetryAlarm);
ui->beepMinuteChkB->setChecked(g_eeGeneral.minuteBeep);
ui->beepCountDownChkB->setChecked(g_eeGeneral.preBeep);
ui->beepFlashChkB->setChecked(g_eeGeneral.flashBeep);
ui->splashScreenChkB->setChecked(!g_eeGeneral.splashMode);
ui->hideNameOnSplashChkB->setChecked(!g_eeGeneral.hideNameOnSplash);
ui->trnMode_1->setCurrentIndex(g_eeGeneral.trainer.mix[0].mode);
ui->trnChn_1->setCurrentIndex(g_eeGeneral.trainer.mix[0].src);
@ -368,6 +257,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
if (GetEepromInterface()->getCapability(MultiposPots)) {
ui->pot1Type->setCurrentIndex(g_eeGeneral.potsType[0]);
ui->pot2Type->setCurrentIndex(g_eeGeneral.potsType[1]);
ui->pot3Type->setCurrentIndex(g_eeGeneral.potsType[2]);
}
else {
ui->potsTypeSeparator->hide();
@ -375,6 +265,16 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->pot1TypeLabel->hide();
ui->pot2Type->hide();
ui->pot2TypeLabel->hide();
ui->pot3Type->hide();
ui->pot3TypeLabel->hide();
}
if (IS_TARANIS(eepromInterface->getBoard())) {
ui->serialPortMode->setCurrentIndex(g_eeGeneral.hw_uartMode);
}
else {
ui->serialPortMode->hide();
ui->serialPortLabel->hide();
}
}
@ -395,6 +295,18 @@ void GeneralEdit::on_pot2Type_currentIndexChanged(int index)
updateSettings();
}
void GeneralEdit::on_pot3Type_currentIndexChanged(int index)
{
g_eeGeneral.potsType[2] = index;
updateSettings();
}
void GeneralEdit::on_serialPortMode_currentIndexChanged(int index)
{
g_eeGeneral.hw_uartMode = index;
updateSettings();
}
void GeneralEdit::unlockSwitchEdited()
{
int i=0;
@ -428,9 +340,8 @@ void GeneralEdit::setValues()
ui->speakerPitchSB->setValue(g_eeGeneral.speakerPitch);
ui->hapticStrengthSB->setValue(g_eeGeneral.hapticStrength);
ui->hapticmodeCB->setCurrentIndex(g_eeGeneral.hapticMode+2);
ui->battcalibDSB->setValue((double)g_eeGeneral.vBatCalib/10);
ui->battCalibDSB->setValue((double)g_eeGeneral.vBatCalib/10);
ui->CurrentCalib_SB->setValue((double)g_eeGeneral.currentCalib);
ui->battCalib->setValue((double)g_eeGeneral.vBatCalib/10);
ui->ana1Neg->setValue(g_eeGeneral.calibSpanNeg[0]);
ui->ana2Neg->setValue(g_eeGeneral.calibSpanNeg[1]);
@ -466,27 +377,6 @@ void GeneralEdit::setValues()
ui->PPM_MultiplierDSB->setValue((qreal)(g_eeGeneral.PPM_Multiplier+10)/10);
}
void GeneralEdit::setSwitchDefPos()
{
quint8 x = g_eeGeneral.switchWarningStates & 0x38;
if(x==0x00 || x==0x18 || x== 0x28 || x==0x38 || x==0x30) //illegal states for ID0/1/2
{
g_eeGeneral.switchWarningStates &= ~0x38; // turn all off, make sure only one is on
g_eeGeneral.switchWarningStates |= 0x08;
}
switchDefPosEditLock = true;
ui->swTHRChkB->setChecked(g_eeGeneral.switchWarningStates & 0x01);
ui->swRUDChkB->setChecked(g_eeGeneral.switchWarningStates & 0x02);
ui->swELEChkB->setChecked(g_eeGeneral.switchWarningStates & 0x04);
ui->swID0ChkB->setChecked(g_eeGeneral.switchWarningStates & 0x08);
ui->swID1ChkB->setChecked(g_eeGeneral.switchWarningStates & 0x10);
ui->swID2ChkB->setChecked(g_eeGeneral.switchWarningStates & 0x20);
ui->swAILChkB->setChecked(g_eeGeneral.switchWarningStates & 0x40);
ui->swGEAChkB->setChecked(g_eeGeneral.switchWarningStates & 0x80);
switchDefPosEditLock = false;
}
void GeneralEdit::updateSettings()
{
radioData.generalSettings = g_eeGeneral;
@ -505,10 +395,9 @@ void GeneralEdit::on_battwarningDSB_editingFinished()
updateSettings();
}
void GeneralEdit::on_battcalibDSB_editingFinished()
void GeneralEdit::on_battCalibDSB_editingFinished()
{
g_eeGeneral.vBatCalib = ui->battcalibDSB->value()*10;
ui->battCalib->setValue(ui->battcalibDSB->value());
g_eeGeneral.vBatCalib = ui->battCalibDSB->value()*10;
updateSettings();
}
@ -596,29 +485,12 @@ void GeneralEdit::on_timezoneSB_editingFinished()
updateSettings();
}
void GeneralEdit::on_blOnStickMoveSB_editingFinished()
{
int i = ui->blOnStickMoveSB->value()/5;
if((i*5)!=ui->blOnStickMoveSB->value())
ui->blOnStickMoveSB->setValue(i*5);
g_eeGeneral.lightOnStickMove = i;
updateSettings();
}
void GeneralEdit::on_inactimerSB_editingFinished()
{
g_eeGeneral.inactivityTimer = ui->inactimerSB->value();
updateSettings();
}
void GeneralEdit::on_inputfilterCB_currentIndexChanged(int index)
{
g_eeGeneral.filterInput = index;
updateSettings();
}
void GeneralEdit::on_memwarnChkB_stateChanged(int )
{
g_eeGeneral.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1;
@ -631,12 +503,6 @@ void GeneralEdit::on_alarmwarnChkB_stateChanged(int )
updateSettings();
}
void GeneralEdit::on_enableTelemetryAlarmChkB_stateChanged(int )
{
g_eeGeneral.enableTelemetryAlarm = ui->enableTelemetryAlarmChkB->isChecked();
updateSettings();
}
void GeneralEdit::on_beeperCB_currentIndexChanged(int index)
{
g_eeGeneral.beeperMode = (BeeperMode)(index-2);
@ -885,13 +751,6 @@ void GeneralEdit::on_ana8Pos_editingFinished()
updateSettings();
}
void GeneralEdit::on_battCalib_editingFinished()
{
g_eeGeneral.vBatCalib = ui->battCalib->value()*10;
ui->battcalibDSB->setValue(ui->battCalib->value());
updateSettings();
}
void GeneralEdit::on_volume_SB_editingFinished()
{
g_eeGeneral.speakerVolume = ui->volume_SB->value();
@ -934,6 +793,31 @@ void GeneralEdit::on_bgVolume_SL_valueChanged()
updateSettings();
}
void GeneralEdit::on_varioP0_SB_editingFinished()
{
g_eeGeneral.varioPitch = (ui->varioP0_SB->value()-700)/10;
updateVarioPitchRange();
updateSettings();
}
void GeneralEdit::updateVarioPitchRange()
{
ui->varioPMax_SB->setMaximum(700+(g_eeGeneral.varioPitch*10)+1000+800);
ui->varioPMax_SB->setMinimum(700+(g_eeGeneral.varioPitch*10)+1000-800);
}
void GeneralEdit::on_varioPMax_SB_editingFinished()
{
g_eeGeneral.varioRange = (ui->varioPMax_SB->value()-(700+(g_eeGeneral.varioPitch*10))-1000)/10;
updateSettings();
}
void GeneralEdit::on_varioR0_SB_editingFinished()
{
g_eeGeneral.varioRepeat = (ui->varioR0_SB->value()-500)/10;
updateSettings();
}
void GeneralEdit::on_PPM1_editingFinished()
{
g_eeGeneral.trainer.calib[0] = ui->PPM1->value();
@ -963,49 +847,18 @@ void GeneralEdit::on_tabWidget_currentChanged(int index)
g.generalEditTab(index);
}
void GeneralEdit::on_beepMinuteChkB_stateChanged(int )
{
g_eeGeneral.minuteBeep = ui->beepMinuteChkB->isChecked() ? 1 : 0;
updateSettings();
}
void GeneralEdit::on_beepCountDownChkB_stateChanged(int )
{
g_eeGeneral.preBeep = ui->beepCountDownChkB->isChecked() ? 1 : 0;
updateSettings();
}
void GeneralEdit::on_beepFlashChkB_stateChanged(int )
{
g_eeGeneral.flashBeep = ui->beepFlashChkB->isChecked() ? 1 : 0;
updateSettings();
}
void GeneralEdit::on_splashScreenChkB_stateChanged(int )
{
g_eeGeneral.splashMode = ui->splashScreenChkB->isChecked() ? 0 : 1;
updateSettings();
}
void GeneralEdit::on_hideNameOnSplashChkB_stateChanged(int )
{
g_eeGeneral.hideNameOnSplash = ui->hideNameOnSplashChkB->isChecked() ? 0 : 1;
updateSettings();
}
void GeneralEdit::on_PPM_MultiplierDSB_editingFinished()
{
g_eeGeneral.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10;
updateSettings();
}
void GeneralEdit::on_ownerNameLE_editingFinished()
{
strncpy(g_eeGeneral.ownerName, ui->ownerNameLE->text().toAscii(), 10);
updateSettings();
}
void GeneralEdit::on_speakerPitchSB_editingFinished()
{
g_eeGeneral.speakerPitch = ui->speakerPitchSB->value();
@ -1024,18 +877,6 @@ void GeneralEdit::on_soundModeCB_currentIndexChanged(int index)
updateSettings();
}
void GeneralEdit::on_PotScrollEnableChkB_stateChanged(int )
{
g_eeGeneral.disablePotScroll = ui->PotScrollEnableChkB->isChecked() ? false : true;
updateSettings();
}
void GeneralEdit::on_blinvert_cb_stateChanged(int )
{
g_eeGeneral.blightinv = ui->blinvert_cb->isChecked();
updateSettings();
}
void GeneralEdit::on_faimode_CB_stateChanged(int )
{
if (ui->faimode_CB->isChecked()) {
@ -1053,159 +894,6 @@ void GeneralEdit::on_faimode_CB_stateChanged(int )
updateSettings();
}
void GeneralEdit::on_BandGapEnableChkB_stateChanged(int )
{
g_eeGeneral.disableBG = ui->BandGapEnableChkB->isChecked() ? false : true;
updateSettings();
}
void GeneralEdit::on_crosstrimChkB_stateChanged(int )
{
g_eeGeneral.crosstrim = ui->crosstrimChkB->isChecked() ? true : false;
updateSettings();
}
void GeneralEdit::on_frskyintalarmChkB_stateChanged(int )
{
g_eeGeneral.frskyinternalalarm = ui->frskyintalarmChkB->isChecked() ? true : false ;
updateSettings();
}
void GeneralEdit::on_StickScrollChkB_stateChanged(int )
{
g_eeGeneral.stickScroll = ui->StickScrollChkB->isChecked() ? true : false;
updateSettings();
}
void GeneralEdit::on_PPMSimChkB_stateChanged(int )
{
g_eeGeneral.enablePpmsim = ui->PPMSimChkB->isChecked() ? true : false;
updateSettings();
}
void GeneralEdit::on_swtchCB_1_currentIndexChanged(int index)
{
g_eeGeneral.trainer.mix[0].swtch = RawSwitch(ui->swtchCB_1->itemData(ui->swtchCB_1->currentIndex()).toInt());
updateSettings();
}
void GeneralEdit::on_swtchCB_2_currentIndexChanged(int index)
{
g_eeGeneral.trainer.mix[1].swtch = RawSwitch(ui->swtchCB_2->itemData(ui->swtchCB_2->currentIndex()).toInt());
updateSettings();
}
void GeneralEdit::on_swtchCB_3_currentIndexChanged(int index)
{
g_eeGeneral.trainer.mix[2].swtch = RawSwitch(ui->swtchCB_3->itemData(ui->swtchCB_3->currentIndex()).toInt());
updateSettings();
}
void GeneralEdit::on_swtchCB_4_currentIndexChanged(int index)
{
g_eeGeneral.trainer.mix[3].swtch = RawSwitch(ui->swtchCB_4->itemData(ui->swtchCB_4->currentIndex()).toInt());
updateSettings();
}
void GeneralEdit::getGeneralSwitchDefPos(int i, bool val)
{
if(val)
g_eeGeneral.switchWarningStates |= (1<<(i-1));
else
g_eeGeneral.switchWarningStates &= ~(1<<(i-1));
}
void GeneralEdit::on_swTHRChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
getGeneralSwitchDefPos(1,ui->swTHRChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_telalarmsChkB_stateChanged(int )
{
g_eeGeneral.enableTelemetryAlarm=ui->telalarmsChkB->isChecked();
updateSettings();
}
void GeneralEdit::on_swRUDChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
getGeneralSwitchDefPos(2,ui->swRUDChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swELEChkB_stateChanged(int )
{
getGeneralSwitchDefPos(3,ui->swELEChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swID0ChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
if(ui->swID0ChkB->isChecked())
{
switchDefPosEditLock = true;
ui->swID1ChkB->setChecked(false);
ui->swID2ChkB->setChecked(false);
switchDefPosEditLock = false;
}
else
return;
g_eeGeneral.switchWarningStates &= ~0x30; //turn off ID1/2
getGeneralSwitchDefPos(4,ui->swID0ChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swID1ChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
if(ui->swID1ChkB->isChecked())
{
switchDefPosEditLock = true;
ui->swID0ChkB->setChecked(false);
ui->swID2ChkB->setChecked(false);
switchDefPosEditLock = false;
}
else
return;
g_eeGeneral.switchWarningStates &= ~0x28; //turn off ID0/2
getGeneralSwitchDefPos(5,ui->swID1ChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swID2ChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
if(ui->swID2ChkB->isChecked())
{
switchDefPosEditLock = true;
ui->swID0ChkB->setChecked(false);
ui->swID1ChkB->setChecked(false);
switchDefPosEditLock = false;
}
else
return;
g_eeGeneral.switchWarningStates &= ~0x18; //turn off ID1/2
getGeneralSwitchDefPos(6,ui->swID2ChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swAILChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
getGeneralSwitchDefPos(7,ui->swAILChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_swGEAChkB_stateChanged(int )
{
if(switchDefPosEditLock) return;
getGeneralSwitchDefPos(8,ui->swGEAChkB->isChecked());
updateSettings();
}
void GeneralEdit::on_calretrieve_PB_clicked()
{
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
@ -1356,6 +1044,9 @@ void GeneralEdit::on_calstore_PB_clicked()
g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0')));
g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0')));
g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage));
QDateTime dateTime = QDateTime::currentDateTime();
g.profile[profile_id].timeStamp(dateTime.toString("yyyy-MM-dd hh:mm"));
QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved."));
}
}

View file

@ -27,20 +27,13 @@ private:
bool mavbaudEditLock;
void getGeneralSwitchDefPos(int i, bool val);
void setSwitchDefPos();
void updateVarioPitchRange();
signals:
void modelValuesChanged();
private slots:
void on_ownerNameLE_editingFinished();
void on_PotScrollEnableChkB_stateChanged(int);
void on_blinvert_cb_stateChanged(int);
void on_faimode_CB_stateChanged(int );
void on_BandGapEnableChkB_stateChanged(int);
void on_crosstrimChkB_stateChanged(int );
void on_frskyintalarmChkB_stateChanged(int );
void on_StickScrollChkB_stateChanged(int );
void on_PPMSimChkB_stateChanged(int );
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_hapticStrengthSB_editingFinished();
@ -51,11 +44,7 @@ private slots:
void on_hapticLengthCB_currentIndexChanged(int index);
void on_PPM_MultiplierDSB_editingFinished();
void on_splashScreenChkB_stateChanged(int );
void on_hideNameOnSplashChkB_stateChanged(int);
void on_beepCountDownChkB_stateChanged(int );
void on_beepMinuteChkB_stateChanged(int );
void on_alarmwarnChkB_stateChanged(int );
void on_enableTelemetryAlarmChkB_stateChanged(int );
void on_gpsFormatCB_currentIndexChanged(int index);
void on_tabWidget_currentChanged(int index);
void on_displayTypeCB_currentIndexChanged(int index);
@ -65,22 +54,17 @@ private slots:
void on_units_CB_currentIndexChanged(int index);
void on_trnMode_1_currentIndexChanged(int index);
void on_trnChn_1_currentIndexChanged(int index);
void on_swtchCB_1_currentIndexChanged(int index);
void on_trnWeight_1_editingFinished();
void on_trnMode_2_currentIndexChanged(int index);
void on_trnChn_2_currentIndexChanged(int index);
void on_swtchCB_2_currentIndexChanged(int index);
void on_trnWeight_2_editingFinished();
void on_trnMode_3_currentIndexChanged(int index);
void on_trnChn_3_currentIndexChanged(int index);
void on_swtchCB_3_currentIndexChanged(int index);
void on_trnWeight_3_editingFinished();
void on_trnMode_4_currentIndexChanged(int index);
void on_swtchCB_4_currentIndexChanged(int index);
void on_trnChn_4_currentIndexChanged(int index);
void on_trnWeight_4_editingFinished();
void on_battCalib_editingFinished();
void on_CurrentCalib_SB_editingFinished();
void on_ana1Neg_editingFinished();
@ -119,33 +103,27 @@ private slots:
void on_varioVolume_SL_valueChanged();
void on_wavVolume_SL_valueChanged();
void on_varioP0_SB_editingFinished();
void on_varioPMax_SB_editingFinished();
void on_varioR0_SB_editingFinished();
void on_pot1Type_currentIndexChanged(int index);
void on_pot2Type_currentIndexChanged(int index);
void on_pot3Type_currentIndexChanged(int index);
void on_serialPortMode_currentIndexChanged(int index);
void on_stickmodeCB_currentIndexChanged(int index);
void on_channelorderCB_currentIndexChanged(int index);
void on_beeperCB_currentIndexChanged(int index);
void on_memwarnChkB_stateChanged(int );
void on_telalarmsChkB_stateChanged(int );
void on_inputfilterCB_currentIndexChanged(int index);
void on_inactimerSB_editingFinished();
void on_backlightautoSB_editingFinished();
void on_backlightswCB_currentIndexChanged(int index);
void on_mavbaud_CB_currentIndexChanged(int index);
void on_voiceLang_CB_currentIndexChanged(int index);
void on_blOnStickMoveSB_editingFinished();
void on_battcalibDSB_editingFinished();
void on_battCalibDSB_editingFinished();
void on_battwarningDSB_editingFinished();
void on_contrastSB_editingFinished();
void on_beepFlashChkB_stateChanged(int );
void on_swTHRChkB_stateChanged(int );
void on_swRUDChkB_stateChanged(int );
void on_swELEChkB_stateChanged(int );
void on_swID0ChkB_stateChanged(int );
void on_swID1ChkB_stateChanged(int );
void on_swID2ChkB_stateChanged(int );
void on_swAILChkB_stateChanged(int );
void on_swGEAChkB_stateChanged(int );
void on_calretrieve_PB_clicked();
void on_calstore_PB_clicked();
void unlockSwitchEdited();

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,41 @@
#include "simulatordialog.h"
#include "flashinterface.h"
const QColor colors[C9X_MAX_CURVES] = {
QColor(0,0,127),
QColor(0,127,0),
QColor(127,0,0),
QColor(0,127,127),
QColor(127,0,127),
QColor(127,127,0),
QColor(127,127,127),
QColor(0,0,255),
QColor(0,127,255),
QColor(127,0,255),
QColor(0,255,0),
QColor(0,255,127),
QColor(127,255,0),
QColor(255,0,0),
QColor(255,0,127),
QColor(255,127,0),
QColor(0,0,127),
QColor(0,127,0),
QColor(127,0,0),
QColor(0,127,127),
QColor(127,0,127),
QColor(127,127,0),
QColor(127,127,127),
QColor(0,0,255),
QColor(0,127,255),
QColor(127,0,255),
QColor(0,255,0),
QColor(0,255,127),
QColor(127,255,0),
QColor(255,0,0),
QColor(255,0,127),
QColor(255,127,0),
};
QString getPhaseName(int val, char * phasename)
{
if (!val) return "---";
@ -63,27 +98,6 @@ void populateVoiceLangCB(QComboBox *b, QString language)
}
}
void populateTTraceCB(QComboBox *b, int value)
{
const QString strings9x[] = { QObject::tr("THR"), QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3")};
const QString stringstaranis[] = { QObject::tr("THR"), QObject::tr("S1"), QObject::tr("S2"), QObject::tr("LS"), QObject::tr("RS")};
b->clear();
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
for (int i=0; i< 5; i++) {
b->addItem(stringstaranis[i]);
}
} else {
for (int i=0; i< 4; i++) {
b->addItem(strings9x[i]);
}
}
int channels=(IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16);
for (int i=1; i<= channels; i++) {
b->addItem(QObject::tr("CH%1").arg(i, 2, 10, QChar('0')));
}
b->setCurrentIndex(value);
}
void populateRotEncCB(QComboBox *b, int value, int renumber)
{
QString strings[] = { QObject::tr("No"), QObject::tr("RotEnc A"), QObject::tr("Rot Enc B"), QObject::tr("Rot Enc C"), QObject::tr("Rot Enc D"), QObject::tr("Rot Enc E")};
@ -95,31 +109,6 @@ void populateRotEncCB(QComboBox *b, int value, int renumber)
b->setCurrentIndex(value);
}
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last=false, int hubproto=0)
{
int telem_hub[] = {0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,0,2,2,1,1,1,1,1,1};
b->clear();
b->addItem(RawSource(SOURCE_TYPE_NONE, 0).toString());
for (unsigned int i = 0; i <= (last ? TELEMETRY_SOURCES_DISPLAY_COUNT : TELEMETRY_SOURCES_STATUS_COUNT); i++) {
b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString());
if (!(i>=sizeof(telem_hub)/sizeof(int) || telem_hub[i]==0 || ((telem_hub[i]>=hubproto) && hubproto!=0))) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if (value>=sizeof(telem_hub)/sizeof(int))
b->setCurrentIndex(0);
else if (telem_hub[value]==0 || ((telem_hub[value]>=hubproto) && hubproto!=0)) {
b->setCurrentIndex(value);
}
b->setMaxVisibleItems(10);
}
QString getProtocolStr(const int proto)
{
static const char *strings[] = { "OFF",
@ -292,7 +281,7 @@ void CurveGroup::update()
if (lastType != curve.type) {
lastType = curve.type;
curveValueCB->clear();
for (int i=-numcurves; i<numcurves; i++) {
for (int i=-numcurves; i<=numcurves; i++) {
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, i).toString());
}
}
@ -761,19 +750,6 @@ QString getFrSkyAlarmType(int alarm)
}
}
QString getFrSkyBlades(int blades)
{
switch (blades) {
case 1:
return "3";
case 2:
return "4";
default:
return "2";
}
}
QString getFrSkyUnits(int units)
{
switch(units) {

View file

@ -4,6 +4,8 @@
#include <QtGui>
#include "eeprominterface.h"
extern const QColor colors[C9X_MAX_CURVES];
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(LogicalSwitches)-1)
//convert from mode 1 to mode generalSettings.stickMode
@ -27,7 +29,6 @@
void populateGvSourceCB(QComboBox *b, int value);
void populateVoiceLangCB(QComboBox *b, QString language);
void populateTTraceCB(QComboBox *b, int value);
void populateRotEncCB(QComboBox *b, int value, int renumber);
void populateBacklightCB(QComboBox *b, const uint8_t value);
@ -88,7 +89,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=
void populatePhasesCB(QComboBox *b, int value);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model);
@ -120,7 +120,6 @@ QString getCenterBeep(ModelData * g_model);
/* FrSky helpers */
QString getFrSkyAlarmType(int alarm);
QString getFrSkyBlades(int blades);
QString getFrSkyUnits(int units);
QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units);

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -63,6 +63,7 @@
#include "warnings.h"
#include "helpers.h"
#include "appdata.h"
#include "taranisnotfound.h"
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
@ -222,7 +223,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId)
if(ignoreSettings) {
downloadDialog_forWait = new downloadDialog(this, tr("Checking for updates"));
downloadDialog_forWait->show();
downloadDialog_forWait->exec();
} else {
downloadDialog_forWait = NULL; // TODO needed?
}
@ -272,7 +273,7 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply)
downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName);
installer_fileName = fileName;
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
dd->show();
dd->exec();
}
}
#else
@ -1024,7 +1025,8 @@ void MainWindow::readEeprom()
if (IS_TARANIS(eepromInterface->getBoard())) {
QString path=FindTaranisPath();
if (path.isEmpty()) {
QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected."));
taranisNotFoundDialog *tnfd = new taranisNotFoundDialog(this);
tnfd->exec();
res=false;
} else {
QStringList str;
@ -1080,7 +1082,8 @@ void MainWindow::writeFileToEeprom()
if (IS_TARANIS(eepromInterface->getBoard())) {
QString path=FindTaranisPath();
if (path.isEmpty()) {
QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected."));
taranisNotFoundDialog *tnfd = new taranisNotFoundDialog(this);
tnfd->exec();
return;
} else {
QStringList str;
@ -1131,7 +1134,8 @@ void MainWindow::writeFileToEeprom()
if (IS_TARANIS(eepromInterface->getBoard())) {
QString path=FindTaranisPath();
if (path.isEmpty()) {
QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected."));
taranisNotFoundDialog *tnfd = new taranisNotFoundDialog(this);
tnfd->exec();
return;
} else {
QStringList str;
@ -1156,7 +1160,8 @@ void MainWindow::writeFileToEeprom()
if (IS_TARANIS(eepromInterface->getBoard())) {
QString path=FindTaranisPath();
if (path.isEmpty()) {
QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify the eeprom disk is connected."));
taranisNotFoundDialog *tnfd = new taranisNotFoundDialog(this);
tnfd->exec();
return;
}
else {
@ -1251,15 +1256,16 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
if ((svnTags.at(0) == "open9x")||(svnTags.at(0) == "opentx")) {
if (revision > 1464) {
QString fwBuild = flash.getBuild();
if (fwBuild.contains("-")) {
QStringList buildTags = fwBuild.split("-", QString::SkipEmptyParts);
QString fwEEprom = flash.getEEprom();
if (fwEEprom.contains("-")) {
QStringList buildTags = fwEEprom.split("-", QString::SkipEmptyParts);
if (buildTags.size() >= 1)
version = buildTags.at(0).toInt();
if (buildTags.size() >= 2)
variant = buildTags.at(1).toInt();
} else {
version = fwBuild.toInt(); // TODO changer le nom de la variable
}
else {
version = fwEEprom.toInt();
}
}
else {
@ -1401,7 +1407,8 @@ void MainWindow::readEepromToFile()
if (IS_TARANIS(eepromInterface->getBoard())) {
QString path=FindTaranisPath();
if (path.isEmpty()) {
QMessageBox::warning(this, tr("Taranis radio not found"), tr("Impossible to identify the radio on your system, please verify that the eeprom disk is connected."));
taranisNotFoundDialog *tnfd = new taranisNotFoundDialog(this);
tnfd->exec();
return;
}
else {
@ -1530,18 +1537,20 @@ MdiChild *MainWindow::createMdiChild()
return child;
}
QAction * MainWindow::addAct(QString icon, QString sName, QString lName, QKeySequence::StandardKey shortcut, const char *slot)
QAction * MainWindow::addAct(QString icon, QString sName, QString lName, QKeySequence::StandardKey shortcut, const char *slot, QObject *slotObj)
{
QAction * newAction = new QAction( this );
if (!icon.isEmpty())
newAction->setIcon(CompanionIcon(icon));
newAction->setIcon(CompanionIcon(icon));
if (!sName.isEmpty())
newAction->setText(sName);
if (!lName.isEmpty())
newAction->setStatusTip(lName);
if (shortcut != 0)
newAction->setShortcuts(shortcut);
connect(newAction, SIGNAL(triggered()), this, slot);
if (slotObj == NULL)
slotObj = this;
connect(newAction, SIGNAL(triggered()), slotObj, slot);
return newAction;
}
@ -1584,7 +1593,7 @@ void MainWindow::createActions()
openAct = addAct("open.png", tr("Open Models+Settings..."), tr("Open Models and Settings file"), QKeySequence::Open, SLOT(openFile()));
saveAct = addAct("save.png", tr("Save Models+Settings..."), tr("Save Models and Settings file"), QKeySequence::Save, SLOT(save()));
saveAsAct = addAct("saveas.png", tr("Save Models+Settings as..."), tr("Save Models and Settings file"), QKeySequence::SaveAs, SLOT(saveAs()));
exitAct = addAct("exit.png", tr("Exit"), tr("Exit the application"), QKeySequence::Quit, SLOT(newFile()));
exitAct = addAct("exit.png", tr("Exit"), tr("Exit the application"), QKeySequence::Quit, SLOT(closeAllWindows()), qApp);
cutAct = addAct("cut.png", tr("Cut Model"), tr("Cut current model to the clipboard"), QKeySequence::Cut, SLOT(cut()));
copyAct = addAct("copy.png", tr("Copy Model..."), tr("Copy current model to the clipboard"), QKeySequence::Copy, SLOT(copy()));
pasteAct = addAct("paste.png", tr("Paste Model..."), tr("Paste model from clipboard"), QKeySequence::Paste, SLOT(paste()));

View file

@ -49,7 +49,7 @@
#include "eeprominterface.h"
#define SPLASH_TIME 5
#define MAX_RECENT 10
#define MAX_RECENT 15
#define MAX_PROFILES 15
class MdiChild;
@ -158,7 +158,7 @@ private slots:
private:
void createActions();
QAction * addAct(QString, QString, QString, QKeySequence::StandardKey, const char *);
QAction * addAct(QString, QString, QString, QKeySequence::StandardKey, const char *, QObject *slotObj=NULL);
QAction * addAct(QActionGroup *, QString, QString, const char *);
QAction * addAct(QString, QString, QString, const char *);

File diff suppressed because it is too large Load diff

View file

@ -10,18 +10,24 @@ Channels::Channels(QWidget * parent, ModelData & model):
ModelPanel(parent, model)
{
QGridLayout * gridLayout = new QGridLayout(this);
bool minimize = false;
int col = 1;
if (GetEepromInterface()->getCapability(ChannelsName))
{
minimize=true;
addLabel(gridLayout, tr("Name"), col++);
addLabel(gridLayout, tr("Offset"), col++);
addLabel(gridLayout, tr("Min"), col++);
addLabel(gridLayout, tr("Max"), col++);
addLabel(gridLayout, tr("Invert"), col++);
}
addLabel(gridLayout, tr("Offset"), col++, minimize);
addLabel(gridLayout, tr("Min"), col++, minimize);
addLabel(gridLayout, tr("Max"), col++, minimize);
addLabel(gridLayout, tr("Invert"), col++, minimize);
if (IS_TARANIS(GetEepromInterface()->getBoard()))
addLabel(gridLayout, tr("Curve"), col++, minimize);
if (GetEepromInterface()->getCapability(PPMCenter))
addLabel(gridLayout, tr("Center"), col++);
addLabel(gridLayout, tr("Center"), col++, minimize);
if (GetEepromInterface()->getCapability(SYMLimits))
addLabel(gridLayout, tr("Sym"), col++);
addLabel(gridLayout, tr("Sym"), col++, true);
for (int i=0; i<GetEepromInterface()->getCapability(Outputs); i++) {
col = 0;
@ -29,6 +35,7 @@ Channels::Channels(QWidget * parent, ModelData & model):
// Channel label
QLabel *label = new QLabel(this);
label->setText(tr("Channel %1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout->addWidget(label, i+1, col++, 1, 1);
// Channel name
@ -88,6 +95,19 @@ Channels::Channels(QWidget * parent, ModelData & model):
connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited()));
gridLayout->addWidget(invCB, i+1, col++, 1, 1);
// Curve
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
QComboBox * curveCB = new QComboBox(this);
curveCB->setProperty("index", i);
int numcurves = GetEepromInterface()->getCapability(NumCurves);
for (int j=-numcurves; j<=numcurves; j++) {
curveCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(), j);
}
curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves);
connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited()));
gridLayout->addWidget(curveCB, i+1, col++, 1, 1);
}
// PPM center
if (GetEepromInterface()->getCapability(PPMCenter)) {
QSpinBox * center = new QSpinBox(this);
@ -110,6 +130,8 @@ Channels::Channels(QWidget * parent, ModelData & model):
gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
}
}
// Push the rows up
addVSpring(gridLayout, 0,GetEepromInterface()->getCapability(Outputs)+1);
}
Channels::~Channels()
@ -168,6 +190,14 @@ void Channels::invEdited()
emit modified();
}
void Channels::curveEdited()
{
QComboBox *cb = qobject_cast<QComboBox*>(sender());
int index = cb->property("index").toInt();
model.limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt());
emit modified();
}
void Channels::ppmcenterEdited()
{
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());

View file

@ -18,6 +18,7 @@ class Channels : public ModelPanel
void minEdited();
void maxEdited();
void invEdited();
void curveEdited();
void ppmcenterEdited();
};

View file

@ -1,217 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="ca_ctype_label_2">
<property name="text">
<string>Curve type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="ca_coeff_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="ca_coeff_label_2">
<property name="text">
<string>Coefficient</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="ca_side_CB_2">
<item>
<property name="text">
<string>Both</string>
</property>
</item>
<item>
<property name="text">
<string>x&gt;0</string>
</property>
</item>
<item>
<property name="text">
<string>x&lt;0</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="ca_ymid_label_2">
<property name="text">
<string>Y at X=0</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="ca_ymax_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="ca_ymid_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="ca_side_label_2">
<property name="text">
<string>Side</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="ca_ymin_label_2">
<property name="text">
<string>Y at X=-100</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="ca_ymin_SB_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="ca_ymax_label_2">
<property name="text">
<string>Y at X=100</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="ca_ctype_CB_2">
<item>
<property name="text">
<string>Linear</string>
</property>
</item>
<item>
<property name="text">
<string>Single Expo</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetrical f(x)=-f(-x)</string>
</property>
</item>
<item>
<property name="text">
<string>Symmetrical f(x)=f(-x)</string>
</property>
</item>
</widget>
</item>
</layout>
</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>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -10,24 +10,87 @@
#define GFX_MARGIN 16
static const QColor colors[C9X_MAX_CURVES] = {
QColor(0,0,127),
QColor(0,127,0),
QColor(127,0,0),
QColor(0,127,127),
QColor(127,0,127),
QColor(127,127,0),
QColor(127,127,127),
QColor(0,0,255),
QColor(0,127,255),
QColor(127,0,255),
QColor(0,255,0),
QColor(0,255,127),
QColor(127,255,0),
QColor(255,0,0),
QColor(255,0,127),
QColor(255,127,0),
};
#define CURVE_COEFF_ENABLE 1
#define CURVE_YMID_ENABLE 2
#define CURVE_YMIN_ENABLE 4
float curveLinear(float x, float coeff, float yMin, float yMid, float yMax)
{
float a = (yMax-yMin) / 200.0;
return yMin + a * (x+100.0);
}
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;
}
float curveExpo(float x, float coeff, float yMin, float yMid, float yMax)
{
float a = (yMax-yMin) / 100.0;
x += 100.0;
x /= 2.0;
if (coeff >= 0) {
return round(c9xexpou(x, coeff)*a + yMin);
}
else {
coeff = -coeff;
x = 100 - x;
return round((100.0 - c9xexpou(x, coeff))*a + yMin);
}
}
float curveSymmetricalY(float x, float coeff, float yMin, float yMid, float yMax)
{
bool invert;
if (x<0) {
x = -x;
invert = 1;
}
else {
invert = 0;
}
float y;
if (coeff >= 0) {
y = round(c9xexpou(x, coeff) * (yMax/100.0));
}
else {
coeff = -coeff;
x = 100.0 - x;
y = round((100.0-c9xexpou(x, coeff)) * (yMax/100.0));
}
if (invert) {
y = -y;
}
return y;
}
float curveSymmetricalX(float x, float coeff, float yMin, float yMid, float yMax)
{
float a = (yMax-yMid) / 100.0;
if (x<0)
x = -x;
float y;
if (coeff >= 0) {
y = round(c9xexpou(x, coeff) * a + yMid);
}
else {
coeff = -coeff;
x = 100-x;
y = round((100.0-c9xexpou(x, coeff)) * a + yMid);
}
return y;
}
#if 0
#ifdef __APPLE__
@ -145,6 +208,11 @@ Curves::Curves(QWidget * parent, ModelData & model):
}
}
addTemplate(tr("Linear"), CURVE_YMIN_ENABLE, curveLinear);
addTemplate(tr("Single Expo"), CURVE_COEFF_ENABLE | CURVE_YMIN_ENABLE, curveExpo);
addTemplate(tr("Symmetrical f(x)=-f(-x)"), CURVE_COEFF_ENABLE, curveSymmetricalY);
addTemplate(tr("Symmetrical f(x)=f(-x)"), CURVE_COEFF_ENABLE | CURVE_YMID_ENABLE, curveSymmetricalX);
lock = false;
}
@ -189,41 +257,16 @@ void Curves::update()
ui->curveName->setText(model.curves[currentCurve].name);
}
int count = model.curves[currentCurve].count;
for (int i=0; i<count; i++) {
spny[i]->show();
spny[i]->setValue(model.curves[currentCurve].points[i].y);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spnx[i]->show();
if (i==0 || i==model.curves[currentCurve].count-1) {
spnx[i]->setDisabled(true);
spnx[i]->setMaximum(+100);
spnx[i]->setMinimum(-100);
}
else {
spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x);
spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x);
}
spnx[i]->setValue(model.curves[currentCurve].points[i].x);
}
else {
spnx[i]->hide();
}
}
for (int i=count; i<C9X_MAX_POINTS; i++) {
spny[i]->hide();
spnx[i]->hide();
}
updateCurveType();
updateCurve();
updateCurvePoints();
lock = false;
}
void Curves::setCurrentCurve(int index)
{
currentCurve = index;
currentCurve = index;
}
void Curves::updateCurveType()
@ -253,6 +296,8 @@ void Curves::updateCurveType()
void Curves::updateCurve()
{
lock = true;
Node * nodel = 0;
Node * nodex = 0;
QColor color;
@ -317,18 +362,51 @@ void Curves::updateCurve()
scene->addItem(nodex);
if (i>0) scene->addItem(new Edge(nodel, nodex));
}
lock = false;
}
void Curves::updateCurvePoints()
{
lock = true;
int count = model.curves[currentCurve].count;
for (int i=0; i<count; i++) {
spny[i]->show();
spny[i]->setValue(model.curves[currentCurve].points[i].y);
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spnx[i]->show();
if (i==0 || i==model.curves[currentCurve].count-1) {
spnx[i]->setDisabled(true);
spnx[i]->setMaximum(+100);
spnx[i]->setMinimum(-100);
}
else {
spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x);
spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x);
}
spnx[i]->setValue(model.curves[currentCurve].points[i].x);
}
else {
spnx[i]->hide();
}
}
for (int i=count; i<C9X_MAX_POINTS; i++) {
spny[i]->hide();
spnx[i]->hide();
}
lock = false;
}
void Curves::onPointEdited()
{
if (!lock) {
lock = true;
int index = sender()->property("index").toInt();
model.curves[currentCurve].points[index].x = spnx[index]->value();
model.curves[currentCurve].points[index].y = spny[index]->value();
updateCurve();
emit modified();
lock = false;
}
}
@ -390,7 +468,7 @@ void Curves::on_curvePoints_currentIndexChanged(int index)
// TODO something better + reuse!
for (int i=0; i<C9X_MAX_POINTS; i++) {
model.curves[currentCurve].points[i].x = (i >= model.curves[currentCurve].count-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].y = 0;
}
@ -413,7 +491,7 @@ void Curves::on_curveCustom_currentIndexChanged(int index)
// TODO something better + reuse!
for (int i=0; i<C9X_MAX_POINTS; i++) {
model.curves[currentCurve].points[i].x = (i >= model.curves[currentCurve].count-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
model.curves[currentCurve].points[i].y = 0;
}
@ -444,213 +522,72 @@ void Curves::resizeEvent(QResizeEvent *event)
QRect qr = ui->curvePreview->contentsRect();
ui->curvePreview->scene()->setSceneRect(GFX_MARGIN, GFX_MARGIN, qr.width()-GFX_MARGIN*2, qr.height()-GFX_MARGIN*2);
updateCurve();
ModelPanel::resizeEvent(event);
}
#if 0
void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
void Curves::on_curveType_currentIndexChanged()
{
int index=ui->ca_ctype_CB->currentIndex();
switch (index) {
int index = ui->curveType->currentIndex();
unsigned int flags = templates[index].flags;
ui->curveCoeffLabel->setVisible(flags & CURVE_COEFF_ENABLE);
ui->curveCoeff->setVisible(flags & CURVE_COEFF_ENABLE);
ui->yMax->setValue(100);
ui->yMidLabel->setVisible(flags & CURVE_YMID_ENABLE);
ui->yMid->setVisible(flags & CURVE_YMID_ENABLE);
ui->yMid->setValue(0);
ui->yMinLabel->setVisible(flags & CURVE_YMIN_ENABLE);
ui->yMin->setVisible(flags & CURVE_YMIN_ENABLE);
ui->yMin->setValue(-100);
}
void Curves::addTemplate(QString name, unsigned int flags, curveFunction function)
{
CurveCreatorTemplate tmpl;
tmpl.name = name;
tmpl.flags = flags;
tmpl.function = function;
templates.append(tmpl);
ui->curveType->addItem(name);
}
void Curves::on_curveApply_clicked()
{
int index = ui->curveType->currentIndex();
int numpoints = model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
float x;
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM)
x = model.curves[currentCurve].points[i].x;
else
x = -100.0 + (200.0/(numpoints-1))*i;
bool apply = false;
switch (ui->curveSide->currentIndex()) {
case 0:
ui->ca_coeff_SB->hide();
ui->ca_coeff_label->hide();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->show();
ui->ca_ymin_label->show();
ui->ca_ymin_SB->setValue(-100);
ui->ca_ymax_SB->setValue(100);
apply = true;
break;
case 1:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->show();
ui->ca_ymin_label->show();
ui->ca_ymin_SB->setValue(-100);
ui->ca_ymax_SB->setValue(100);
if (x>=0)
apply = true;
break;
case 2:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->hide();
ui->ca_ymid_label->hide();
ui->ca_ymin_SB->hide();
ui->ca_ymin_label->hide();
ui->ca_ymax_SB->setValue(100);
break;
case 3:
ui->ca_coeff_SB->show();
ui->ca_coeff_label->show();
ui->ca_ymid_SB->show();
ui->ca_ymid_label->show();
ui->ca_ymin_SB->hide();
ui->ca_ymin_label->hide();
ui->ca_ymid_SB->setValue(0);
ui->ca_ymax_SB->setValue(100);
if (x<0)
apply = true;
break;
}
}
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()
{
int index=ui->ca_ctype_CB->currentIndex();
float x;
int y;
int invert=0;
float a;
if (index==0) {
a=(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/200.0;
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x+100);
} else {
x=(200.0/(numpoints-1))*i;
}
y=ui->ca_ymin_SB->value()+a*x;
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (x>=100) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (x<100) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
} else if (index==1) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=((model.curves[currentCurve].points[i].x)+100)/2.0;
} else {
x=(100.0/(numpoints-1))*i;
}
a=ui->ca_coeff_SB->value();
if (a>=0) {
y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value());
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/100.0+ui->ca_ymin_SB->value());
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (x>=50) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (x<50) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
} else if (index==2) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
}
a=ui->ca_coeff_SB->value();
if (x<0) {
x=-x;
invert=1;
} else {
invert=0;
}
if (a>=0) {
y=round(c9xexpou(x,a)*(ui->ca_ymax_SB->value()/100.0));
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*(ui->ca_ymax_SB->value()/100.0));
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
if (invert==1) {
model.curves[currentCurve].points[i].y=-y;
} else {
model.curves[currentCurve].points[i].y=y;
}
break;
case 1:
if (invert==0) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (invert==1) {
model.curves[currentCurve].points[i].y=-y;
}
break;
}
}
} else if (index==3) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
}
int pos=(x>=0);
a=ui->ca_coeff_SB->value();
if (x<0) {
x=-x;
}
if (a>=0) {
y=round(c9xexpou(x,a)*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value());
} else {
a=-a;
x=100-x;
y=round((100.0-c9xexpou(x,a))*((ui->ca_ymax_SB->value()-ui->ca_ymid_SB->value())/100.0)+ui->ca_ymid_SB->value());
}
switch (ui->ca_side_CB->currentIndex()) {
case 0:
model.curves[currentCurve].points[i].y=y;
break;
case 1:
if (pos) {
model.curves[currentCurve].points[i].y=y;
}
break;
case 2:
if (!pos) {
model.curves[currentCurve].points[i].y=y;
}
break;
}
}
if (apply) {
model.curves[currentCurve].points[i].y = templates[index].function(x, ui->curveCoeff->value(), ui->yMin->value(), ui->yMid->value(), ui->yMax->value());
}
updateSettings();
setCurrentCurve(currentCurve);
drawCurve();
}
updateCurve();
updateCurvePoints();
emit modified();
}
#if 0
void ModelEdit::clearCurves(bool ask)
{
if (ask) {

View file

@ -8,6 +8,14 @@ namespace Ui {
class Curves;
}
typedef float (*curveFunction) (float x, float coeff, float yMin, float yMid, float yMax);
struct CurveCreatorTemplate {
QString name;
unsigned int flags;
curveFunction function;
};
class Curves : public ModelPanel
{
Q_OBJECT
@ -30,9 +38,12 @@ class Curves : public ModelPanel
void onNodeMoved(int x, int y);
void onNodeFocus();
void onNodeUnfocus();
void on_curveType_currentIndexChanged();
void on_curveApply_clicked();
protected:
virtual void resizeEvent(QResizeEvent *event);
void addTemplate(QString name, unsigned int flags, curveFunction function);
private:
Ui::Curves *ui;
@ -40,10 +51,13 @@ class Curves : public ModelPanel
bool visibleCurves[C9X_MAX_CURVES];
QSpinBox * spnx[C9X_MAX_POINTS];
QSpinBox * spny[C9X_MAX_POINTS];
QVector<CurveCreatorTemplate> templates;
void setCurrentCurve(int index);
void updateCurve();
void updateCurveType();
void updateCurvePoints();
bool allowCurveType(int points, CurveData::CurveType type);
void setPointY(int i, int x, int y);
};

View file

@ -1,161 +1,344 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Curves</class>
<widget class="QWidget" name="Curves">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>638</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_80" columnstretch="0,0,0,0,0">
<item row="0" column="0" rowspan="3">
<layout class="QGridLayout" name="curvesLayout"/>
</item>
<item row="0" column="1" rowspan="3">
<layout class="QGridLayout" name="gridLayout_8" rowstretch="0,0,0" columnstretch="1,0">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="curvePoints"/>
</item>
<item>
<widget class="QComboBox" name="curveCustom">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="curveSmooth">
<item>
<property name="text">
<string>Lines</string>
</property>
</item>
<item>
<property name="text">
<string>Smooth</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="curveTypeLabel">
<property name="text">
<string>Curve type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="curveNameLabel">
<property name="text">
<string>Curve name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="curveName">
<property name="maxLength">
<number>6</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGraphicsView" name="curvePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2" rowspan="3" colspan="2">
<layout class="QGridLayout" name="pointsLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item row="5" column="0" colspan="5">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4" rowspan="3">
<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>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Curves</class>
<widget class="QWidget" name="Curves">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>718</width>
<height>539</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="curvesLayout"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_1">
<property name="rightMargin">
<number>10</number>
</property>
<item>
<widget class="QGraphicsView" name="curvePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>400</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="curveNameLabel">
<property name="text">
<string>Curve name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0">
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="curvePoints"/>
</item>
<item>
<widget class="QComboBox" name="curveCustom">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="curveSmooth">
<item>
<property name="text">
<string>Lines</string>
</property>
</item>
<item>
<property name="text">
<string>Smooth</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="curveName">
<property name="maxLength">
<number>6</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="curveTypeLabel">
<property name="text">
<string>Curve type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<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>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="pointsLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="curveCreator">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="title">
<string>Curve Creator</string>
</property>
<layout class="QGridLayout" name="gridLayout_76" rowstretch="0,0,0,0,0,0,0,0">
<item row="3" column="0">
<widget class="QLabel" name="yMidLabel">
<property name="text">
<string>Y at X=0</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QSpinBox" name="yMax">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="yMaxLabel">
<property name="text">
<string>Y at X=100</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QSpinBox" name="curveCoeff">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QComboBox" name="curveSide">
<item>
<property name="text">
<string>Both</string>
</property>
</item>
<item>
<property name="text">
<string>x&gt;0</string>
</property>
</item>
<item>
<property name="text">
<string>x&lt;0</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QSpinBox" name="yMin">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<widget class="QPushButton" name="curveApply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="curveSideLabel">
<property name="text">
<string>Side</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QSpinBox" name="yMid">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="curveType"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="curveTypeLabel_2">
<property name="text">
<string>Curve type</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="yMinLabel">
<property name="text">
<string>Y at X=-100</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="curveCoeffLabel">
<property name="text">
<string>Coefficient</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</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>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -54,11 +54,11 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
{
QGridLayout * gridLayout = new QGridLayout(this);
int col = 1;
addLabel(gridLayout, tr("Switch"), col++);
addLabel(gridLayout, tr("Action"), col++);
addLabel(gridLayout, tr("Parameters"), col++);
addLabel(gridLayout, tr("Enable"), col++);
addLabel(gridLayout, tr("Switch"), 1);
addLabel(gridLayout, tr("Action"), 2);
addLabel(gridLayout, tr("Parameters"), 3);
addLabel(gridLayout, tr("Enable"), 4, true );
addEmptyLabel(gridLayout, 5 );
lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
@ -104,13 +104,15 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
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);
label->setText(tr("SF%1").arg(i+1));
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0);
// The switch
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i);
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
@ -161,6 +163,12 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited()));
#ifdef PHONON
phononLock=false;
clickObject = new Phonon::MediaObject(this);
clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this);
Phonon::createPath(clickObject, clickOutput);
connect(clickObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State,Phonon::State)));
playBT[i] = new QPushButton(this);
playBT[i]->setProperty("index", i);
playBT[i]->setProperty("state", "play");
@ -178,11 +186,13 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchEnable[i] = new QCheckBox(this);
fswtchEnable[i]->setProperty("index", i);
fswtchEnable[i]->setText(tr("ON"));
fswtchEnable[i]->setFixedWidth( 50 );
repeatLayout->addWidget(fswtchEnable[i], i+1);
fswtchEnable[i]->setChecked(model.funcSw[i].enabled);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
}
// Push rows upward
addDoubleSpring(gridLayout, 5, num_fsw+1);
lock = false;
}
@ -203,6 +213,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta
clickObject->clearQueue();
clickObject->clear();
for (int i=0; i<GetEepromInterface()->getCapability(CustomFunctions); i++) {
playBT[i]->setProperty("state", "play");
playBT[i]->setObjectName(QString("play_%1").arg(i));
playBT[i]->setIcon(CompanionIcon("play.png"));
}

View file

@ -1,13 +1,13 @@
#include "expodialog.h"
#include "ui_expodialog.h"
#include "eeprominterface.h"
#include "helpers.h"
ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, int stickMode) :
ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, int stickMode, char * inputName) :
QDialog(parent),
ui(new Ui::ExpoDialog),
model(model),
ed(expoData)
ed(expoData),
inputName(inputName)
{
ui->setupUi(this);
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
@ -45,8 +45,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
}
if (GetEepromInterface()->getCapability(VirtualInputs)) {
ui->sideLabel->hide();
ui->sideCB->hide();
ui->inputName->setMaxLength(4);
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
ui->sourceCB->removeItem(0);
@ -76,7 +74,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
}
ui->inputName->setValidator(new QRegExpValidator(rx, this));
ui->inputName->setText(model.inputNames[ed->chn]);
ui->inputName->setText(inputName);
ui->lineName->setValidator(new QRegExpValidator(rx, this));
ui->lineName->setText(ed->name);
@ -93,6 +91,9 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
for (int i=0; i<9; i++) {
connect(cb_fp[i], SIGNAL(toggled(bool)), this, SLOT(valuesChanged()));
}
if (GetEepromInterface()->getCapability(VirtualInputs))
connect(ui->inputName, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
QTimer::singleShot(0, this, SLOT(shrink()));
}
@ -137,7 +138,7 @@ void ExpoDialog::valuesChanged()
ed->mode = ui->sideCB->currentIndex() + 1;
strcpy(ed->name, ui->lineName->text().toAscii().data());
strcpy(model.inputNames[ed->chn], ui->inputName->text().toAscii().data());
strcpy(inputName, ui->inputName->text().toAscii().data());
ed->phases=0;
for (int i=8; i>=0 ; i--) {

View file

@ -14,7 +14,7 @@ namespace Ui {
class ExpoDialog : public QDialog {
Q_OBJECT
public:
ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, int stickMode);
ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, int stickMode, char * inputName);
~ExpoDialog();
protected:
@ -28,6 +28,7 @@ class ExpoDialog : public QDialog {
Ui::ExpoDialog * ui;
ModelData & model;
ExpoData * ed;
char * inputName;
GVarGroup * gvGroup;
CurveGroup * curveGroup;
};

View file

@ -165,7 +165,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="leftTrims_3" columnstretch="0,1" columnminimumwidth="80,0">
<layout class="QGridLayout" name="leftTrims_3" columnstretch="0,1">
<item row="1" column="0">
<widget class="QLabel" name="trim1Label">
<property name="text">
@ -299,7 +299,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="righTrims_2" columnstretch="0,1" columnminimumwidth="80,0">
<layout class="QGridLayout" name="righTrims_2" columnstretch="0,1">
<item row="1" column="0">
<widget class="QLabel" name="trim4Label">
<property name="text">
@ -423,6 +423,19 @@
</layout>
</widget>
</item>
<item row="0" column="4">
<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>

View file

@ -194,33 +194,29 @@ void FlightMode::update()
for (int i=0; i<gvCount; i++) {
gvNames[i]->setText(model.gvars_names[i]);
if (phase.gvars[i] < 1024) {
gvValues[i]->setValue(phase.gvars[i]);
gvValues[i]->setDisabled(false);
}
else {
int idx = phase.gvars[i] - 1025;
if (idx >= i) idx++;
// TODO no!!!!
PhaseData *phasegvar = &model.phaseData[idx];
gvValues[i]->setValue(phasegvar->gvars[i]);
gvValues[i]->setDisabled(true);
gvValues[i]->setDisabled(false);
int idx = phase.gvars[i];
PhaseData *phasegvar = &phase;
while (idx >= 1024) {
idx -= 1025;
phasegvar = &model.phaseData[idx];
idx = phasegvar->gvars[i];
gvValues[i]->setDisabled(true);
}
gvValues[i]->setValue(phasegvar->gvars[i]);
}
for (int i=0; i<reCount; i++) {
if (phase.rotaryEncoders[i] < 1024) {
reValues[i]->setValue(phase.rotaryEncoders[i]);
reValues[i]->setDisabled(false);
}
else {
int idx = phase.rotaryEncoders[i] - 1025;
if (idx >= i) idx++;
// TODO no!!!!
PhaseData *phasere = &model.phaseData[idx];
reValues[i]->setValue(phasere->rotaryEncoders[i]);
for (int i=0; i<reCount; i++) {
reValues[i]->setDisabled(false);
int idx = phase.rotaryEncoders[i];
PhaseData *phasere = &phase;
while (idx >= 1024) {
idx -= 1025;
phasere = &model.phaseData[idx];
idx = phasere->rotaryEncoders[i];
reValues[i]->setDisabled(true);
}
reValues[i]->setValue(phasere->rotaryEncoders[i]);
}
}
@ -311,21 +307,12 @@ void FlightMode::phaseGVUse_currentIndexChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int gvar = comboBox->property("index").toInt();
if (index == 0) {
int value = phase.gvars[gvar];
if (value>1024) {
value=0;
}
gvValues[gvar]->setValue(value);
gvValues[gvar]->setEnabled(true);
phase.gvars[gvar]=value;
phase.gvars[gvar]=0;
}
else {
phase.gvars[gvar] = 1024+index;
// TOTO it's wrong!!!
int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].gvars[gvar];
gvValues[gvar]->setValue(value);
gvValues[gvar]->setDisabled(true);
}
update();
emit modified();
lock = false;
}
@ -348,21 +335,12 @@ void FlightMode::phaseREUse_currentIndexChanged(int index)
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
int re = comboBox->property("index").toInt();
if (index == 0) {
// TODO no!!!
int value = phase.rotaryEncoders[re];
if (value > 1024) {
value = 0;
}
reValues[re]->setValue(value);
reValues[re]->setEnabled(true);
phase.rotaryEncoders[re] = value;
phase.rotaryEncoders[re] = 0;
}
else {
phase.rotaryEncoders[re] = 1024 + index;
int value = model.phaseData[index + (index>phaseIdx ? 0 :-1)].rotaryEncoders[re];
reValues[re]->setValue(value);
reValues[re]->setDisabled(true) ;
phase.rotaryEncoders[re] = 1024 + index; ;
}
update();
lock = false;
emit modified();
}

View file

@ -98,12 +98,11 @@ void InputsPanel::update()
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
}
}
else {
switch (md->mode) {
case (1): str += " <-"; break;
case (2): str += " ->"; break;
default: str += " "; break;
};
switch (md->mode) {
case (1): str += " <-"; break;
case (2): str += " ->"; break;
default: str += " "; break;
}
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight));
@ -169,12 +168,18 @@ void InputsPanel::gm_openExpo(int index)
if(index<0 || index>=C9X_MAX_EXPOS) return;
ExpoData mixd(model.expoData[index]);
char inputName[4+1];
emit modified();
update();
if (GetEepromInterface()->getCapability(VirtualInputs))
strcpy(inputName, model.inputNames[mixd.chn]);
ExpoDialog *g = new ExpoDialog(this, model, &mixd, generalSettings.stickMode);
ExpoDialog *g = new ExpoDialog(this, model, &mixd, generalSettings.stickMode, inputName);
if (g->exec()) {
model.expoData[index] = mixd;
if (GetEepromInterface()->getCapability(VirtualInputs))
strcpy(model.inputNames[mixd.chn], inputName);
emit modified();
update();
}

View file

@ -28,12 +28,10 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
// The label
QLabel * label = new QLabel(this);
label->setProperty("index", i);
if (i < 9)
label->setText(tr("LS%1").arg(i+1));
else
label->setText(tr("LS%1").arg(QChar('A'+i-9)));
label->setText(tr("L%1").arg(i+1));
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint)));
gridLayout->addWidget(label, i+1, 0);
@ -60,10 +58,11 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
cswitchValue[i]->setVisible(false);
// V2
QHBoxLayout *v2Layout = new QHBoxLayout();
cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
v2Layout->addWidget(cswitchSource2[i]);
cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this);
cswitchOffset[i]->setProperty("index",i);
@ -72,8 +71,18 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
cswitchOffset[i]->setAccelerated(true);
cswitchOffset[i]->setDecimals(0);
connect(cswitchOffset[i], SIGNAL(editingFinished()), this, SLOT(edited()));
gridLayout->addWidget(cswitchOffset[i], i+1, 3);
cswitchOffset[i]->setVisible(false);
v2Layout->addWidget(cswitchOffset[i]);
cswitchOffset2[i] = new QDoubleSpinBox(this);
cswitchOffset2[i]->setProperty("index",i);
cswitchOffset2[i]->setMaximum(125);
cswitchOffset2[i]->setMinimum(-125);
cswitchOffset2[i]->setAccelerated(true);
cswitchOffset2[i]->setDecimals(0);
connect(cswitchOffset2[i], SIGNAL(editingFinished()), this, SLOT(edited()));
cswitchOffset2[i]->setVisible(false);
v2Layout->addWidget(cswitchOffset2[i]);
gridLayout->addLayout(v2Layout, i+1, 3);
// AND
cswitchAnd[i] = new QComboBox(this);
@ -105,7 +114,8 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
}
}
// Push rows upward
addVSpring(gridLayout,0,GetEepromInterface()->getCapability(LogicalSwitches)+1);
lock = false;
}
@ -205,19 +215,19 @@ void LogicalSwitchesPanel::edited()
switch (model.customSw[i].getFunctionFamily())
{
case LS_FAMILY_VOFS:
{
source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
}
else {
model.customSw[i].val2 = ((cswitchOffset[i]->value()-range.offset)/range.step)/* TODO - source.getRawOffset(model)*/;
cswitchOffset[i]->setValue((model.customSw[i].val2 /* + TODO source.getRawOffset(model)*/)*range.step+range.offset);
}
{
source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
}
else {
model.customSw[i].val2 = ((cswitchOffset[i]->value()-range.offset)/range.step)/* TODO - source.getRawOffset(model)*/;
cswitchOffset[i]->setValue((model.customSw[i].val2 /* + TODO source.getRawOffset(model)*/)*range.step+range.offset);
}
break;
}
case LS_FAMILY_TIMER:
model.customSw[i].val1 = TimToVal(cswitchValue[i]->value());
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
@ -225,8 +235,14 @@ void LogicalSwitchesPanel::edited()
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
case LS_FAMILY_STAY:
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
if (sender() == cswitchOffset[i]) {
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
}
else {
model.customSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model.customSw[i].val2;
}
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, true);
break;
default:
break;
@ -243,92 +259,98 @@ void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool
sb->setMinimum(allowZero ? 0.0 : 0.1);
sb->setMaximum(175);
float value = ValToTim(timer);
if (value>60)
if (value>=60)
sb->setSingleStep(1);
else if (value>2)
else if (value>=2)
sb->setSingleStep(0.5);
else
sb->setSingleStep(0.1);
sb->setValue(value);
}
#define SOURCE1_VISIBLE 0x1
#define SOURCE2_VISIBLE 0x2
#define VALUE1_VISIBLE 0x4
#define VALUE2_VISIBLE 0x8
#define VALUE3_VISIBLE 0x10
void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{
lock = true;
RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
unsigned int mask = 0;
RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
switch (model.customSw[i].getFunctionFamily())
{
case LS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(true);
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]->setSingleStep(range.step);
if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
}
else {
cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case LS_FAMILY_VBOOL:
case LS_FAMILY_STICKY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(false);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break;
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);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(false);
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));
break;
case LS_FAMILY_TIMER:
cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false);
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
switch (model.customSw[i].getFunctionFamily())
{
case LS_FAMILY_VOFS:
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE;
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]->setSingleStep(range.step);
if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
}
else {
cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case LS_FAMILY_VBOOL:
case LS_FAMILY_STICKY:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break;
case LS_FAMILY_STAY:
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
updateTimerParam(cswitchOffset2[i], model.customSw[i].val2+model.customSw[i].val3, true);
break;
case LS_FAMILY_VCOMP:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
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));
break;
case LS_FAMILY_TIMER:
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
lock = false;
cswitchSource1[i]->setVisible(mask & SOURCE1_VISIBLE);
cswitchSource2[i]->setVisible(mask & SOURCE2_VISIBLE);
cswitchValue[i]->setVisible(mask & VALUE1_VISIBLE);
cswitchOffset[i]->setVisible(mask & VALUE2_VISIBLE);
cswitchOffset2[i]->setVisible(mask & VALUE3_VISIBLE);
lock = false;
}
void LogicalSwitchesPanel::updateLine(int i)
{
lock = true;
populateCSWCB(csw[i], model.customSw[i].func);
lock = true;
setSwitchWidgetVisibility(i);
lock = true;
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
cswitchDuration[i]->setValue(model.customSw[i].duration/10.0);
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
}
lock = false;
}
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/10.0);
cswitchDelay[i]->setValue(model.customSw[i].delay/10.0);
}
lock = false;
updateLine(i);
}
}
@ -338,36 +360,27 @@ void LogicalSwitchesPanel::cswPaste()
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-csw")) {
QByteArray cswData = mimeData->data("application/x-companion-csw");
LogicalSwitchData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
emit modified();
updateSelectedSwitch();
updateLine(selectedSwitch);
}
}
void LogicalSwitchesPanel::cswDelete()
{
model.customSw[selectedSwitch].clear();
emit modified();
updateSelectedSwitch();
model.customSw[selectedSwitch].clear();
emit modified();
updateLine(selectedSwitch);
}
void LogicalSwitchesPanel::cswCopy()
{
QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void LogicalSwitchesPanel::updateSelectedSwitch()
{
lock = true;
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
setSwitchWidgetVisibility(selectedSwitch);
lock = false;
QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void LogicalSwitchesPanel::cswCut()

View file

@ -32,6 +32,7 @@ class LogicalSwitchesPanel : public ModelPanel
QComboBox * csw[C9X_NUM_CSW];
QDoubleSpinBox * cswitchValue[C9X_NUM_CSW];
QDoubleSpinBox * cswitchOffset[C9X_NUM_CSW];
QDoubleSpinBox * cswitchOffset2[C9X_NUM_CSW];
QComboBox * cswitchAnd[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDuration[C9X_NUM_CSW];
QDoubleSpinBox * cswitchDelay[C9X_NUM_CSW];
@ -40,8 +41,7 @@ class LogicalSwitchesPanel : public ModelPanel
void setSwitchWidgetVisibility(int i);
int selectedSwitch;
void updateSelectedSwitch();
void updateV2(int index);
void updateLine(int index);
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
};

View file

@ -27,12 +27,6 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, i
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, md->weight, 100, -limit, limit);
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, md->sOffset, 0, -limit, limit);
if (GetEepromInterface()->getCapability(VirtualInputs)) {
ui->trimLabel->hide();
ui->trimCB->hide();
}
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve);
ui->MixDR_CB->setChecked(md->noExpo==0);
@ -41,10 +35,13 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, i
ui->label_MixDR->hide();
}
ui->trimCB->addItem(tr("Rud"), 1);
ui->trimCB->addItem(tr("Ele"), 2);
ui->trimCB->addItem(tr("Thr"), 3);
ui->trimCB->addItem(tr("Ail"), 4);
if (!GetEepromInterface()->getCapability(VirtualInputs)) {
ui->trimCB->addItem(tr("Rud"));
ui->trimCB->addItem(tr("Ele"));
ui->trimCB->addItem(tr("Thr"));
ui->trimCB->addItem(tr("Ail"));
}
ui->trimCB->setCurrentIndex(1 - md->carryTrim);
int namelength = GetEepromInterface()->getCapability(HasMixerNames);

View file

@ -43,6 +43,29 @@ MixesPanel::~MixesPanel()
{
}
QString MixesPanel::getChannelLabel(int curDest)
{
QString str;
int outputs = GetEepromInterface()->getCapability(Outputs);
if (curDest > outputs) {
str = QObject::tr("X%1 ").arg(curDest-outputs);
}
else {
str = QObject::tr("CH%1").arg(curDest);
str.append(" ");
str = str.left(4);
if (GetEepromInterface()->getCapability(HasChNames)) {
QString name = model.limitData[curDest-1].name;
if (!name.isEmpty()) {
name = QString("(") + name + QString(")");
}
name.append(" ");
str += name.left(8);
}
}
return str;
}
void MixesPanel::update()
{
// curDest -> destination channel4
@ -52,26 +75,13 @@ void MixesPanel::update()
unsigned int curDest = 0;
int i;
unsigned int outputs = GetEepromInterface()->getCapability(Outputs);
int showNames = false; // TODO in a menu ui->showNames_Ckb->isChecked();
for (i=0; i<GetEepromInterface()->getCapability(Mixes); i++) {
MixData *md = &model.mixData[i];
if ((md->destCh==0) || (md->destCh>outputs+(unsigned int)GetEepromInterface()->getCapability(ExtraChannels))) continue;
QString str = "";
while (curDest<(md->destCh-1)) {
while (curDest < md->destCh-1) {
curDest++;
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
}
else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
str = getChannelLabel(curDest);
qba.clear();
qba.append((quint8)-curDest);
QListWidgetItem *itm = new QListWidgetItem(str);
@ -79,23 +89,12 @@ void MixesPanel::update()
MixerlistWidget->addItem(itm);
}
if (md->destCh > outputs) {
str = tr("X%1 ").arg(md->destCh-outputs);
}
else {
str = tr("CH%1%2").arg(md->destCh/10).arg(md->destCh%10);
str.append(" ");
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[md->destCh-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
str = getChannelLabel(md->destCh);
if (curDest != md->destCh) {
curDest = md->destCh;
} else {
}
else {
str.fill(' ');
}
@ -116,13 +115,11 @@ void MixesPanel::update()
str += " " + tr("Switch(%1)").arg(md->swtch.toString());
}
if (!GetEepromInterface()->getCapability(VirtualInputs)) {
if (md->carryTrim>0) {
str += " " + tr("No Trim");
}
else if (md->carryTrim<0) {
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
}
if (md->carryTrim>0) {
str += " " + tr("No Trim");
}
else if (md->carryTrim<0) {
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
}
if (md->noExpo) str += " " + tr("No DR/Expo");
@ -154,21 +151,7 @@ void MixesPanel::update()
while(curDest<outputs+GetEepromInterface()->getCapability(ExtraChannels)) {
curDest++;
QString str;
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
}
else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;
if (!name.isEmpty()) {
name.append(" ");
str=name.left(6);
}
}
}
QString str = getChannelLabel(curDest);
qba.clear();
qba.append((quint8)-curDest);
QListWidgetItem *itm = new QListWidgetItem(str);

View file

@ -50,7 +50,7 @@ class MixesPanel : public ModelPanel
void mixersDeleteList(QList<int> list);
QList<int> createMixListFromSelected();
void setSelectedByMixList(QList<int> list);
QString getChannelLabel(int curDest);
};
#endif // MIXES_H

View file

@ -22,6 +22,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
generalSettings(radioData.generalSettings)
{
ui->setupUi(this);
setWindowIcon(CompanionIcon("edit.png"));
restoreGeometry(g.modelEditGeo());
ui->pushButton->setIcon(CompanionIcon("simulate.png"));
addTab(new Setup(this, model), tr("Setup"));
@ -32,7 +33,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
addTab(new Channels(this, model), tr("Channels"));
addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches"));
if (GetEepromInterface()->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment"));
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Special Functions"));
addTab(new Curves(this, model), tr("Curves"));
if (GetEepromInterface()->getCapability(Telemetry) & TM_HASTELEMETRY)
addTab(new TelemetryPanel(this, model), tr("Telemetry"));

View file

@ -16,15 +16,42 @@ void ModelPanel::update()
{
}
void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col)
void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col, bool minimize)
{
QLabel *label = new QLabel(this);
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter);
label->setMargin(3);
label->setMargin(5);
label->setText(text);
if (!minimize)
label->setMinimumWidth(100);
gridLayout->addWidget(label, 0, col, 1, 1);
}
void ModelPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
{
QLabel *label = new QLabel(this);
label->setText("");
gridLayout->addWidget(label, 0, col, 1, 1);
}
void ModelPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}

View file

@ -22,8 +22,11 @@ class ModelPanel : public QWidget
protected:
ModelData & model;
bool lock;
void addLabel(QGridLayout * gridLayout, QString text, int col);
void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
void addEmptyLabel(QGridLayout * gridLayout, int col);
void addHSpring(QGridLayout *, int col, int row);
void addVSpring(QGridLayout *, int col, int row);
void addDoubleSpring(QGridLayout *, int col, int row);
};
#endif // CHANNELS_H

View file

@ -112,11 +112,15 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
else {
ui->label_trainerMode->hide();
ui->trainerMode->hide();
if (moduleIdx == 0)
label = tr("Internal Radio System");
else
label = tr("External Radio Module");
if (GetEepromInterface()->getCapability(NumModules) > 1) {
if (moduleIdx == 0)
label = tr("Internal Radio System");
else
label = tr("External Radio Module");
}
else {
label = tr("Radio System");
}
}
ui->label_module->setText(label);
@ -351,14 +355,13 @@ Setup::Setup(QWidget *parent, ModelData & model):
QString path = g.profile[g.id()].sdPath();
path.append("/BMP/");
QDir qd(path);
int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4;
if (qd.exists()) {
QStringList filters;
filters << "*.bmp" << "*.bmp";
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
QFileInfo fi(file);
QString temp = fi.completeBaseName();
if (!items.contains(temp) && temp.length() <= vml) {
if (!items.contains(temp) && temp.length() <= 10+4) {
items.append(temp);
}
}
@ -500,8 +503,10 @@ void Setup::on_trimIncrement_currentIndexChanged(int index)
void Setup::on_throttleSource_currentIndexChanged(int index)
{
model.thrTraceSrc = index;
emit modified();
if (!lock) {
model.thrTraceSrc = ui->throttleSource->itemData(index).toInt();
emit modified();
}
}
void Setup::on_name_editingFinished()
@ -514,8 +519,8 @@ void Setup::on_name_editingFinished()
void Setup::on_image_currentIndexChanged(int index)
{
if (!lock) {
strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength));
QString path=g.profile[g.id()].sdPath();
strncpy(model.bitmap, ui->image->currentText().toAscii(), 10);
QString path = g.profile[g.id()].sdPath();
path.append("/BMP/");
QDir qd(path);
if (qd.exists()) {
@ -530,7 +535,7 @@ void Setup::on_image_currentIndexChanged(int index)
image.load(fileName);
}
if (!image.isNull()) {
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(64, 32)));;
}
else {
ui->imagePreview->clear();
@ -543,12 +548,45 @@ void Setup::on_image_currentIndexChanged(int index)
}
}
void Setup::populateThrottleSourceCB()
{
const QString sources9x[] = { QObject::tr("THR"), QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3")};
const QString sourcesTaranis[] = { QObject::tr("THR"), QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS")};
unsigned int i;
lock = true;
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
for (i=0; i<6; i++) {
ui->throttleSource->addItem(sourcesTaranis[i], i);
}
}
else {
for (i=0; i<4; i++) {
ui->throttleSource->addItem(sources9x[i], i);
}
}
if (model.thrTraceSrc < i)
ui->throttleSource->setCurrentIndex(model.thrTraceSrc);
int channels = (IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16);
for (int i=0; i<channels; i++) {
ui->throttleSource->addItem(QObject::tr("CH%1").arg(i+1, 2, 10, QChar('0')), THROTTLE_SOURCE_FIRST_CHANNEL+i);
if (model.thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1);
}
lock = false;
}
void Setup::update()
{
ui->name->setText(model.name);
ui->throttleReverse->setChecked(model.throttleReversed);
populateTTraceCB(ui->throttleSource, model.thrTraceSrc);
populateThrottleSourceCB();
ui->throttleWarning->setChecked(!model.disableThrottleWarning);
//trim inc, thro trim, thro expo, instatrim

View file

@ -6,6 +6,7 @@
#include <QCheckBox>
#include <QSlider>
#include <QSpinBox>
#include <QComboBox>
#include <QLabel>
namespace Ui {
@ -104,6 +105,7 @@ class Setup : public ModelPanel
void updateStartupSwitches();
void updatePotWarnings();
void updateBeepCenter();
void populateThrottleSourceCB();
};
#endif // SETUP_H

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>787</width>
<height>727</height>
<width>840</width>
<height>520</height>
</rect>
</property>
<property name="windowTitle">
@ -16,175 +16,88 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,0,0,0,0,0">
<item row="4" column="1">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="3">
<widget class="QComboBox" name="image"/>
</item>
<item row="0" column="4">
<widget class="QLabel" name="imagePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QCheckBox" name="throttleReverse">
<property name="whatsThis">
<string>Reverse throttle operation.
If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well.
</string>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
<string>Reverse Throttle</string>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_26">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="1">
<widget class="QCheckBox" name="extendedLimits">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_24">
<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 row="0" column="2">
<widget class="QLabel" name="modelImage_label">
<property name="text">
<string>Model Image</string>
<string>Extended Limits</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="name">
<widget class="QComboBox" name="throttleSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>10</number>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="extendedTrims">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Extended Trims</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Model Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_timer2">
<property name="text">
<string>Timer2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Timer1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_ttrace">
<property name="text">
<string>Throttle Source</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="swwarn_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Switch Warnings</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Center beep</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QGridLayout" name="centerBeepLayout"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Trim Increment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<item row="0" column="1">
<widget class="QCheckBox" name="throttleTrim">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Trim</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="throttleWarning">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Throttle Warning</string>
</property>
</widget>
</item>
<item row="0" column="4">
<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 row="1" column="0">
<widget class="QComboBox" name="trimIncrement">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -219,173 +132,393 @@
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="extendedLimits">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Extended Limits</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="extendedTrims">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Extended Trims</string>
</property>
</widget>
</item>
<item>
<item row="1" column="3">
<widget class="QCheckBox" name="displayText">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Display Checklist</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>
</layout>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="throttleSource">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleTrim">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Throttle Trim</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleWarning">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Throttle Warning</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="throttleReverse">
<property name="whatsThis">
<string>Reverse throttle operation.
If this is checked the throttle will be reversed. Idle will be forward, trim will also be reversed and the throttle warning will be reversed as well.
</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Reverse Throttle</string>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item row="5" column="1">
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0" columnstretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_potWarning">
<property name="enabled">
<bool>true</bool>
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label_timer2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Pot Warnings</string>
<string>Timer2</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QGridLayout" name="potWarningLayout">
<item row="0" column="0">
<widget class="QComboBox" name="potWarningMode">
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item row="1" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Timer1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ttrace">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Throttle Source</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Trim Increment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QGridLayout" name="centerBeepLayout"/>
</item>
<item>
<spacer name="horizontalSpacer_4">
<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="7" column="0" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Center beep</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="name">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>10</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="modelImage_label">
<property name="text">
<string>Model Image</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="imagePreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>32</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>
<item>
<widget class="QComboBox" name="image"/>
</item>
<item>
<spacer name="horizontalSpacer_26">
<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">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="QLabel" name="swwarn_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Warnings</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Switch Warnings</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0" columnstretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item alignment="Qt::AlignTop">
<widget class="QLabel" name="label_potWarning">
<property name="text">
<string>Pot Warnings</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="potWarningLayout">
<item row="0" column="0" alignment="Qt::AlignTop">
<widget class="QComboBox" name="potWarningMode">
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<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>
</layout>
</item>
</layout>
</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>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Model</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="modulesLayout"/>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

View file

@ -6,14 +6,46 @@
<rect>
<x>0</x>
<y>0</y>
<width>694</width>
<height>340</height>
<width>628</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_module">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="moduleGB">
<property name="sizePolicy">
@ -35,7 +67,41 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_69" rowstretch="0,0,0,0,0,0,0,0,0" columnstretch="0,0,0,0,0,0,0">
<item row="7" column="1" colspan="5">
<property name="margin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="2" column="3" alignment="Qt::AlignLeft">
<widget class="QSpinBox" name="channelsStart">
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string>ch</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="6" column="1" colspan="5">
<widget class="QFrame" name="failsafesFrame">
<property name="maximumSize">
<size>
@ -56,7 +122,7 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_failsafeMode">
<property name="maximumSize">
<size>
@ -72,7 +138,7 @@
</property>
</widget>
</item>
<item row="3" column="2" alignment="Qt::AlignRight">
<item row="2" column="2" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_channelsStart">
<property name="maximumSize">
<size>
@ -88,7 +154,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="protocol">
<property name="maximumSize">
<size>
@ -98,7 +164,7 @@
</property>
</widget>
</item>
<item row="4" column="4" alignment="Qt::AlignRight">
<item row="3" column="4" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmDelay">
<property name="maximumSize">
<size>
@ -114,7 +180,7 @@
</property>
</widget>
</item>
<item row="4" column="5">
<item row="3" column="5">
<widget class="QSpinBox" name="ppmDelay">
<property name="maximumSize">
<size>
@ -142,7 +208,7 @@
</property>
</widget>
</item>
<item row="4" column="3" alignment="Qt::AlignLeft">
<item row="3" column="3" alignment="Qt::AlignLeft">
<widget class="QComboBox" name="ppmPolarity">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -168,23 +234,7 @@
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_rxNumber">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>RX Number</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QComboBox" name="trainerMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -210,7 +260,7 @@
</item>
</widget>
</item>
<item row="4" column="2" alignment="Qt::AlignRight">
<item row="3" column="2" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmPolarity">
<property name="maximumSize">
<size>
@ -226,7 +276,7 @@
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<item row="0" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_trainerMode">
<property name="maximumSize">
<size>
@ -242,38 +292,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="rxNumber">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="ppmFrameLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -307,33 +326,7 @@
</property>
</widget>
</item>
<item row="4" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmFrameLength">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>PPM Frame Length</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="QLabel" name="label_module">
<property name="styleSheet">
<string notr="true">font-weight: bold;</string>
</property>
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="3" column="5" alignment="Qt::AlignLeft">
<item row="2" column="5" alignment="Qt::AlignLeft">
<widget class="QSpinBox" name="channelsCount">
<property name="maximumSize">
<size>
@ -361,35 +354,23 @@
</property>
</widget>
</item>
<item row="3" column="3" alignment="Qt::AlignLeft">
<widget class="QSpinBox" name="channelsStart">
<item row="3" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_ppmFrameLength">
<property name="maximumSize">
<size>
<width>125</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>PPM Frame Length</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string>ch</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="4" alignment="Qt::AlignRight">
<item row="2" column="4" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_channelsCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -411,7 +392,7 @@
</property>
</widget>
</item>
<item row="6" column="1" alignment="Qt::AlignLeft">
<item row="5" column="1" alignment="Qt::AlignLeft">
<widget class="QComboBox" name="failsafeMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -440,9 +421,14 @@
<string>No Pulses</string>
</property>
</item>
<item>
<property name="text">
<string>Receiver</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" alignment="Qt::AlignRight">
<item row="6" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="failsafesLayoutLabel">
<property name="maximumSize">
<size>
@ -458,20 +444,7 @@
</property>
</widget>
</item>
<item row="8" column="0">
<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 row="3" column="0" alignment="Qt::AlignRight">
<item row="2" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_protocol">
<property name="maximumSize">
<size>
@ -487,6 +460,79 @@
</property>
</widget>
</item>
<item row="2" column="6">
<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 row="8" column="0">
<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 row="5" column="5">
<widget class="QSpinBox" name="rxNumber">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>125</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QLabel" name="label_rxNumber">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>RX Number</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -28,10 +28,20 @@ TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
update();
ui->UnitCB->setCurrentIndex(analog.type);
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
}
else {
ui->alarm1LevelCB->hide();
ui->alarm2LevelCB->hide();
ui->alarm1GreaterCB->hide();
ui->alarm2GreaterCB->hide();
ui->alarm1Label->setText(tr("Low Alarm"));
ui->alarm2Label->setText(tr("Critical Alarm"));
}
if (!(GetEepromInterface()->getCapability(Telemetry) & TM_HASOFFSET)) {
ui->CalibSB->hide();
@ -281,7 +291,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
for (int c=0; c<GetEepromInterface()->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
fieldsCB[l][c] = new QComboBox(this);
fieldsCB[l][c]->setProperty("index", c + (l<<8));
populateCustomScreenFieldCB(fieldsCB[l][c], screen.body.lines[l].source[c], (l<4), model.frsky.usrProto);
populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model.frsky.usrProto);
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
connect(fieldsCB[l][c], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldChanged(int)));
}
@ -290,7 +300,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
for (int l=0; l<4; l++) {
barsCB[l] = new QComboBox(this);
barsCB[l]->setProperty("index", l);
populateCustomScreenFieldCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto);
populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto);
connect(barsCB[l], SIGNAL(currentIndexChanged(int)), this, SLOT(barSourceChanged(int)));
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
@ -316,6 +326,31 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
update();
}
void TelemetryCustomScreen::populateTelemetrySourceCB(QComboBox *b, unsigned int value, bool last, int hubproto)
{
int telem_hub[] = {0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,0,2,2,1,1,1,1,1,1};
b->clear();
b->addItem(RawSource(SOURCE_TYPE_NONE, 0).toString());
for (unsigned int i = 0; i < (last ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_DISPLAY_COUNT); i++) {
b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString());
if (!(i>=sizeof(telem_hub)/sizeof(int) || telem_hub[i]==0 || ((telem_hub[i]>=hubproto) && hubproto!=0))) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if (value>=sizeof(telem_hub)/sizeof(int))
b->setCurrentIndex(0);
else if (telem_hub[value]==0 || ((telem_hub[value]>=hubproto) && hubproto!=0)) {
b->setCurrentIndex(value);
}
b->setMaxVisibleItems(10);
}
TelemetryCustomScreen::~TelemetryCustomScreen()
{
delete ui;
@ -347,6 +382,8 @@ void TelemetryCustomScreen::update()
void TelemetryCustomScreen::updateBar(int line)
{
lock = true;
int index = screen.body.bars[line].source;
barsCB[line]->setCurrentIndex(index);
if (index) {
@ -372,6 +409,8 @@ void TelemetryCustomScreen::updateBar(int line)
minSB[line]->setDisabled(true);
maxSB[line]->setDisabled(true);
}
lock = false;
}
void TelemetryCustomScreen::on_screenType_currentIndexChanged(int index)
@ -393,13 +432,15 @@ void TelemetryCustomScreen::customFieldChanged(int value)
void TelemetryCustomScreen::barSourceChanged(int index)
{
QComboBox * cb = qobject_cast<QComboBox*>(sender());
int line = cb->property("index").toInt();
screen.body.bars[line].source = index;
screen.body.bars[line].barMin = 0;
screen.body.bars[line].barMax = 0;
updateBar(line);
emit modified();
if (!lock) {
QComboBox * cb = qobject_cast<QComboBox*>(sender());
int line = cb->property("index").toInt();
screen.body.bars[line].source = index;
screen.body.bars[line].barMin = 0;
screen.body.bars[line].barMax = 0;
updateBar(line);
emit modified();
}
}
void TelemetryCustomScreen::barMinChanged(double value)
@ -447,6 +488,10 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model):
ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i+1));
}
if (IS_ARM(GetEepromInterface()->getBoard())) {
ui->bladesCount->setMinimum(1);
}
setup();
}
@ -467,8 +512,16 @@ void TelemetryPanel::setup()
}
ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value);
ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value);
ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
}
else {
ui->rssiAlarm1CB->hide();
ui->rssiAlarm2CB->hide();
ui->rssiAlarm1Label->setText(tr("Low Alarm"));
ui->rssiAlarm2Label->setText(tr("Critical Alarm"));
}
if (!GetEepromInterface()->getCapability(HasAltitudeSel)) {
ui->AltitudeGPS_ChkB->hide();
@ -585,7 +638,7 @@ void TelemetryPanel::setup()
ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto);
ui->frskyUnitsCB->setCurrentIndex(model.frsky.imperial);
ui->frskyBladesCB->setCurrentIndex(model.frsky.blades);
ui->bladesCount->setValue(model.frsky.blades);
ui->frskyCurrentCB->setCurrentIndex(model.frsky.currentSource);
ui->frskyVoltCB->setCurrentIndex(model.frsky.voltsSource);
@ -599,13 +652,13 @@ void TelemetryPanel::onAnalogModified()
void TelemetryPanel::on_frskyUnitsCB_currentIndexChanged(int index)
{
model.frsky.imperial=index;
model.frsky.imperial = index;
emit modified();
}
void TelemetryPanel::on_frskyBladesCB_currentIndexChanged(int index)
void TelemetryPanel::on_bladesCount_editingFinished()
{
model.frsky.blades=index;
model.frsky.blades = ui->bladesCount->value();
emit modified();
}

View file

@ -61,6 +61,9 @@ class TelemetryCustomScreen : public ModelPanel
void barMinChanged(double value);
void barMaxChanged(double value);
protected:
void populateTelemetrySourceCB(QComboBox *b, unsigned int value, bool last, int hubproto);
private:
void updateBar(int line);
Ui::TelemetryCustomScreen * ui;
@ -86,7 +89,7 @@ class TelemetryPanel : public ModelPanel
void onAnalogModified();
void on_frskyProtoCB_currentIndexChanged(int index);
void on_frskyUnitsCB_currentIndexChanged(int index);
void on_frskyBladesCB_currentIndexChanged(int index);
void on_bladesCount_editingFinished();
void on_frskyCurrentCB_currentIndexChanged(int index);
void on_frskyVoltCB_currentIndexChanged(int index);
void on_AltitudeToolbar_ChkB_toggled(bool checked);

View file

@ -6,16 +6,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<width>757</width>
<height>457</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14" stretch="0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout_14" stretch="0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
@ -33,37 +36,86 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="title">
<string>A1</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="A1Layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>1</number>
<number>3</number>
</property>
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>A1</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="A2GB">
<property name="title">
<string>A2</string>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="A2Layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>1</number>
<number>3</number>
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>A2</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="RSSIGB">
<property name="sizePolicy">
@ -72,14 +124,52 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>RSSI</string>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_927">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="1" column="3">
<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 row="3" column="1">
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="rssiAlarm1Label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -98,7 +188,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="rssiAlarm1CB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -128,7 +218,7 @@
</item>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="2">
<widget class="QSpinBox" name="rssiAlarm1SB">
<property name="enabled">
<bool>true</bool>
@ -156,10 +246,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_928">
<item row="2" column="0">
<widget class="QLabel" name="rssiAlarm2Label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -175,7 +265,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="rssiAlarm2CB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -205,7 +295,7 @@
</item>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QSpinBox" name="rssiAlarm2SB">
<property name="enabled">
<bool>true</bool>
@ -233,18 +323,18 @@
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
<property name="text">
<string>RSSI</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
@ -252,7 +342,17 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13" stretch="1,1">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13" stretch="1,0,1">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
@ -264,19 +364,31 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Serial Protocol</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>1</number>
<number>3</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_34" columnstretch="0,1,1,1">
<item row="2" column="0">
<property name="horizontalSpacing">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -289,7 +401,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="frskyUnitsCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -309,7 +421,7 @@
</item>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QLabel" name="current_label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -328,7 +440,7 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_112">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -347,7 +459,7 @@
</property>
</widget>
</item>
<item row="2" column="3">
<item row="3" column="3">
<widget class="QComboBox" name="frskyCurrentCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -377,7 +489,7 @@
</item>
</widget>
</item>
<item row="0" column="1" colspan="3">
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="frskyProtoCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -397,7 +509,7 @@
</item>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="frskyVoltCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -427,32 +539,7 @@
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="frskyBladesCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_113">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -471,7 +558,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QLabel" name="blades_label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -484,11 +571,53 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Serial Protocol</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QDoubleSpinBox" name="bladesCount">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="minimum">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>5.000000000000000</double>
</property>
<property name="value">
<double>2.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="altimetryGB">
<property name="sizePolicy">
@ -497,19 +626,28 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Altimetry / Vario</string>
</property>
<layout class="QGridLayout" name="gridLayout_39">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>1</number>
<number>3</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_40" rowstretch="1,0,0" columnstretch="0,0">
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_40" rowstretch="1,0,0,0" columnstretch="0,0">
<property name="horizontalSpacing">
<number>9</number>
</property>
<item row="1" column="1">
<widget class="QComboBox" name="varioSourceCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@ -544,7 +682,7 @@
</item>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<layout class="QGridLayout" name="gridLayout_66" columnstretch="1,0,0,0">
<item row="0" column="0">
<widget class="QLabel" name="VarioLabel_1">
@ -558,7 +696,7 @@
<string>Sink Max</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -681,7 +819,7 @@
<string>Climb Max</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -697,7 +835,7 @@
<string>Sink Min</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -713,27 +851,27 @@
<string>Climb Min</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="varioSource_label">
<property name="text">
<string>Vario source</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="varioLimit_label">
<property name="text">
<string>Vario limits</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QCheckBox" name="AltitudeGPS_ChkB">
@ -763,6 +901,19 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Altimetry</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -770,6 +921,13 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="variousGB">
<property name="sizePolicy">
@ -778,19 +936,38 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Various</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>1</number>
<number>9</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QLabel" name="mahCount_label">
<property name="text">
<string>mAh count</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="mahCount_SB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -803,34 +980,7 @@
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="mahCount_label">
<property name="text">
<string>mAh count</string>
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="fasOffset_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FAS Offset</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="mahCount_ChkB">
<property name="text">
<string>Persistent mAh</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="fasOffset_DSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -852,7 +1002,27 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="0">
<widget class="QLabel" name="fasOffset_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FAS Offset</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="mahCount_ChkB">
<property name="text">
<string>Persistent mAh</string>
</property>
</widget>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -865,6 +1035,25 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Various</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<width>276</width>
<height>118</height>
</rect>
</property>
@ -14,6 +14,21 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_11" columnstretch="1,1,1,1" columnminimumwidth="0,0,0,0">
<item row="0" column="0">
@ -43,7 +58,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_919">
<widget class="QLabel" name="alarm1Label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -106,7 +121,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_921">
<widget class="QLabel" name="alarm2Label">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -260,7 +275,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="UnitCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">

View file

@ -277,10 +277,7 @@ void ModelsListWidget::refreshList()
clear();
int msize;
div_t divresult;
QString name = radioData->generalSettings.ownerName;
if(!name.isEmpty())
name.prepend(" - ");
addItem(tr("General Settings") + name);
addItem(tr("General Settings"));
EEPROMInterface *eepromInterface = GetEepromInterface();
int availableEEpromSize = eepromInterface->getEEpromSize()-64; //let's consider fat

View file

@ -42,7 +42,8 @@ printDialog::printDialog(QWidget *parent, GeneralSettings *gg, ModelData *gm, QS
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
gvars=1;
}
} else {
}
else {
gvars=1;
}
@ -519,23 +520,6 @@ void printDialog::printCurves()
int i,r,g,b,c,count;
char buffer[16];
QPen pen(Qt::black, 2, Qt::SolidLine);
QColor * qplot_color[16];
qplot_color[0]=new QColor(0,0,127);
qplot_color[1]=new QColor(0,127,0);
qplot_color[2]=new QColor(127,0,0);
qplot_color[3]=new QColor(0,127,127);
qplot_color[4]=new QColor(127,0,127);
qplot_color[5]=new QColor(127,127,0);
qplot_color[6]=new QColor(127,127,127);
qplot_color[7]=new QColor(0,0,255);
qplot_color[8]=new QColor(0,127,255);
qplot_color[9]=new QColor(127,0,255);
qplot_color[10]=new QColor(0,255,0);
qplot_color[11]=new QColor(0,255,127);
qplot_color[12]=new QColor(127,255,0);
qplot_color[13]=new QColor(255,0,0);
qplot_color[14]=new QColor(255,0,127);
qplot_color[15]=new QColor(255,127,0);
QString str = "<table border=1 cellspacing=0 cellpadding=3 style=\"page-break-before:auto;\" width=\"100%\"><tr><td><h2>";
str.append(tr("Curves"));
@ -552,16 +536,18 @@ void printDialog::printCurves()
painter.drawRect(0,0,ISIZEW,ISIZEW);
str.append("<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">"+QString("<tr><td width=\"400\"><img src=\"%1\" border=0></td><td><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">").arg(curvefile5));
for(i=0; i<numcurves; i++) {
pen.setColor(*qplot_color[i]);
pen.setColor(colors[i]);
painter.setPen(pen);
qplot_color[i]->getRgb(&r,&g,&b);
colors[i].getRgb(&r,&g,&b);
c=r;
c*=256;
c+=g;
c*=256;
c+=b;
sprintf(buffer,"%06x",c);
str.append(QString("<tr><td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td></tr>").arg(i+1));
if(i%2 == 0) str.append("<tr>");
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td>").arg(i+1));
if(i%2) str.append("</tr>");
}
str.append("</table></td></tr><tr><td colspan=2><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">");
str.append("<tr>");
@ -576,9 +562,9 @@ void printDialog::printCurves()
str.append(doTC(tr("pt %1").arg(i+1), "", true));
str.append("</tr>");
for(i=0; i<numcurves; i++) {
pen.setColor(*qplot_color[i]);
pen.setColor(colors[i]);
painter.setPen(pen);
qplot_color[i]->getRgb(&r,&g,&b);
colors[i].getRgb(&r,&g,&b);
c=r;
c*=256;
c+=g;
@ -697,7 +683,7 @@ void printDialog::printFSwitches()
{
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Switch Assignments")+"</h2></td></tr>");
str.append("<tr><td><h2>"+tr("Special Functions")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3><tr>");
str.append(doTC(tr("Switch"), "", true));
str.append(doTL(tr("Function"), "", true));
@ -767,7 +753,7 @@ void printDialog::printFrSky()
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr>");
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Frsky serial protocol")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyProtocol(fd->usrProto)+"</td></tr>");
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("System of units")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyMeasure(fd->imperial)+"</td></tr>");
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Propeller blades")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyBlades(fd->blades)+"</td></tr>");
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Blades")+"</b></td><td colspan=8 align=\"left\">"+fd->blades+"</td></tr>");
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr></table>");
#if 0
if (GetEepromInterface()->getCapability(TelemetryBars) || (GetEepromInterface()->getCapability(TelemetryCSFields))) {

View file

@ -364,7 +364,7 @@ void SimulatorDialog9X::setLightOn(bool enable)
list << "bl" << "gr" << "rd" << "or" << "yl";
bg = QString("-") + list[backLight];
}
ui->top->setStyleSheet(QString("background:url(:/images/9xdt.png%1);").arg(bg));
ui->top->setStyleSheet(QString("background:url(:/images/9xdt%1.png);").arg(bg));
ui->bottom->setStyleSheet(QString("background:url(:/images/9xdb%1.png);").arg(bg));
ui->left->setStyleSheet(QString("background:url(:/images/9xdl%1.png);").arg(bg));
ui->right->setStyleSheet(QString("background:url(:/images/9xdr%1.png);").arg(bg));
@ -515,6 +515,7 @@ void SimulatorDialogTaranis::getValues()
{
-ui->dialP_1->value(),
ui->dialP_2->value(),
0,
-ui->dialP_3->value(),
ui->dialP_4->value()
},

View file

@ -14,6 +14,10 @@
*
*/
#if !defined(NUM_LOGICAL_SWITCH) && defined(NUM_CSW)
#define NUM_LOGICAL_SWITCH NUM_CSW
#endif
#ifdef INIT_IMPORT
#undef INIT_IMPORT
#ifdef FRSKY
@ -49,7 +53,7 @@ if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40;
#undef GETVALUES_IMPORT
memset(outputs.chans, 0, sizeof(outputs.chans));
memcpy(outputs.chans, g_chans512, sizeof(g_chans512));
for (int i=0; i<NUM_CSW; i++)
for (int i=0; i<NUM_LOGICAL_SWITCH; i++)
#if defined(BOLD_FONT)
outputs.vsw[i] = getSwitch(SWSRC_SW1+i);
#else

View file

@ -21,7 +21,7 @@
struct TxInputs {
int sticks[NUM_STICKS]; /* lh lv rv rh */
int pots[4]; /* TODO NUM_POTS */
int pots[5]; /* TODO NUM_POTS */
int switches[10]; /* TODO NUM_SWITCHES */
bool keys[6]; /* TODO NUM_KEYS */
bool rotenc;

View file

@ -101,17 +101,32 @@ int main(int argc, char *argv[])
RegisterFirmwares();
SimulatorDialog *dialog;
const char * eepromFileName;
if (argc > 1 && !strcmp(argv[1], "taranis")) {
QMessageBox msgBox;
msgBox.setWindowTitle("Radio type");
msgBox.setText("Which radio type do you want to simulate?");
msgBox.setIcon(QMessageBox::Question);
QAbstractButton *taranisButton = msgBox.addButton("Taranis", QMessageBox::ActionRole);
msgBox.addButton("9X", QMessageBox::ActionRole);
QPushButton *exitButton = msgBox.addButton(QMessageBox::Close);
msgBox.exec();
if (msgBox.clickedButton() == exitButton)
return 0;
else if (msgBox.clickedButton() == taranisButton) {
current_firmware_variant = GetFirmwareVariant("opentx-taranis-en");
eepromFileName = "eeprom-taranis.bin";
dialog = new SimulatorDialogTaranis();
}
else {
eepromFileName = "eeprom-9x.bin";
dialog = new SimulatorDialog9X();
}
dialog->show();
dialog->start("eeprom.bin");
dialog->start(eepromFileName);
int result = app.exec();

View file

@ -0,0 +1,19 @@
#include "taranisnotfound.h"
#include "ui_taranisnotfound.h"
taranisNotFoundDialog::taranisNotFoundDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::taranisNotFoundDialog)
{
ui->setupUi(this);
}
taranisNotFoundDialog::~taranisNotFoundDialog()
{
delete ui;
}
void taranisNotFoundDialog::on_OK_clicked()
{
accept();
}

View file

@ -0,0 +1,22 @@
#ifndef TARANISNOTFOUNDDIALOG_H
#define TARANISNOTFOUNDDIALOG_H
#include <QDialog>
namespace Ui {
class taranisNotFoundDialog;
}
class taranisNotFoundDialog : public QDialog
{
Q_OBJECT
public:
explicit taranisNotFoundDialog(QWidget *parent = 0);
~taranisNotFoundDialog();
private:
Ui::taranisNotFoundDialog *ui;
private slots:
void on_OK_clicked();
};
#endif // TARANISNOTFOUNDDIALOG_H

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>taranisNotFoundDialog</class>
<widget class="QDialog" name="taranisNotFoundDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>350</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>367</width>
<height>350</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>367</width>
<height>350</height>
</size>
</property>
<property name="windowTitle">
<string>No Taranis Radio Found</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;No Taranis Radio was found!&lt;/p&gt;&lt;p&gt;Make sure that you hold the lower trim buttons towards the center while you turn it on.&lt;/p&gt;&lt;p&gt;Then connect the USB wire.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="companion.qrc">:/images/taranison.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<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="QPushButton" name="OK">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<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>
</layout>
</widget>
<resources>
<include location="companion.qrc"/>
</resources>
<connections/>
</ui>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -109,11 +109,18 @@ Section "OpenTX companion" SecDummy
${registerExtension} "$INSTDIR\companion.exe" ".hex" "HEX_File"
${registerExtension} "$INSTDIR\companion.exe" ".companion" "EEPE_File"
${registerExtension} "$INSTDIR\companion.exe" ".eepm" "EEPM_File"
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
;Registry information for add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "DisplayName" "OpenTX Companion"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "DisplayIcon" "$\"$INSTDIR\companion.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "Publisher" "OpenTX"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "URLInfoAbout" "http://www.open-tx.org"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ImageMaker" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
@ -178,6 +185,7 @@ Section "Uninstall"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCU "Software\companion9x"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX"
SectionEnd

View file

@ -12,14 +12,14 @@
;General
;Name and file
Name "OpenTX companion"
Name "OpenTX Companion"
OutFile "companionInstall_v@C9X_VERSION@.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\OpenTX companion"
InstallDir "$PROGRAMFILES\OpenTX"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\companion9x" ""
InstallDirRegKey HKCU "Software\OpenTX" ""
;Compressor options
SetCompressor /FINAL /SOLID lzma
@ -66,7 +66,7 @@
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\companion9x"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenTX"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
@ -77,7 +77,7 @@
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Launch companion"
!define MUI_FINISHPAGE_RUN_TEXT "Launch OpenTX Companion"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
# !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
# !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\readme.txt
@ -95,7 +95,7 @@
;--------------------------------
;Installer Sections
Section "OpenTX companion" SecDummy
Section "OpenTX Companion" SecDummy
SetOutPath "$INSTDIR"
@ -129,7 +129,7 @@ Section "OpenTX companion" SecDummy
SetOutPath "$INSTDIR"
;Store installation folder
WriteRegStr HKCU "Software\companion9x" "" $INSTDIR
WriteRegStr HKCU "Software\OpenTX" "" $INSTDIR
;Associate with extentions ,bin and .hex
${registerExtension} "$INSTDIR\companion.exe" ".bin" "BIN_File"
@ -141,6 +141,14 @@ Section "OpenTX companion" SecDummy
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
;Registry information for add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "DisplayName" "OpenTX Companion"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "DisplayIcon" "$\"$INSTDIR\companion.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "Publisher" "OpenTX"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX" "URLInfoAbout" "http://www.open-tx.org"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ImageMaker" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
@ -207,7 +215,8 @@ Section "Uninstall"
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey /ifempty HKCU "Software\companion9x"
DeleteRegKey /ifempty HKCU "Software\OpenTX"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX"
SectionEnd

View file

@ -1,6 +1,6 @@
Copyright © 2011-2013 Bertrand Songis and Romolo Manfredini
Copyright © 2011-2014 OpenTX team
companion9x is based on code named eePe by author - Erez Raviv <erezraviv@gmail.com>
OpenTX Companion is based on code named eePe by author - Erez Raviv <erezraviv@gmail.com>
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

View file

@ -1,5 +1,26 @@
<SVN CURRENT>
<h2>2940 / 2014-02-02</h2>
[Arm Boards]
<ul>
<li>Wav files played even in silent mode
<li>GPS support had broken VFAS
</ul>
[all]
<ul>
<li>Custom function triggered by a CSW based on analog triggering erroneously at powerup
<li>Problem with mixer weight field when !GVARS
<li>PPM5 was broken
</ul>
<h2>2923 / 2014-01-08</h2>
[Arm Boards]
<ul>
<li>Audio freeze bug fixed
<li>Aurora gimbals support
</ul>
<h2>2834 / 2013-10-29</h2>
[Arm Boards]
<ul>
@ -10,7 +31,7 @@
[all]
<ul>
<li>Mixer bug when a MULTIPLY mix used with a slow
<li>I GVAR popup removed
<li>GVAR popup removed
<li>Sticky virtual switches are reset when ResetFlight function is called
</ul>

View file

@ -1,13 +1,28 @@
<SVN CURRENT>
<h2>2940 / 2014-02-02</h2>
<ul>
<li>Wav files played even in silent mode
<li>GPS support had broken VFAS
<li>Custom function triggered by a CSW based on analog triggering erroneously at powerup
<li>Problem with mixer weight field when !GVARS
<li>PPM5 was broken
</ul>
<h2>2923 / 2014-01-08</h2>
<ul>
<li>DSM2 Support
<li>New S.PORT sensors support
<li>Audio freeze bug fixed
<li>Telemetry corruption
<li>A2 alarms reinstated in D16 mode for X8R2Analog sensor
<li>Telemetry lost alarm no more triggered by a telemetry reset
</ul>
<h2>2834 / 2013-10-29</h2>
<ul>
<li>Altitude played without decimal when &gt;= 10m
<li>Check to avoid too long paths when playing SD files
</ul>
[all]
<ul>
<li>Mixer bug when a MULTIPLY mix used with a slow
<li>I GVAR popup removed
<li>Sticky virtual switches are reset when ResetFlight function is called

View file

@ -16,3 +16,4 @@
/SOUNDS
/LOGS
/allsrc.cpp
/BMP

View file

@ -28,14 +28,20 @@ extern "C" {
/ object instead of the sector buffer in the individual file object for file
/ data transfer. This reduces memory consumption 512 bytes each file object. */
#if defined(BOOT)
#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
#else
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
#endif
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
/ f_truncate and useless f_getfree. */
#if defined(BOOT)
#define _FS_MINIMIZE 1 /* 0 to 3 */
#else
#define _FS_MINIMIZE 0 /* 0 to 3 */
#endif
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
/
/ 0: Full function.
@ -45,7 +51,11 @@ extern "C" {
/ 3: f_lseek is removed in addition to 2. */
#if defined(BOOT)
#define _USE_STRFUNC 0 /* 0:Disable or 1-2:Enable */
#else
#define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */
#endif
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
@ -186,7 +196,7 @@ extern "C" {
/* A header file that defines sync object types on the O/S, such as
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
#if defined(CPUARM)
#if defined(CPUARM) && !defined(BOOT)
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
#define _SYNC_t unsigned char /*OS_MutexID*/ /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
#else

View file

@ -271,8 +271,9 @@ MENUS_LOCK == NO
# Define programs and commands.
SHELL = sh
IMG2LBM = -python ../util/img2lbm.py
BIN2LBM = -python ../util/bin2lbm.py
TRANSLATE = -python ../util/translate.py
VERSION = 2.0
VERSION = 1.99
SRC =
CPPSRC =
@ -281,7 +282,7 @@ EXTRAINCDIRS =
# MCU name
ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X TARANIS))
$(error Sorry, the PCB $(PCB) is not supported yet in openTx)
$(error Sorry, the PCB $(PCB) is not supported yet in OpenTX)
endif
GVARS_VARIANT = +1
@ -613,7 +614,7 @@ ifeq ($(PCB), TARANIS)
else
CPPDEFS = -DREV4
endif
LDSCRIPT = targets/taranis/stm32_flash.ld
LDSCRIPT = targets/taranis/stm32_flash_bl.ld
TRGT = arm-none-eabi-
MCU = cortex-m3
OPT = 2
@ -627,13 +628,14 @@ ifeq ($(PCB), TARANIS)
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc
EXTRAINCDIRS += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc
BOARDSRC = targets/taranis/board_taranis.cpp
EXTRABOARDSRC += targets/taranis/lcd_driver.cpp targets/taranis/aspi.cpp targets/taranis/i2c.c
EXTRABOARDSRC += targets/taranis/lcd_driver.cpp targets/taranis/aspi.c targets/taranis/i2c.c targets/taranis/delays.c
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
SRC += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp
PULSESSRC = protocols/pulses_arm.cpp protocols/ppm_arm.cpp protocols/pxx_arm.cpp
CPPSRC += audio_arm.cpp
CPPSRC += targets/taranis/pwr_driver.cpp targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/delays.cpp targets/taranis/uart3_driver.cpp targets/taranis/sport_driver.cpp
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/sport_driver.cpp
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp loadboot.cpp
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
@ -645,18 +647,14 @@ ifeq ($(PCB), TARANIS)
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
SRC += targets/taranis/usb_bsp.c targets/taranis/usbd_desc.c
SRC += targets/taranis/usb_bsp.c targets/taranis/usbd_desc.c targets/taranis/usbd_hid_joystick.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_core.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd_int.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
SRC += targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
EXTRABOARDSRC += targets/taranis/usbd_usr.cpp targets/taranis/usbd_storage_msd.cpp
EXTRABOARDSRC += targets/taranis/usbd_usr.cpp
SRC += targets/sky9x/syscalls.c
ifneq ($(LUA), NO)
@ -697,6 +695,7 @@ ifeq ($(PCB), TARANIS)
CPPSRC += protocols/hubsan.cpp
CPPSRC += targets/taranis/a7105_driver.cpp
endif
endif
CC = $(TRGT)gcc
@ -728,7 +727,7 @@ else
TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi")
endif
CPPSRC += opentx.cpp $(PULSESSRC) stamp.cpp gui/menus.cpp gui/menu_model.cpp gui/menu_general.cpp gui/view_main.cpp gui/view_statistics.cpp $(EEPROMSRC) lcd.cpp keys.cpp maths.cpp translations.cpp $(TTS_SRC)
CPPSRC += opentx.cpp $(PULSESSRC) stamp.cpp gui/menus.cpp gui/menu_model.cpp gui/menu_general.cpp gui/view_main.cpp gui/view_statistics.cpp $(EEPROMSRC) lcd.cpp keys.cpp maths.cpp translations.cpp fonts.cpp $(TTS_SRC)
# Debugging format.
# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
@ -979,8 +978,10 @@ ifeq ($(HELI), YES)
endif
ifeq ($(TEMPLATES), YES)
CPPDEFS += -DTEMPLATES
CPPSRC += templates.cpp
ifneq ($(PCB), TARANIS)
CPPDEFS += -DTEMPLATES
CPPSRC += templates.cpp
endif
endif
ifeq ($(PXX), YES)
@ -1082,10 +1083,21 @@ all: begin gccversion sizebefore build sizeafter end
# Change the build target to build a HEX file or a library.
ifeq ($(ARCH), AVR)
build: stamp_header tra lbm allsrc.cpp elf remallsrc hex
else ifeq ($(PCB), TARANIS)
build: stamp_header tra lbm bootloader.lbm allsrc.cpp elf remallsrc bin
else
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
endif
# build bootloader
bootloader.lbm: bootloader/bootloader_ramBoot.bin
test -z "$$(find $^ -size +32k)"
$(BIN2LBM) $^ $@
.PHONY bootloader/bootloader_ramBoot.bin:
@echo "Building bootloader..."
$(MAKE) -C bootloader PCB=$(PCB) PCBREV=$(PCBREV)
tra: translations/en.h translations/cz.h translations/de.h translations/es.h translations/fi.h translations/fr.h translations/it.h translations/pl.h translations/pt.h translations/se.h
lbm: fonts bitmaps/sticks.lbm
@ -1237,7 +1249,7 @@ sizeafter:
@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); fi
# Display compiler version information.
gccversion :
gccversion:
@$(CC) --version
FOXINC=-I/usr/local/include/fox-1.6 -I/usr/include/fox-1.6 \
@ -1277,8 +1289,7 @@ endif
%.eep: %.elf
@echo
@echo $(MSG_EEPROM) $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@ -1344,6 +1355,8 @@ clean_list :
$(REMOVE) *.lst
$(REMOVE) allsrc.cpp
$(REMOVE) stamp-opentx.h
$(REMOVE) `find . -name "*.lbm"`
$(MAKE) -C bootloader clean
#### Install

View file

@ -324,7 +324,7 @@ void getSwitchAudioFile(char * filename, int index)
str += 5;
}
else {
str += 1;
*(str+1) = 0;
}
strcat(str, SOUNDS_EXT);
}
@ -390,7 +390,7 @@ void referenceModelAudioFiles()
}
// Logical Switches Audio Files <switchname>-[on|off].wav
for (int i=0; i<NUM_CSW && !found; i++) {
for (int i=0; i<NUM_LOGICAL_SWITCH && !found; i++) {
for (int event=0; event<2; event++) {
getLogicalSwitchAudioFile(path, i, event);
if (!strcmp(filename, fn)) {

1
radio/src/bootloader/.gitignore vendored Executable file
View file

@ -0,0 +1 @@
/*.o

View file

@ -0,0 +1,342 @@
#
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
#
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#
##############################################################################################
# Start of default section
#
TRGT = arm-none-eabi-
CC = $(TRGT)gcc
CP = $(TRGT)objcopy
CLSS = $(TRGT)objdump
AS = $(TRGT)as
#gcc -x assembler-with-cpp
BIN = $(CP) -O ihex
BINX = $(CP) -O binary
OBJDIR = .
MCU = cortex-m3
# List all default C defines here, like -D_DEBUG=1
DDEFS =
# List all default ASM defines here, like -D_DEBUG=1
DADEFS =
# List all default directories to look for include files here
DINCDIR =
# List the default directory to look for the libraries here
DLIBDIR =
# List all default libraries here
DLIBS =
MEMORIES = sram
EXT = STD
#
# End of default section
##############################################################################################
##############################################################################################
# Start of user section
#
#
# Define project name and Ram/Flash mode here
PROJECT = bootloader
ifeq ($(PCB), TARANIS)
RUN_FROM_FLASH = 0
else
ifeq ($(PCB), X9D)
RUN_FROM_FLASH = 0
else
RUN_FROM_FLASH = 1
endif
endif
# PCB revision
PCBREV =
EXTRAINCDIRS =
#
# Define linker script file here
#
ifeq ($(RUN_FROM_FLASH), 1)
ifeq ($(REVX), 1)
LDSCRIPT = sam3s8c_boot.ld
FULL_PRJ = $(PROJECT)_flash8
EXTRAINCDIRS += include
# EXTRAINCDIRS += ../
else
LDSCRIPT = sam3s4c_boot.ld
FULL_PRJ = $(PROJECT)_flash4
EXTRAINCDIRS += include
# EXTRAINCDIRS += ../
endif
TRGT = arm-none-eabi-
CPPDEFS += -DPCBSKY
UDEFS = -Dat91sam3s8
# If REVX board
ifeq ($(REVX), 1)
CPPDEFS += -DREVX
endif
CPPDEFS += -DREVB
else
ifeq ($(PCB), TARANIS)
ARCH = ARM
LDSCRIPT = ../targets/taranis/stm32_ramBoot.ld
TRGT = arm-none-eabi-
CPPDEFS += -DHSE_VALUE=12000000
CPPDEFS += -DPCBTARANIS
FULL_PRJ = $(PROJECT)_ramBoot
EXTRAINCDIRS += ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc
EXTRAINCDIRS += ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc
EXTRAINCDIRS += ../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc
EXTRAINCDIRS += ../targets/taranis
EXTRAINCDIRS += ../fonts/std
ifeq ($(PCBREV), REV3)
CPPDEFS += -DREV3
else ifeq ($(PCBREV), REV4a)
CPPDEFS += -DREV4a
else
CPPDEFS += -DREV4
endif
endif
endif
# List all user C define here, like -D_DEBUG=1
# Define ASM defines here
UADEFS =
ifeq ($(PCB), TARANIS)
SRC = ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c \
../targets/taranis/i2c.c \
../targets/taranis/delays.c \
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c \
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c \
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c \
../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c \
../FatFs/ff.c \
../FatFs/option/ccsbcs.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_core.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_dcd_int.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c \
../targets/taranis/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c \
../targets/taranis/usbd_desc.c \
../targets/taranis/aspi.c \
../targets/taranis/usb_bsp.c \
../targets/taranis/usb_driver.c \
../targets/taranis/pwr_driver.c
CPPSRC = ../targets/taranis/lcd_driver.cpp \
../targets/taranis/keys_driver.cpp \
../targets/taranis/diskio.cpp \
../targets/taranis/usbd_usr.cpp \
../targets/taranis/usbd_storage_msd.cpp \
../lcd.cpp \
../keys.cpp \
../fonts.cpp \
boot.cpp
# List ASM source files here
ASRC = ../targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
else
# List C source files here
SRC = core_cm3.c \
board_lowlevel.c \
crt.c \
usb/device/core/USBD_UDP.c usb/device/core/USBDDriver.c usb/device/core/USBDCallbacks.c \
usb/device/massstorage/MSDDriver.c usb/device/massstorage/MSDDStateMachine.c \
usb/device/massstorage/MSDLun.c usb/device/massstorage/MSDDriverDescriptors.c usb/device/massstorage/SBCMethods.c \
usb/common/core/USBEndpointDescriptor.c usb/common/core/USBGenericRequest.c \
usb/common/core/USBFeatureRequest.c usb/common/core/USBInterfaceRequest.c usb/common/core/USBGetDescriptorRequest.c \
usb/common/core/USBSetAddressRequest.c usb/common/core/USBSetConfigurationRequest.c \
usb/common/core/USBConfigurationDescriptor.c usb/common/core/USBGenericDescriptor.c \
MEDSdcard.c \
vectors_sam3s.c
CPPSRC = lcdboot.cpp \
ff.cpp \
diskio.cpp \
driversboot.cpp \
logicioboot.cpp \
sdcard_driver.cpp \
massstorage.cpp \
bootsamEeprom.cpp \
ff_lfn.cpp \
power.cpp \
boot.cpp
# List ASM source files here
ASRC =
endif
# List all user directories here
UINCDIR = ./inc
# \
# ./cmsis/core \
# ./cmsis/device
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
# Define optimisation level here
OPT = -Os
#
# End of user defines
##############################################################################################
VPATH = $(DIRS)
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
ifeq ($(RUN_FROM_FLASH), 0)
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=0
else
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=1
endif
ADEFS = $(DADEFS) $(UADEFS)
AXOBJS = $(ASRC:%.s=%.o)
CXOBJS = $(SRC:%.c=%.o)
CPPXOBJS = $(CPPSRC:%.cpp=%.o)
LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch $(LIBDIR)
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -fverbose-asm $(DEFS)
CPPFLAGS += $(CPPDEFS)
CPFLAGS += $(CPPDEFS)
CPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
AOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(AXOBJS) ))
COBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CXOBJS) ))
CPPOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CPPXOBJS) ))
DIRS = $(sort $(dir $(AXOBJS) $(CXOBJS) $(CPPXOBJS) ) )
CPPDEFS += -DCPUARM
# If serial Debug required
ifeq ($(DEBUG), 1)
CPPDEFS += -DDEBUG
endif
CPPDEFS += -DBOOT
# Generate dependency information
CPFLAGS += -MD -MP -MF .dep/$(@F).d
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
#
# makefile rules
#
all: size_before $(OBJS) $(COBJS) $(CPPOBJS) $(FULL_PRJ).elf $(FULL_PRJ).hex $(FULL_PRJ).lss $(FULL_PRJ).bin size
#begin:
# @echo $(AXOBJS) $(CXOBJS) $(CPPXOBJS)
# @echo
# @echo $(OBJS) $(COBJS) $(CPPOBJS)
# @echo
# @echo $(DIRS)
size_before:
# arm-none-eabi-size $(FULL_PRJ).elf
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
size:
# arm-none-eabi-size $(FULL_PRJ).elf
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp
$(CC) -c $(CPPFLAGS) -fno-exceptions -I . $(INCDIR) $< -o $@
$(COBJS) : $(OBJDIR)/%.o : %.c
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
$(AOBJS) : $(OBJDIR)/%.o : %.s
$(AS) -c $(ASFLAGS) $< -o $@
%elf: $(AOBJS) $(COBJS) $(CPPOBJS)
$(CC) $(AOBJS) $(COBJS) $(CPPOBJS) $(LDFLAGS) $(LIBS) -o $@
# Create extended listing file from ELF output file.
%.lss: %.elf
$(CLSS) -h -S $< > $@
%hex: %elf
$(BIN) $< $@
%bin: %elf
$(BINX) $< $@
# $(PROJECT)_flash8
# $(PROJECT)_flash4
# $(PROJECT)_ramBootS
# $(PROJECT)_ramBootT
clean:
-rm -f *.o
-rm -f *.elf
-rm -f *.map
-rm -f *.hex
-rm -f *.bin
-rm -f *.lss
-rm -fR .dep
#
# Include the dependency files, should be the last of the makefile
#
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# *** EOF ***

View file

@ -0,0 +1,943 @@
/****************************************************************************
* Copyright (c) 2014 by Michael Blandford. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************
* Other Authors:
* - Andre Bernet
* - Bertrand Songis
* - Bryan J. Rentoul (Gruvin)
* - Cameron Weeks
* - Erez Raviv
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini
* - Thomas Husterer
*
****************************************************************************/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#if defined(PCBTARANIS)
#include "stm32f2xx_flash.h"
#endif
#include "board_taranis.h"
#include "../pwr.h"
#include "../lcd.h"
#include "../keys.h"
#include "../sdcard.h"
#include "../FatFs/ff.h"
#include "../FatFs/diskio.h"
#include "../translations/en.h"
#if defined(PCBTARANIS)
#define BOOTLOADER_TITLE " OpenTX Boot Loader v1.0"
#define BOOT_KEY_UP KEY_PLUS
#define BOOT_KEY_DOWN KEY_MINUS
#define BOOT_KEY_LEFT KEY_MENU
#define BOOT_KEY_RIGHT KEY_PAGE
#define BOOT_KEY_MENU KEY_ENTER
#define BOOT_KEY_EXIT KEY_EXIT
#define DISPLAY_CHAR_WIDTH 35
#elif defined(PCBSKY9X)
#define BOOTLOADER_TITLE "Boot Loader - Sky9x"
#endif
#define BOOTLOADER_SIZE 0x8000
#if defined(PCBTARANIS)
#define FIRMWARE_ADDRESS 0x08000000
#elif defined(PCBSKY9X)
#define FIRMWARE_ADDRESS 0x00400000
#endif
// states
enum BootLoaderStates {
ST_START,
ST_FLASH_MENU,
ST_DIR_CHECK,
ST_OPEN_DIR,
ST_FILE_LIST,
ST_FLASH_CHECK,
ST_FLASHING,
ST_FLASH_DONE,
ST_USB,
ST_REBOOT,
};
/*----------------------------------------------------------------------------
* Local variables
*----------------------------------------------------------------------------*/
uint32_t FirmwareSize;
uint32_t Master_frequency;
volatile uint8_t Tenms;
uint8_t EE_timer;
TCHAR FlashFilename[60];
FIL FlashFile;
DIR Dj;
FILINFO Finfo;
TCHAR Filenames[20][50];
uint32_t FileSize[20];
uint32_t FnStartIndex;
uint32_t Valid;
uint32_t FlashSize;
uint32_t FlashBlocked = 1;
uint32_t LockBits;
uint32_t Block_buffer[1024];
UINT BlockCount;
#if defined(PCBSKY9X)
extern int32_t EblockAddress;
#endif
extern uint32_t EepromBlocked;
extern void init_spi(void);
extern void writeBlock(void);
/*----------------------------------------------------------------------------
* Global functions
*----------------------------------------------------------------------------*/
#if defined(PCBSKY9X)
// Starts TIMER0 at full speed (MCK/2) for delay timing
// @ 36MHz this is 18MHz
// This was 6 MHz, we may need to slow it to TIMER_CLOCK2 (MCK/8=4.5 MHz)
void start_timer0()
{
register Tc *ptc;
PMC->PMC_PCER0 |= 0x00800000L; // Enable peripheral clock to TC0
ptc = TC0;// Tc block 0 (TC0-2)
ptc->TC_BCR = 0;// No sync
ptc->TC_BMR = 2;
ptc->TC_CHANNEL[0].TC_CMR = 0x00008001;// Waveform mode MCK/8 for 36MHz osc.(Upset be write below)
ptc->TC_CHANNEL[0].TC_RC = 0xFFF0;
ptc->TC_CHANNEL[0].TC_RA = 0;
ptc->TC_CHANNEL[0].TC_CMR = 0x00008040;// 0000 0000 0000 0000 1000 0000 0100 0000, stop at regC, 18MHz
ptc->TC_CHANNEL[0].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
}
void stop_timer0( void )
{
TC0->TC_CHANNEL[0].TC_CCR = TC_CCR0_CLKDIS; // Disable clock
}
void delay2ms()
{
TC0->TC_CHANNEL[0].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 )// 2mS, Value depends on MCK/2 (used 18MHz)
{
// Wait
}
}
#endif
#if defined(PCBTARANIS)
uint32_t isFirmwareStart(uint32_t *block)
{
if ((block[0] & 0xFFFC0000) != 0x20000000) {
return 0;
}
if ((block[1] & 0xFFF00000) != 0x08000000) {
return 0;
}
if ((block[2] & 0xFFF00000) != 0x08000000) {
return 0;
}
return 1;
}
#elif defined(PCBSKY9X)
uint32_t isFirmwareStart( uint32_t *block )
{
if ((block[0] & 0xFFFE3000) != 0x20000000 ) {
return 0;
}
if ((block[1] & 0xFFF80000) != 0x00400000) {
return 0;
}
if ((block[2] & 0xFFF80000) != 0x00400000) {
return 0;
}
return 1;
}
#endif
#if defined(PCBSKY9X)
uint32_t (*IAP_Function)(uint32_t, uint32_t);
uint32_t program( uint32_t *address, uint32_t *buffer ) // size is 256 bytes
{
uint32_t FlashSectorNum;
uint32_t flash_cmd = 0;
uint32_t i;
// uint32_t flash_status = 0;
// uint32_t EFCIndex = 0; // 0:EEFC0, 1: EEFC1
/* Initialize the function pointer (retrieve function address from NMI vector) */
if ((uint32_t) address == FIRMWARE_START+BOOTLOADER_SIZE) {
if (isFirmwareStart(buffer))
FlashBlocked = 0;
else
FlashBlocked = 1;
}
if (FlashBlocked) {
return 1;
}
// Always initialise this here, setting a default doesn't seem to work
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
FlashSectorNum = (uint32_t) address;
FlashSectorNum >>= 8;// page size is 256 bytes
FlashSectorNum &= 2047;// max page number
/* Send data to the sector here */
for ( i = 0; i < 64; i += 1 )
{
*address++ = *buffer++;
}
/* build the command to send to EEFC */
flash_cmd = (0x5A << 24) | (FlashSectorNum << 8) | 0x03; //AT91C_MC_FCMD_EWP ;
__disable_irq();
/* Call the IAP function with appropriate command */
i = IAP_Function( 0, flash_cmd );
__enable_irq();
return i;
}
uint32_t readLockBits()
{
// Always initialise this here, setting a default doesn't seem to work
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
uint32_t flash_cmd = (0x5A << 24) | 0x0A;//AT91C_MC_FCMD_GLB ;
__disable_irq();
(void) IAP_Function( 0, flash_cmd );
__enable_irq();
return EFC->EEFC_FRR;
}
void clearLockBits()
{
uint32_t i;
uint32_t flash_cmd = 0;
// Always initialise this here, setting a default doesn't seem to work
IAP_Function = (uint32_t (*)(uint32_t, uint32_t)) *(( uint32_t *)0x00800008);
for ( i = 0; i < 16; i += 1 )
{
flash_cmd = (0x5A << 24) | ((128*i) << 8) | 0x09; //AT91C_MC_FCMD_CLB ;
__disable_irq();
/* Call the IAP function with appropriate command */
(void) IAP_Function( 0, flash_cmd );
__enable_irq();
}
}
#endif
void interrupt10ms(void)
{
Tenms |= 1; // 10 mS has passed
uint8_t enuk = KEY_MENU;
uint8_t in = ~readKeys();
for (int i = 1; i < 7; i++) {
uint8_t value = in & (1 << i);
keys[enuk].input(value, (EnumKeys) enuk);
++enuk;
}
}
#if defined(PCBSKY9X)
void init10msTimer()
{
register Tc *ptc;
register uint32_t timer;
PMC->PMC_PCER0 |= 0x02000000L; // Enable peripheral clock to TC2
timer = Master_frequency / 12800;// MCK/128 and 100 Hz
ptc = TC0;// Tc block 0 (TC0-2)
ptc->TC_BCR = 0;// No sync
ptc->TC_BMR = 0;
ptc->TC_CHANNEL[2].TC_CMR = 0x00008000;// Waveform mode
ptc->TC_CHANNEL[2].TC_RC = timer;// 10 Hz
ptc->TC_CHANNEL[2].TC_RA = timer >> 1;
ptc->TC_CHANNEL[2].TC_CMR = 0x0009C003;// 0000 0000 0000 1001 1100 0000 0000 0011
// MCK/128, set @ RA, Clear @ RC waveform
ptc->TC_CHANNEL[2].TC_CCR = 5;// Enable clock and trigger it (may only need trigger)
NVIC_EnableIRQ(TC2_IRQn);
TC0->TC_CHANNEL[2].TC_IER = TC_IER0_CPCS;
}
extern "C" void TC2_IRQHandler()
{
register uint32_t dummy;
/* Clear status bit to acknowledge interrupt */
dummy = TC0->TC_CHANNEL[2].TC_SR;
(void) dummy; // Discard value - prevents compiler warning
interrupt10ms();
}
#endif
#if defined(PCBTARANIS)
void init10msTimer()
{
// Timer14
RCC->APB1ENR |= RCC_APB1ENR_TIM14EN; // Enable clock
TIM14->ARR = 9999; // 10mS
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS from 12MHz
TIM14->CCER = 0;
TIM14->CCMR1 = 0;
TIM14->EGR = 0;
TIM14->CR1 = 5;
TIM14->DIER |= 1;
NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn);
}
extern "C" void TIM8_TRG_COM_TIM14_IRQHandler()
{
TIM14->SR &= ~TIM_SR_UIF;
interrupt10ms();
}
void init_hw_timer()
{
// Timer13
RCC->APB1ENR |= RCC_APB1ENR_TIM13EN; // Enable clock
TIM13->ARR = 65535;
TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1;// 0.1uS from 12MHz
TIM13->CCER = 0;
TIM13->CCMR1 = 0;
TIM13->EGR = 0;
TIM13->CR1 = 1;
}
// delay in units of 0.1 uS up to 6.5535 mS
void hw_delay(uint16_t time)
{
TIM13->CNT = 0;
TIM13->EGR = 1; // Re-start counter
while ( TIM13->CNT < time) {
// wait
}
}
//After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the
//Flash memory against possible unwanted operations due, for example, to electric
//disturbances. The following sequence is used to unlock this register:
//1. Write KEY1 = 0x45670123 in the Flash key register (FLASH_KEYR)
//2. Write KEY2 = 0xCDEF89AB in the Flash key register (FLASH_KEYR)
//Any wrong sequence will return a bus error and lock up the FLASH_CR register until the
//next reset.
//The FLASH_CR register can be locked again by software by setting the LOCK bit in the
//FLASH_CR register.
void unlockFlash()
{
FLASH->KEYR = 0x45670123;
FLASH->KEYR = 0xCDEF89AB;
}
void waitFlashIdle()
{
while (FLASH->SR & FLASH_FLAG_BSY) {
wdt_reset();
}
}
#define SECTOR_MASK ((uint32_t)0xFFFFFF07)
void eraseSector(uint32_t sector)
{
waitFlashIdle();
FLASH->CR &= CR_PSIZE_MASK;
FLASH->CR |= FLASH_PSIZE_WORD;
FLASH->CR &= SECTOR_MASK;
FLASH->CR |= FLASH_CR_SER | (sector << 3);
FLASH->CR |= FLASH_CR_STRT;
/* Wait for operation to be completed */
waitFlashIdle();
/* if the erase operation is completed, disable the SER Bit */
FLASH->CR &= (~FLASH_CR_SER);
FLASH->CR &= SECTOR_MASK;
}
uint32_t program(uint32_t *address, uint32_t *buffer) // size is 256 bytes
{
uint32_t i;
if ((uint32_t) address == 0x08008000) {
if (isFirmwareStart(buffer)) {
FlashBlocked = 0;
}
else {
FlashBlocked = 1;
}
}
if (FlashBlocked) {
return 1;
}
if ((uint32_t) address == 0x08008000) {
eraseSector(2);
}
if ((uint32_t) address == 0x0800C000) {
eraseSector(3);
}
if ((uint32_t) address == 0x08010000) {
eraseSector(4);
}
if ((uint32_t) address == 0x08020000) {
eraseSector(5);
}
if ((uint32_t) address == 0x08040000) {
eraseSector(6);
}
if ((uint32_t) address == 0x08060000) {
eraseSector(7);
}
// Now program the 256 bytes
for (i = 0; i < 64; i += 1) {
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */
// Wait for last operation to be completed
waitFlashIdle();
FLASH->CR &= CR_PSIZE_MASK;
FLASH->CR |= FLASH_PSIZE_WORD;
FLASH->CR |= FLASH_CR_PG;
*address = *buffer;
/* Wait for operation to be completed */
waitFlashIdle();
FLASH->CR &= (~FLASH_CR_PG);
/* Check the written value */
if (*address != *buffer) {
/* Flash content doesn't match SRAM content */
return 2;
}
/* Increment FLASH destination address */
address += 1;
buffer += 1;
}
return 0;
}
#endif
uint8_t *cpystr(uint8_t *dest, uint8_t *source)
{
while ((*dest++ = *source++))
;
return dest - 1;
}
FRESULT readBinDir(DIR *dj, FILINFO *fno)
{
FRESULT fr;
uint32_t loop;
do {
loop = 0;
fr = f_readdir(dj, fno); // First entry
if (fr != FR_OK || fno->fname[0] == 0) {
break;
}
if (*fno->lfname == 0) {
cpystr((uint8_t *) fno->lfname, (uint8_t *) fno->fname); // Copy 8.3 name
}
int32_t len = strlen(fno->lfname) - 4;
if (len < 0) {
loop = 1;
}
if (fno->lfname[len] != '.') {
loop = 1;
}
if ((fno->lfname[len + 1] != 'b') && (fno->lfname[len + 1] != 'B')) {
loop = 1;
}
if ((fno->lfname[len + 2] != 'i') && (fno->lfname[len + 2] != 'I')) {
loop = 1;
}
if ((fno->lfname[len + 3] != 'n') && (fno->lfname[len + 3] != 'N')) {
loop = 1;
}
} while (loop);
return fr;
}
uint32_t fillNames(uint32_t index)
{
uint32_t i;
FRESULT fr;
Finfo.lfname = Filenames[0];
Finfo.lfsize = 48;
fr = f_readdir(&Dj, 0); // rewind
fr = f_readdir(&Dj, &Finfo); // Skip .
fr = f_readdir(&Dj, &Finfo); // Skip ..
i = 0;
while (i <= index) {
fr = readBinDir(&Dj, &Finfo); // First entry
FileSize[0] = Finfo.fsize;
i += 1;
if (fr == FR_NO_FILE) {
return 0;
}
}
for (i = 1; i < 7; i += 1) {
Finfo.lfname = Filenames[i];
fr = readBinDir(&Dj, &Finfo); // First entry
FileSize[i] = Finfo.fsize;
if (fr != FR_OK || Finfo.fname[0] == 0) {
break;
}
}
return i;
}
FRESULT openFirmwareFile(uint32_t index)
{
cpystr(cpystr((uint8_t *)FlashFilename, (uint8_t *)FIRMWARES_PATH "/"), (uint8_t *) Filenames[index]);
f_open(&FlashFile, FlashFilename, FA_READ);
f_lseek(&FlashFile, BOOTLOADER_SIZE);
return f_read(&FlashFile, (BYTE *) Block_buffer, 4096, &BlockCount);
}
int menuFlashFile(uint32_t index, uint8_t event)
{
FRESULT fr;
lcd_putsLeft(4*FH, "\012Hold [ENT] to start loading" );
if (Valid == 0) {
// Validate file here
// return 3 if invalid
fr = openFirmwareFile(index);
fr = f_close(&FlashFile);
Valid = 1;
if (isFirmwareStart(Block_buffer) == 0) {
Valid = 2;
}
}
if (Valid == 2) {
lcd_putsLeft(4*FH, "\011No firmware found in the file!");
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
return 0;
}
return -1;
}
if (event == EVT_KEY_LONG(BOOT_KEY_MENU)) {
fr = openFirmwareFile(index);
FirmwareSize = FileSize[index];
if (fr != FR_OK) {
return 0; // File open error
}
return 1;
}
else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
return 0;
}
return -1;
}
extern Key keys[];
static uint32_t PowerUpDelay;
int main()
{
uint8_t index = 0;
#if defined(PCBTARANIS)
uint8_t TenCount = 2;
#endif
uint8_t maxhsize = DISPLAY_CHAR_WIDTH;
FRESULT fr;
uint32_t state = ST_START;
uint32_t nameCount = 0;
uint32_t vpos = 0;
uint32_t hpos = 0;
uint32_t firmwareAddress = FIRMWARE_ADDRESS;
uint32_t firmwareWritten = 0;
#if defined(PCBTARANIS)
wdt_reset();
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; // Enable portA clock
#endif
pwrInit();
#if defined(PCBSKY9X)
MATRIX->CCFG_SYSIO |= 0x000000F0L; // Disable syspins, enable B4,5,6,7
#endif
#if defined(PCBSKY9X)
init_SDcard();
PIOC->PIO_PER = PIO_PC25; // Enable bit C25 (USB-detect)
start_timer0();
#endif
lcdInit();
#if defined(PCBSKY9X)
extern uint8_t OptrexDisplay;
OptrexDisplay = 1;
#endif
lcd_clear();
lcd_putsLeft(0, BOOTLOADER_TITLE);
lcd_invert_line(0);
lcdRefresh();
#if defined(PCBSKY9X)
OptrexDisplay = 0;
lcdRefresh();
#endif
#if defined(PCBTARANIS)
keysInit();
I2C_EE_Init();
init_hw_timer();
#endif
__enable_irq();
init10msTimer();
#if defined(PCBSKY9X)
EblockAddress = -1;
init_spi();
#endif
#if defined(PCBSKY9X)
uint32_t chip_id = CHIPID->CHIPID_CIDR;
FlashSize = ( (chip_id >> 8 ) & 0x000F ) == 9 ? 256 : 512;
#elif defined(PCBTARANIS)
FlashSize = 512;
#endif
#if defined(PCBSKY9X)
LockBits = readLockBits();
if (LockBits) {
clearLockBits();
}
#endif
#if defined(PCBTARANIS)
// SD card detect pin
sdInit();
unlockFlash();
usbInit();
usbStart();
#endif
for (;;) {
wdt_reset();
if (Tenms) {
wdt_reset(); // Retrigger hardware watchdog
if (EE_timer) {
if (--EE_timer == 0) {
#if defined(PCBSKY9X)
writeBlock();
#endif
}
}
Tenms = 0;
lcd_clear();
lcd_putsLeft(0, BOOTLOADER_TITLE);
lcd_invert_line(0);
uint8_t event = getEvent();
if (usbPlugged()) {
state = ST_USB;
}
if (state == ST_START) {
lcd_putsLeft(2*FH, "\010Load Firmware");
lcd_putsLeft(3*FH, "\010Exit");
lcd_invert_line(2+vpos);
lcd_putsLeft(6*FH, INDENT "Or plug in a USB cable for mass storage");
if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
vpos = (vpos+1) & 0x01;
}
else if (event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
if (vpos == 0)
state = ST_FLASH_MENU;
else
state = ST_REBOOT;
}
}
if (state == ST_USB) {
lcd_putsLeft(4*FH, "\026USB Connected");
if (usbPlugged() == 0) {
vpos = 0;
state = ST_START;
}
#if defined(PCBSKY9X)
usbMassStorage();
lcd_putc( 0, 6*FH, 'F' );
lcd_putc( 6, 6*FH, '0' + FlashBlocked );
lcd_putc( 0, 7*FH, 'E' );
lcd_putc( 6, 7*FH, '0' + EepromBlocked );
#endif
}
if (state == ST_FLASH_MENU) {
sdInit();
state = ST_DIR_CHECK;
}
else if (state == ST_DIR_CHECK) {
fr = f_chdir(FIRMWARES_PATH);
if (fr == FR_OK) {
state = ST_OPEN_DIR;
}
else {
lcd_putsLeft(2*FH, INDENT "No firmware in " FIRMWARES_PATH " directory");
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
vpos = 0;
state = ST_START;
}
}
}
if (state == ST_OPEN_DIR) {
index = 0;
fr = f_opendir(&Dj, ".");
if (fr == FR_OK) {
state = ST_FILE_LIST;
nameCount = fillNames(0);
hpos = 0;
vpos = 0;
}
}
if (state == ST_FILE_LIST) {
uint32_t limit = 6;
if (nameCount < limit) {
limit = nameCount;
}
maxhsize = 0;
for (uint32_t i=0; i<limit; i++) {
uint32_t x;
x = strlen(Filenames[i]);
if (x > maxhsize) {
maxhsize = x;
}
if (x > DISPLAY_CHAR_WIDTH) {
if (hpos + DISPLAY_CHAR_WIDTH > x) {
x = x - DISPLAY_CHAR_WIDTH;
}
else {
x = hpos;
}
}
else {
x = 0;
}
lcd_putsnAtt(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0);
}
if (event == EVT_KEY_REPT(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
if (vpos < limit - 1) {
vpos += 1;
}
else {
if (nameCount > limit) {
index += 1;
nameCount = fillNames(index);
}
}
}
else if (event == EVT_KEY_REPT(BOOT_KEY_UP) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
if (vpos > 0) {
vpos -= 1;
}
else {
if (index) {
index -= 1;
nameCount = fillNames(index);
}
}
}
#if !defined(PCBTARANIS)
else if (event == EVT_KEY_REPT(BOOT_KEY_RIGHT) || event == EVT_KEY_FIRST(BOOT_KEY_RIGHT)) {
if (hpos + DISPLAY_CHAR_WIDTH < maxhsize) {
hpos += 1;
}
}
else if (event == EVT_KEY_REPT(BOOT_KEY_LEFT) || event == EVT_KEY_FIRST(BOOT_KEY_LEFT)) {
if (hpos) {
hpos -= 1;
}
}
#endif
else if (event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
// Select file to flash
state = ST_FLASH_CHECK;
Valid = 0;
}
else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
state = ST_START;
vpos = 0;
}
lcd_invert_line(2 + vpos);
}
else if (state == ST_FLASH_CHECK) {
int result = menuFlashFile(vpos, event);
FirmwareSize = FileSize[vpos] - BOOTLOADER_SIZE;
if (result == 0) {
// canceled
state = ST_FILE_LIST;
}
else if (result == 1) {
// confirmed
firmwareAddress = FIRMWARE_ADDRESS + BOOTLOADER_SIZE;
firmwareWritten = 0;
state = ST_FLASHING;
}
}
if (state == ST_FLASHING) {
// Commit to flashing
uint32_t blockOffset = 0;
lcd_putsLeft(4*FH, "\032Loading...");
while (BlockCount) {
program((uint32_t *) firmwareAddress, &Block_buffer[blockOffset]); // size is 256 bytes
blockOffset += 64; // 32-bit words (256 bytes)
firmwareAddress += 256;
if (BlockCount > 256) {
BlockCount -= 256;
}
else {
BlockCount = 0;
}
}
firmwareWritten += 4; // 4K blocks
lcd_rect( 3, 6*FH+4, 204, 7);
lcd_hline(5, 6*FH+6, (200*2*firmwareWritten-32)/(FlashSize), FORCE);
lcd_hline(5, 6*FH+7, (200*2*firmwareWritten-32)/(FlashSize), FORCE);
lcd_hline(5, 6*FH+8, (200*2*firmwareWritten-32)/(FlashSize), FORCE);
fr = f_read(&FlashFile, (BYTE *)Block_buffer, sizeof(Block_buffer), &BlockCount);
if (BlockCount == 0) {
state = ST_FLASH_DONE;
}
if (firmwareWritten >= FlashSize - 32) {
state = ST_FLASH_DONE; // Backstop
}
}
if (state == ST_FLASH_DONE) {
lcd_putsLeft(4*FH, "\024Loading Complete");
if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_FIRST(BOOT_KEY_MENU)) {
state = ST_START;
vpos = 0;
}
}
if (event == EVT_KEY_LONG(BOOT_KEY_EXIT)) {
state = ST_REBOOT;
}
if (--TenCount == 0) {
TenCount = 2;
lcdRefresh();
}
if (PowerUpDelay < 20) { // 200 mS
PowerUpDelay += 1;
}
else {
sdPoll10ms();
}
}
if (pwrCheck() == e_power_off && state != ST_FLASHING && state != ST_USB) {
pwrOff();
for (;;) {
// Wait for power to go off
}
}
if (state == ST_REBOOT) {
if ((~readKeys() & 0x7E) == 0) {
NVIC_SystemReset();
}
}
}
return 0;
}

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