1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-04-11 03:02:20 +02:00

LP-240 Add Mag error display in percent - Lower rates for telemetry

This commit is contained in:
Laurent Lalanne 2016-02-26 10:12:10 +01:00
parent 1aaf9b9f0e
commit 8211efe804
2 changed files with 15 additions and 9 deletions

View File

@ -60,10 +60,10 @@
// #define DEBUG // #define DEBUG
#define MAG_ALARM_THRESHOLD 20 #define MAG_ALARM_THRESHOLD 5
// Uncomment this to enable 6 point calibration on the accels // Uncomment this to enable 6 point calibration on the accels
#define NOISE_SAMPLES 50 #define NOISE_SAMPLES 50
class Thread : public QThread { class Thread : public QThread {
public: public:
@ -499,12 +499,12 @@ void ConfigRevoWidget::onBoardAuxMagError()
// Apply new rates // Apply new rates
UAVObject::Metadata mdata = magSensor->getMetadata(); UAVObject::Metadata mdata = magSensor->getMetadata();
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC); UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
mdata.flightTelemetryUpdatePeriod = 100; mdata.flightTelemetryUpdatePeriod = 300;
magSensor->setMetadata(mdata); magSensor->setMetadata(mdata);
mdata = auxMagSensor->getMetadata(); mdata = auxMagSensor->getMetadata();
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC); UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
mdata.flightTelemetryUpdatePeriod = 100; mdata.flightTelemetryUpdatePeriod = 300;
auxMagSensor->setMetadata(mdata); auxMagSensor->setMetadata(mdata);
displayMagError = true; displayMagError = true;
@ -525,7 +525,7 @@ void ConfigRevoWidget::onBoardAuxMagError()
float zDiff = 0.0f; float zDiff = 0.0f;
// Smooth Mag readings // Smooth Mag readings
float alpha = 0.8f; float alpha = 0.7f;
float inv_alpha = (1.0f - alpha); float inv_alpha = (1.0f - alpha);
// OnBoard mag // OnBoard mag
onboardMagFiltered[0] = (onboardMagFiltered[0] * alpha) + (onboardMag[0] * inv_alpha); onboardMagFiltered[0] = (onboardMagFiltered[0] * alpha) + (onboardMag[0] * inv_alpha);
@ -579,6 +579,7 @@ void ConfigRevoWidget::onBoardAuxMagError()
void ConfigRevoWidget::updateMagAlarm(float errorMag, float errorAuxMag) void ConfigRevoWidget::updateMagAlarm(float errorMag, float errorAuxMag)
{ {
RevoSettings *revoSettings = RevoSettings::GetInstance(getObjectManager()); RevoSettings *revoSettings = RevoSettings::GetInstance(getObjectManager());
Q_ASSERT(revoSettings); Q_ASSERT(revoSettings);
RevoSettings::DataFields revoSettingsData = revoSettings->getData(); RevoSettings::DataFields revoSettingsData = revoSettings->getData();
@ -627,11 +628,16 @@ void ConfigRevoWidget::updateMagAlarm(float errorMag, float errorAuxMag)
} else { } else {
auxMagErrorCount++; auxMagErrorCount++;
} }
errorAuxMag = ((errorAuxMag * 100.0f) <= 100.0f) ? errorAuxMag * 100.0f : 100.0f;
m_ui->auxMagStatus->setText("AuxMag\n" + QString::number(errorAuxMag, 'f', 1) + "%");
} else { } else {
// Disable aux mag alarm // Disable aux mag alarm
bgColorAuxMag = "grey"; bgColorAuxMag = "grey";
m_ui->auxMagStatus->setText("AuxMag\nnot found");
} }
errorMag = ((errorMag * 100.0f) <= 100.0f) ? errorMag * 100.0f : 100.0f;
m_ui->onBoardMagStatus->setText("OnBoard\n" + QString::number(errorMag, 'f', 1) + "%");
m_ui->onBoardMagStatus->setStyleSheet( m_ui->onBoardMagStatus->setStyleSheet(
"QLabel { background-color: " + bgColorMag + ";" "QLabel { background-color: " + bgColorMag + ";"
"color: rgb(255, 255, 255); border-radius: 5; margin:1px; font:bold; }"); "color: rgb(255, 255, 255); border-radius: 5; margin:1px; font:bold; }");

View File

@ -1356,7 +1356,7 @@ font:bold;</string>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>100</width>
<height>35</height> <height>35</height>
</size> </size>
</property> </property>
@ -1385,8 +1385,8 @@ font:bold;</string>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>100</width>
<height>35</height> <height>40</height>
</size> </size>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -1409,7 +1409,7 @@ font:bold;</string>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>110</width> <width>110</width>
<height>0</height> <height>20</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">