mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 09:15:38 +03:00
Merge origin/romolo/companion9x_ge
This commit is contained in:
commit
aadce547a5
7 changed files with 264 additions and 55 deletions
|
@ -65,6 +65,8 @@
|
|||
<file>images/fuses.png</file>
|
||||
<file>images/list.png</file>
|
||||
<file>images/maps.png</file>
|
||||
<file>images/track.png</file>
|
||||
<file>images/track0.png</file>
|
||||
<file>images/play.png</file>
|
||||
<file>images/stop.png</file>
|
||||
<file>images/read_eeprom_file.png</file>
|
||||
|
|
BIN
companion/src/images/track.png
Normal file
BIN
companion/src/images/track.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 747 B |
BIN
companion/src/images/track0.png
Normal file
BIN
companion/src/images/track0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -178,12 +178,35 @@ void logsDialog::selectionChanged()
|
|||
void logsDialog::on_mapsButton_clicked() {
|
||||
int n = csvlog.count(); // number of points in graph
|
||||
if (n==0) return;
|
||||
int latcol=0, longcol=0, altcol=0, coursecol=0, speedcol=0;
|
||||
int latcol=0, longcol=0, altcol=0, speedcol=0;
|
||||
int itemSelected=0.;
|
||||
bool rangeSelected=false;
|
||||
enum fieldtype {
|
||||
T_F,
|
||||
I_F,
|
||||
F_F,
|
||||
G_F
|
||||
};
|
||||
ui->FieldsTW->setDisabled(true);
|
||||
ui->logTable->setDisabled(true);
|
||||
QString fields[]={"SWR","RSSI","A1","A2","GPS Date"\
|
||||
,"GPS Time","Long","Lat","Course","GPS Speed","GPS Alt","Baro Alt"\
|
||||
,"Vertical Speed","Temp1","Temp2","RPM","Fuel","Cell volts","Cell 1"\
|
||||
,"Cell 2","Cell 3","Cell 4","Cell 5","Cell 6","Current","Consumption"\
|
||||
,"Vfas","AccelX","AccelY","AccelZ","Rud","Ele","Thr","Ail"\
|
||||
,"S1","S2","LS","RS","SA","SB","SC","SD","SE","SF","SG","SH"};
|
||||
int fieldstype[]={I_F,I_F,F_F,F_F,T_F\
|
||||
,T_F,G_F,G_F,F_F,G_F,G_F,F_F\
|
||||
,F_F,F_F,F_F,I_F,I_F,F_F,F_F\
|
||||
,F_F,F_F,F_F,F_F,F_F,F_F,F_F\
|
||||
,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\
|
||||
,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F};
|
||||
|
||||
QSettings settings("companion9x", "companion9x");
|
||||
QString gePath=settings.value("gePath", "").toString();
|
||||
if (gePath.isEmpty() || !QFile(gePath).exists()) {
|
||||
ui->FieldsTW->setDisabled(false);
|
||||
ui->logTable->setDisabled(false);
|
||||
return;
|
||||
}
|
||||
for (int i=1; i<csvlog.at(0).count(); i++) {
|
||||
|
@ -200,9 +223,6 @@ void logsDialog::on_mapsButton_clicked() {
|
|||
if (csvlog.at(0).at(i).contains("GPS Speed")) {
|
||||
speedcol=i;
|
||||
}
|
||||
if (csvlog.at(0).at(i).contains("Course")) {
|
||||
coursecol=i;
|
||||
}
|
||||
}
|
||||
if (longcol==0 || latcol==0 || altcol==0) {
|
||||
return;
|
||||
|
@ -216,9 +236,16 @@ void logsDialog::on_mapsButton_clicked() {
|
|||
if (itemSelected==0) {
|
||||
itemSelected=n-1;
|
||||
}
|
||||
QString geFilename = QDir::tempPath() + "/flight.kml";
|
||||
|
||||
QString geFilename = QDir::tempPath() + "/track0.png";
|
||||
if (QFile::exists(geFilename)) {
|
||||
unlink(geFilename.toAscii());
|
||||
QFile::remove(geFilename);
|
||||
}
|
||||
QFile::copy(":/images/track0.png", geFilename);
|
||||
|
||||
geFilename = QDir::tempPath() + "/flight.kml";
|
||||
if (QFile::exists(geFilename)) {
|
||||
QFile::remove(geFilename);
|
||||
}
|
||||
QFile geFile(geFilename);
|
||||
if (!geFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
|
@ -226,25 +253,103 @@ void logsDialog::on_mapsButton_clicked() {
|
|||
tr("Cannot write file %1:\n%2.")
|
||||
.arg(geFilename)
|
||||
.arg(geFile.errorString()));
|
||||
ui->FieldsTW->setDisabled(false);
|
||||
ui->logTable->setDisabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QString latitude,longitude;
|
||||
double flatitude, flongitude,temp;
|
||||
QTextStream outputStream(&geFile);
|
||||
outputStream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
|
||||
outputStream << "<Document>\n\t<name>flight.kml</name>\n\t<Placemark><name>My Flight</name>\n\t\t<LineString>\n";
|
||||
outputStream << "\t\t\t<tessellate>1</tessellate>\n\t\t\t<gx:altitudeMode>relativeToGround</gx:altitudeMode>\n\t\t\t<coordinates>\n\t\t\t\t";
|
||||
for (int i=1; i<n; i++) {
|
||||
if ((ui->logTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||
outputStream << csvlog.at(i).at(longcol) << "," << csvlog.at(i).at(latcol) << "," << csvlog.at(i).at(altcol) << " " ;
|
||||
outputStream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">\n";
|
||||
outputStream << "\t<Document>\n\t\t<name>" << logFilename << "</name>\n";
|
||||
outputStream << "\t\t<Style id=\"multiTrack_n\">\n\t\t\t<IconStyle>\n\t\t\t\t<Icon>\n\t\t\t\t\t<href>file://" << QDir::tempPath() << "/track0.png</href>\n\t\t\t\t</Icon>\n\t\t\t</IconStyle>\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
|
||||
outputStream << "\t\t<Style id=\"multiTrack_h\">\n\t\t\t<IconStyle>\n\t\t\t\t<scale>1.2</scale>\n\t\t\t\t<Icon>\n\t\t\t\t\t<href>file://" << QDir::tempPath() << "/track0.png</href>\n\t\t\t\t</Icon>\n\t\t\t</IconStyle>\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>8</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
|
||||
outputStream << "\t\t<StyleMap id=\"multiTrack\">\n\t\t\t<Pair>\n\t\t\t\t<key>normal</key>\n\t\t\t\t<styleUrl>#multiTrack_n</styleUrl>\n\t\t\t</Pair>\n\t\t\t<Pair>\n\t\t\t\t<key>highlight</key>\n\t\t\t\t<styleUrl>#multiTrack_h</styleUrl>\n\t\t\t</Pair>\n\t\t</StyleMap>\n";
|
||||
outputStream << "\t\t<Style id=\"lineStyle\">\n\t\t\t<LineStyle>\n\t\t\t\t<color>991081f4</color>\n\t\t\t\t<width>6</width>\n\t\t\t</LineStyle>\n\t\t</Style>\n";
|
||||
outputStream << "\t\t<Schema id=\"schema\">\n";
|
||||
outputStream << "\t\t\t<gx:SimpleArrayField name=\"GPSSpeed\" type=\"float\">\n\t\t\t\t<displayName>GPS Speed</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
||||
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
||||
if (ui->FieldsTW->item(0,i)->isSelected() && fieldstype[i]!=G_F ) {
|
||||
outputStream << "\t\t\t<gx:SimpleArrayField name=\""<< fields[i].replace(" ","_") <<"\" ";
|
||||
switch (fieldstype[i]) {
|
||||
case T_F:
|
||||
outputStream << "type=\"string\"";
|
||||
break;
|
||||
case I_F:
|
||||
outputStream << "type=\"int\"";
|
||||
break;
|
||||
case F_F:
|
||||
outputStream << "type=\"float\"";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
outputStream << ">\n\t\t\t\t<displayName>" << fields[i] << "</displayName>\n\t\t\t</gx:SimpleArrayField>\n";
|
||||
}
|
||||
}
|
||||
outputStream << "\n\t\t\t</coordinates>\n\t\t</LineString>\n\t</Placemark>\n</Document>\n</kml>\n";
|
||||
outputStream << "\t\t</Schema>\n";
|
||||
|
||||
QString planeName;
|
||||
if (logFilename.indexOf("-")>0) {
|
||||
planeName=logFilename.left(logFilename.indexOf("-"));
|
||||
} else {
|
||||
planeName=logFilename;
|
||||
}
|
||||
outputStream << "\t\t<Folder>\n\t\t\t<name>Log Data</name>\n\t\t\t<Placemark>\n\t\t\t\t<name>" << planeName << "</name>\n\t\t\t\t<styleUrl>#multiTrack</styleUrl>\n\t\t\t\t<gx:Track>\n";
|
||||
for (int i=1; i<n; i++) {
|
||||
if ((ui->logTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||
QString tstamp=csvlog.at(i).at(0)+QString("T")+csvlog.at(i).at(1);
|
||||
outputStream << "\t\t\t\t\t<when>"<< tstamp <<"</when>\n";
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=1; i<n; i++) {
|
||||
if ((ui->logTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||
latitude=csvlog.at(i).at(latcol).trimmed();
|
||||
longitude=csvlog.at(i).at(longcol).trimmed();
|
||||
temp=int(latitude.left(latitude.length()-1).toDouble()/100);
|
||||
flatitude=temp+(latitude.left(latitude.length()-1).toDouble()-temp*100)/60.0;
|
||||
temp=int(longitude.left(longitude.length()-1).toDouble()/100);
|
||||
flongitude=temp+(longitude.left(longitude.length()-1).toDouble()-temp*100)/60.0;
|
||||
if (latitude.right(1)!="N") {
|
||||
flatitude*=-1;
|
||||
}
|
||||
if (longitude.right(1)!="E") {
|
||||
flongitude*=-1;
|
||||
}
|
||||
latitude.sprintf("%3.8f", flatitude);
|
||||
longitude.sprintf("%3.8f", flongitude);
|
||||
outputStream << "\t\t\t\t\t<gx:coord>" << longitude << " " << latitude << " " << csvlog.at(i).at(altcol) << "</gx:coord>\n" ;
|
||||
}
|
||||
}
|
||||
outputStream << "\t\t\t\t\t<ExtendedData>\n\t\t\t\t\t\t<SchemaData schemaUrl=\"#schema\">\n";
|
||||
outputStream << "\t\t\t\t\t\t\t<gx:SimpleArrayData name=\"GPSSpeed\">\n";
|
||||
for (int i=1; i<n; i++) {
|
||||
if ((ui->logTable->item(i-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||
outputStream << "\t\t\t\t\t\t\t\t<gx:value>"<< csvlog.at(i).at(speedcol) <<"</gx:value>\n";
|
||||
}
|
||||
}
|
||||
outputStream << "\t\t\t\t\t\t\t</gx:SimpleArrayData>\n";
|
||||
for (int i=0; i<csvlog.at(0).count()-2; i++) {
|
||||
if (ui->FieldsTW->item(0,i)->isSelected() && fieldstype[i]!= G_F ) {
|
||||
outputStream << "\t\t\t\t\t\t\t<gx:SimpleArrayData name=\""<< fields[i].replace(" ","_") <<"\">\n";
|
||||
for (int j=1; j<n; j++) {
|
||||
if ((ui->logTable->item(j-1,1)->isSelected() &&rangeSelected) || !rangeSelected) {
|
||||
outputStream << "\t\t\t\t\t\t\t\t<gx:value>"<< csvlog.at(j).at(i+2) <<"</gx:value>\n";
|
||||
}
|
||||
}
|
||||
outputStream << "\t\t\t\t\t\t\t</gx:SimpleArrayData>\n";
|
||||
}
|
||||
}
|
||||
outputStream << "\t\t\t\t\t\t</SchemaData>\t\t\t\t\t</ExtendedData>\n\t\t\t\t</gx:Track>\n\t\t\t</Placemark>\n\t\t</Folder>\n\t</Document>\n</kml>";
|
||||
geFile.close();
|
||||
|
||||
QStringList parameters;
|
||||
parameters << geFilename;
|
||||
QProcess *process = new QProcess(this);
|
||||
process->startDetached(gePath, parameters);
|
||||
process->start(gePath, parameters);
|
||||
ui->FieldsTW->setDisabled(false);
|
||||
ui->logTable->setDisabled(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -528,6 +633,7 @@ bool logsDialog::cvsFileParse()
|
|||
} else {
|
||||
ui->sessions_CB->clear();
|
||||
csvlog.clear();
|
||||
logFilename.clear();
|
||||
QTextStream inputStream(&file);
|
||||
QRegExp rx2("(?:\"([^\"]*)\";?)|(?:([^,]*),?)");
|
||||
QStringList list;
|
||||
|
@ -576,6 +682,7 @@ bool logsDialog::cvsFileParse()
|
|||
}
|
||||
lines++;
|
||||
}
|
||||
logFilename=QFileInfo(file.fileName()).baseName();
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
|
|
@ -43,6 +43,7 @@ private:
|
|||
double GetScale(QString channel);
|
||||
QList<QColor> palette;
|
||||
bool plotLock;
|
||||
QString logFilename;
|
||||
};
|
||||
|
||||
#endif // LOGSDIALOG_H
|
||||
|
|
|
@ -78,37 +78,45 @@
|
|||
#define FRSKY_LAST_ID 0x3F
|
||||
|
||||
// FrSky new DATA IDs (2 bytes)
|
||||
#define RSSI_ID 0xf101
|
||||
#define ADC1_ID 0xf102
|
||||
#define ADC2_ID 0xf103
|
||||
#define BATT_ID 0xf104
|
||||
#define SWR_ID 0xf105
|
||||
#define T1_FIRST_ID 0x0400
|
||||
#define T1_LAST_ID 0x040f
|
||||
#define T2_FIRST_ID 0x0410
|
||||
#define T2_LAST_ID 0x041f
|
||||
#define RPM_FIRST_ID 0x0500
|
||||
#define RPM_LAST_ID 0x050f
|
||||
#define FUEL_FIRST_ID 0x0600
|
||||
#define FUEL_LAST_ID 0x060f
|
||||
#define ALT_FIRST_ID 0x0100
|
||||
#define ALT_LAST_ID 0x010f
|
||||
#define VARIO_FIRST_ID 0x0110
|
||||
#define VARIO_LAST_ID 0x011f
|
||||
#define ACCX_FIRST_ID 0x0700
|
||||
#define ACCX_LAST_ID 0x070f
|
||||
#define ACCY_FIRST_ID 0x0710
|
||||
#define ACCY_LAST_ID 0x071f
|
||||
#define ACCZ_FIRST_ID 0x0720
|
||||
#define ACCZ_LAST_ID 0x072f
|
||||
#define CURR_FIRST_ID 0x0200
|
||||
#define CURR_LAST_ID 0x020f
|
||||
#define VFAS_FIRST_ID 0x0210
|
||||
#define VFAS_LAST_ID 0x021f
|
||||
#define GPS_SPEED_FIRST_ID 0x0830
|
||||
#define GPS_SPEED_LAST_ID 0x083f
|
||||
#define CELLS_FIRST_ID 0x0300
|
||||
#define CELLS_LAST_ID 0x030f
|
||||
#define RSSI_ID 0xf101
|
||||
#define ADC1_ID 0xf102
|
||||
#define ADC2_ID 0xf103
|
||||
#define BATT_ID 0xf104
|
||||
#define SWR_ID 0xf105
|
||||
#define T1_FIRST_ID 0x0400
|
||||
#define T1_LAST_ID 0x040f
|
||||
#define T2_FIRST_ID 0x0410
|
||||
#define T2_LAST_ID 0x041f
|
||||
#define RPM_FIRST_ID 0x0500
|
||||
#define RPM_LAST_ID 0x050f
|
||||
#define FUEL_FIRST_ID 0x0600
|
||||
#define FUEL_LAST_ID 0x060f
|
||||
#define ALT_FIRST_ID 0x0100
|
||||
#define ALT_LAST_ID 0x010f
|
||||
#define VARIO_FIRST_ID 0x0110
|
||||
#define VARIO_LAST_ID 0x011f
|
||||
#define ACCX_FIRST_ID 0x0700
|
||||
#define ACCX_LAST_ID 0x070f
|
||||
#define ACCY_FIRST_ID 0x0710
|
||||
#define ACCY_LAST_ID 0x071f
|
||||
#define ACCZ_FIRST_ID 0x0720
|
||||
#define ACCZ_LAST_ID 0x072f
|
||||
#define CURR_FIRST_ID 0x0200
|
||||
#define CURR_LAST_ID 0x020f
|
||||
#define VFAS_FIRST_ID 0x0210
|
||||
#define VFAS_LAST_ID 0x021f
|
||||
#define CELLS_FIRST_ID 0x0300
|
||||
#define CELLS_LAST_ID 0x030f
|
||||
#define GPS_LONG_LATI_FIRST_ID 0x0800
|
||||
#define GPS_LONG_LATI_LAST_ID 0x080f
|
||||
#define GPS_ALT_FIRST_ID 0x0820
|
||||
#define GPS_ALT_LAST_ID 0x082f
|
||||
#define GPS_SPEED_FIRST_ID 0x0830
|
||||
#define GPS_SPEED_LAST_ID 0x083f
|
||||
#define GPS_COURS_FIRST_ID 0x0840
|
||||
#define GPS_COURS_LAST_ID 0x084f
|
||||
#define GPS_TIME_DATE_FIRST_ID 0x0850
|
||||
#define GPS_TIME_DATE_LAST_ID 0x085f
|
||||
|
||||
// FrSky wrong IDs ?
|
||||
#define BETA_VARIO_ID 0x8030
|
||||
|
@ -179,7 +187,8 @@ void processHubPacket(uint8_t id, uint16_t value)
|
|||
if (frskyData.hub.rpm > frskyData.hub.maxRpm)
|
||||
frskyData.hub.maxRpm = frskyData.hub.rpm;
|
||||
break;
|
||||
|
||||
//case GPS_COURS_BP_ID:
|
||||
//frskyData.hub.gpsCourse_bp = value;
|
||||
case TEMP1_ID:
|
||||
if (frskyData.hub.temperature1 > frskyData.hub.maxTemperature1)
|
||||
frskyData.hub.maxTemperature1 = frskyData.hub.temperature1;
|
||||
|
@ -214,14 +223,15 @@ void processHubPacket(uint8_t id, uint16_t value)
|
|||
break;
|
||||
|
||||
case GPS_ALT_AP_ID:
|
||||
frskyData.hub.gpsAltitude_bp = frskyData.hub.gpsAltitude_bp*100;
|
||||
if (!frskyData.hub.gpsAltitudeOffset)
|
||||
frskyData.hub.gpsAltitudeOffset = -frskyData.hub.gpsAltitude_bp;
|
||||
frskyData.hub.gpsAltitude_bp += frskyData.hub.gpsAltitudeOffset;
|
||||
if (!frskyData.hub.baroAltitudeOffset) {
|
||||
if (frskyData.hub.gpsAltitude_bp > frskyData.hub.maxAltitude)
|
||||
frskyData.hub.maxAltitude = frskyData.hub.gpsAltitude_bp;
|
||||
if (frskyData.hub.gpsAltitude_bp < frskyData.hub.minAltitude)
|
||||
frskyData.hub.minAltitude = frskyData.hub.gpsAltitude_bp;
|
||||
if (frskyData.hub.gpsAltitude_bp > frskyData.hub.maxAltitude*100)
|
||||
frskyData.hub.maxAltitude = frskyData.hub.gpsAltitude_bp/100;
|
||||
if (frskyData.hub.gpsAltitude_bp < frskyData.hub.minAltitude*100)
|
||||
frskyData.hub.minAltitude = frskyData.hub.gpsAltitude_bp/100;
|
||||
}
|
||||
|
||||
if (!frskyData.hub.pilotLatitude && !frskyData.hub.pilotLongitude) {
|
||||
|
@ -235,6 +245,7 @@ void processHubPacket(uint8_t id, uint16_t value)
|
|||
|
||||
case GPS_SPEED_BP_ID:
|
||||
// Speed => Max speed
|
||||
frskyData.hub.gpsSpeed_bp = (frskyData.hub.gpsSpeed_bp * 46) / 25;
|
||||
if (frskyData.hub.gpsSpeed_bp > frskyData.hub.maxGpsSpeed)
|
||||
frskyData.hub.maxGpsSpeed = frskyData.hub.gpsSpeed_bp;
|
||||
break;
|
||||
|
@ -294,6 +305,7 @@ void processSportPacket(uint8_t *packet)
|
|||
/* uint8_t dataId = packet[0]; */
|
||||
uint8_t prim = packet[1];
|
||||
uint16_t appId = *((uint16_t *)(packet+2));
|
||||
static uint8_t t_coor;
|
||||
|
||||
if (!checkSportPacket(packet))
|
||||
return;
|
||||
|
@ -378,9 +390,92 @@ void processSportPacket(uint8_t *packet)
|
|||
}
|
||||
else if (appId >= GPS_SPEED_FIRST_ID && appId <= GPS_SPEED_LAST_ID) {
|
||||
frskyData.hub.gpsSpeed_bp = SPORT_DATA_U32(packet);
|
||||
frskyData.hub.gpsSpeed_bp = (frskyData.hub.gpsSpeed_bp * 46) / 25/1000;
|
||||
if (frskyData.hub.gpsSpeed_bp > frskyData.hub.maxGpsSpeed)
|
||||
frskyData.hub.maxGpsSpeed = frskyData.hub.gpsSpeed_bp;
|
||||
}
|
||||
else if(appId>=GPS_TIME_DATE_FIRST_ID && appId<=GPS_TIME_DATE_LAST_ID) {
|
||||
uint32_t gps_time_date = SPORT_DATA_U32(packet);
|
||||
if(gps_time_date & 0x000000ff) {
|
||||
frskyData.hub.year = (uint16_t)((gps_time_date & 0xff000000)>>24);
|
||||
frskyData.hub.month =(uint8_t)((gps_time_date & 0x00ff0000)>>16);
|
||||
frskyData.hub.day = (uint8_t)((gps_time_date & 0x0000ff00)>>8);
|
||||
}
|
||||
else {
|
||||
frskyData.hub.hour =(uint8_t) ((gps_time_date & 0xff000000)>>24);
|
||||
frskyData.hub.min = (uint8_t)((gps_time_date & 0x00ff0000)>>16);
|
||||
frskyData.hub.sec =(uint16_t) ((gps_time_date & 0x0000ff00)>>8);
|
||||
frskyData.hub.hour = ((uint8_t)(frskyData.hub.hour + g_eeGeneral.timezone + 24)) % 24;
|
||||
}
|
||||
}
|
||||
else if(appId>=GPS_COURS_FIRST_ID && appId<=GPS_COURS_LAST_ID) {
|
||||
uint32_t course = SPORT_DATA_U32(packet);
|
||||
frskyData.hub.gpsCourse_bp = course/100;
|
||||
frskyData.hub.gpsCourse_ap = course%100;
|
||||
}
|
||||
else if (appId>=GPS_ALT_FIRST_ID && appId<=GPS_ALT_LAST_ID) {
|
||||
int32_t gps_altitude;
|
||||
gps_altitude = SPORT_DATA_S32(packet);
|
||||
frskyData.hub.gpsAltitude_bp = gps_altitude;
|
||||
|
||||
if (!frskyData.hub.gpsAltitudeOffset)
|
||||
frskyData.hub.gpsAltitudeOffset = -frskyData.hub.gpsAltitude_bp;
|
||||
|
||||
frskyData.hub.gpsAltitude_bp += frskyData.hub.gpsAltitudeOffset;
|
||||
|
||||
if (!frskyData.hub.baroAltitudeOffset) {
|
||||
if (frskyData.hub.gpsAltitude_bp > frskyData.hub.maxAltitude*100)
|
||||
frskyData.hub.maxAltitude = frskyData.hub.gpsAltitude_bp/100;
|
||||
|
||||
if (frskyData.hub.gpsAltitude_bp < frskyData.hub.minAltitude*100)
|
||||
frskyData.hub.minAltitude = frskyData.hub.gpsAltitude_bp/100;
|
||||
}
|
||||
|
||||
if (!frskyData.hub.pilotLatitude && !frskyData.hub.pilotLongitude) {
|
||||
// First received GPS position => Pilot GPS position
|
||||
if(t_coor)
|
||||
getGpsPilotPosition();
|
||||
}
|
||||
else if (frskyData.hub.gpsDistNeeded || g_menuStack[g_menuStackPtr] == menuTelemetryFrsky) {
|
||||
getGpsDistance();
|
||||
}
|
||||
}
|
||||
else if(appId>=GPS_LONG_LATI_FIRST_ID && appId<=GPS_LONG_LATI_LAST_ID) {
|
||||
uint32_t gps_long_lati_data = SPORT_DATA_U32(packet);
|
||||
if (gps_long_lati_data)
|
||||
{
|
||||
frskyData.hub.gpsFix = 1;
|
||||
t_coor = 1;
|
||||
}
|
||||
|
||||
uint32_t gps_long_lati_b1w,gps_long_lati_a1w;
|
||||
gps_long_lati_b1w = (gps_long_lati_data&0x3fffffff)/10000;
|
||||
gps_long_lati_a1w = (gps_long_lati_data&0x3fffffff)%10000;
|
||||
switch ((gps_long_lati_data & 0xc0000000)>>30) {
|
||||
case 0: {
|
||||
frskyData.hub.gpsLatitude_bp = (gps_long_lati_b1w/60*100)+(gps_long_lati_b1w%60);
|
||||
frskyData.hub.gpsLatitude_ap = gps_long_lati_a1w;
|
||||
frskyData.hub.gpsLatitudeNS = 'N';
|
||||
}break;
|
||||
case 1: {
|
||||
frskyData.hub.gpsLatitude_bp = (gps_long_lati_b1w/60*100) + (gps_long_lati_b1w%60);
|
||||
frskyData.hub.gpsLatitude_ap = gps_long_lati_a1w;
|
||||
frskyData.hub.gpsLatitudeNS = 'S'; }break;
|
||||
case 2: {
|
||||
frskyData.hub.gpsLongitude_bp = (gps_long_lati_b1w/60*100) +(gps_long_lati_b1w%60);
|
||||
frskyData.hub.gpsLongitude_ap = gps_long_lati_a1w;
|
||||
frskyData.hub.gpsLongitudeEW = 'E'; }break;
|
||||
case 3: {
|
||||
frskyData.hub.gpsLongitude_bp = (gps_long_lati_b1w/60*100) +(gps_long_lati_b1w%60);
|
||||
frskyData.hub.gpsLongitude_ap = gps_long_lati_a1w;
|
||||
frskyData.hub.gpsLongitudeEW = 'W';}break;
|
||||
}
|
||||
if (frskyData.hub.gpsFix > 0 && frskyData.hub.gpsLatitude_bp > 1)
|
||||
frskyData.hub.gpsFix = 0;
|
||||
if (frskyData.hub.gpsFix > 0 && frskyData.hub.gpsLongitude_bp > 1)
|
||||
frskyData.hub.gpsFix = 0;
|
||||
}
|
||||
|
||||
else if (appId >= CELLS_FIRST_ID && appId <= CELLS_LAST_ID) {
|
||||
uint32_t cells = SPORT_DATA_U32(packet);
|
||||
uint8_t battnumber = cells & 0xF;
|
||||
|
|
|
@ -173,12 +173,16 @@ bool FRSKY_alarmRaised(uint8_t idx);
|
|||
|
||||
void resetTelemetry();
|
||||
|
||||
#define TELEMETRY_GPS_SPEED_BP frskyData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP frskyData.hub.gpsSpeed_ap
|
||||
#define TELEMETRY_GPS_SPEED_LOG frskyData.hub.gpsSpeed_bp<0?'-':' ',abs(frskyData.hub.gpsSpeed_bp/1000),abs(frskyData.hub.gpsSpeed_bp%1000)
|
||||
|
||||
#define TELEMETRY_GPS_ALT_AP (frskyData.hub.gpsAltitude_bp%100)
|
||||
#define TELEMETRY_GPS_ALT_BP (frskyData.hub.gpsAltitude_bp/100)
|
||||
#define TELEMETRY_GPS_ALT_LOG frskyData.hub.gpsAltitude_bp < 0 ? '-':' ',abs(frskyData.hub.gpsAltitude_bp/100),abs(frskyData.hub.gpsAltitude_bp%100)
|
||||
|
||||
#define TELEMETRY_ALT_BP (frskyData.hub.baroAltitude / 100)
|
||||
#define TELEMETRY_ALT_AP (frskyData.hub.baroAltitude % 100)
|
||||
#define TELEMETRY_GPS_SPEED_BP frskyData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP frskyData.hub.gpsSpeed_ap
|
||||
#define TELEMETRY_GPS_ALT_AP frskyData.hub.gpsAltitude_ap
|
||||
#define TELEMETRY_GPS_ALT_BP frskyData.hub.gpsAltitude_bp
|
||||
#define TELEMETRY_ALT frskyData.hub.baroAltitude < 0 ? '-' : ' ', abs(frskyData.hub.baroAltitude / 100), abs(frskyData.hub.baroAltitude % 100)
|
||||
#define TELEMETRY_ALT_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_CELLS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue