a3214128b480b38720a1010eaf67355a90741ce6
[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 #define _GNU_SOURCE
22
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <fcntl.h>
28 #include <err.h>
29 #include <errno.h>
30 #include <getopt.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <assert.h>
34
35 #include <gtk/gtk.h>
36 #include <glade/glade.h>
37 #include <gconf/gconf-client.h>
38
39 struct usbdev {
40         char    *sys;
41         char    *tty;
42         char    *manufacturer;
43         char    *product;
44         char    *serial;
45         int     idProduct;
46         int     idVendor;
47 };
48
49 struct aostate {
50         char    callsign[16];
51         int     serial;
52         int     rssi;
53         char    state[16];
54         int     tick;
55         int     accel;
56         int     pres;
57         int     temp;
58         int     batt;
59         int     drogue;
60         int     main;
61         int     nsat;
62         int     locked;
63         struct {
64                 int hour;
65                 int minute;
66                 int second;
67         } gps_time;
68         double  lat;
69         double  lon;
70         int     alt;
71 };
72
73 void
74 aoview_monitor_disconnect(void);
75
76 void
77 aoview_monitor_connect(char *tty);
78
79 struct aoview_serial *
80 aoview_serial_open(const char *tty);
81
82 void
83 aoview_serial_close(struct aoview_serial *serial);
84
85 void
86 aoview_serial_set_callback(struct aoview_serial *serial,
87                            GSourceFunc func,
88                            gpointer data,
89                            GDestroyNotify notify);
90
91 void
92 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
93
94 int
95 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
96
97 int
98 aoview_serial_getc(struct aoview_serial *serial);
99
100 void
101 aoview_dev_dialog_init(GladeXML *xml);
102
103 int
104 aoview_usb_scan(struct usbdev ***devs_ret);
105
106 void
107 aoview_usbdev_free(struct usbdev *usbdev);
108
109 void
110 aoview_state_notify(struct aostate *state);
111
112 void
113 aoview_state_init(GladeXML *xml);
114
115 int16_t
116 aoview_pres_to_altitude(int16_t pres);
117
118 int16_t
119 aoview_altitude_to_pres(int16_t alt);
120
121 char *
122 aoview_fullname (char *dir, char *file);
123
124 char *
125 aoview_basename(char *file);
126
127 GtkTreeViewColumn *
128 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
129
130 int
131 aoview_mkdir(char *dir);
132
133 void
134 aoview_log_init(GladeXML *xml);
135
136 void
137 aoview_log_set_serial(int serial);
138
139 int
140 aoview_log_get_serial(void);
141
142 void
143 aoview_log_printf(char *format, ...);
144
145 void
146 aoview_table_start(void);
147
148 void
149 aoview_table_add_row(char *label, char *format, ...);
150
151 void
152 aoview_table_finish(void);
153
154 void
155 aoview_table_init(GladeXML *xml);
156
157
158 #endif /* _AOVIEW_H_ */