Trim aoview_serial_set_callback args down to just port and callback
[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 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <fcntl.h>
32 #include <err.h>
33 #include <errno.h>
34 #include <getopt.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <assert.h>
38 #include <math.h>
39
40 #include <gtk/gtk.h>
41 #include <glade/glade.h>
42 #include <gconf/gconf-client.h>
43
44 struct usbdev {
45         char    *sys;
46         char    *tty;
47         char    *manufacturer;
48         char    *product;
49         char    *serial;
50         int     idProduct;
51         int     idVendor;
52 };
53
54 struct aodata {
55         char    callsign[16];
56         int     serial;
57         int     rssi;
58         char    state[16];
59         int     tick;
60         int     accel;
61         int     pres;
62         int     temp;
63         int     batt;
64         int     drogue;
65         int     main;
66         int     flight_accel;
67         int     ground_accel;
68         int     flight_vel;
69         int     flight_pres;
70         int     ground_pres;
71         int     nsat;
72         int     gps_locked;
73         int     gps_connected;
74         struct {
75                 int hour;
76                 int minute;
77                 int second;
78         } gps_time;
79         double  lat;            /* degrees (+N -S) */
80         double  lon;            /* degrees (+E -W) */
81         int     alt;            /* m */
82         double  ground_speed;   /* m/s */
83         int     course;         /* degrees */
84         double  climb_rate;     /* m/s */
85         double  hdop;           /* unitless? */
86         int     h_error;        /* m */
87         int     v_error;        /* m */
88 };
89
90 struct aostate {
91         struct aodata   data;
92
93         /* derived data */
94
95         struct aodata   prev_data;
96
97         double          report_time;
98
99         gboolean        ascent; /* going up? */
100
101         int     ground_altitude;
102         int     height;
103         double  speed;
104         double  acceleration;
105         double  battery;
106         double  temperature;
107         double  main_sense;
108         double  drogue_sense;
109         double  baro_speed;
110
111         int     max_height;
112         double  max_acceleration;
113         double  max_speed;
114
115         double  lat;
116         double  lon;
117         int     gps_valid;
118
119         double  pad_lat;
120         double  pad_lon;
121         double  pad_alt;
122         double  pad_lat_total;
123         double  pad_lon_total;
124         double  pad_alt_total;
125         int     npad;
126         int     prev_npad;
127
128         double  distance;
129         double  bearing;
130         int     gps_height;
131
132         int     speak_tick;
133         int     speak_altitude;
134 };
135
136 extern struct aostate aostate;
137
138 /* GPS is 'stable' when we've seen at least this many samples */
139 #define MIN_PAD_SAMPLES 10
140
141 void
142 aoview_monitor_disconnect(void);
143
144 gboolean
145 aoview_monitor_connect(char *tty);
146
147 gboolean
148 aoview_monitor_parse(const char *line);
149
150 void
151 aoview_monitor_reset(void);
152
153 struct aoview_serial *
154 aoview_serial_open(const char *tty);
155
156 void
157 aoview_serial_close(struct aoview_serial *serial);
158
159 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
160
161 void
162 aoview_serial_set_callback(struct aoview_serial *serial,
163                            aoview_serial_callback func);
164
165 void
166 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
167
168 int
169 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
170
171 int
172 aoview_serial_getc(struct aoview_serial *serial);
173
174 void
175 aoview_dev_dialog_init(GladeXML *xml);
176
177 int
178 aoview_usb_scan(struct usbdev ***devs_ret);
179
180 void
181 aoview_usbdev_free(struct usbdev *usbdev);
182
183 void
184 aoview_state_notify(struct aodata *data);
185
186 void
187 aoview_state_new(void);
188
189 void
190 aoview_state_init(GladeXML *xml);
191
192 int16_t
193 aoview_pres_to_altitude(int16_t pres);
194
195 int16_t
196 aoview_altitude_to_pres(int16_t alt);
197
198 char *
199 aoview_fullname (char *dir, char *file);
200
201 char *
202 aoview_basename(char *file);
203
204 GtkTreeViewColumn *
205 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
206
207 int
208 aoview_mkdir(char *dir);
209
210 void
211 aoview_log_init(GladeXML *xml);
212
213 void
214 aoview_log_set_serial(int serial);
215
216 int
217 aoview_log_get_serial(void);
218
219 void
220 aoview_log_printf(char *format, ...);
221
222 void
223 aoview_log_new(void);
224
225 void
226 aoview_table_start(void);
227
228 void
229 aoview_table_add_row(int column, char *label, char *format, ...);
230
231 void
232 aoview_table_finish(void);
233
234 void
235 aoview_table_init(GladeXML *xml);
236
237 void
238 aoview_table_clear(void);
239
240 struct aoview_file;
241
242 extern char *aoview_file_dir;
243
244 void
245 aoview_file_finish(struct aoview_file *file);
246
247 gboolean
248 aoview_file_start(struct aoview_file *file);
249
250 const char *
251 aoview_file_name(struct aoview_file *file);
252
253 void
254 aoview_file_set_serial(struct aoview_file *file, int serial);
255
256 int
257 aoview_file_get_serial(struct aoview_file *file);
258
259 void
260 aoview_file_printf(struct aoview_file *file, char *format, ...);
261
262 void
263 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
264
265 struct aoview_file *
266 aoview_file_new(char *ext);
267
268 void
269 aoview_file_destroy(struct aoview_file *file);
270
271 void
272 aoview_file_init(GladeXML *xml);
273
274 /* aoview_eeprom.c */
275
276 gboolean
277 aoview_eeprom_save(const char *device);
278
279 void
280 aoview_eeprom_init(GladeXML *xml);
281
282 /* aoview_voice.c */
283 void aoview_voice_open(void);
284
285 void aoview_voice_close(void);
286
287 void aoview_voice_speak(char *format, ...);
288
289 /* aoview_label.c */
290
291 void aoview_label_init(GladeXML *xml);
292
293 void
294 aoview_label_show(struct aostate *state);
295
296 /* aoview_flite.c */
297
298 FILE *
299 aoview_flite_start(void);
300
301 void
302 aoview_flite_stop(void);
303
304 #endif /* _AOVIEW_H_ */