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