From b3cb503a0db856fe41ddccc53a2865e560cb4b84 Mon Sep 17 00:00:00 2001 From: Kjell Kernen Date: Tue, 18 Mar 2014 14:35:06 +0100 Subject: [PATCH] The profile tab now shows if there is radio settings like calibration data in the profile or not. It also displays a starage date for the data. The radio settings are time stamped when they are saved to profile. I would prefer to stamp them when they are retrieved from the sender, but this is not possible in any good way with the current file format. I intended to use file storage times, but this turned out to be a bad idea since the date can get screwed up in a lot of different ways. --- companion/src/appdata.cpp | 35 +++--- companion/src/appdata.h | 4 + companion/src/apppreferencesdialog.cpp | 21 +++- companion/src/apppreferencesdialog.ui | 146 ++++++++++++++++--------- companion/src/generaledit.cpp | 4 + 5 files changed, 141 insertions(+), 69 deletions(-) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index ec634da4d..c54ff6634 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -296,6 +296,7 @@ QString Profile::display() const { return _display; } QString Profile::haptic() const { return _haptic; } QString Profile::speaker() const { return _speaker; } QString Profile::stickPotCalib() const { return _stickPotCalib; } +QString Profile::timeStamp() const { return _timeStamp; } QString Profile::trainerCalib() const { return _trainerCalib; } int Profile::currentCalib() const { return _currentCalib; } int Profile::gsStickMode() const { return _gsStickMode; } @@ -320,6 +321,7 @@ void Profile::display (const QString x) { store(x, _display, "Displa void Profile::haptic (const QString x) { store(x, _haptic, "Haptic" ,"Profiles", QString("profile%1").arg(index));} void Profile::speaker (const QString x) { store(x, _speaker, "Speaker" ,"Profiles", QString("profile%1").arg(index));} void Profile::stickPotCalib (const QString x) { store(x, _stickPotCalib, "StickPotCalib" ,"Profiles", QString("profile%1").arg(index));} +void Profile::timeStamp (const QString x) { store(x, _timeStamp, "TimeStamp" ,"Profiles", QString("profile%1").arg(index));} void Profile::trainerCalib (const QString x) { store(x, _trainerCalib, "TrainerCalib" ,"Profiles", QString("profile%1").arg(index));} void Profile::currentCalib (const int x) { store(x, _currentCalib, "currentCalib" ,"Profiles", QString("profile%1").arg(index));} void Profile::gsStickMode (const int x) { store(x, _gsStickMode, "GSStickMode" ,"Profiles", QString("profile%1").arg(index));} @@ -385,6 +387,24 @@ bool Profile::existsOnDisk() return (keyList.length() > 0); } +void Profile::initFwVariables() +{ + _beeper = ""; + _countryCode = ""; + _display = ""; + _haptic = ""; + _speaker = ""; + _stickPotCalib = ""; + _timeStamp = ""; + _trainerCalib = ""; + + _currentCalib = 0; + _gsStickMode = 0; + _ppmMultiplier = 0; + _vBatCalib = 0; + _vBatWarn = 0; +} + void Profile::init(int newIndex) { index = newIndex; @@ -399,19 +419,7 @@ void Profile::init(int newIndex) _channelOrder = 0; _defaultMode = 1; - _beeper = ""; - _countryCode = ""; - _display = ""; - _haptic = ""; - _speaker = ""; - _stickPotCalib = ""; - _trainerCalib = ""; - - _currentCalib = 0; - _gsStickMode = 0; - _ppmMultiplier = 0; - _vBatCalib = 0; - _vBatWarn = 0; + initFwVariables(); // Do not write empty profiles to disk except the default (0) profile. if ( index > 0 && !existsOnDisk()) @@ -439,6 +447,7 @@ void Profile::flush() getset( _haptic, "Haptic" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _speaker, "Speaker" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _stickPotCalib, "StickPotCalib" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _timeStamp, "TimeStamp" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _trainerCalib, "TrainerCalib" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _currentCalib, "currentCalib" ,0 ,"Profiles", QString("profile%1").arg(index)); getset( _gsStickMode, "GSStickMode" ,0 ,"Profiles", QString("profile%1").arg(index)); diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 443f6bab2..bad1a1c7a 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -109,6 +109,7 @@ class Profile: protected CompStoreObj QString _haptic; QString _speaker; QString _stickPotCalib; + QString _timeStamp; QString _trainerCalib; int _currentCalib; int _gsStickMode; @@ -134,6 +135,7 @@ class Profile: protected CompStoreObj QString haptic() const; QString speaker() const; QString stickPotCalib() const; + QString timeStamp() const; QString trainerCalib() const; int currentCalib() const; int gsStickMode() const; @@ -158,6 +160,7 @@ class Profile: protected CompStoreObj void haptic (const QString); void speaker (const QString); void stickPotCalib (const QString); + void timeStamp (const QString); void trainerCalib (const QString); void currentCalib (const int); void gsStickMode (const int); @@ -170,6 +173,7 @@ class Profile: protected CompStoreObj void remove(); bool existsOnDisk(); void init(int newIndex); + void initFwVariables(); void flush(); }; diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 17787f9c0..d00e7b08a 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -69,12 +69,13 @@ void appPreferencesDialog::writeValues() else g.profile[g.id()].name(ui->profileNameLE->text()); - // If a new radio type has been choosen, several things need to change + // If a new radio type has been choosen, several things need to reset if ( initialRadioType != ui->radioCB->currentIndex()) { g.profile[g.id()].fwName(""); g.profile[g.id()].fwType(getDefaultFwType(ui->radioCB->currentIndex())); - current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].fwType()); + current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].fwType()); + g.profile[g.id()].initFwVariables(); } } @@ -156,11 +157,23 @@ void appPreferencesDialog::initSettings() ui->sdPath->setText(g.profile[g.id()].sdPath()); ui->profileNameLE->setText(g.profile[g.id()].name()); ui->SplashFileName->setText(g.profile[g.id()].splashFile()); - initialRadioType = getRadioType(g.profile[g.id()].fwType()); ui->radioCB->setCurrentIndex(initialRadioType); - displayImage( g.profile[g.id()].splashFile() ); + + QString hwSettings; + if (g.profile[g.id()].stickPotCalib() == "" ) { + hwSettings = QString(tr("EMPTY: No radio settings stored in profile")); + } + else { + QString str = g.profile[g.id()].timeStamp(); + if (str.isEmpty()) + hwSettings = QString(tr("AVAILABLE: Radio settings of unknown age")); + else + hwSettings = QString(tr("AVAILABLE: Radio settings stored %1").arg(str)); + } + ui->lblGeneralSettings->setText(hwSettings); + } void appPreferencesDialog::on_libraryPathButton_clicked() diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index 865c969a5..cb053f298 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 734 - 492 + 640 + 499 @@ -26,22 +26,21 @@ Edit Settings + + 6 + + + 6 + + + 6 + + + 6 + 2 - - 6 - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -52,7 +51,20 @@ Radio Profile - + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -106,7 +118,7 @@ Mode 4: - + @@ -256,7 +268,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -276,20 +288,7 @@ This is used by the templated to determine which channel goes to what number out - - - - Qt::Vertical - - - - 20 - 40 - - - - - + @@ -302,7 +301,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -318,14 +317,14 @@ This is used by the templated to determine which channel goes to what number out - + Append version number to FW file name - + @@ -341,7 +340,7 @@ This is used by the templated to determine which channel goes to what number out - + true @@ -363,35 +362,28 @@ This is used by the templated to determine which channel goes to what number out - + Offer to write FW to Tx after download - - - - Remove Profile - - - - + Open Folder - + Qt::Horizontal - + true @@ -413,14 +405,14 @@ This is used by the templated to determine which channel goes to what number out - + Clear Image - + Select Image @@ -434,7 +426,7 @@ This is used by the templated to determine which channel goes to what number out - + Qt::Horizontal @@ -457,7 +449,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -533,7 +525,7 @@ This is used by the templated to determine which channel goes to what number out - + Qt::Horizontal @@ -546,6 +538,46 @@ This is used by the templated to determine which channel goes to what number out + + + + Remove Profile + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + General Settings + + + + + + + + 0 + 18 + + + + TextLabel + + + @@ -965,6 +997,16 @@ This is used by the templated to determine which channel goes to what number out + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/companion/src/generaledit.cpp b/companion/src/generaledit.cpp index 8cccc654c..437441846 100644 --- a/companion/src/generaledit.cpp +++ b/companion/src/generaledit.cpp @@ -2,6 +2,7 @@ #include "ui_generaledit.h" #include "helpers.h" #include "appdata.h" +#include #include #define BIT_WARN_THR ( 0x01 ) @@ -1356,6 +1357,9 @@ void GeneralEdit::on_calstore_PB_clicked() g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0'))); g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0'))); g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage)); + + QDateTime dateTime = QDateTime::currentDateTime(); + g.profile[profile_id].timeStamp(dateTime.toString("yyyy-MM-dd hh:mm")); QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved.")); } }