diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 3a8dd26b7..20c86879c 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -155,7 +155,6 @@ SET( companion_SRCS modelslist.cpp mountlist.cpp avroutputdialog.cpp - preferencesdialog.cpp apppreferencesdialog.cpp fwpreferencesdialog.cpp burnconfigdialog.cpp @@ -178,7 +177,6 @@ SET( companion_SRCS SET( companion_MOC_HDRS avroutputdialog.h - preferencesdialog.h apppreferencesdialog.h fwpreferencesdialog.h burnconfigdialog.h @@ -214,7 +212,6 @@ SET( companion_UIS comparedialog.ui fusesdialog.ui logsdialog.ui - preferencesdialog.ui apppreferencesdialog.ui fwpreferencesdialog.ui simulatordialog.ui diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 4b425a61b..24a3a15e1 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -14,7 +14,7 @@ appPreferencesDialog::appPreferencesDialog(QWidget *parent) : ui(new Ui::appPreferencesDialog) { ui->setupUi(this); - setWindowIcon(CompanionIcon("preferences.png")); + setWindowIcon(CompanionIcon("apppreferences.png")); initSettings(); connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); #ifndef JOYSTICKS @@ -56,8 +56,19 @@ void appPreferencesDialog::writeValues() settings.remove("js_ctrl"); } - MainWindow * mw = (MainWindow *)this->parent(); - mw->unloadProfile(); + settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); + settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); + settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); + settings.setValue("profileId", ui->profileIndexLE->text()); + settings.setValue("Name", ui->profileNameLE->text()); + settings.setValue("sdPath", ui->sdPath->text()); + settings.setValue("SplashFileName", ui->SplashFileName->text()); + if (!ui->SplashFileName->text().isEmpty()) + settings.setValue("SplashImage", ""); + settings.setValue("firmware", ui->firmwareLE->text()); + + saveProfile(); } void appPreferencesDialog::on_snapshotPathButton_clicked() @@ -75,6 +86,7 @@ void appPreferencesDialog::initSettings() { QSettings settings; ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool()); + ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool()); QString Path=settings.value("snapshotPath", "").toString(); if (QDir(Path).exists()) { @@ -142,6 +154,26 @@ void appPreferencesDialog::initSettings() ui->joystickcalButton->setDisabled(true); } #endif +// Profile Tab Inits + ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt()); + ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt()); + ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool()); + Path=settings.value("sdPath", "").toString(); + if (QDir(Path).exists()) { + ui->sdPath->setText(Path); + } + ui->profileIndexLE->setText(settings.value("profileId", "").toString()); + ui->profileNameLE->setText(settings.value("Name", "").toString()); + + QString fileName=settings.value("SplashFileName","").toString(); + if (!fileName.isEmpty()) { + QFile file(fileName); + if (file.exists()){ + ui->SplashFileName->setText(fileName); + displayImage( fileName ); + } + } + ui->firmwareLE->setText(settings.value("firmware","").toString()); } void appPreferencesDialog::on_libraryPathButton_clicked() @@ -222,3 +254,142 @@ void appPreferencesDialog::on_joystickcalButton_clicked() { } #endif +// ******** Profile tab functions + +void appPreferencesDialog::on_sdPathButton_clicked() +{ + QSettings settings; + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString()); + if (!fileName.isEmpty()) { + ui->sdPath->setText(fileName); + } +} + +void appPreferencesDialog::saveProfile() +{ + QSettings settings; + + QString profile=QString("profile") + settings.value("profileId").toString(); + QString name=ui->profileNameLE->text(); + if (name.isEmpty()) { + name = profile; + ui->profileNameLE->setText(name); + } + settings.beginGroup("Profiles"); + settings.beginGroup(profile); + settings.setValue("Name",name); + settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); + settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); + settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); + settings.setValue("sdPath", ui->sdPath->text()); + settings.setValue("SplashFileName", ui->SplashFileName->text()); + settings.setValue("firmware", ui->firmwareLE->text()); + settings.endGroup(); + settings.endGroup(); +} + +void appPreferencesDialog::loadProfileString(QString profile, QString label) +{ + QSettings settings; + QString value; + + settings.beginGroup("Profiles"); + settings.beginGroup(profile); + value = settings.value(label).toString(); + settings.endGroup(); + settings.endGroup(); + + settings.setValue( label, value ); +} + +void appPreferencesDialog::loadProfile() +{ + QSettings settings; + QString profile=QString("profile") + settings.value("profileId").toString(); + + loadProfileString( profile, "Name" ); + loadProfileString( profile, "default_channel_order" ); + loadProfileString( profile, "default_mode" ); + loadProfileString( profile, "burnFirmware" ); + loadProfileString( profile, "rename_firmware_files" ); + loadProfileString( profile, "sdPath" ); + loadProfileString( profile, "SplashFileName" ); + loadProfileString( profile, "firmware" ); +} + +void appPreferencesDialog::on_removeProfileButton_clicked() +{ + QSettings settings; + QString profileId = settings.value("profileId").toString(); + if ( profileId == "1" ) + QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed.")); + else + { + QString profile=QString("profile") + profileId; + settings.beginGroup("Profiles"); + settings.remove(profile); + settings.endGroup(); + settings.setValue("profileId", "1"); + + loadProfile(); + initSettings(); + } +} + +bool appPreferencesDialog::displayImage( QString fileName ) +{ + QImage image(fileName); + if (image.isNull()) + { + QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); + return false; + } + + int width=ui->imageLabel->width(); + ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, 64))); + if (width==212) { + image=image.convertToFormat(QImage::Format_RGB32); + QRgb col; + int gray, height = image.height(); + for (int i = 0; i < width; ++i) { + for (int j = 0; j < height; ++j) { + col = image.pixel(i, j); + gray = qGray(col); + image.setPixel(i, j, qRgb(gray, gray, gray)); + } + } + ui->imageLabel->setPixmap(QPixmap::fromImage(image)); + } + else { + ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono))); + } + return true; +} + +void appPreferencesDialog::on_SplashSelect_clicked() +{ + QString supportedImageFormats; + for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) { + supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; + } + + QSettings settings; + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); + + if (!fileName.isEmpty()) { + settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); + + if (displayImage(fileName)) + ui->SplashFileName->setText(fileName); + } +} + +void appPreferencesDialog::on_clearImageButton_clicked() { + ui->imageLabel->clear(); + ui->SplashFileName->clear(); +} + + + diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index d47682512..b6f6c3896 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -23,6 +23,10 @@ public: private: Ui::appPreferencesDialog *ui; void initSettings(); + bool displayImage( QString fileName ); + void saveProfile(); + void loadProfileString(QString profile, QString label); + void loadProfile(); private slots: void writeValues(); @@ -31,6 +35,12 @@ private slots: void on_snapshotClipboardCKB_clicked(); void on_backupPathButton_clicked(); void on_ge_pathButton_clicked(); + + void on_sdPathButton_clicked(); + void on_removeProfileButton_clicked(); + void on_SplashSelect_clicked(); + void on_clearImageButton_clicked(); + #ifdef JOYSTICKS void on_joystickChkB_clicked(); void on_joystickcalButton_clicked(); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index bc1f734f3..33cfe311a 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 685 - 456 + 462 @@ -23,7 +23,7 @@ - Application Preferences + Edit Settings @@ -32,230 +32,7 @@ 6 - - - - Open Folder - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Joystick - - - - - - - Simulator capture folder - - - - - - - Remember simulator switch values - - - - - - - - 0 - 0 - - - - User Splash Screens - - - - - - - - 0 - 0 - - - - Files to keep - - - - - - - Offer to use wizard for new models - - - true - - - - - - - Qt::Horizontal - - - - - - - - 100 - 16777215 - - - - - Blue - - - - - Green - - - - - Red - - - - - Orange - - - - - Yellow - - - - - - - - Automatic check for Companion updates - - - true - - - - - - - Qt::Horizontal - - - - - - - true - - - true - - - - - - - Only capture to clipboard - - - - - - - - 40 - 0 - - - - - 50 - 16777215 - - - - 15 - - - 10 - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - - 250 - 0 - - - - true - - - - - - - Calibrate - - - - - - - Automatic Backup Folder - - - - + Qt::Horizontal @@ -265,187 +42,919 @@ - - - - Open Folder - - - false - - - - - - - true - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Simulator BackLight - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Enable automatic backup before writing firmware - - - - - - - Show splash screen when Companion starts - - - true - - - - - - - Find Executable - - - - - - - Open Folder - - - - - - - Enable - - - - - - - Google Earth Executable - - - - - - - Automatic check for OpenTX firmware updates - - - true - - - - - - - - 0 - 0 - - - - - Include companion splashes - - - - - Only user defined splashes - - - - - - - - - 0 - 0 - - - - Splash Screen Library - - - - - - - true - - - true + + + + 0 + + + Application Settings + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Automatic Backup Folder + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + 15 + + + 10 + + + + + + + + 0 + 0 + + + + User Splash Screens + + + + + + + + 0 + 0 + + + + + Include companion splashes + + + + + Only user defined splashes + + + + + + + + Google Earth Executable + + + + + + + Automatic check for OpenTX firmware updates + + + true + + + + + + + + 350 + 0 + + + + true + + + + + + + Open Folder + + + + + + + Qt::Horizontal + + + + + + + + 350 + 0 + + + + true + + + + + + + Find Executable + + + + + + + + 0 + 0 + + + + Files to keep + + + + + + + + 0 + 0 + + + + Splash Screen Library + + + + + + + Enable automatic backup before writing firmware + + + + + + + Open Folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + + + + Automatic check for Companion updates + + + true + + + + + + + Qt::Horizontal + + + + + + + Offer to use wizard for new models + + + true + + + + + + + Show splash screen when Companion starts + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + true + + + + + + + + Simulator Settings + + + + + + + 0 + 0 + + + + Simulator BackLight + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Enable + + + + + + + Open Folder + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 16777215 + + + + + Blue + + + + + Green + + + + + Red + + + + + Orange + + + + + Yellow + + + + + + + + + 0 + 0 + + + + Joystick + + + + + + + Only capture to clipboard + + + + + + + + 0 + 0 + + + + + + + + Calibrate + + + + + + + Remember simulator switch values + + + + + + + Simulator capture folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + true + + + + 350 + 0 + + + + true + + + + + + + + Radio Settings + + + + + + + 16777215 + 16777215 + + + + Mode selection: + +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + + + + 1 + + + + Mode 1 (RUD ELE THR AIL) + + + + + Mode 2 (RUD THR ELE AIL) + + + + + Mode 3 (AIL ELE THR RUD) + + + + + Mode 4 (AIL THR ELE RUD) + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Channel order + +This is used by the templated to determine which channel goes to what number output. + + + 0 + + + + R E T A + + + + + R E A T + + + + + R T E A + + + + + R T A E + + + + + R A E T + + + + + R A T E + + + + + E R T A + + + + + E R A T + + + + + E T R A + + + + + E T A R + + + + + E A R T + + + + + E A T R + + + + + T R E A + + + + + T R A E + + + + + T E R A + + + + + T E A R + + + + + T A R E + + + + + T A E R + + + + + A R E T + + + + + A R T E + + + + + A E R T + + + + + A E T R + + + + + A T R E + + + + + A T E R + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Default Stick Mode + + + + + + + Settings Profile + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + Splash Screen + + + + + + + + 0 + 0 + + + + Channel Order + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Append version number to FW file name + + + + + + + + 0 + 0 + + + + SD Structure path + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + true + + + + 350 + 0 + + + + true + + + + + + + Select Image + + + + + + + + 0 + 0 + + + + + 128 + 64 + + + + + 128 + 64 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Offer to write FW to Tx after download + + + + + + + Remove Profile + + + + + + + Clear Image + + + + + + + Open Folder + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + + + + true + + + + 0 + 0 + + + + true + + + + + + + false + + + + 30 + 16777215 + + + + + + + + Firmware + + + + + + + false + + + + + - startupCheck_companion9x - backupEnable - line - backupPath - line_2 - startupCheck_fw - wizardEnable_ChkB - ge_label - label_5 - showSplash - line_3 - ge_pathButton - line_4 - backupPathButton - label_3 - backLightColor - snapshotPath - snapshotPathButton - snapshotClipboardCKB - label_11 - joystickCB - joystickcalButton - ge_lineedit - simuSW - buttonBox - line_5 - joystickChkB - label_17 - label_19 - historySize - label_9 - libraryPath - libraryPathButton - line_6 - splashincludeCB - label_10 - buttonBox + tabWidget ge_lineedit ge_pathButton historySize @@ -456,6 +965,10 @@ backupPath backupPathButton backupEnable + splashincludeCB + libraryPath + libraryPathButton + buttonBox snapshotPath snapshotPathButton snapshotClipboardCKB @@ -464,6 +977,12 @@ joystickCB joystickChkB joystickcalButton + sdPath + SplashFileName + stickmodeCB + channelorderCB + renameFirmware + burnFirmware @@ -476,8 +995,8 @@ accept() - 376 - 596 + 382 + 455 157 @@ -492,8 +1011,8 @@ reject() - 396 - 596 + 402 + 455 286 diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 070fe3dc0..3b8240f6c 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -7,19 +7,128 @@ #include "splashlibrary.h" #include "flashinterface.h" +//*** Side Class *** + Side::Side(){ imageLabel = 0; fileNameEdit = 0; saveButton = 0; - source=new Source; - *source = UNDEFINED; + saveToFileName = new QString(""); + source = new Source(UNDEFINED); } -void Side::copyImage( Side side ){ - if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED)) +void Side::copyImage( Side side ) +{ + if ((*source!=UNDEFINED) && (*side.source!=UNDEFINED)) imageLabel->setPixmap(*side.imageLabel->pixmap()); } +bool Side::displayImage( QString fileName, Source pictSource ) +{ + QImage image; + + if (fileName.isEmpty()) { + return false; + } + if (pictSource == FW ){ + FlashInterface flash(fileName); + if (!flash.hasSplash()) + return false; + else + image = flash.getSplash(); + } + else { + image.load(fileName); + } + if (image.isNull()) { + return false; + } + if (imageLabel->width()==424) { + image=image.convertToFormat(QImage::Format_RGB32); + QRgb col; + int gray; + int width = image.width(); + int height = image.height(); + for (int i = 0; i < width; ++i) { + for (int j = 0; j < height; ++j) { + col = image.pixel(i, j); + gray = qGray(col); + image.setPixel(i, j, qRgb(gray, gray, gray)); + } + } + imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2))); + } + else { + imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); + } + switch (pictSource){ + case FW: + fileNameEdit->setText(QObject::tr("FW: %1").arg(fileName)); + *saveToFileName = fileName; + *source=FW; + break; + case PICT: + fileNameEdit->setText(QObject::tr("Pict: %1").arg(fileName)); + *saveToFileName = fileName; + *source=PICT; + break; + case PROFILE: + fileNameEdit->setText(QObject::tr("Profile image")); + *saveToFileName = fileName; + *source=PROFILE; + break; + default: + break; + } + saveButton->setEnabled(true); + libraryButton->setEnabled(true); + invertButton->setEnabled(true); + return true; +} + +bool Side::refreshImage() +{ + return displayImage( *saveToFileName, *source ); +} + +bool Side::saveImage() +{ + QSettings settings; + + if (*source == FW ) + { + FlashInterface flash(*saveToFileName); + if (!flash.hasSplash()) { + return false; + } + QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); + if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) { + settings.setValue("lastFlashDir", QFileInfo(*saveToFileName).dir().absolutePath()); + } + else { + return false; + } + } + else if (*source == PICT) { + QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); + if (image.save(*saveToFileName)) { + settings.setValue("lastImagesDir", QFileInfo(*saveToFileName).dir().absolutePath()); + } + else { + return false; + } + } + else if (*source == PROFILE) { + QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); + if (!image.save(*saveToFileName)) { + return false; + } + } + return true; +} + +//*** customizeSplashDialog Class *** + customizeSplashDialog::customizeSplashDialog(QWidget *parent) : QDialog(parent), ui(new Ui::customizeSplashDialog) @@ -39,6 +148,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) : left.invertButton = ui->leftInvertButton; right.invertButton = ui->rightInvertButton; + loadProfile(left); resize(0,0); } @@ -62,25 +172,10 @@ void customizeSplashDialog::loadFirmware(Side side) QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); if (!fileName.isEmpty()) { - QFile file(fileName); - if (fileName.isEmpty() || !file.exists()) - return; - - FlashInterface flash(fileName); - if (!flash.hasSplash()) { - QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file")); - return; - } - - side.saveButton->setEnabled(true); - side.imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash())); - side.imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2); - side.fileNameEdit->setText(fileName); + if (!side.displayImage( fileName, FW )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName)); + else settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); - *side.source=FW; - side.saveButton->setEnabled(true); - side.libraryButton->setEnabled(true); - side.invertButton->setEnabled(true); } } @@ -96,46 +191,25 @@ void customizeSplashDialog::loadPicture(Side side) QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); - if (fileName.isEmpty()){ - return; + if (!fileName.isEmpty()) { + if (!side.displayImage( fileName, PICT )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName)); + else + settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); } - QImage image(fileName); - if (image.isNull()) { - QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); - return; - } - if (side.imageLabel->width()==424) { - image=image.convertToFormat(QImage::Format_RGB32); - QRgb col; - int gray; - int width = image.width(); - int height = image.height(); - for (int i = 0; i < width; ++i) - { - for (int j = 0; j < height; ++j) - { - col = image.pixel(i, j); - gray = qGray(col); - image.setPixel(i, j, qRgb(gray, gray, gray)); - } - } - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2))); - } else { - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); - } - - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); - side.fileNameEdit->setText(fileName); - *side.source=PICT; - side.saveButton->setEnabled(true); - side.libraryButton->setEnabled(true); - side.invertButton->setEnabled(true); } void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left);} void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);} void customizeSplashDialog::loadProfile(Side side) { + QSettings settings; + QString fileName=settings.value("SplashFileName","").toString(); + + if (!fileName.isEmpty()) { + if (!side.displayImage( fileName, PROFILE )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the profile image %1.").arg(fileName)); + } } void customizeSplashDialog::on_leftLibraryButton_clicked(){libraryButton_clicked(left);} @@ -143,67 +217,26 @@ void customizeSplashDialog::on_rightLibraryButton_clicked(){libraryButton_clicke void customizeSplashDialog::libraryButton_clicked( Side side ) { QString fileName; - splashLibrary *ld = new splashLibrary(this,&fileName); ld->exec(); if (!fileName.isEmpty()) { - QImage image(fileName); - if (image.isNull()) { - QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); - return; - } - if (side.imageLabel->width()==424) { - image=image.convertToFormat(QImage::Format_RGB32); - QRgb col; - int gray; - int width = image.width(); - int height = image.height(); - for (int i = 0; i < width; ++i) - { - for (int j = 0; j < height; ++j) - { - col = image.pixel(i, j); - gray = qGray(col); - image.setPixel(i, j, qRgb(gray, gray, gray)); - } - } - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2))); - } else { - side.imageLabel->setPixmap(QPixmap::fromImage(image.scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); - } + if (!side.displayImage( fileName, UNDEFINED )) + QMessageBox::critical(this, tr("Error"), tr("Cannot load the library image %1.").arg(fileName)); } } void customizeSplashDialog::on_leftSaveButton_clicked(){saveButton_clicked(left);} void customizeSplashDialog::on_rightSaveButton_clicked(){saveButton_clicked(right);} -void customizeSplashDialog::saveButton_clicked(Side side) +void customizeSplashDialog::saveButton_clicked( Side side ) { - QSettings settings; - QString fileName = side.fileNameEdit->text(); - - if (*side.source == FW) - { - FlashInterface flash(fileName); - if (!flash.hasSplash()) { - QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName)); - return; - } - QImage image = side.imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); - if (flash.setSplash(image) && (flash.saveFlash(fileName) > 0)) - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); - else - QMessageBox::critical(this, tr("Error"), tr("Could not store image in firmware file %1").arg(fileName)); - } - else if (*side.source == PICT) - { - if (!fileName.isEmpty()) { - QImage image = side.imageLabel->pixmap()->toImage().scaled(side.imageLabel->width()/2, side.imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); - if (image.save(fileName)) - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); - else - QMessageBox::critical(this, tr("Error"), tr("The image file %1 could not be stored").arg(fileName)); + if (side.saveImage()){ + QMessageBox::information(this, tr("File Saved"), tr("The image was saved to the file %1").arg(*side.saveToFileName)); + if ( !side.refreshImage()){ + QMessageBox::critical(this, tr("Image Refresh Error"), tr("Failed to refresh image from file %1").arg(*side.saveToFileName)); } } + else + QMessageBox::critical(this, tr("File Save Error"), tr("Failed to write image to %1").arg(*side.saveToFileName)); } void customizeSplashDialog::on_leftInvertButton_clicked(){invertButton_clicked(left);} diff --git a/companion/src/customizesplashdialog.h b/companion/src/customizesplashdialog.h index 8ae954d1c..b4db9a60e 100644 --- a/companion/src/customizesplashdialog.h +++ b/companion/src/customizesplashdialog.h @@ -17,6 +17,9 @@ class Side public: Side(); void copyImage( Side ); + bool displayImage( QString fileName, Source source ); + bool saveImage(); + bool refreshImage(); QLabel *imageLabel; QLineEdit *fileNameEdit; @@ -24,6 +27,9 @@ public: QPushButton *invertButton; QToolButton *libraryButton; + QString *saveToFileName; + +private: Source *source; }; diff --git a/companion/src/customizesplashdialog.ui b/companion/src/customizesplashdialog.ui index b98d87907..fa6c57d9f 100644 --- a/companion/src/customizesplashdialog.ui +++ b/companion/src/customizesplashdialog.ui @@ -254,6 +254,16 @@ + + + + true + + + Load Profile + + + @@ -268,16 +278,6 @@ - - - - false - - - Load Profile - - - @@ -550,6 +550,16 @@ + + + + true + + + Load Profile + + + @@ -567,16 +577,6 @@ - - - - false - - - Load Profile - - - @@ -625,12 +625,17 @@ leftFileNameEdit leftInvertButton + leftLibraryButton + leftLoadProfileButton + leftLoadFwButton leftLoadPictButton leftSaveButton copyLeftToRightButton copyRightToLeftButton rightFileNameEdit rightInvertButton + rightLibraryButton + rightLoadProfileButton rightLoadFwButton rightLoadPictButton rightSaveButton diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 3864b9f41..6a3806b21 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -734,7 +734,7 @@ GeneralSettings::GeneralSettings() QSettings settings; templateSetup = settings.value("default_channel_order", 0).toInt(); stickMode = settings.value("default_mode", 1).toInt(); - int profile_id = settings.value("ActiveProfile", 0).toInt(); + int profile_id = settings.value("profileId", 0).toInt(); if (profile_id>0) { settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profile_id); diff --git a/companion/src/fwpreferencesdialog.cpp b/companion/src/fwpreferencesdialog.cpp index 2dfce0e73..735e18acc 100644 --- a/companion/src/fwpreferencesdialog.cpp +++ b/companion/src/fwpreferencesdialog.cpp @@ -12,7 +12,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) : updateLock(false) { ui->setupUi(this); - setWindowIcon(CompanionIcon("preferences.png")); + setWindowIcon(CompanionIcon("fwpreferences.png")); QCheckBox * OptionCheckBox[]= { ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7, @@ -38,7 +38,7 @@ fwPreferencesDialog::fwPreferencesDialog(QWidget *parent) : connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged())); connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); - resize(0,0); + shrink(); } @@ -47,32 +47,43 @@ fwPreferencesDialog::~fwPreferencesDialog() delete ui; } +void fwPreferencesDialog::showVoice(bool show) +{ + if (show) + showVoice(); + else + hideVoice(); +} + +void fwPreferencesDialog::showVoice() +{ + ui->voiceLine->show(); + ui->voiceLabel->show(); + ui->voiceCombo->show(); + ui->voice_dnld->show(); +} + +void fwPreferencesDialog::hideVoice() +{ + ui->voiceLine->hide(); + ui->voiceLabel->hide(); + ui->voiceCombo->hide(); + ui->voice_dnld->hide(); + QTimer::singleShot(0, this, SLOT(shrink())); +} + +void fwPreferencesDialog::shrink() +{ + resize(0,0); +} + void fwPreferencesDialog::baseFirmwareChanged() { QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex()); voice=NULL; foreach(FirmwareInfo * firmware, firmwares) { if (firmware->id == selected_firmware) { - if (firmware->voice) { - ui->voiceLabel->show(); - ui->voiceCombo->show(); - ui->voice_dnld->show(); - ui->sdPathButton->show(); - ui->sdPath->show(); - ui->sdPathLabel->show(); - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); - } else { - ui->voiceLabel->hide(); - ui->voiceCombo->hide(); - ui->voice_dnld->hide(); - ui->sdPathButton->hide(); - ui->sdPath->hide(); - ui->sdPathLabel->hide(); - } + showVoice(firmware->voice); populateFirmwareOptions(firmware); break; } @@ -109,11 +120,6 @@ FirmwareVariant fwPreferencesDialog::getFirmwareVariant() return default_firmware_variant; } -void fwPreferencesDialog::firmwareLangChanged() -{ - firmwareChanged(); -} - void fwPreferencesDialog::firmwareOptionChanged(bool state) { QCheckBox *cb = qobject_cast(sender()); @@ -134,19 +140,7 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state) } } if (voice) { - if (voice->isChecked()) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); - } else { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setDisabled(true); - ui->sdPath->setDisabled(true); - } + showVoice(voice->isChecked()); } return firmwareChanged(); @@ -157,37 +151,24 @@ void fwPreferencesDialog::firmwareOptionChanged(bool state) } } else if (cb && !state) { if (cb->text()=="voice") { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); + hideVoice(); } } - if (voice ) { - if (voice->isChecked()) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - } else { - ui->voiceLabel->setDisabled(true); - ui->voiceCombo->setDisabled(true); - ui->voice_dnld->setDisabled(true); - ui->sdPathButton->setDisabled(true); - ui->sdPath->setDisabled(true); - } + if (voice) { + showVoice(voice->isChecked()); } else if (firmware) { if (firmware->voice) { - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); + showVoice(); } } return firmwareChanged(); } +void fwPreferencesDialog::firmwareLangChanged() +{ + firmwareChanged(); +} + void fwPreferencesDialog::firmwareChanged() { if (updateLock) @@ -233,21 +214,10 @@ void fwPreferencesDialog::firmwareChanged() void fwPreferencesDialog::writeValues() { QSettings settings; - settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); - settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); + settings.setValue("cpu_id", ui->CPU_ID_LE->text()); - settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); - settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); current_firmware_variant = getFirmwareVariant(); settings.setValue("firmware", current_firmware_variant.id); - settings.setValue("profileId", ui->ProfSlot_SB->value()); - settings.setValue("sdPath", ui->sdPath->text()); - settings.setValue("SplashFileName", ui->SplashFileName->text()); - if (!ui->SplashFileName->text().isEmpty()) - settings.setValue("SplashImage", ""); - - MainWindow * mw = (MainWindow *)this->parent(); - mw->unloadProfile(); } void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) @@ -269,14 +239,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1); } - if (ui->langCombo->count()) { - ui->langCombo->show(); - ui->langLabel->show(); - } - else { - ui->langCombo->hide(); - ui->langLabel->hide(); - } + showVoice(ui->langCombo->count()!=0); int index = 0; foreach(QList @@ -32,181 +32,13 @@ 6 - - - - Download Voice + + + + Qt::Horizontal - - - - - - Offer to write FW to Tx after download - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - Download FW - - - - - - - Options - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - Processor ID - - - - - - - - 0 - 0 - - - - CheckBox - - - - - - - - 0 - 0 - - - - FwInfo - - - - - - - - 0 - 0 - - - - CheckBox + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -223,6 +55,19 @@ + + + + + 0 + 0 + + + + CheckBox + + + @@ -246,35 +91,6 @@ - - - - - 0 - 0 - - - - Default Stick Mode - - - - - - - - 0 - 0 - - - - Channel Order - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -301,60 +117,6 @@ - - - - - 190 - 16777215 - - - - Mode selection: - -Mode 1: - Left stick: Elevator, Rudder - Right stick: Throttle, Aileron - -Mode 2: - Left stick: Throttle, Rudder - Right stick: Elevator, Aileron - -Mode 3: - Left stick: Elevator, Aileron - Right stick: Throttle, Rudder - -Mode 4: - Left stick: Throttle, Aileron - Right stick: Elevator, Rudder - - - - - 1 - - - - Mode 1 (RUD ELE THR AIL) - - - - - Mode 2 (RUD THR ELE AIL) - - - - - Mode 3 (AIL ELE THR RUD) - - - - - Mode 4 (AIL THR ELE RUD) - - - - @@ -394,6 +156,9 @@ Mode 4: + + + @@ -410,8 +175,8 @@ Mode 4: - - + + @@ -436,159 +201,6 @@ Mode 4: - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 75 - 16777215 - - - - Channel order - -This is used by the templated to determine which channel goes to what number output. - - - 0 - - - - R E T A - - - - - R E A T - - - - - R T E A - - - - - R T A E - - - - - R A E T - - - - - R A T E - - - - - E R T A - - - - - E R A T - - - - - E T R A - - - - - E T A R - - - - - E A R T - - - - - E A T R - - - - - T R E A - - - - - T R A E - - - - - T E R A - - - - - T E A R - - - - - T A R E - - - - - T A E R - - - - - A R E T - - - - - A R T E - - - - - A E R T - - - - - A E T R - - - - - A T R E - - - - - A T E R - - - - @@ -641,19 +253,6 @@ This is used by the templated to determine which channel goes to what number out - - - - - 0 - 0 - - - - CheckBox - - - @@ -914,40 +513,6 @@ This is used by the templated to determine which channel goes to what number out - - - - Append version number to FW file name - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - Sans Serif - 75 - true - - - - Profile - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -961,37 +526,6 @@ This is used by the templated to determine which channel goes to what number out - - - - true - - - true - - - - - - - - 50 - 16777215 - - - - Set language of voice. -May be different from firmware language - - - - - - - Open Image - - - @@ -1006,109 +540,202 @@ May be different from firmware language - - - - - 0 - 0 - - - - Splash Screen - - - - - - - Clear Image - - - - - - - - - - - 0 - 0 - - + + - 16777215 + 50 16777215 - - 1 - - - 10 + + Set language of voice. +May be different from firmware language - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - + + - Open Folder + Download Voice - - - - true - - - true - - - - - + + - + 0 0 - SD Structure path - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + CheckBox - - + + + + + 0 + 0 + + - Save Profile + CheckBox + + + + + + + Download FW + + + + + + + Options + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + Processor ID + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + + 0 + 0 + + + + FwInfo + + + + + + + + 0 + 0 + + + + CheckBox + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal @@ -1161,10 +788,6 @@ May be different from firmware language optionCheckBox_40 optionCheckBox_41 optionCheckBox_42 - stickmodeCB - channelorderCB - renameFirmware - burnFirmware diff --git a/companion/src/images/originals/classical icons/apppreferences.png b/companion/src/images/originals/classical icons/apppreferences.png index 1f6613e40..d24ef0ad7 100644 Binary files a/companion/src/images/originals/classical icons/apppreferences.png and b/companion/src/images/originals/classical icons/apppreferences.png differ diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index df57d182c..2f126e48b 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -124,12 +124,6 @@ MainWindow::MainWindow(): updateMenus(); readSettings(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } setUnifiedTitleAndToolBarOnMac(true); this->setWindowIcon(QIcon(":/icon.png")); this->setIconSize(QSize(32,32)); @@ -752,23 +746,20 @@ void MainWindow::loadProfile() { QSettings settings; QAction *action = qobject_cast(sender()); - int chord,defmod, burnfw; - bool renfw; if (action) { int profnum=action->data().toInt(); QSettings settings; - settings.setValue("ActiveProfile",profnum); + settings.setValue("profileId",profnum); settings.beginGroup("Profiles"); QString profile=QString("profile%1").arg(profnum); settings.beginGroup(profile); - ActiveProfile=profnum; - ActiveProfileName=settings.value("Name", "").toString(); - chord=settings.value("default_channel_order", 0).toInt(); - defmod=settings.value("default_mode", 0).toInt(); - burnfw=settings.value("burnFirmware", 0).toInt(); + QString profileName=settings.value("Name", "").toString(); + int chord=settings.value("default_channel_order", 0).toInt(); + int defmod=settings.value("default_mode", 0).toInt(); + bool burnfw=settings.value("burnFirmware", false).toBool(); QString sdPath=settings.value("sdPath", ".").toString(); - renfw=settings.value("rename_firmware_files", false).toBool(); + bool renfw=settings.value("rename_firmware_files", false).toBool(); QString SplashFileName=settings.value("SplashFileName","").toString(); QString SplashImage=settings.value("SplashImage", "").toString(); QString firmware_id=settings.value("firmware", default_firmware_variant.id).toString(); @@ -777,6 +768,7 @@ void MainWindow::loadProfile() settings.setValue("firmware", firmware_id); settings.endGroup(); settings.endGroup(); + settings.setValue("Name", profileName ); settings.setValue("default_channel_order", chord); settings.setValue("default_mode", defmod); settings.setValue("burnFirmware", burnfw); @@ -785,46 +777,15 @@ void MainWindow::loadProfile() settings.setValue("SplashFileName", SplashFileName); settings.setValue("SplashImage", SplashImage); settings.setValue("firmware", firmware_id); - settings.setValue("profileId", profnum); current_firmware_variant = GetFirmwareVariant(firmware_id); - FirmwareInfo *firmware = GetCurrentFirmware(); - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - // settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { MdiChild *mdiChild = qobject_cast(window->widget()); mdiChild->eepromInterfaceChanged(); } - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } -} -void MainWindow::unloadProfile() -{ - ActiveProfile=0; - ActiveProfileName=""; - QSettings settings; - settings.setValue("ActiveProfile", 0); - FirmwareInfo *firmware = GetCurrentFirmware(); - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); -} - -void MainWindow::preferences() -{ - preferencesDialog *pd = new preferencesDialog(this); - pd->exec(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); + updateMenus(); } - else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } - - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { - MdiChild *mdiChild = qobject_cast(window->widget()); - mdiChild->eepromInterfaceChanged(); - } - updateMenus(); } void MainWindow::appPreferences() @@ -838,14 +799,6 @@ void MainWindow::fwPreferences() { fwPreferencesDialog *pd = new fwPreferencesDialog(this); pd->exec(); - FirmwareInfo *firmware = GetCurrentFirmware(); - if (ActiveProfile) { - setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName)); - } - else { - setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name)); - } - foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { MdiChild *mdiChild = qobject_cast(window->widget()); mdiChild->eepromInterfaceChanged(); @@ -1640,19 +1593,9 @@ void MainWindow::updateMenus() compareAct->setEnabled(activeMdiChild()); updateRecentFileActions(); updateProfilesActions(); - bool notfound=true; + QSettings settings; - settings.beginGroup("Profiles"); - for (int i=0; isetDisabled(notfound); + setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString())); } MdiChild *MainWindow::createMdiChild() @@ -1701,16 +1644,12 @@ void MainWindow::createActions() logsAct->setStatusTip(tr("Open log file")); connect(logsAct, SIGNAL(triggered()), this, SLOT(logFile())); - preferencesAct = new QAction(tr("&Old Preferences Dialog..."), this); - preferencesAct->setStatusTip(tr("Used the old Preferences Dialog")); - connect(preferencesAct, SIGNAL(triggered()), this, SLOT(preferences())); - - appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Application Preferences..."), this); - appPreferencesAct->setStatusTip(tr("Edit application preferences")); + appPreferencesAct = new QAction(CompanionIcon("apppreferences.png"), tr("&Setting..."), this); + appPreferencesAct->setStatusTip(tr("Edit Settings")); connect(appPreferencesAct, SIGNAL(triggered()), this, SLOT(appPreferences())); - fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads and Profiles..."), this); - fwPreferencesAct->setStatusTip(tr("Firmware and voice file downloads as well as profile definition.")); + fwPreferencesAct = new QAction(CompanionIcon("fwpreferences.png"), tr("&Downloads..."), this); + fwPreferencesAct->setStatusTip(tr("Download firmware and voice files")); connect(fwPreferencesAct, SIGNAL(triggered()), this, SLOT(fwPreferences())); checkForUpdatesAct = new QAction(CompanionIcon("update.png"), tr("&Check for updates..."), this); @@ -1833,6 +1772,9 @@ void MainWindow::createActions() connect(profileActs[i], SIGNAL(triggered()), this, SLOT(loadProfile())); } updateProfilesActions(); + createProfileAct = new QAction(tr("New Profile"), this); + createProfileAct->setStatusTip(tr("Create a new Radio Setting Profile")); + connect(createProfileAct, SIGNAL(triggered()), this, SLOT(createProfile())); classicThemeAct = new QAction(tr("Classic"), this); classicThemeAct->setStatusTip(tr("The multicolor classical Companion icon theme")); @@ -1917,7 +1859,6 @@ void MainWindow::createMenus() { QMenu *recentFileMenu=new QMenu(tr("Recent Files")); - QMenu *profilesMenu=new QMenu(tr("Firmware Profiles")); QMenu *languageMenu=new QMenu(tr("Set Menu Language")); QMenu *themeMenu=new QMenu(tr("Set Icon Theme")); QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size")); @@ -1939,11 +1880,7 @@ void MainWindow::createMenus() fileMenu->addAction(compareAct); fileMenu->addSeparator(); fileMenu->addAction(fwPreferencesAct); - fileMenu->addMenu(profilesMenu); - - profilesMenu->setIcon(CompanionIcon("profiles.png")); - for (int i=0; iaddAction(profileActs[i]); + fileMenu->addMenu(createProfilesMenu()); fileMenu->addAction(exitAct); editMenu = menuBar()->addMenu(tr("&Edit")); @@ -1977,7 +1914,6 @@ void MainWindow::createMenus() settingsMenu->addSeparator(); settingsMenu->addAction(appPreferencesAct); settingsMenu->addAction(customizeSplashAct); - settingsMenu->addAction(preferencesAct); settingsMenu->addAction(burnConfigAct); burnMenu = menuBar()->addMenu(tr("&Read/Write")); @@ -2021,9 +1957,15 @@ QMenu *MainWindow::createRecentFileMenu() QMenu *MainWindow::createProfilesMenu() { - QMenu *profilesMenu = new QMenu(this); - for ( int i = 0; i < MAX_PROFILES; ++i) + QMenu *profilesMenu=new QMenu(tr("Radio Settings Profiles")); + int i; + for ( i = 0; i < MAX_PROFILES; ++i) { profilesMenu->addAction(profileActs[i]); + } + if ( i>0 ) + profilesMenu->addSeparator(); + profilesMenu->addAction(createProfileAct); + profilesMenu->setIcon(CompanionIcon("profiles.png")); return profilesMenu; } @@ -2039,11 +1981,14 @@ void MainWindow::createToolBars() case 1: size=QSize(24,24); break; + case 2: + size=QSize(32,32); + break; case 3: size=QSize(48,48); break; default: - size=QSize(32,32); + size=QSize(24,24); break; } fileToolBar = addToolBar(tr("File")); @@ -2051,11 +1996,11 @@ void MainWindow::createToolBars() fileToolBar->setObjectName("File"); fileToolBar->addAction(newAct); fileToolBar->addAction(openAct); - QToolButton * recentToolButton = new QToolButton; - recentToolButton->setPopupMode(QToolButton::InstantPopup); - recentToolButton->setMenu(createRecentFileMenu()); - recentToolButton->setIcon(CompanionIcon("recentdocument.png")); - recentToolButton->setToolTip(tr("Recent Files")); + QToolButton * recentToolButton = new QToolButton; + recentToolButton->setPopupMode(QToolButton::InstantPopup); + recentToolButton->setMenu(createRecentFileMenu()); + recentToolButton->setIcon(CompanionIcon("recentdocument.png")); + recentToolButton->setToolTip(tr("Recent Files")); fileToolBar->addWidget(recentToolButton); fileToolBar->addAction(saveAct); fileToolBar->addAction(logsAct); @@ -2063,24 +2008,12 @@ void MainWindow::createToolBars() fileToolBar->addAction(appPreferencesAct); fileToolBar->addAction(fwPreferencesAct); fileToolBar->addAction(customizeSplashAct); - profileButton = new QToolButton; - profileButton->setPopupMode(QToolButton::InstantPopup); - profileButton->setMenu(createProfilesMenu()); - profileButton->setIcon(CompanionIcon("profiles.png")); - profileButton->setToolTip(tr("Firmware Profiles")); + profileButton = new QToolButton; + profileButton->setPopupMode(QToolButton::InstantPopup); + profileButton->setMenu(createProfilesMenu()); + profileButton->setIcon(CompanionIcon("profiles.png")); + profileButton->setToolTip(tr("Firmware Profiles")); fileToolBar->addWidget(profileButton); - bool notfound=true; - settings.beginGroup("Profiles"); - for (int i=0; isetDisabled(notfound); fileToolBar->addSeparator(); fileToolBar->addAction(simulateAct); fileToolBar->addAction(printAct); @@ -2092,7 +2025,6 @@ void MainWindow::createToolBars() editToolBar->addAction(cutAct); editToolBar->addAction(copyAct); editToolBar->addAction(pasteAct); - burnToolBar = new QToolBar(tr("Write")); addToolBar( Qt::LeftToolBarArea, burnToolBar ); @@ -2128,14 +2060,10 @@ void MainWindow::readSettings() checkCompanion9x = settings.value("startup_check_companion", true).toBool(); checkFW = settings.value("startup_check_fw", true).toBool(); MaxRecentFiles =settings.value("history_size",10).toInt(); - ActiveProfile=settings.value("activeprofile",0).toInt(); - if (ActiveProfile) { - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(ActiveProfile); - settings.beginGroup(profile); - ActiveProfileName=settings.value("Name","").toString(); - settings.endGroup(); - settings.endGroup(); + if (settings.value("profileId",0).toInt() == 0) + { + createProfile(); + settings.setValue("profileId", "1"); } } @@ -2189,6 +2117,8 @@ void MainWindow::updateProfilesActions() { int i; QSettings settings; + int activeProfile = settings.value("profileId").toInt(); + settings.beginGroup("Profiles"); for (i=0; isetText(text); profileActs[i]->setData(i+1); profileActs[i]->setVisible(true); + if ((i+1) == activeProfile) + profileActs[i]->setIcon(CompanionIcon("arrow-right.png")); + else + profileActs[i]->setIcon(CompanionIcon("")); + } else { profileActs[i]->setVisible(false); } settings.endGroup(); } - // separatorAct->setVisible(numRecentFiles > 0); } +void MainWindow::createProfile() +{ + int firstFreeIndex = 0; + QSettings settings; + settings.beginGroup("Profiles"); + for (int i=0; firstFreeIndex ==0 && i R E T A - + R H G S R E A T - + R H S G R T E A - + R G H S R T A E - + R G S H R A E T - + R S H G R A T E - + R S G H E R T A - + H R G S E R A T - + H R S G E T R A - + H G R S E T A R - + H G S R E A R T - + H S R G E A T R - + H S G R T R E A - + G R H S T R A E - + G R S H T E R A - + G H R S T E A R - + G H S R T A R E - + G S R H T A E R - + G S H R A R E T - + S R H G A R T E - + S R G H A E R T - + S H R G A E T R - + S H G R A T R E - + S G R H A T E R - + S G H R @@ -1987,92 +1987,92 @@ FAI-funktionen kan inte slås av i sändaren. Condition - Villkor + Villkor V1 - V1 + V1 V2 - V2 + V2 AND - OCH + OCH Duration - Varaktighet + Varaktighet Delay - Fördröjning + Fördröjning LS%1 - LB%1 + LB%1 &Delete - + &Ta bort Delete - Ta bort + Ta bort &Copy - &Kopiera + &Kopiera Ctrl+C - Ctrl+C + Ctrl+C &Cut - Klipp &Ut + Klipp &Ut Ctrl+X - Ctrl+X + Ctrl+X &Paste - Klistra &In + Klistra &In Ctrl+V - Ctrl+V + Ctrl+V MainWindow - + - + File loaded Filen har laddats - + @@ -2129,18 +2129,18 @@ Vill du ladda ned den nya versionen nu ? Filen sparades - + Copyright Copyright - - + + &%1 %2 &%1 %2 - + &New &Ny @@ -2180,12 +2180,12 @@ Vill du ladda ned den nya versionen nu ? Spara dokumentet under nytt namn - + &Check for updates... &Sök efter uppdateringar... - + Display previous message again at startup ? Skall föregående varning visas igen vid uppstart ? @@ -2214,7 +2214,7 @@ Version %2 finns tillgänglig. Vill du ladda ned den nu ? - + Write Models and settings from %1 to the Tx? Skriv Modeller och Inställningar från %1 till sändaren? @@ -2234,7 +2234,32 @@ Vill du ladda ned den nu ? Säkerhetskopieringen misslyckades - + + OpenTX Companion - FW: %1 - Profile: %2 + OpenTX Companion - FW: %1 - Profil: %2 + + + + &Setting... + &Inställningar... + + + + Edit Settings + Redigera Inställningar + + + + &Downloads... + &Nedladdningar... + + + + Download firmware and voice files + Ladda ned firmware och röstfiler + + + Customize the splash screen of your TX Ställ din sändares startbild @@ -2354,35 +2379,26 @@ Vill du ladda ned den nu ? Visa information om programmet - - + + Recent Files Senaste Filer - + &File &Arkiv - - - - Companion - Models and Settings Editor - %1 - profile %2 - Companion - Editor för Modeller och Inställningar - %1 - profile %2 + Companion - Editor för Modeller och Inställningar - %1 - profile %2 - - - - - Companion - Models and Settings Editor - %1 - Companion - Editor för Modeller och Inställningar - %1 + Companion - Editor för Modeller och Inställningar - %1 - + Checking for updates Letar efter uppdateringar @@ -2397,7 +2413,7 @@ Vill du ladda ned den nu ? Ladda inte ned versionen (r%1)? - + OpenTX Home Page: <a href='%1'>%1</a> OpenTX Hemsida: <a href='%1'>%1</a> @@ -2417,27 +2433,23 @@ Vill du ladda ned den nu ? Version %1, %3 - &Old Preferences Dialog... - Den &Gamla Inställningsdialogen... + Den &Gamla Inställningsdialogen... - Used the old Preferences Dialog - Använde den gamla inställningsdialogen + Använde den gamla inställningsdialogen - &Application Preferences... - &Programmets Inställningar... + &Programmets Inställningar... - Edit application preferences - Redigera programmets inställningar + Redigera programmets inställningar - + Show Companion changelog Visa en lista med förändringar av Companion @@ -2502,32 +2514,32 @@ Vill du ladda ned den nu ? Läs firmware från sändaren - + Set Menu Language Ställ in Menyspråk - + &Edit &Redigera - + &Help &Hjälp - + File Arkiv - + Edit Redigera - + Help Hjälp @@ -2537,12 +2549,12 @@ Vill du ladda ned den nu ? Redo - + Contributors &List... &Bidragsgivare... - + Display previous warning again at startup ? SKall föregående varning visas igen vid uppstart ? @@ -2551,8 +2563,8 @@ Vill du ladda ned den nu ? - - + + @@ -2564,21 +2576,21 @@ Vill du ladda ned den nu ? Fel - + Cannot write file %1: %2. Filen %1 kunde inte skrivas: %2. - + New release available En ny version finns tillgänglig - + Error opening file %1: @@ -2587,7 +2599,7 @@ Vill du ladda ned den nu ? %2. - + Compilation server termporary failure, try later Tillfälligt fel i byggservern. Försök igen senare @@ -2604,7 +2616,7 @@ Vill du ladda ned den nu ? Okänt server-fel. Försök igen senare - + Compare... Jämför... @@ -2614,7 +2626,7 @@ Vill du ladda ned den nu ? Jämför modeller - + Backup is impossible @@ -2634,23 +2646,22 @@ Vill du ladda ned den nu ? Varning - - + Firmware Profiles Profiler för Firmware - + &Read/Write &Läs/Skriv - + Write Skriv - + Unable to find file %1! Kan inte hitta filen %1 ! @@ -2662,7 +2673,7 @@ Vill du ladda ned den nu ? %2. - + &loadBackup... ladda&Backup... @@ -2687,7 +2698,7 @@ Vill du ladda ned den nu ? Öppna loggfil - + @@ -2704,7 +2715,7 @@ Vill du ladda ned den nu ? Det går inte att identifiera sändaren. Verifiera att EEPOROM-skivan är ansluteten. - + Yes Ja @@ -2766,7 +2777,7 @@ Vill du ladda ned den nu ? Ikonernas storlek kommer att justeras nästa gång Companion startas. - + Firmware updates Firmware-uppdatering @@ -2879,17 +2890,15 @@ Starta skrivningen i alla fall ? Om Companion - &Downloads and Profiles... - &Nedladdningar och Profiler... + &Nedladdningar och Profiler... - Firmware and voice file downloads as well as profile definition. - Ladda ned firmware och röstfiler. Definera profildata. + Ladda ned firmware och röstfiler. Definera profildata. - + Check for new version of Companion Sök efter ny version av Companion @@ -2924,7 +2933,17 @@ Starta skrivningen i alla fall ? Inställningar för &kommunikation... - + + New Profile + Ny Profil + + + + Create a new Radio Setting Profile + Lägg till en ny profil med radio-inställningar + + + Classic Klassiskt @@ -3101,15 +3120,15 @@ Starta skrivningen i alla fall ? Manuals and other Documents - + Manualer och andra Dokument Open the OpenTX document page in a web browser - + Öppna OpenTX dokumentsida i en webbläsare - + Set Icon Theme Ställ in Ikontema @@ -3119,12 +3138,17 @@ Starta skrivningen i alla fall ? Ställ in Ikonstorlek - + &Settings &Inställningar - + + Radio Settings Profiles + Profiler för Radioinställningar + + + Invalid Models and Settings File %1 Filen innehåller inte Modeller och Inställningar: %1 @@ -4784,7 +4808,7 @@ p, li { white-space: pre-wrap; } Det går inte att använda Expo på en specialkurva i open9x - + Support for frsky telemetry mod Stöd för FrSky telemeri @@ -4810,7 +4834,7 @@ p, li { white-space: pre-wrap; } OpenTX for 9X board - + OpenTX för 9X @@ -4877,22 +4901,22 @@ p, li { white-space: pre-wrap; } OpenTX for M128 / 9X board - + OpenTX för 9X med m128-processor OpenTX for 9XR - + OpenTX för 9XR OpenTX for 9XR with M128 chip - + OpenTX för 9XR med m128-processor OpenTX for Gruvin9x board / 9X - + OpenTX för 9X med Gruvin9X-kort @@ -4902,7 +4926,7 @@ p, li { white-space: pre-wrap; } OpenTX for FrSky Taranis Rev4a - + OpenTX för FrSky Taranis Rev4a @@ -5026,7 +5050,7 @@ p, li { white-space: pre-wrap; } OpenTX for Sky9x board / 9X - + OpenTX för 9X med Sky9X-kort @@ -5227,47 +5251,47 @@ p, li { white-space: pre-wrap; } RudTrim Left - + RoderTrim Vänster RudTrim Right - + RoderTrim Höger EleTrim Down - + HöjdTrim Ned EleTrim Up - + HöjdTrim Upp ThrTrim Down - + GasTrim Ned ThrTrim Up - + GasTrim Upp AilTrim Left - + SkevTrim Vänster AilTrim Right - + SkevTrim Höger ABS - + ABS @@ -5287,87 +5311,87 @@ p, li { white-space: pre-wrap; } ??? - + ??? a>x - + a>x a<x - + a<x |a|>x - + |a|>x |a|<x - + |a|<x AND - OCH + OCH OR - + ELLER XOR - + XOR a=b - + a=b a!=b - + a!=b a>b - + a>b a<b - + a<b a>=b - + a>=b a<=b - + a<=b d>=x - + d>=x |d|>=x - + |d|>=x a~x - + a~x @@ -5377,7 +5401,7 @@ p, li { white-space: pre-wrap; } Sticky - + Klistrig @@ -5387,7 +5411,7 @@ p, li { white-space: pre-wrap; } Unknown - + Okänd @@ -5407,7 +5431,7 @@ p, li { white-space: pre-wrap; } Set Timer %1 - + Stääll in Timer %1 @@ -5796,7 +5820,7 @@ p, li { white-space: pre-wrap; } openTX accepterar bar %1 punkter i alla kurvor - + @@ -5805,24 +5829,24 @@ p, li { white-space: pre-wrap; } - + OpenTX doesn't accept this protocol OpenTX accepterar inte detta protokoll - + OpenTX doesn't allow this number of channels OpenTX accepterar inte detta antal kanaler - + Your radio probably uses a wrong firmware, eeprom size is 4096 but only the first 2048 are used Din sändare har antagligen laddats med felaktig programvara. eeprom-storleken är 4096, men enbart den första hälften används - + Support for MAVLINK devices Stöd för MAVLINK-enheter @@ -5909,7 +5933,7 @@ eeprom-storleken är 4096, men enbart den första hälften används OpenTX for FrSky Taranis - + OpenTx för FrSky Taranis @@ -5972,6 +5996,21 @@ Gruppen bakom OpenTX/Companion. Use Trim from Flight mode %1 + Own Trim as an offset Använd trim från flygläge %1 + Eget trim som offset + + + FW: %1 + FW: %1 + + + + Pict: %1 + Bild: %1 + + + + Profile image + Profilbild + Setup @@ -5981,7 +6020,7 @@ Gruppen bakom OpenTX/Companion. Form - + Model Name Modellnamn @@ -6001,12 +6040,11 @@ Gruppen bakom OpenTX/Companion. Gas-kontroll - Switch startup Warning - Brytarvarning vid start + Brytarvarning vid start - + Center beep Centrumpip @@ -6016,27 +6054,30 @@ Gruppen bakom OpenTX/Companion. Trimsteg - ON - På + På - + OFF Av - Check - Kontrollera + Kontrollera - + Model Image Modell-ikon - + + Switch Warnings + Brytarvarningar + + + Exponential Exponentiella @@ -6071,7 +6112,12 @@ Gruppen bakom OpenTX/Companion. Utökade trimmar - + + Display Checklist + Visa Checklista + + + Throttle Trim Gastrim @@ -6096,6 +6142,21 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga Reverse Throttle Inverterad gas + + + Pot Warnings + Pot-varningar + + + + Manual + Manuella + + + + Auto + Automatiska + Telemetry @@ -6560,150 +6621,444 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga appPreferencesDialog - + Application Preferences Programmets Inställningar - + + Simulator capture folder Lagra simulatorbilder i - + + Remember simulator switch values Spara läget för alla brytare i simulatorn - + + + + + Open Folder Öppna katalog - + + User Splash Screens Egna Startbilder - + + Edit Settings + Redigera Inställningar + + + + Application Settings + Programmet + + + + Simulator Settings + Simulatorn + + + + Blue Blå + Green Grön + Red Röd + Orange Orange + Yellow Gul - + + Radio Settings + Radion + + + + Mode selection: + +Mode 1: + Left stick: Elevator, Rudder + Right stick: Throttle, Aileron + +Mode 2: + Left stick: Throttle, Rudder + Right stick: Elevator, Aileron + +Mode 3: + Left stick: Elevator, Aileron + Right stick: Throttle, Rudder + +Mode 4: + Left stick: Throttle, Aileron + Right stick: Elevator, Rudder + + + Välj Mode: + +Mode 1: + Vänster spak: Höjdroder, Sidroder + Höger spak: Gas, Skevroder + +Mode 2: + Vänster spak: Gas, Sidroder + Höger spak: Höjdroder, Skevroder + +Mode 3: + Vänster spak: Höjdroder, Skevroder + Höger spak: Gas, Sidroder + +Mode 4: + Vänster spak: Gas, Skevroder + Höger spak: Höjdroder, Sidroder + + + + + + Mode 1 (RUD ELE THR AIL) + Mode 1 (ROD HÖJ GAS SKE) + + + + Mode 2 (RUD THR ELE AIL) + Mode 2 (ROD GAS HÖJ SKE) + + + + Mode 3 (AIL ELE THR RUD) + Mode 3 (SKE HÖJ GAS ROD) + + + + Mode 4 (AIL THR ELE RUD) + Mode 4 (SKE GAS HÖJ ROD) + + + + Channel order + +This is used by the templated to determine which channel goes to what number output. + Kanalordning + +Detta används av mallen för att koppla kanal till output-nummer. + + + + R E T A + R H G S + + + + R E A T + R H S G + + + + R T E A + R G H S + + + + R T A E + R G S H + + + + R A E T + R S H G + + + + R A T E + R S G H + + + + E R T A + H R G S + + + + E R A T + H R S G + + + + E T R A + H G R S + + + + E T A R + H G S R + + + + E A R T + H S R G + + + + E A T R + H S G R + + + + T R E A + G R H S + + + + T R A E + G R S H + + + + T E R A + G H R S + + + + T E A R + G H S R + + + + T A R E + G S R H + + + + T A E R + G S H R + + + + A R E T + S R H G + + + + A R T E + S R G H + + + + A E R T + S H R G + + + + A E T R + S H G R + + + + A T R E + S G R H + + + + A T E R + S G H R + + + + Default Stick Mode + Spaktilldelning + + + + Settings Profile + Profil + + + + Splash Screen + Startbild + + + + Channel Order + Kanalordning + + + + Append version number to FW file name + Addera versionsnumret till FW-filnamnet + + + + SD Structure path + Sökväg till SD-struktur + + + + Select Image + Välj Bild + + + + Offer to write FW to Tx after download + Skriv FW till Tx efter nedladdning + + + + Remove Profile + Ta bort Profil + + + + Clear Image + Ta bort Bild + + + + Firmware + Firmware + + + + Include companion splashes Användarens bilder och Companion-bilder + Only user defined splashes Enbart användarens bilder - + + Splash Screen Library Bibliotek för startbilder - + + Files to keep Behåll filer - + + Simulator BackLight Simulatorbelysning - + + Automatic Backup Folder Säkerhetskopiera till folder - + + Only capture to clipboard Spara bara bilder till Urklipp - + + Joystick Joystick - + + Find Executable Sök Program - + + Google Earth Executable Sökväg till Google Earth - + + Calibrate Kalibrera - + + Enable Aktivera - + + Show splash screen when Companion starts Visa en start-bild då Companion startas - + + Automatic check for OpenTX firmware updates Sök automatiskt efter uppdateringar av OpenTX - + + Automatic check for Companion updates Sök automatiskt efter uppdateringar av Companion - + + Offer to use wizard for new models Erbjud användning av modellguiden för nya modeller - + + Enable automatic backup before writing firmware Säkerhetskopiera innan firmware-skrivning - + Select your snapshot folder Välj katalog för snapshots av Tx-simulatorn - - + + No joysticks found Ingen joystick hittades @@ -6722,6 +7077,41 @@ Gasen reverseras om alternativet väljs. Tomgång ligger då uppåt. Trim och ga Select Google Earth executable Sökväg till Google Earth + + + Select the folder replicating your SD structure + Välj katalog med en kopia av din SD-struktur + + + + Not possible to remove profile + Det går inte att ta bort profilen + + + + The default profile can not be removed. + Standard-profilen kan inte tas bort. + + + + Error + Fel + + + + Cannot load %1. + Det går inte att ladda %1. + + + + Open Image to load + Öppna bild för laddning + + + + Images (%1) + Bilder (%1) + avrOutputDialog @@ -7924,7 +8314,7 @@ m2560 för v4.1-kort Invertera - + Load FW Ladda FW @@ -7936,13 +8326,13 @@ m2560 för v4.1-kort Ladda Bild - - + + Load Profile Ladda Profil - + Save Spara @@ -7954,27 +8344,74 @@ m2560 för v4.1-kort Öppna bildbibliotek - + Open Öppna - - - - - - + + + + Error Fel - - Could not find bitmap to replace in file - Det finns ingen bild att byta i firmware-filen + + Cannot load embedded FW image from %1. + Det gick inte att ladda bild från FW-filen %1. - + + Cannot load the image file %1. + Det gick inte att ladda bildfilen %1. + + + + Cannot load the profile image %1. + Det gick inte att ladda profilbilden %1. + + + + Cannot load the library image %1. + Det gick inte att ladda biblioteks-bilden %1. + + + + File Saved + Filen sparades + + + + The image was saved to the file %1 + Bilden sparades till filen %1 + + + + Image Refresh Error + Fel vid återläsning av bild + + + + Failed to refresh image from file %1 + Det gick inte att återladda bilden från filen %1 + + + + File Save Error + Fel vid filskrivning + + + + Failed to write image to %1 + Filen %1 kunde inte skrivas + + + Could not find bitmap to replace in file + Det finns ingen bild att byta i firmware-filen + + + Open Image to load Öppna bild för laddning @@ -7984,21 +8421,16 @@ m2560 för v4.1-kort Bilder (%1) - - Cannot load %1. - Kunde inte ladda %1. + Kunde inte ladda %1. - - Could not store image in firmware file %1 - Det gick inte att spara bilden i firmware-filen %1 + Det gick inte att spara bilden i firmware-filen %1 - The image file %1 could not be stored - Det gick inte att spara bilden i filen %1 + Det gick inte att spara bilden i filen %1 @@ -8176,7 +8608,39 @@ p, li { white-space: pre-wrap; } fwPreferencesDialog - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8186,70 +8650,34 @@ p, li { white-space: pre-wrap; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CheckBox Kryssruta - + Set language of voice. May be different from firmware language Välj språk för röstfunktioner. Får skilja från språket för firmware - SD Structure path - Sökväg till SD-struktur + Sökväg till SD-struktur - + Processor ID Processortyp - Default Stick Mode - Spaktilldelning + Spaktilldelning - Channel Order - Kanalordning + Kanalordning - Mode selection: Mode 1: @@ -8269,7 +8697,7 @@ Mode 4: Right stick: Elevator, Rudder - Välj Mode: + Välj Mode: Mode 1: Vänster spak: Höjdroder, Sidroder @@ -8290,241 +8718,104 @@ Mode 4: - Mode 1 (RUD ELE THR AIL) - Mode 1 (ROD HÖJ GAS SKE) + Mode 1 (ROD HÖJ GAS SKE) - Mode 2 (RUD THR ELE AIL) - Mode 2 (ROD GAS HÖJ SKE) + Mode 2 (ROD GAS HÖJ SKE) - Mode 3 (AIL ELE THR RUD) - Mode 3 (SKE HÖJ GAS ROD) + Mode 3 (SKE HÖJ GAS ROD) - Mode 4 (AIL THR ELE RUD) - Mode 4 (SKE GAS HÖJ ROD) + Mode 4 (SKE GAS HÖJ ROD) - + Options Val - Channel order This is used by the templated to determine which channel goes to what number output. - Kanalordning + Kanalordning Används av mallarna för att koppla ihop kanaler med numrerade utgångar. - Open Folder - Öppna Katalog + Öppna Katalog - Offer to write FW to Tx after download - Skriv FW till Tx efter nedladdning + Skriv FW till Tx efter nedladdning - + Downloads and Profiles Nedladdning och Profiler - Save Profile - Spara Profil + Spara Profil - + Menu Language Menyspråk - Profile - Profil + Profil - + Voice Language Röstspråk - + Firmware Type Firmware-typ - Append version number to FW file name - Addera versionsnumret till FW-filnamnet + Addera versionsnumret till FW-filnamnet - + Download Voice Ladda Röstfiler - + FwInfo --- - - R E T A - - - - - R E A T - - - - - R T E A - - - - - R T A E - - - - - R A E T - - - - - R A T E - - - - - E R T A - - - - - E R A T - - - - - E T R A - - - - - E T A R - - - - - E A R T - - - - - E A T R - - - - - T R E A - - - - - T R A E - - - - - T E R A - - - - - T E A R - - - - - T A R E - - - - - T A E R - - - - - A R E T - - - - - A R T E - - - - - A E R T - - - - - A E T R - - - - - A T R E - - - - - A T E R - - - - Open Image - Öppna bild + Öppna bild - - Splash Screen - - - - Clear Image - Ta bort Bild + Ta bort Bild - + Download FW Ladda ned Firmware - + Check for updates Sök efter uppdateringar - + Last downloaded release: %1 Senast nedladdade release: %1 @@ -8539,34 +8830,28 @@ Används av mallarna för att koppla ihop kanaler med numrerade utgångar.Firmware-filen kan inte laddas ned av Companion. - Select the folder replicating your SD structure - Välj katalog med en kopia av din SD-struktur + Välj katalog med en kopia av din SD-struktur - Profile name is empty, profile slot %1 will be deleted.<br>Are you sure ? - Profilnamn saknas, profilplats %1 kommer att raderas.<br> Är du säker? + Profilnamn saknas, profilplats %1 kommer att raderas.<br> Är du säker? - Open Image to load - Öppna bildfil för laddning + Öppna bildfil för laddning - Images (%1) - Bilder (%1) + Bilder (%1) - Error - Fel + Fel - Cannot load %1. - Kan inte ladda %1. + Kan inte ladda %1. @@ -9428,122 +9713,122 @@ Mode 4: R E T A - + R H G S R E A T - + R H S G R T E A - + R G H S R T A E - + R G S H R A E T - + R S H G R A T E - + R S G H E R T A - + H R G S E R A T - + H R S G E T R A - + H G R S E T A R - + H G S R E A R T - + H S R G E A T R - + H S G R T R E A - + G R H S T R A E - + G R S H T E R A - + G H R S T E A R - + G H S R T A R E - + G S R H T A E R - + G S H R A R E T - + S R H G A R T E - + S R G H A E R T - + S H R G A E T R - + S H G R A T R E - + S G R H A T E R - + S G H R diff --git a/radio/src/.gitignore b/radio/src/.gitignore index abbd8a427..4ef246e21 100644 --- a/radio/src/.gitignore +++ b/radio/src/.gitignore @@ -10,3 +10,6 @@ /*.o /*.bin /*.lst +/SCRIPTS +/SOUNDS +/LOGS diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index 88fcc076a..ab81d93bf 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -111,8 +111,6 @@ PACK(typedef struct { }) MixData_v215; #endif - - PACK(typedef struct { int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw uint16_t start:12; @@ -220,15 +218,38 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings) } #if defined(PCBTARANIS) +int ConvertSource_215_to_216(int source, bool insertZero=false) +{ + if (insertZero) + source += 1; + // Virtual Inputs and Lua Outputs added + if (source > 0) + source += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; + // 4 GVARS added + if (source > MIXSRC_GVAR1+4) + source += 4; + return source; +} + int ConvertSwitch_215_to_216(int swtch) { - if (swtch <= SWSRC_LAST_SWITCH) + if (swtch < 0) + return -ConvertSwitch_215_to_216(-swtch); + else if (swtch <= SWSRC_LAST_SWITCH) return swtch; else return swtch + (2*4) + (2*6); // 4 trims and 2 * 6-pos added as switches } #else -inline int ConvertSwitch_215_to_216(int swtch) +int ConvertSource_215_to_216(int source, bool removeZero=false) +{ + // 4 GVARS added + if (source > MIXSRC_GVAR1+4) + source += 4; + return source; +} + +int ConvertSwitch_215_to_216(int swtch) { if (swtch <= SWSRC_LAST_SWITCH) return swtch; @@ -250,22 +271,28 @@ void ConvertModel_215_to_216(ModelData &model) // Mixes: GVARS in weight moved from 512 to 4096 and -512 to -4096, because GVARS may be used in limits [-1250:1250] // Switches: two 6-pos pots added, REa added to Sky9x - TRACE("Model conversion from v215 to v216"); - assert(sizeof(ModelData_v215) <= sizeof(ModelData)); ModelData_v215 oldModel; memcpy(&oldModel, &model, sizeof(oldModel)); memset(&model, 0, sizeof(ModelData)); + char name[LEN_MODEL_NAME+1]; + zchar2str(name, oldModel.header.name, LEN_MODEL_NAME); + TRACE("Model %s conversion from v215 to v216", name); + memcpy(&g_model.header, &oldModel.header, sizeof(g_model.header)); for (uint8_t i=0; i<2; i++) { - g_model.timers[i].mode = oldModel.timers[i].mode; - g_model.timers[i].start = oldModel.timers[i].start; - g_model.timers[i].minuteBeep = oldModel.timers[i].minuteBeep; - g_model.timers[i].persistent = oldModel.timers[i].persistent; - g_model.timers[i].countdownBeep = oldModel.timers[i].countdownBeep; - g_model.timers[i].value = oldModel.timers[i].value; + TimerData & timer = g_model.timers[i]; + if (oldModel.timers[i].mode >= TMRMODE_FIRST_SWITCH) + timer.mode = TMRMODE_FIRST_SWITCH + ConvertSwitch_215_to_216(oldModel.timers[i].mode - TMRMODE_FIRST_SWITCH + 1) - 1; + else + timer.mode = oldModel.timers[i].mode; + timer.start = oldModel.timers[i].start; + timer.minuteBeep = oldModel.timers[i].minuteBeep; + timer.persistent = oldModel.timers[i].persistent; + timer.countdownBeep = oldModel.timers[i].countdownBeep; + timer.value = oldModel.timers[i].value; } g_model.protocol = oldModel.protocol; g_model.thrTrim = oldModel.thrTrim; @@ -277,43 +304,44 @@ void ConvertModel_215_to_216(ModelData &model) g_model.beepANACenter = oldModel.beepANACenter; for (uint8_t i=0; i<64; i++) { + MixData & mix = g_model.mixData[i]; #if defined(PCBTARANIS) - g_model.mixData[i].destCh = oldModel.mixData[i].destCh; - g_model.mixData[i].phases = oldModel.mixData[i].phases; - g_model.mixData[i].mltpx = oldModel.mixData[i].mltpx; - g_model.mixData[i].weight = oldModel.mixData[i].weight; - g_model.mixData[i].swtch = ConvertSwitch_215_to_216(oldModel.mixData[i].swtch); + mix.destCh = oldModel.mixData[i].destCh; + mix.phases = oldModel.mixData[i].phases; + mix.mltpx = oldModel.mixData[i].mltpx; + mix.weight = oldModel.mixData[i].weight; + mix.swtch = ConvertSwitch_215_to_216(oldModel.mixData[i].swtch); if (oldModel.mixData[i].curveMode==0/*differential*/) { - g_model.mixData[i].curve.type = CURVE_REF_DIFF; - g_model.mixData[i].curve.value = oldModel.mixData[i].curveParam; + mix.curve.type = CURVE_REF_DIFF; + mix.curve.value = oldModel.mixData[i].curveParam; } else if (oldModel.mixData[i].curveParam <= 6) { - g_model.mixData[i].curve.type = CURVE_REF_FUNC; - g_model.mixData[i].curve.value = oldModel.mixData[i].curveParam; + mix.curve.type = CURVE_REF_FUNC; + mix.curve.value = oldModel.mixData[i].curveParam; } else { - g_model.mixData[i].curve.type = CURVE_REF_CUSTOM; - g_model.mixData[i].curve.value = oldModel.mixData[i].curveParam - 6; + mix.curve.type = CURVE_REF_CUSTOM; + mix.curve.value = oldModel.mixData[i].curveParam - 6; } - g_model.mixData[i].mixWarn = oldModel.mixData[i].mixWarn; - g_model.mixData[i].delayUp = oldModel.mixData[i].delayUp; - g_model.mixData[i].delayDown = oldModel.mixData[i].delayDown; - g_model.mixData[i].speedUp = oldModel.mixData[i].speedUp; - g_model.mixData[i].speedDown = oldModel.mixData[i].speedDown; - g_model.mixData[i].srcRaw = oldModel.mixData[i].srcRaw; - if (g_model.mixData[i].srcRaw > 4 || oldModel.mixData[i].noExpo) - g_model.mixData[i].srcRaw += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; - g_model.mixData[i].offset = oldModel.mixData[i].offset; - memcpy(g_model.mixData[i].name, oldModel.mixData[i].name, LEN_EXPOMIX_NAME); + mix.mixWarn = oldModel.mixData[i].mixWarn; + mix.delayUp = oldModel.mixData[i].delayUp; + mix.delayDown = oldModel.mixData[i].delayDown; + mix.speedUp = oldModel.mixData[i].speedUp; + mix.speedDown = oldModel.mixData[i].speedDown; + mix.srcRaw = oldModel.mixData[i].srcRaw; + if (mix.srcRaw > 4 || oldModel.mixData[i].noExpo) + mix.srcRaw = ConvertSource_215_to_216(mix.srcRaw); + mix.offset = oldModel.mixData[i].offset; + memcpy(mix.name, oldModel.mixData[i].name, LEN_EXPOMIX_NAME); #else - memcpy(&g_model.mixData[i], &oldModel.mixData[i], sizeof(g_model.mixData[i])); + memcpy(&mix, &oldModel.mixData[i], sizeof(mix)); #endif - if (g_model.mixData[i].weight <= -508) - g_model.mixData[i].weight = g_model.mixData[i].weight + 512 - 4096; - else if (g_model.mixData[i].weight >= 507) - g_model.mixData[i].weight = g_model.mixData[i].weight - 512 + 4096; + if (mix.weight <= -508) + mix.weight = mix.weight + 512 - 4096; + else if (mix.weight >= 507) + mix.weight = mix.weight - 512 + 4096; else - g_model.mixData[i].offset = g_model.mixData[i].offset * g_model.mixData[i].weight / 100; + mix.offset = mix.offset * mix.weight / 100; } for (uint8_t i=0; i<32; i++) { g_model.limitData[i].min = 10 * oldModel.limitData[i].min; @@ -414,63 +442,65 @@ void ConvertModel_215_to_216(ModelData &model) sw.andsw = oldModel.customSw[i].andsw; #if defined(PCBTARANIS) uint8_t cstate = cswFamily(sw.func); - if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) { - if (sw.v1 > 0) sw.v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; - if (sw.v1 > MIXSRC_GVAR1+4) sw.v1 += 4; + if (cstate == LS_FAMILY_BOOL) { + sw.v1 = ConvertSwitch_215_to_216(sw.v1); + sw.v2 = ConvertSwitch_215_to_216(sw.v2); } - if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_DIFF) { - if (sw.v1 >= MIXSRC_FIRST_TELEM) { - switch ((uint8_t)sw.v1) { - case MIXSRC_FIRST_TELEM + TELEM_TM1-1: - case MIXSRC_FIRST_TELEM + TELEM_TM2-1: - sw.v2 = (sw.v2+128) * 3; - break; - case MIXSRC_FIRST_TELEM + TELEM_ALT-1: - case MIXSRC_FIRST_TELEM + TELEM_GPSALT-1: - case MIXSRC_FIRST_TELEM + TELEM_MIN_ALT-1: - case MIXSRC_FIRST_TELEM + TELEM_MAX_ALT-1: - sw.v2 = (sw.v2+128) * 8 - 500; - break; - case MIXSRC_FIRST_TELEM + TELEM_RPM-1: - case MIXSRC_FIRST_TELEM + TELEM_MAX_RPM-1: - sw.v2 = (sw.v2+128) * 50; - break; - case MIXSRC_FIRST_TELEM + TELEM_T1-1: - case MIXSRC_FIRST_TELEM + TELEM_T2-1: - case MIXSRC_FIRST_TELEM + TELEM_MAX_T1-1: - case MIXSRC_FIRST_TELEM + TELEM_MAX_T2-1: - sw.v2 = (sw.v2+128) + 30; - break; - case MIXSRC_FIRST_TELEM + TELEM_CELL-1: - case MIXSRC_FIRST_TELEM + TELEM_HDG-1: - sw.v2 = (sw.v2+128) * 2; - break; - case MIXSRC_FIRST_TELEM + TELEM_DIST-1: - case MIXSRC_FIRST_TELEM + TELEM_MAX_DIST-1: - sw.v2 = (sw.v2+128) * 8; - break; - case MIXSRC_FIRST_TELEM + TELEM_CURRENT-1: - case MIXSRC_FIRST_TELEM + TELEM_POWER-1: - sw.v2 = (sw.v2+128) * 5; - break; - case MIXSRC_FIRST_TELEM + TELEM_CONSUMPTION-1: - sw.v2 = (sw.v2+128) * 20; - break; - default: - sw.v2 += 128; - break; + else if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) { + sw.v1 = ConvertSource_215_to_216(sw.v1); + if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_DIFF) { + if (sw.v1 >= MIXSRC_FIRST_TELEM) { + switch ((uint8_t)sw.v1) { + case MIXSRC_FIRST_TELEM + TELEM_TM1-1: + case MIXSRC_FIRST_TELEM + TELEM_TM2-1: + sw.v2 = (sw.v2+128) * 3; + break; + case MIXSRC_FIRST_TELEM + TELEM_ALT-1: + case MIXSRC_FIRST_TELEM + TELEM_GPSALT-1: + case MIXSRC_FIRST_TELEM + TELEM_MIN_ALT-1: + case MIXSRC_FIRST_TELEM + TELEM_MAX_ALT-1: + sw.v2 = (sw.v2+128) * 8 - 500; + break; + case MIXSRC_FIRST_TELEM + TELEM_RPM-1: + case MIXSRC_FIRST_TELEM + TELEM_MAX_RPM-1: + sw.v2 = (sw.v2+128) * 50; + break; + case MIXSRC_FIRST_TELEM + TELEM_T1-1: + case MIXSRC_FIRST_TELEM + TELEM_T2-1: + case MIXSRC_FIRST_TELEM + TELEM_MAX_T1-1: + case MIXSRC_FIRST_TELEM + TELEM_MAX_T2-1: + sw.v2 = (sw.v2+128) + 30; + break; + case MIXSRC_FIRST_TELEM + TELEM_CELL-1: + case MIXSRC_FIRST_TELEM + TELEM_HDG-1: + sw.v2 = (sw.v2+128) * 2; + break; + case MIXSRC_FIRST_TELEM + TELEM_DIST-1: + case MIXSRC_FIRST_TELEM + TELEM_MAX_DIST-1: + sw.v2 = (sw.v2+128) * 8; + break; + case MIXSRC_FIRST_TELEM + TELEM_CURRENT-1: + case MIXSRC_FIRST_TELEM + TELEM_POWER-1: + sw.v2 = (sw.v2+128) * 5; + break; + case MIXSRC_FIRST_TELEM + TELEM_CONSUMPTION-1: + sw.v2 = (sw.v2+128) * 20; + break; + default: + sw.v2 += 128; + break; + } } } - } - if (cstate == LS_FAMILY_COMP) { - if (sw.v2 > 0) sw.v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; - if (sw.v2 > MIXSRC_GVAR1+4) sw.v2 += 4; + if (cstate == LS_FAMILY_COMP) { + sw.v2 = ConvertSource_215_to_216(sw.v2); + } } #endif } for (uint8_t i=0; i<32; i++) { CustomFnData & fn = g_model.funcSw[i]; - fn.swtch = oldModel.funcSw[i].swtch; + fn.swtch = ConvertSwitch_215_to_216(oldModel.funcSw[i].swtch); fn.func = oldModel.funcSw[i].func; if (fn.func <= 15) { fn.all.param = fn.func; @@ -537,17 +567,13 @@ void ConvertModel_215_to_216(ModelData &model) } if (fn.func == FUNC_PLAY_VALUE || fn.func == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(fn.func) && fn.all.mode == FUNC_ADJUST_GVAR_SOURCE)) { #if defined(PCBTARANIS) - fn.all.param += 1 + MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; + fn.all.param = ConvertSource_215_to_216(fn.all.param, true); #endif - if (fn.all.param > MIXSRC_GVAR1+4) fn.all.param += 4; } } g_model.swashR = oldModel.swashR; -#if defined(PCBTARANIS) - if (g_model.swashR.collectiveSource > 0) g_model.swashR.collectiveSource += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; - if (g_model.swashR.collectiveSource > MIXSRC_GVAR1+4) g_model.swashR.collectiveSource += 4; -#endif + g_model.swashR.collectiveSource = ConvertSource_215_to_216(g_model.swashR.collectiveSource); for (uint8_t i=0; i<9; i++) { memcpy(&g_model.phaseData[i], &oldModel.phaseData[i], sizeof(oldModel.phaseData[i])); // the last 4 gvars will remain blank diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 9d65e18c0..8d271aa56 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -4543,10 +4543,11 @@ void menuModelLogicalSwitches(uint8_t event) // CSW params uint8_t cstate = cswFamily(cs->func); #if defined(CPUARM) - int16_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; + int16_t v1_unsigned=(uint8_t)cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; int16_t v3_min=0, v3_max=100; #else int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; + uint8_t v1_unsigned = cs->v1; #endif if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { @@ -4582,7 +4583,7 @@ void menuModelLogicalSwitches(uint8_t event) } #endif else if (cstate == LS_FAMILY_COMP) { - putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); + putsMixerSource(CSW_2ND_COLUMN, y, v1_unsigned, attr1); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); @@ -4596,7 +4597,7 @@ void menuModelLogicalSwitches(uint8_t event) INCDEC_ENABLE_CHECK(NULL); } else { - putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); + putsMixerSource(CSW_2ND_COLUMN, y, v1_unsigned, attr1); if (horz == 1) { INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); @@ -4606,11 +4607,11 @@ void menuModelLogicalSwitches(uint8_t event) INCDEC_ENABLE_CHECK(NULL); } #if defined(FRSKY) - if (cs->v1 >= MIXSRC_FIRST_TELEM) { - putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); - v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); + if (v1_unsigned >= MIXSRC_FIRST_TELEM) { + putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_unsigned - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); + v2_max = maxTelemValue(v1_unsigned - MIXSRC_FIRST_TELEM + 1); #if defined(CPUARM) - v2_min = minTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); + v2_min = minTelemValue(v1_unsigned - MIXSRC_FIRST_TELEM + 1); if (cs->v2 < v2_min || cs->v2 > v2_max) { cs->v2 = 0; eeDirty(EE_MODEL); @@ -4635,8 +4636,8 @@ void menuModelLogicalSwitches(uint8_t event) v2_min = -125; v2_max = 125; } #else - if (cs->v1 >= MIXSRC_FIRST_TELEM) { - putsTelemetryChannel(CSW_3RD_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); + if (v1_unsigned >= MIXSRC_FIRST_TELEM) { + putsTelemetryChannel(CSW_3RD_COLUMN, y, v1_unsigned - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), LEFT|attr2); v2_min = -128; v2_max = 127; } else { @@ -4711,17 +4712,17 @@ void menuModelLogicalSwitches(uint8_t event) break; } case LS_FIELD_V1: - cs->v1 = CHECK_INCDEC_PARAM(event, cs->v1, v1_min, v1_max); + cs->v1 = CHECK_INCDEC_PARAM(event, v1_unsigned, v1_min, v1_max); break; case LS_FIELD_V2: cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); #if defined(PCBTARANIS) - if (cstate==LS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { + if (cstate==LS_FAMILY_OFS && v1_unsigned!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); - getvalue_t x = getValue(cs->v1); - if (cs->v1 < MIXSRC_GVAR1) + getvalue_t x = getValue(v1_unsigned); + if (v1_unsigned < MIXSRC_GVAR1) cs->v2 = calcRESXto100(x); - else if (cs->v1 - MIXSRC_FIRST_TELEM + 1 == TELEM_ALT) + else if (v1_unsigned - MIXSRC_FIRST_TELEM + 1 == TELEM_ALT) cs->v2 *= 100; eeDirty(EE_MODEL); } diff --git a/radio/src/maths.cpp b/radio/src/maths.cpp index 346a7dba7..93330af1c 100644 --- a/radio/src/maths.cpp +++ b/radio/src/maths.cpp @@ -164,14 +164,10 @@ void varioWakeup() if (verticalSpeed < 0 || (int16_t)(s_varioTmr-tmr10ms) < 0) { #if defined(CPUARM) - uint16_t SoundVarioBeepTime; - uint16_t SoundVarioBeepFreq; + int SoundVarioBeepTime; + int SoundVarioBeepFreq; if (verticalSpeed > 0) { - if (verticalSpeed > 1276) { - SoundVarioBeepTime=5; - } else { - SoundVarioBeepTime = 320 - (verticalSpeed >> 2); - } + SoundVarioBeepTime = min(5, 320 - (verticalSpeed >> 2)); SoundVarioBeepFreq = 1000 + verticalSpeed; } else { diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 2c5476807..be6e6e11e 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1404,11 +1404,14 @@ enum MixSources { #define MIN_POINTS 3 #define MAX_POINTS 17 -#define TMRMODE_NONE 0 -#define TMRMODE_ABS 1 -#define TMRMODE_THR 2 -#define TMRMODE_THR_REL 3 -#define TMRMODE_THR_TRG 4 +enum TimerModes { + TMRMODE_NONE, + TMRMODE_ABS, + TMRMODE_THR, + TMRMODE_THR_REL, + TMRMODE_THR_TRG, + TMRMODE_FIRST_SWITCH +}; #define COUNTDOWN_SILENT 0 #define COUNTDOWN_BEEPS 1 @@ -1504,7 +1507,7 @@ enum FailsafeModes { #define BeepANACenter uint8_t #endif -PACK(typedef struct t_ModelHeader { +PACK(typedef struct { char name[LEN_MODEL_NAME]; // must be first for eeLoadModelName uint8_t modelId; MODELDATA_BITMAP diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index a73224d1e..8a08ea51f 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -201,7 +201,7 @@ char idx2char(int8_t idx) return ' '; } -#if defined(PCBTARANIS) +#if defined(CPUARM) int8_t char2idx(char c) { if (c == '_') return 37; @@ -1248,6 +1248,7 @@ getvalue_t getValue(uint8_t i) else if (i==MIXSRC_SF) return (switchState(SW_SF0) ? -1024 : 1024); else if (i==MIXSRC_SG) return (switchState(SW_SG0) ? -1024 : (switchState(SW_SG1) ? 0 : 1024)); else if (i==MIXSRC_SH) return (switchState(SW_SH0) ? -1024 : 1024); + else if (i<=MIXSRC_LAST_CSW) return getSwitch(SWSRC_FIRST_CSW+i-MIXSRC_FIRST_CSW) ? 1024 : -1024; #else else if (i==MIXSRC_3POS) return (getSwitch(SW_ID0-SW_BASE+1) ? -1024 : (getSwitch(SW_ID1-SW_BASE+1) ? 0 : 1024)); // don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning @@ -1255,10 +1256,9 @@ getvalue_t getValue(uint8_t i) else if (i==MIXSRC_3POS2) return (getSwitch(SW_ID3-SW_BASE+1) ? -1024 : (getSwitch(SW_ID4-SW_BASE+1) ? 0 : 1024)); // don't use switchState directly to give getSwitch possibility to hack values if needed for switch warning #endif + else if (i<=MIXSRC_LAST_CSW) return getSwitch(SWSRC_THR+i-MIXSRC_THR) ? 1024 : -1024; #endif - else if (i<=MIXSRC_LAST_CSW) return getSwitch(SWSRC_FIRST_CSW+i-MIXSRC_FIRST_CSW) ? 1024 : -1024; - else if (i<=MIXSRC_LAST_PPM) { int16_t x = g_ppmIns[i-MIXSRC_FIRST_PPM]; if (i