-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaza_data.ino
73 lines (53 loc) · 2.21 KB
/
naza_data.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
skyData - markab
FrSky telemetry data module for Naza and TBS frame sensors
Created based on ideas from the following projects...
https://code.google.com/p/nazatofrsky/
https://code.google.com/p/bagaosd/
https://code.google.com/p/openxvario/
*/
// ************************************************************************************
// INCLUDE
// ************************************************************************************
#include "NazaDecoderLib.h"
// ************************************************************************************
// Process Data
// ************************************************************************************
void Naza_ProcessData(void) {
if((NazaSerial.available()) && ENABLE_NAZA) {
uint8_t decoded_message = NazaDecoder.decode(NazaSerial.read());
switch (decoded_message) {
case NAZA_MESSAGE_GPS:
// process fix data
data_gps_fix_type = NazaDecoder.getFixType();
data_gps_sat_count = NazaDecoder.getNumSat();
if(data_gps_fix_type == 3) {
data_gps_alt = (NazaDecoder.getAlt() * 100);
data_gps_vario = (NazaDecoder.getClimbSpeed() * 100);
// process longitude
double longitude = NazaDecoder.getLon();
int32_t longitude2 = longitude * 10000000;
if(longitude2 < 0) {
data_gps_long = ((abs(longitude2) / 100) * 6) | 0xC0000000;
}
else {
data_gps_long = ((abs(longitude2) / 100) * 6) | 0x80000000;
}
// process latitude
double latitude = NazaDecoder.getLat();
int32_t latitude2 = latitude * 10000000;
if(latitude2 < 0 ) {
data_gps_lati = ((abs(latitude2) /100 ) * 6) | 0x40000000;
}
else {
data_gps_lati = ((abs(latitude2) / 100) * 6);
}
data_gps_speed = (NazaDecoder.getSpeed() * 100);
}
break;
case NAZA_MESSAGE_COMPASS:
data_gps_cours = (NazaDecoder.getHeading() * 100);
break;
}
}
}