1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Merge pull request #831 from srcejon/fix_829

Add support for choosing different units in APRS feature
This commit is contained in:
Edouard Griffiths 2021-04-03 05:57:53 +02:00 committed by GitHub
commit 7fcc3f462b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 359 additions and 86 deletions

View File

@ -363,7 +363,11 @@ bool APRSGUI::handleMessage(const Message& message)
else
{
swgMapItem->setImage(new QString(QString("qrc:///%1").arg(aprs->m_symbolImage)));
swgMapItem->setText(new QString(aprs->toText()));
swgMapItem->setText(new QString(aprs->toText(true, false, '\n',
m_settings.m_altitudeUnits == APRSSettings::METRES,
(int)m_settings.m_speedUnits,
m_settings.m_temperatureUnits == APRSSettings::CELSIUS,
m_settings.m_rainfallUnits == APRSSettings::MILLIMETRE)));
}
swgMapItem->setImageMinZoom(11);
@ -609,6 +613,7 @@ void APRSGUI::displaySettings()
ui->igate->setChecked(m_settings.m_igateEnabled);
ui->stationFilter->setCurrentIndex((int)m_settings.m_stationFilter);
ui->filterAddressee->setText(m_settings.m_filterAddressee);
setUnits();
// Order and size columns
displayTableSettings(ui->packetsTable, packetsTableMenu, m_settings.m_packetsTableColumnSizes, m_settings.m_packetsTableColumnIndexes, APRS_PACKETS_TABLE_COLUMNS);
@ -693,11 +698,11 @@ void APRSGUI::updateSummary(APRSStation *station)
ui->status->setText(station->m_latestStatus);
ui->comment->setText(station->m_latestComment);
ui->position->setText(station->m_latestPosition);
ui->altitude->setText(station->m_latestAltitude);
ui->altitude->setText(convertAltitude(station->m_latestAltitude));
ui->course->setText(station->m_latestCourse);
ui->speed->setText(station->m_latestSpeed);
ui->speed->setText(convertSpeed(station->m_latestSpeed));
ui->txPower->setText(station->m_powerWatts);
ui->antennaHeight->setText(station->m_antennaHeightFt);
ui->antennaHeight->setText(convertAltitude(station->m_antennaHeightFt));
ui->antennaGain->setText(station->m_antennaGainDB);
ui->antennaDirectivity->setText(station->m_antennaDirectivity);
ui->radioRange->setText(station->m_radioRange);
@ -779,17 +784,17 @@ void APRSGUI::addPacketToGUI(APRSStation *station, APRSPacket *aprs)
if (aprs->m_hasGust)
gustsItem->setData(Qt::DisplayRole, aprs->m_gust);
if (aprs->m_hasTemp)
temperatureItem->setData(Qt::DisplayRole, aprs->m_temp);
temperatureItem->setData(Qt::DisplayRole, convertTemperature(aprs->m_temp));
if (aprs->m_hasHumidity)
humidityItem->setData(Qt::DisplayRole, aprs->m_humidity);
if (aprs->m_hasBarometricPressure)
pressureItem->setData(Qt::DisplayRole, aprs->m_barometricPressure/10.0f);
if (aprs->m_hasRainLastHr)
rainLastHourItem->setData(Qt::DisplayRole, aprs->m_rainLastHr);
rainLastHourItem->setData(Qt::DisplayRole, convertRainfall(aprs->m_rainLastHr));
if (aprs->m_hasRainLast24Hrs)
rainLast24HoursItem->setData(Qt::DisplayRole, aprs->m_rainLast24Hrs);
rainLast24HoursItem->setData(Qt::DisplayRole, convertRainfall(aprs->m_rainLast24Hrs));
if (aprs->m_hasRainSinceMidnight)
rainSinceMidnightItem->setData(Qt::DisplayRole, aprs->m_rainSinceMidnight);
rainSinceMidnightItem->setData(Qt::DisplayRole, convertRainfall(aprs->m_rainSinceMidnight));
if (aprs->m_hasLuminsoity)
luminosityItem->setData(Qt::DisplayRole, aprs->m_luminosity);
if (aprs->m_hasSnowfallLast24Hrs)
@ -939,11 +944,11 @@ void APRSGUI::addPacketToGUI(APRSStation *station, APRSPacket *aprs)
longitudeItem->setData(Qt::DisplayRole, aprs->m_longitude);
}
if (aprs->m_hasAltitude)
altitudeItem->setData(Qt::DisplayRole, aprs->m_altitudeFt);
altitudeItem->setData(Qt::DisplayRole, convertAltitude(aprs->m_altitudeFt));
if (aprs->m_hasCourseAndSpeed)
{
courseItem->setData(Qt::DisplayRole, aprs->m_course);
speedItem->setData(Qt::DisplayRole, aprs->m_speed);
speedItem->setData(Qt::DisplayRole, convertSpeed(aprs->m_speed));
}
}
@ -1155,17 +1160,17 @@ void APRSGUI::plotWeather()
else if (plotSelectIdx == 2 && aprs->m_hasGust)
addToSeries(series, dt, aprs->m_gust, minValue, maxValue);
else if (plotSelectIdx == 3 && aprs->m_hasTemp)
addToSeries(series, dt, aprs->m_temp, minValue, maxValue);
addToSeries(series, dt, convertTemperature(aprs->m_temp), minValue, maxValue);
else if (plotSelectIdx == 4 && aprs->m_hasHumidity)
addToSeries(series, dt, aprs->m_humidity, minValue, maxValue);
else if (plotSelectIdx == 5 && aprs->m_hasBarometricPressure)
addToSeries(series, dt, aprs->m_barometricPressure/10.0, minValue, maxValue);
else if (plotSelectIdx == 6 && aprs->m_hasRainLastHr)
addToSeries(series, dt, aprs->m_rainLastHr, minValue, maxValue);
addToSeries(series, dt, convertRainfall(aprs->m_rainLastHr), minValue, maxValue);
else if (plotSelectIdx == 7 && aprs->m_hasRainLast24Hrs)
addToSeries(series, dt, aprs->m_rainLast24Hrs, minValue, maxValue);
addToSeries(series, dt, convertRainfall(aprs->m_rainLast24Hrs), minValue, maxValue);
else if (plotSelectIdx == 8 && aprs->m_hasRainSinceMidnight)
addToSeries(series, dt, aprs->m_rainSinceMidnight, minValue, maxValue);
addToSeries(series, dt, convertRainfall(aprs->m_rainSinceMidnight), minValue, maxValue);
else if (plotSelectIdx == 9 && aprs->m_hasLuminsoity)
addToSeries(series, dt, aprs->m_luminosity, minValue, maxValue);
else if (plotSelectIdx == 10 && aprs->m_hasSnowfallLast24Hrs)
@ -1383,11 +1388,11 @@ void APRSGUI::plotMotion()
else if (plotSelectIdx == 1 && aprs->m_hasPosition)
addToSeries(series, dt, aprs->m_longitude, minValue, maxValue);
else if (plotSelectIdx == 2 && aprs->m_hasAltitude)
addToSeries(series, dt, aprs->m_altitudeFt, minValue, maxValue);
addToSeries(series, dt, convertAltitude(aprs->m_altitudeFt), minValue, maxValue);
else if (plotSelectIdx == 3 && aprs->m_hasCourseAndSpeed)
addToSeries(series, dt, aprs->m_course, minValue, maxValue);
else if (plotSelectIdx == 4 && aprs->m_hasCourseAndSpeed)
addToSeries(series, dt, aprs->m_speed, minValue, maxValue);
addToSeries(series, dt, convertSpeed(aprs->m_speed), minValue, maxValue);
}
}
}
@ -1606,8 +1611,8 @@ void APRSGUI::resizeTable()
ui->motionTable->setItem(row, MOTION_COL_LATITUDE, new QTableWidgetItem("Latitude"));
ui->motionTable->setItem(row, MOTION_COL_LONGITUDE, new QTableWidgetItem("Longitude"));
ui->motionTable->setItem(row, MOTION_COL_ALTITUDE, new QTableWidgetItem("Message No"));
ui->motionTable->setItem(row, MOTION_COL_ALTITUDE, new QTableWidgetItem("Course"));
ui->motionTable->setItem(row, MOTION_COL_ALTITUDE, new QTableWidgetItem("Speed"));
ui->motionTable->setItem(row, MOTION_COL_COURSE, new QTableWidgetItem("Course"));
ui->motionTable->setItem(row, MOTION_COL_SPEED, new QTableWidgetItem("Speed"));
ui->motionTable->resizeColumnsToContents();
ui->motionTable->removeRow(row);
@ -1905,17 +1910,79 @@ QAction *APRSGUI::motionTable_createCheckableItem(QString &text, int idx, bool c
return action;
}
void APRSGUI::setUnits()
{
ui->altitudeUnitsLabel->setText(APRSSettings::m_altitudeUnitNames[m_settings.m_altitudeUnits]);
ui->antennaHeightUnitsLabel->setText(APRSSettings::m_altitudeUnitNames[m_settings.m_altitudeUnits]);
ui->speedUnitsLabel->setText(APRSSettings::m_speedUnitNames[m_settings.m_speedUnits]);
ui->weatherTable->horizontalHeaderItem(WEATHER_COL_TEMPERATURE)->setText(QString("Temp (%1)").arg(APRSSettings::m_temperatureUnitNames[m_settings.m_temperatureUnits]));
// Display data using new units
int idx = ui->stationSelect->currentIndex();
if (idx >= 0)
on_stationSelect_currentIndexChanged(idx);
}
QString APRSGUI::convertAltitude(const QString& altitude)
{
if ((m_settings.m_altitudeUnits == APRSSettings::FEET) || altitude.isEmpty())
return altitude;
else
return QString::number((int)std::round(Units::feetToMetres(altitude.toFloat())));
}
float APRSGUI::convertAltitude(float altitude)
{
if (m_settings.m_altitudeUnits == APRSSettings::FEET)
return altitude;
else
return std::round(Units::feetToMetres(altitude));
}
QString APRSGUI::convertSpeed(const QString& speed)
{
if ((m_settings.m_speedUnits == APRSSettings::KNOTS) || speed.isEmpty())
return speed;
else if (m_settings.m_speedUnits == APRSSettings::MPH)
return QString::number(Units::knotsToIntegerMPH(speed.toFloat()));
else
return QString::number(Units::knotsToIntegerKPH(speed.toFloat()));
}
int APRSGUI::convertSpeed(int speed)
{
if (m_settings.m_speedUnits == APRSSettings::KNOTS)
return speed;
else if (m_settings.m_speedUnits == APRSSettings::MPH)
return Units::knotsToIntegerMPH(speed);
else
return Units::knotsToIntegerKPH(speed);
}
int APRSGUI::convertTemperature(int temperature)
{
if (m_settings.m_temperatureUnits == APRSSettings::FAHRENHEIT)
return temperature;
else
return (int)std::round(Units::fahrenheitToCelsius(temperature));
}
int APRSGUI::convertRainfall(int rainfall)
{
if (m_settings.m_rainfallUnits == APRSSettings::HUNDREDTHS_OF_AN_INCH)
return rainfall;
else
return (int)std::round(Units::inchesToMilimetres(rainfall/100.0f));
}
// Show settings dialog
void APRSGUI::on_displaySettings_clicked()
{
APRSSettingsDialog dialog(m_settings.m_igateServer, m_settings.m_igateCallsign,
m_settings.m_igatePasscode, m_settings.m_igateFilter);
APRSSettingsDialog dialog(&m_settings);
if (dialog.exec() == QDialog::Accepted)
{
m_settings.m_igateServer = dialog.m_igateServer;
m_settings.m_igateCallsign = dialog.m_igateCallsign;
m_settings.m_igatePasscode = dialog.m_igatePasscode;
m_settings.m_igateFilter = dialog.m_igateFilter;
setUnits();
applySettings();
}
}

