Add preliminary aoview code
[fw/altos] / aoview / aoview.h
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 _AOVIEW_H_
19 #define _AOVIEW_H_
20
21 #include <gtk/gtk.h>
22 #include <glade/glade.h>
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <err.h>
30 #include <errno.h>
31 #include <getopt.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <assert.h>
35
36 struct usbdev {
37         char    *sys;
38         char    *tty;
39         char    *manufacturer;
40         char    *product;
41         char    *serial;
42         int     idProduct;
43         int     idVendor;
44 };
45
46 struct aostate {
47         char    callsign[16];
48         int     serial;
49         int     rssi;
50         char    state[16];
51         int     tick;
52         int     accel;
53         int     pres;
54         int     temp;
55         int     batt;
56         int     drogue;
57         int     main;
58         int     nsat;
59         int     locked;
60         struct {
61                 int hour;
62                 int minute;
63                 int second;
64         } gps_time;
65         double  lat;
66         double  lon;
67         int     alt;
68 };
69
70 void
71 aoview_monitor_disconnect(void);
72
73 void
74 aoview_monitor_connect(char *tty);
75
76 struct aoview_serial *
77 aoview_serial_open(const char *tty);
78
79 void
80 aoview_serial_close(struct aoview_serial *serial);
81
82 void
83 aoview_serial_set_callback(struct aoview_serial *serial,
84                            GSourceFunc func,
85                            gpointer data,
86                            GDestroyNotify notify);
87
88 void
89 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
90
91 int
92 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
93
94 int
95 aoview_serial_getc(struct aoview_serial *serial);
96
97 void
98 aoview_dev_dialog_init(GladeXML *xml);
99
100 int
101 aoview_usb_scan(struct usbdev ***devs_ret);
102
103 void
104 aoview_usbdev_free(struct usbdev *usbdev);
105
106 void
107 aoview_state_notify(struct aostate *state);
108
109 void
110 aoview_state_init(GladeXML *xml);
111
112 int16_t
113 aoview_pres_to_altitude(int16_t pres);
114
115 int16_t
116 aoview_altitude_to_pres(int16_t alt);
117
118 #endif /* _AOVIEW_H_ */