altos: Add delays to bt startup sequence
[fw/altos] / src / ao_gps_print.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #ifndef AO_GPS_TEST
19 #include "ao.h"
20 #endif
21 #include "ao_telem.h"
22
23 void
24 ao_gps_print(__xdata struct ao_gps_data *gps_data) __reentrant
25 {
26         char    state;
27
28         if (gps_data->flags & AO_GPS_VALID)
29                 state = AO_TELEM_GPS_STATE_LOCKED;
30         else if (gps_data->flags & AO_GPS_RUNNING)
31                 state = AO_TELEM_GPS_STATE_UNLOCKED;
32         else
33                 state = AO_TELEM_GPS_STATE_ERROR;
34         printf(AO_TELEM_GPS_STATE " %c "
35                AO_TELEM_GPS_NUM_SAT " %d ",
36                state,
37                (gps_data->flags & AO_GPS_NUM_SAT_MASK) >> AO_GPS_NUM_SAT_SHIFT);
38         if (!(gps_data->flags & AO_GPS_VALID))
39                 return;
40         printf(AO_TELEM_GPS_LATITUDE " %ld "
41                AO_TELEM_GPS_LONGITUDE " %ld "
42                AO_TELEM_GPS_ALTITUDE " %d ",
43                gps_data->latitude,
44                gps_data->longitude,
45                gps_data->altitude);
46
47         if (gps_data->flags & AO_GPS_DATE_VALID)
48                 printf(AO_TELEM_GPS_YEAR " %d "
49                        AO_TELEM_GPS_MONTH " %d "
50                        AO_TELEM_GPS_DAY " %d ",
51                        gps_data->year,
52                        gps_data->month,
53                        gps_data->day);
54
55         printf(AO_TELEM_GPS_HOUR " %d "
56                AO_TELEM_GPS_MINUTE " %d "
57                AO_TELEM_GPS_SECOND " %d ",
58                gps_data->hour,
59                gps_data->minute,
60                gps_data->second);
61
62         printf(AO_TELEM_GPS_HDOP " %d ",
63                gps_data->hdop * 2);
64
65         if (gps_data->flags & AO_GPS_COURSE_VALID) {
66                 printf(AO_TELEM_GPS_HERROR " %d "
67                        AO_TELEM_GPS_VERROR " %d "
68                        AO_TELEM_GPS_VERTICAL_SPEED " %d "
69                        AO_TELEM_GPS_HORIZONTAL_SPEED " %d "
70                        AO_TELEM_GPS_COURSE " %d ",
71                        gps_data->h_error,
72                        gps_data->v_error,
73                        gps_data->climb_rate,
74                        gps_data->ground_speed,
75                        (int) gps_data->course * 2);
76         }
77 }
78
79 void
80 ao_gps_tracking_print(__xdata struct ao_gps_tracking_data *gps_tracking_data) __reentrant
81 {
82         uint8_t c, n, v;
83         __xdata struct ao_gps_sat_data  *sat;
84
85         n = gps_tracking_data->channels;
86         if (n == 0)
87                 return;
88
89         sat = gps_tracking_data->sats;
90         v = 0;
91         for (c = 0; c < n; c++) {
92                 if (sat->svid)
93                         v++;
94                 sat++;
95         }
96
97         printf (AO_TELEM_SAT_NUM " %d ",
98                 v);
99
100         sat = gps_tracking_data->sats;
101         v = 0;
102         for (c = 0; c < n; c++) {
103                 if (sat->svid) {
104                         printf (AO_TELEM_SAT_SVID "%d %d "
105                                 AO_TELEM_SAT_C_N_0 "%d %d ",
106                                 v, sat->svid,
107                                 v, sat->c_n_1);
108                         v++;
109                 }
110                 sat++;
111         }
112 }