View File

@ -169,6 +169,13 @@ private:
void updateSummary(APRSStation *station);
void addPacketToGUI(APRSStation *station, APRSPacket *aprs);
void setUnits();
QString convertAltitude(const QString& altitude);
float convertAltitude(float altitude);
QString convertSpeed(const QString& speed);
int convertSpeed(int speed);
int convertTemperature(int temperature);
int convertRainfall(int rainfall);
private slots:
void onMenuDialogCalled(const QPoint &p);

View File

@ -30,7 +30,7 @@
const PluginDescriptor APRSPlugin::m_pluginDescriptor = {
APRS::m_featureId,
QStringLiteral("APRS"),
QStringLiteral("6.5.0"),
QStringLiteral("6.7.1"),
QStringLiteral("(c) Jon Beniston, M7RCE"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,

View File

@ -33,6 +33,23 @@ const QStringList APRSSettings::m_pipeURIs = {
QStringLiteral("sdrangel.channel.chirpchatdemod")
};
const QStringList APRSSettings::m_altitudeUnitNames = {
QStringLiteral("Feet"),
QStringLiteral("Metres")
};
const QStringList APRSSettings::m_speedUnitNames = {
QStringLiteral("Knots"),
QStringLiteral("MPH"),
QStringLiteral("KPH")
};
const QStringList APRSSettings::m_temperatureUnitNames = {
QStringLiteral("F"),
QStringLiteral("C")
};
APRSSettings::APRSSettings()
{
resetToDefaults();
@ -48,6 +65,10 @@ void APRSSettings::resetToDefaults()
m_igateEnabled = false;
m_stationFilter = ALL;
m_filterAddressee = "";
m_altitudeUnits = FEET;
m_speedUnits = KNOTS;
m_temperatureUnits = FAHRENHEIT;
m_rainfallUnits = HUNDREDTHS_OF_AN_INCH;
m_title = "APRS";
m_rgbColor = QColor(225, 25, 99).rgb();
m_useReverseAPI = false;
@ -106,6 +127,10 @@ QByteArray APRSSettings::serialize() const
s.writeU32(13, m_reverseAPIPort);
s.writeU32(14, m_reverseAPIFeatureSetIndex);
s.writeU32(15, m_reverseAPIFeatureIndex);
s.writeS32(16, (int)m_altitudeUnits);
s.writeS32(17, (int)m_speedUnits);
s.writeS32(18, (int)m_temperatureUnits);
s.writeS32(19, (int)m_rainfallUnits);
for (int i = 0; i < APRS_PACKETS_TABLE_COLUMNS; i++)
s.writeS32(100 + i, m_packetsTableColumnIndexes[i]);
@ -177,6 +202,11 @@ bool APRSSettings::deserialize(const QByteArray& data)
d.readU32(15, &utmp, 0);
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
d.readS32(16, (int *)&m_altitudeUnits, (int)FEET);
d.readS32(17, (int *)&m_speedUnits, (int)KNOTS);
d.readS32(18, (int *)&m_temperatureUnits, (int)FAHRENHEIT);
d.readS32(19, (int *)&m_rainfallUnits, (int)HUNDREDTHS_OF_AN_INCH);
for (int i = 0; i < APRS_PACKETS_TABLE_COLUMNS; i++)
d.readS32(100 + i, &m_packetsTableColumnIndexes[i], i);
for (int i = 0; i < APRS_PACKETS_TABLE_COLUMNS; i++)

View File

@ -46,6 +46,18 @@ struct APRSSettings
ALL, STATIONS, OBJECTS, WEATHER, TELEMETRY, COURSE_AND_SPEED
} m_stationFilter;
QString m_filterAddressee;
enum AltitudeUnits {
FEET, METRES
} m_altitudeUnits;
enum SpeedUnits {
KNOTS, MPH, KPH
} m_speedUnits;
enum TemperatureUnits {
FAHRENHEIT, CELSIUS
} m_temperatureUnits;
enum RainfallUnits {
HUNDREDTHS_OF_AN_INCH, MILLIMETRE
} m_rainfallUnits;
QString m_title;
quint32 m_rgbColor;
bool m_useReverseAPI;
@ -74,6 +86,10 @@ struct APRSSettings
static const QStringList m_pipeTypes;
static const QStringList m_pipeURIs;
static const QStringList m_altitudeUnitNames;
static const QStringList m_speedUnitNames;
static const QStringList m_temperatureUnitNames;
};
#endif // INCLUDE_FEATURE_APRSSETTINGS_H_

View File

@ -17,15 +17,20 @@
#include "aprssettingsdialog.h"
APRSSettingsDialog::APRSSettingsDialog(QString igateServer, QString igateCallsign, QString igatePasscode, QString igateFilter, QWidget* parent) :
APRSSettingsDialog::APRSSettingsDialog(APRSSettings* settings, QWidget* parent) :
QDialog(parent),
ui(new Ui::APRSSettingsDialog)
ui(new Ui::APRSSettingsDialog),
m_settings(settings)
{
ui->setupUi(this);
ui->igateServer->setCurrentText(igateServer);
ui->igateCallsign->setText(igateCallsign);
ui->igatePasscode->setText(igatePasscode);
ui->igateFilter->setText(igateFilter);
ui->igateServer->setCurrentText(m_settings->m_igateServer);
ui->igateCallsign->setText(m_settings->m_igateCallsign);
ui->igatePasscode->setText(m_settings->m_igatePasscode);
ui->igateFilter->setText(m_settings->m_igateFilter);
ui->altitudeUnits->setCurrentIndex((int)m_settings->m_altitudeUnits);
ui->speedUnits->setCurrentIndex((int)m_settings->m_speedUnits);
ui->temperatureUnits->setCurrentIndex((int)m_settings->m_temperatureUnits);
ui->rainfallUnits->setCurrentIndex((int)m_settings->m_rainfallUnits);
}
APRSSettingsDialog::~APRSSettingsDialog()
@ -35,9 +40,13 @@ APRSSettingsDialog::~APRSSettingsDialog()
void APRSSettingsDialog::accept()
{
m_igateServer = ui->igateServer->currentText();
m_igateCallsign = ui->igateCallsign->text();
m_igatePasscode = ui->igatePasscode->text();
m_igateFilter = ui->igateFilter->text();
m_settings->m_igateServer = ui->igateServer->currentText();
m_settings->m_igateCallsign = ui->igateCallsign->text();
m_settings->m_igatePasscode = ui->igatePasscode->text();
m_settings->m_igateFilter = ui->igateFilter->text();
m_settings->m_altitudeUnits = (APRSSettings::AltitudeUnits)ui->altitudeUnits->currentIndex();
m_settings->m_speedUnits = (APRSSettings::SpeedUnits)ui->speedUnits->currentIndex();
m_settings->m_temperatureUnits = (APRSSettings::TemperatureUnits)ui->temperatureUnits->currentIndex();
m_settings->m_rainfallUnits = (APRSSettings::RainfallUnits)ui->rainfallUnits->currentIndex();
QDialog::accept();
}

View File

@ -25,19 +25,15 @@ class APRSSettingsDialog : public QDialog {
Q_OBJECT
public:
explicit APRSSettingsDialog(QString igateServer, QString igateCallsign, QString igatePasscode, QString igateFilter, QWidget* parent = 0);
explicit APRSSettingsDialog(APRSSettings* settings, QWidget* parent = 0);
~APRSSettingsDialog();
QString m_igateServer;
QString m_igateCallsign;
QString m_igatePasscode;
QString m_igateFilter;
private slots:
void accept();
private:
Ui::APRSSettingsDialog* ui;
APRSSettings *m_settings;
};
#endif // INCLUDE_APRSSETTINGSDIALOG_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>351</width>
<height>179</height>
<height>275</height>
</rect>
</property>
<property name="font">
@ -23,6 +23,64 @@
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="igateCallsignLabel">
<property name="text">
<string>IGate Callsign</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="altitudeUnitsLabel">
<property name="text">
<string>Altitude Units</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="altitudeUnits">
<property name="toolTip">
<string>Units used for displaying altitudes</string>
</property>
<item>
<property name="text">
<string>Feet</string>
</property>
</item>
<item>
<property name="text">
<string>Metres</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="speedUnitsLabel">
<property name="text">
<string>Speed Units</string>
</property>
</widget>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="igateFilterLabel">
<property name="text">
<string>IGate Filter</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="igateServer">
<property name="toolTip">
@ -58,40 +116,6 @@
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="igateSeverLabel">
<property name="text">
<string>IGate Server</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="igatePasscodeLabel">
<property name="text">
<string>IGate Passcode</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="igateCallsignLabel">
<property name="text">
<string>IGate Callsign</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="igateFilter">
<property name="toolTip">
@ -99,10 +123,10 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="igateFilterLabel">
<item row="0" column="0">
<widget class="QLabel" name="igateSeverLabel">
<property name="text">
<string>IGate Filter</string>
<string>IGate Server</string>
</property>
</widget>
</item>
@ -120,6 +144,83 @@
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="speedUnits">
<property name="toolTip">
<string>Units used for displaying speeds</string>
</property>
<item>
<property name="text">
<string>Knots</string>
</property>
</item>
<item>
<property name="text">
<string>MPH</string>
</property>
</item>
<item>
<property name="text">
<string>KPH</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="igatePasscodeLabel">
<property name="text">
<string>IGate Passcode</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="temperatureUnits">
<property name="toolTip">
<string>Units used for displaying temperatures</string>
</property>
<item>
<property name="text">
<string>Fahrenheit</string>
</property>
</item>
<item>
<property name="text">
<string>Celsius</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="temperatureUnitsLabel">
<property name="text">
<string>Temperature Units</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="rainfallUnitsLabel">
<property name="text">
<string>Rainfall Units</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="rainfallUnits">
<property name="toolTip">
<string>Units used for displaying rainfall</string>
</property>
<item>
<property name="text">
<string>Hundredths of an inch</string>
</property>
</item>
<item>
<property name="text">
<string>Millimetres</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -28,6 +28,10 @@ Pressing this button shows the APRS Settings Dialog. This dialog allows you to e
* A serverside filter, that specifies which packets should be forwarded from the internet to SDRangel. See http://www.aprs-is.net/javAPRSFilter.aspx
m/50 will send you packets within 50 km of the last known position of the station corresponding to the callsign used to log in with.
If you do not have a corresponding station, you can specify a location by passing a latitude and longitude. E.g: r/lat/lon/50
* The units in which altitudes are displyed (Feet or metres).
* The units in which object speeds are displayed (Knots, MPH or KPH).
* The units in which temperature is displayed (Fahrenheit or Celsius).
* The units in which rainfall is displayed (Hundredths of an inch or millimetres).
<h2>Map</h2>

View File

@ -322,7 +322,8 @@ struct SDRBASE_API APRSPacket {
return bytes;
}
QString toText(bool includeFrom=true, bool includePosition=false, char separator='\n')
QString toText(bool includeFrom=true, bool includePosition=false, char separator='\n',
bool altitudeMetres=false, int speedUnits=0, bool tempCelsius=false, bool rainfallMM=false)
{
QStringList text;
@ -351,9 +352,21 @@ struct SDRBASE_API APRSPacket {
if (includePosition && m_hasPosition)
text.append(QString("Latitude: %1 Longitude: %2").arg(m_latitude).arg(m_longitude));
if (m_hasAltitude)
text.append(QString("Altitude: %1 ft").arg(m_altitudeFt));
{
if (altitudeMetres)
text.append(QString("Altitude: %1 m").arg((int)std::round(Units::feetToMetres(m_altitudeFt))));
else
text.append(QString("Altitude: %1 ft").arg(m_altitudeFt));
}
if (m_hasCourseAndSpeed)
text.append(QString("Course: %1%3 Speed: %2 knts").arg(m_course).arg(m_speed).arg(QChar(0xb0)));
{
if (speedUnits == 0)
text.append(QString("Course: %1%3 Speed: %2 knts").arg(m_course).arg(m_speed).arg(QChar(0xb0)));
else if (speedUnits == 1)
text.append(QString("Course: %1%3 Speed: %2 mph").arg(m_course).arg(Units::knotsToIntegerMPH(m_speed)).arg(QChar(0xb0)));
else
text.append(QString("Course: %1%3 Speed: %2 kph").arg(m_course).arg(Units::knotsToIntegerKPH(m_speed)).arg(QChar(0xb0)));
}
if (m_hasStationDetails)
text.append(QString("TX Power: %1 Watts Antenna Height: %2 m Gain: %3 dB Direction: %4").arg(m_powerWatts).arg(std::round(Units::feetToMetres(m_antennaHeightFt))).arg(m_antennaGainDB).arg(m_antennaDirectivity));
@ -379,7 +392,12 @@ struct SDRBASE_API APRSPacket {
{
air.append("Air");
if (m_hasTemp)
air.append(QString("Temperature %1C").arg(Units::fahrenheitToCelsius(m_temp), 0, 'f', 1));
{
if (tempCelsius)
air.append(QString("Temperature %1C").arg(Units::fahrenheitToCelsius(m_temp), 0, 'f', 1));
else
air.append(QString("Temperature %1F").arg(m_temp));
}
if (m_hasHumidity)
air.append(QString("Humidity %1%").arg(m_humidity));
if (m_hasBarometricPressure)
@ -391,11 +409,26 @@ struct SDRBASE_API APRSPacket {
{
rain.append("Rain");
if (m_hasRainLastHr)
rain.append(QString("%1 mm last hour").arg(std::round(Units::inchesToMilimetres(m_rainLastHr/100.0))));
{
if (rainfallMM)
rain.append(QString("%1 mm last hour").arg(std::round(Units::inchesToMilimetres(m_rainLastHr/100.0))));
else
rain.append(QString("%1 1/100\" last hour").arg(m_rainLastHr));
}
if (m_hasRainLast24Hrs)
rain.append(QString("%1 mm last 24 hours").arg(std::round(Units::inchesToMilimetres(m_rainLast24Hrs/100.0))));
{
if (rainfallMM)
rain.append(QString("%1 mm last 24 hours").arg(std::round(Units::inchesToMilimetres(m_rainLast24Hrs/100.0))));
else
rain.append(QString("%1 1/100\" last 24 hours").arg(m_rainLast24Hrs));
}
if (m_hasRainSinceMidnight)
rain.append(QString("%1 mm since midnight").arg(std::round(Units::inchesToMilimetres(m_rainSinceMidnight/100.0))));
{
if (rainfallMM)
rain.append(QString("%1 mm since midnight").arg(std::round(Units::inchesToMilimetres(m_rainSinceMidnight/100.0))));
else
rain.append(QString("%1 1/100\" since midnight").arg(m_rainSinceMidnight));
}
weather.append(rain.join(' '));
}

View File

@ -61,6 +61,16 @@ public:
return (int)std::round(knotsToKPH(knots));
}
static float knotsToMPH(float knots)
{
return knots * 1.15078f;
}
static int knotsToIntegerMPH(float knots)
{
return (int)std::round(knotsToMPH(knots));
}
static float kmpsToKPH(float kps)
{
return kps * (60.0 * 60.0);