From ce2e8ac1ca9e7a598478691f9aa4b82123eeb96a Mon Sep 17 00:00:00 2001 From: Grieb Date: Fri, 24 Apr 2015 12:13:51 -0300 Subject: [PATCH 1/2] [companion][general settings]Just cosmetcs (re-indent and spaces). --- companion/src/appdata.cpp | 24 ++++++------ companion/src/appdata.h | 8 ++-- companion/src/eeprominterface.h | 18 ++++----- companion/src/generaledit/generalsetup.cpp | 44 +++++++++++----------- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index 395dd68be..28b795244 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -1,6 +1,6 @@ /* * Author - Kjell Kernen - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. @@ -346,7 +346,7 @@ Profile::Profile() index = -1; } -// The default copy operator can not be used since the index variable would be destroyed +// The default copy operator can not be used since the index variable would be destroyed Profile& Profile::operator=(const Profile& rhs) { name ( rhs.name() ); @@ -577,39 +577,39 @@ AppData::AppData() for (int i=0; i - * + * * Based on th9x -> http://code.google.com/p/th9x/ * * This program is free software; you can redistribute it and/or modify @@ -325,9 +325,9 @@ class RawSource { } QString toString(const ModelData * model = NULL); - + RawSourceRange getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags=0) const; - + bool operator == ( const RawSource & other) { return (this->type == other.type) && (this->index == other.index); } @@ -1171,16 +1171,16 @@ class GeneralSettings { unsigned int index; unsigned int position; }; - + static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); bool switchPositionAllowedTaranis(int index) const; bool switchSourceAllowedTaranis(int index) const; }; class RadioData { - public: + public: GeneralSettings generalSettings; - ModelData models[C9X_MAX_MODELS]; + ModelData models[C9X_MAX_MODELS]; }; enum Capability { @@ -1305,15 +1305,15 @@ class EEPROMInterface virtual bool load(RadioData &radioData, const uint8_t *eeprom, int size) = 0; virtual bool loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index) = 0; - + virtual bool loadxml(RadioData &radioData, QDomDocument &doc) = 0; virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0) = 0; virtual int getSize(ModelData &) = 0; - + virtual int getSize(GeneralSettings &) = 0; - + virtual int isAvailable(Protocol proto, int port=0) = 0; virtual const int getEEpromSize() = 0; diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index ddd982e1a..b3cb6dc26 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -3,8 +3,8 @@ #include GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): - GeneralPanel(parent, generalSettings, firmware), - ui(new Ui::GeneralSetup) +GeneralPanel(parent, generalSettings, firmware), +ui(new Ui::GeneralSetup) { ui->setupUi(this); @@ -358,8 +358,8 @@ void GeneralSetupPanel::on_faimode_CB_stateChanged(int) { if (ui->faimode_CB->isChecked()) { int ret = QMessageBox::question(this, "Companion", - tr("If you enable FAI, you loose the vario, the play functions, the telemetry screen.\nThis function cannot be disabled by the radio.\nAre you sure ?") , - QMessageBox::Yes | QMessageBox::No); + tr("If you enable FAI, you loose the vario, the play functions, the telemetry screen.\nThis function cannot be disabled by the radio.\nAre you sure ?") , + QMessageBox::Yes | QMessageBox::No); if (ret==QMessageBox::Yes) { generalSettings.fai = true; } @@ -375,58 +375,58 @@ void GeneralSetupPanel::on_faimode_CB_stateChanged(int) void GeneralSetupPanel::on_speakerPitchSB_editingFinished() { - generalSettings.speakerPitch = ui->speakerPitchSB->value(); - emit modified(); + generalSettings.speakerPitch = ui->speakerPitchSB->value(); + emit modified(); } void GeneralSetupPanel::on_hapticStrength_valueChanged() { - generalSettings.hapticStrength = ui->hapticStrength->value(); - emit modified(); + generalSettings.hapticStrength = ui->hapticStrength->value(); + emit modified(); } void GeneralSetupPanel::on_soundModeCB_currentIndexChanged(int index) { - generalSettings.speakerMode = index; - emit modified(); + generalSettings.speakerMode = index; + emit modified(); } void GeneralSetupPanel::on_splashScreenChkB_stateChanged(int ) { - generalSettings.splashMode = ui->splashScreenChkB->isChecked() ? 0 : 1; - emit modified(); + generalSettings.splashMode = ui->splashScreenChkB->isChecked() ? 0 : 1; + emit modified(); } void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index) { - generalSettings.splashDuration = 3-index; - emit modified(); + generalSettings.splashDuration = 3-index; + emit modified(); } void GeneralSetupPanel::on_beepVolume_SL_valueChanged() { - generalSettings.beepVolume=ui->beepVolume_SL->value(); - emit modified(); + generalSettings.beepVolume=ui->beepVolume_SL->value(); + emit modified(); } void GeneralSetupPanel::on_wavVolume_SL_valueChanged() { - generalSettings.wavVolume=ui->wavVolume_SL->value(); - emit modified(); + generalSettings.wavVolume=ui->wavVolume_SL->value(); + emit modified(); } void GeneralSetupPanel::on_varioVolume_SL_valueChanged() { - generalSettings.varioVolume=ui->varioVolume_SL->value(); - emit modified(); + generalSettings.varioVolume=ui->varioVolume_SL->value(); + emit modified(); } void GeneralSetupPanel::on_bgVolume_SL_valueChanged() { - generalSettings.backgroundVolume=ui->bgVolume_SL->value(); - emit modified(); + generalSettings.backgroundVolume=ui->bgVolume_SL->value(); + emit modified(); } void GeneralSetupPanel::on_varioP0_SB_editingFinished() From dc34596f2dbd6e402bd20d3dd408ed1a79e7ce54 Mon Sep 17 00:00:00 2001 From: Grieb Date: Fri, 24 Apr 2015 14:28:31 -0300 Subject: [PATCH 2/2] [companion][general settings]Add Battery Range Meter to companion eepe General Settings. Fixes #2195. --- companion/src/appdata.cpp | 10 + companion/src/appdata.h | 6 + companion/src/eeprominterface.h | 3 +- .../src/firmwares/opentx/opentxinterface.cpp | 2 + companion/src/generaledit/generaledit.cpp | 12 +- companion/src/generaledit/generalsetup.cpp | 25 ++ companion/src/generaledit/generalsetup.h | 2 + companion/src/generaledit/generalsetup.ui | 231 ++++++++++++------ 8 files changed, 210 insertions(+), 81 deletions(-) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index 28b795244..b4332cfa3 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -314,6 +314,8 @@ int Profile::gsStickMode() const { return _gsStickMode; } int Profile::ppmMultiplier() const { return _ppmMultiplier; } int Profile::vBatCalib() const { return _vBatCalib; } int Profile::vBatWarn() const { return _vBatWarn; } +int Profile::vBatMin() const { return _vBatMin; } +int Profile::vBatMax() const { return _vBatMax; } // Set declarations void Profile::name (const QString x) { store(x, _name, "Name" ,"Profiles", QString("profile%1").arg(index));} @@ -339,6 +341,8 @@ void Profile::gsStickMode (const int x) { store(x, _gsStickMode, "GSStic void Profile::ppmMultiplier (const int x) { store(x, _ppmMultiplier, "PPM_Multiplier" ,"Profiles", QString("profile%1").arg(index));} void Profile::vBatCalib (const int x) { store(x, _vBatCalib, "VbatCalib" ,"Profiles", QString("profile%1").arg(index));} void Profile::vBatWarn (const int x) { store(x, _vBatWarn, "vBatWarn" ,"Profiles", QString("profile%1").arg(index));} +void Profile::vBatMin (const int x) { store(x, _vBatMin, "VbatMin" ,"Profiles", QString("profile%1").arg(index));} +void Profile::vBatMax (const int x) { store(x, _vBatMax, "VbatMax" ,"Profiles", QString("profile%1").arg(index));} // Constructor Profile::Profile() @@ -370,6 +374,8 @@ Profile& Profile::operator=(const Profile& rhs) ppmMultiplier( rhs.ppmMultiplier() ); vBatCalib ( rhs.vBatCalib() ); vBatWarn ( rhs.vBatWarn() ); + vBatMin ( rhs.vBatMin() ); + vBatMax ( rhs.vBatMax() ); return *this; } @@ -414,6 +420,8 @@ void Profile::initFwVariables() _ppmMultiplier = 0; _vBatCalib = 0; _vBatWarn = 0; + _vBatMin = 0; + _vBatMax = 0; } void Profile::init(int newIndex) @@ -465,6 +473,8 @@ void Profile::flush() getset( _ppmMultiplier, "PPM_Multiplier" ,0 ,"Profiles", QString("profile%1").arg(index)); getset( _vBatCalib, "VbatCalib" ,0 ,"Profiles", QString("profile%1").arg(index)); getset( _vBatWarn, "vBatWarn" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _vBatMin, "VbatMin" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _vBatMax, "VbatMax" ,0 ,"Profiles", QString("profile%1").arg(index)); } diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 4883ad834..4d6b451f3 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -127,6 +127,8 @@ class Profile: protected CompStoreObj int _ppmMultiplier; int _vBatCalib; int _vBatWarn; + int _vBatMin; + int _vBatMax; public: // All the get definitions @@ -153,6 +155,8 @@ class Profile: protected CompStoreObj int ppmMultiplier() const; int vBatCalib() const; int vBatWarn() const; + int vBatMin() const; + int vBatMax() const; // All the set definitions void name (const QString); @@ -178,6 +182,8 @@ class Profile: protected CompStoreObj void ppmMultiplier (const int); void vBatCalib (const int); void vBatWarn (const int); + void vBatMin (const int); + void vBatMax (const int); Profile(); Profile& operator=(const Profile&); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 65e1b71bf..a080054e5 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1285,7 +1285,8 @@ enum Capability { MavlinkTelemetry, HasInputDiff, HasMixerExpo, - MixersMonitor + MixersMonitor, + HasBatMeterRange }; class SimulatorInterface; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index f02325d9f..5dd892f7d 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -766,6 +766,8 @@ int OpenTxFirmware::getCapability(const Capability capability) return (IS_TARANIS(board) ? true : false); case MixersMonitor: return id.contains("mixersmon") ? 1 : 0; + case HasBatMeterRange: + return (IS_TARANIS(board) ? true : false); default: return 0; } diff --git a/companion/src/generaledit/generaledit.cpp b/companion/src/generaledit/generaledit.cpp index cd4625de2..69a805a4d 100644 --- a/companion/src/generaledit/generaledit.cpp +++ b/companion/src/generaledit/generaledit.cpp @@ -93,7 +93,7 @@ void GeneralEdit::on_calretrieve_PB_clicked() QString HapticSet = g.profile[profile_id].haptic(); QString SpeakerSet = g.profile[profile_id].speaker(); QString CountrySet = g.profile[profile_id].countryCode(); - + if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { QString Byte; int16_t byte16; @@ -121,6 +121,10 @@ void GeneralEdit::on_calretrieve_PB_clicked() generalSettings.currentCalib=currentCalib; generalSettings.vBatCalib=vBatCalib; generalSettings.vBatWarn=vBatWarn; + if (GetCurrentFirmware()->getCapability(HasBatMeterRange)) { + generalSettings.vBatMin = (int8_t) g.profile[profile_id].vBatMin(); + generalSettings.vBatMax = (int8_t) g.profile[profile_id].vBatMax(); + } generalSettings.PPM_Multiplier=PPM_Multiplier; } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, radio calibration was not retrieved")); @@ -197,7 +201,7 @@ void GeneralEdit::on_calstore_PB_clicked() else { QString calib=g.profile[profile_id].stickPotCalib(); if (!(calib.isEmpty())) { - int ret = QMessageBox::question(this, "Companion", + int ret = QMessageBox::question(this, "Companion", tr("Do you want to store calibration in %1 profile
overwriting existing calibration?").arg(name) , QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) { @@ -219,6 +223,10 @@ void GeneralEdit::on_calstore_PB_clicked() g.profile[profile_id].vBatCalib( generalSettings.vBatCalib ); g.profile[profile_id].currentCalib( generalSettings.currentCalib ); g.profile[profile_id].vBatWarn( generalSettings.vBatWarn ); + if (GetCurrentFirmware()->getCapability(HasBatMeterRange)) { + g.profile[profile_id].vBatMin( generalSettings.vBatMin ); + g.profile[profile_id].vBatMax( generalSettings.vBatMax ); + } g.profile[profile_id].ppmMultiplier( generalSettings.PPM_Multiplier ); g.profile[profile_id].gsStickMode( generalSettings.stickMode ); g.profile[profile_id].display( QString("%1%2%3").arg((generalSettings.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)generalSettings.contrast, 2, 16, QChar('0')).arg((uint8_t)generalSettings.backlightBright, 2, 16, QChar('0')) ); diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index b3cb6dc26..4fe740ffa 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -242,6 +242,14 @@ ui(new Ui::GeneralSetup) } ui->blAlarm_ChkB->setChecked(generalSettings.flashBeep); + if (!GetCurrentFirmware()->getCapability(HasBatMeterRange)) { + ui->batMeterRangeLabel->hide(); + ui->HasBatMeterMinRangeLabel->hide(); + ui->HasBatMeterMaxRangeLabel->hide(); + ui->vBatMinDSB->hide(); + ui->vBatMaxDSB->hide(); + } + disableMouseScrolling(); } @@ -352,6 +360,11 @@ void GeneralSetupPanel::setValues() ui->speakerPitchSB->setValue(generalSettings.speakerPitch); ui->hapticStrength->setValue(generalSettings.hapticStrength); ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode+2); + + if (GetCurrentFirmware()->getCapability(HasBatMeterRange)) { + ui->vBatMinDSB->setValue((double)(generalSettings.vBatMin + 90) / 10); + ui->vBatMaxDSB->setValue((double)(generalSettings.vBatMax + 120) / 10); + } } void GeneralSetupPanel::on_faimode_CB_stateChanged(int) @@ -472,6 +485,18 @@ void GeneralSetupPanel::on_battwarningDSB_editingFinished() emit modified(); } +void GeneralSetupPanel::on_vBatMinDSB_editingFinished() +{ + generalSettings.vBatMin = ui->vBatMinDSB->value() * 10 - 90; + emit modified(); +} + +void GeneralSetupPanel::on_vBatMaxDSB_editingFinished() +{ + generalSettings.vBatMax = ui->vBatMaxDSB->value() * 10 - 120; + emit modified(); +} + void GeneralSetupPanel::on_re_CB_currentIndexChanged(int index) { generalSettings.reNavigation = ui->re_CB->currentIndex(); diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index f884d0062..944578235 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -60,6 +60,8 @@ class GeneralSetupPanel : public GeneralPanel void on_backlightautoSB_editingFinished(); void on_battwarningDSB_editingFinished(); + void on_vBatMinDSB_editingFinished(); + void on_vBatMaxDSB_editingFinished(); void on_contrastSB_editingFinished(); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 156464e5c..06ed489d4 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -7,7 +7,7 @@ 0 0 758 - 635 + 661 @@ -230,6 +230,24 @@ + + + + + + + + + + This is the switch selectrion for turning on the backlight (if installed). + + + + + -1 + + + @@ -324,20 +342,6 @@ p, li { white-space: pre-wrap; } - - - - - Standard - - - - - Optrex - - - - @@ -1242,16 +1246,6 @@ Acceptable values are 5v..10v - - - - - - - Contrast - - - @@ -1354,31 +1348,6 @@ Acceptable values are 5v..10v - - - - - - - - - - This is the switch selectrion for turning on the backlight (if installed). - - - - - -1 - - - - - - - LCD Display Type - - - @@ -1386,34 +1355,6 @@ Acceptable values are 5v..10v - - - - - 0 - 0 - - - - - - - - - - - - - 10 - - - 45 - - - 25 - - - @@ -1949,6 +1890,140 @@ p, li { white-space: pre-wrap; } + + + + LCD Display Type + + + + + + + + Standard + + + + + Optrex + + + + + + + + + + + Contrast + + + + + + + + 0 + 0 + + + + + + + + + + + + + 10 + + + 45 + + + 25 + + + + + + + Battery Meter Range + + + + + + + + + Min + + + + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 9.000000000000000 + + + + + + + Max + + + + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 12.000000000000000 + + + + +