[companion][general settings]Add Battery Range Meter to companion eepe General Settings. Fixes #2195.

This commit is contained in:
Grieb
2015-04-24 14:28:31 -03:00
parent ce2e8ac1ca
commit dc34596f2d
8 changed files with 210 additions and 81 deletions
+10
View File
@@ -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));
}
+6
View File
@@ -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&);
+2 -1
View File
@@ -1285,7 +1285,8 @@ enum Capability {
MavlinkTelemetry,
HasInputDiff,
HasMixerExpo,
MixersMonitor
MixersMonitor,
HasBatMeterRange
};
class SimulatorInterface;
@@ -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;
}
+10 -2
View File
@@ -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<br>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')) );
@@ -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();
+2
View File
@@ -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();
+153 -78
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>758</width>
<height>635</height>
<height>661</height>
</rect>
</property>
<property name="windowTitle">
@@ -230,6 +230,24 @@
</item>
</widget>
</item>
<item row="11" column="4">
<widget class="QComboBox" name="backlightswCB">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>This is the switch selectrion for turning on the backlight (if installed).
</string>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="16" column="4">
<layout class="QHBoxLayout" name="backlightColor_Layout">
<item>
@@ -324,20 +342,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="displayTypeCB">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Optrex</string>
</property>
</item>
</widget>
</item>
<item row="29" column="0">
<widget class="QLabel" name="ro_label">
<property name="text">
@@ -1242,16 +1246,6 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_contrast">
<property name="toolTip">
<string extracomment="Screen Contrast [20-45]"/>
</property>
<property name="text">
<string>Contrast</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QSpinBox" name="inactimerSB">
<property name="sizePolicy">
@@ -1354,31 +1348,6 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QComboBox" name="backlightswCB">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>This is the switch selectrion for turning on the backlight (if installed).
</string>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_displayType">
<property name="text">
<string>LCD Display Type</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="mavbaud_label">
<property name="text">
@@ -1386,34 +1355,6 @@ Acceptable values are 5v..10v</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="contrastSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>45</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_volume">
<property name="text">
@@ -1949,6 +1890,140 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_displayType">
<property name="text">
<string>LCD Display Type</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="displayTypeCB">
<item>
<property name="text">
<string>Standard</string>
</property>
</item>
<item>
<property name="text">
<string>Optrex</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_contrast">
<property name="toolTip">
<string extracomment="Screen Contrast [20-45]"/>
</property>
<property name="text">
<string>Contrast</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="contrastSB">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>45</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="batMeterRangeLabel">
<property name="text">
<string>Battery Meter Range</string>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="batMeterRangeLayout" stretch="0,1,0,1">
<item>
<widget class="QLabel" name="HasBatMeterMinRangeLabel">
<property name="text">
<string>Min</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="vBatMinDSB">
<property name="prefix">
<string notr="true"/>
</property>
<property name="suffix">
<string notr="true">v</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>4.000000000000000</double>
</property>
<property name="maximum">
<double>16.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>9.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="HasBatMeterMaxRangeLabel">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="vBatMaxDSB">
<property name="prefix">
<string notr="true"/>
</property>
<property name="suffix">
<string notr="true">v</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>4.000000000000000</double>
</property>
<property name="maximum">
<double>16.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>12.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>