2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
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.
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.
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.
26 uint16_t minutes_fraction;
30 ao_gps_split(int32_t v, __xdata struct ao_gps_split *split) __reentrant
39 split->degrees = v / 10000000;
40 minutes_e7 = (v % 10000000) * 60;
41 split->minutes = minutes_e7 / 10000000;
42 split->minutes_fraction = (minutes_e7 % 10000000) / 1000;
46 ao_gps_print(__xdata struct ao_gps_data *gps_data) __reentrant
49 (gps_data->flags & AO_GPS_NUM_SAT_MASK) >> AO_GPS_NUM_SAT_SHIFT);
50 if (gps_data->flags & AO_GPS_VALID) {
51 static __xdata struct ao_gps_split lat, lon;
52 int16_t climb, climb_int, climb_frac;
54 ao_gps_split(gps_data->latitude, &lat);
55 ao_gps_split(gps_data->longitude, &lon);
56 if (gps_data->flags & AO_GPS_DATE_VALID)
57 printf(" 20%02d-%02d-%02d",
62 printf (" 0000-00-00");
63 printf(" %2d:%02d:%02d",
67 printf(" %2d°%02d.%04d'%c %2d°%02d.%04d'%c %5dm",
71 lat.positive ? 'N' : 'S',
75 lon.positive ? 'E' : 'W',
77 climb = gps_data->climb_rate;
79 climb_int = climb / 100;
80 climb_frac = climb % 100;
83 climb_int = -(climb / 100);
84 climb_frac = climb % 100;
86 printf(" %5u.%02dm/s(H) %d° %5d.%02dm/s(V)",
87 gps_data->ground_speed / 100,
88 gps_data->ground_speed % 100,
92 printf(" %d.%d(hdop) %5u(herr) %5u(verr)",
94 (gps_data->hdop * 2) % 10,
97 } else if (gps_data->flags & AO_GPS_RUNNING) {
100 printf (" not-connected");
105 ao_gps_tracking_print(__xdata struct ao_gps_tracking_data *gps_tracking_data) __reentrant
108 __xdata struct ao_gps_sat_data *sat;
110 n = gps_tracking_data->channels;
112 printf("not-connected");
115 sat = gps_tracking_data->sats;
117 for (c = 0; c < n; c++) {
123 sat = gps_tracking_data->sats;
124 for (c = 0; c < n; c++) {