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 printf(" %2d:%02d:%02d",
60 printf(" %2d°%02d.%04d'%c %2d°%02d.%04d'%c %5dm",
64 lat.positive ? 'N' : 'S',
68 lon.positive ? 'E' : 'W',
70 climb = gps_data->climb_rate;
72 climb_int = climb / 100;
73 climb_frac = climb % 100;
76 climb_int = -(climb / 100);
77 climb_frac = climb % 100;
79 printf(" %5u.%02dm/s(H) %d° %5d.%02dm/s(V)",
80 gps_data->ground_speed / 100,
81 gps_data->ground_speed % 100,
85 printf(" %d.%d(hdop) %5u(herr) %5u(verr)\n",
87 (gps_data->hdop * 2) % 10,
90 } else if (gps_data->flags & AO_GPS_RUNNING) {
91 printf(" unlocked\n");
93 printf (" not-connected\n");