pixmap file should not be executable
[fw/altos] / ao-view / 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 aogps_time {
55         int hour;
56         int minute;
57         int second;
58 };
59
60 struct aogps {
61         int     nsat;
62         int     gps_locked;
63         int     gps_connected;
64         struct aogps_time gps_time;
65         double  lat;            /* degrees (+N -S) */
66         double  lon;            /* degrees (+E -W) */
67         int     alt;            /* m */
68
69         int     gps_extended;   /* has extra data */
70         double  ground_speed;   /* m/s */
71         int     course;         /* degrees */
72         double  climb_rate;     /* m/s */
73         double  hdop;           /* unitless? */
74         int     h_error;        /* m */
75         int     v_error;        /* m */
76 };
77
78 #define SIRF_SAT_STATE_ACQUIRED                 (1 << 0)
79 #define SIRF_SAT_STATE_CARRIER_PHASE_VALID      (1 << 1)
80 #define SIRF_SAT_BIT_SYNC_COMPLETE              (1 << 2)
81 #define SIRF_SAT_SUBFRAME_SYNC_COMPLETE         (1 << 3)
82 #define SIRF_SAT_CARRIER_PULLIN_COMPLETE        (1 << 4)
83 #define SIRF_SAT_CODE_LOCKED                    (1 << 5)
84 #define SIRF_SAT_ACQUISITION_FAILED             (1 << 6)
85 #define SIRF_SAT_EPHEMERIS_AVAILABLE            (1 << 7)
86
87 struct aogps_sat {
88         int     svid;
89         int     state;
90         int     c_n0;
91 };
92
93 struct aogps_tracking {
94         int                     channels;
95         struct aogps_sat        sats[12];
96 };
97
98 struct aodata {
99         char    callsign[16];
100         int     serial;
101         int     rssi;
102         char    state[16];
103         int     tick;
104         int     accel;
105         int     pres;
106         int     temp;
107         int     batt;
108         int     drogue;
109         int     main;
110         int     flight_accel;
111         int     ground_accel;
112         int     flight_vel;
113         int     flight_pres;
114         int     ground_pres;
115         struct aogps    gps;
116         struct aogps_tracking   gps_tracking;
117 };
118
119 struct aostate {
120         struct aodata   data;
121
122         /* derived data */
123
124         struct aodata   prev_data;
125
126         double          report_time;
127
128         gboolean        ascent; /* going up? */
129
130         int     ground_altitude;
131         int     height;
132         double  speed;
133         double  acceleration;
134         double  battery;
135         double  temperature;
136         double  main_sense;
137         double  drogue_sense;
138         double  baro_speed;
139
140         int     max_height;
141         double  max_acceleration;
142         double  max_speed;
143
144         struct aogps    gps;
145         struct aogps_tracking   gps_tracking;
146
147         int     gps_valid;
148         double  pad_lat;
149         double  pad_lon;
150         double  pad_alt;
151         double  pad_lat_total;
152         double  pad_lon_total;
153         double  pad_alt_total;
154         int     npad;
155         int     prev_npad;
156
157         double  distance;
158         double  bearing;
159         int     gps_height;
160
161         int     speak_tick;
162         int     speak_altitude;
163 };
164
165 extern struct aostate aostate;
166
167 /* GPS is 'stable' when we've seen at least this many samples */
168 #define MIN_PAD_SAMPLES 10
169
170 void
171 aoview_monitor_disconnect(void);
172
173 gboolean
174 aoview_monitor_connect(char *tty);
175
176 gboolean
177 aoview_monitor_parse(const char *line);
178
179 void
180 aoview_monitor_reset(void);
181
182 struct aoview_serial *
183 aoview_serial_open(const char *tty);
184
185 void
186 aoview_serial_close(struct aoview_serial *serial);
187
188 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
189
190 void
191 aoview_serial_set_callback(struct aoview_serial *serial,
192                            aoview_serial_callback func);
193
194 void
195 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
196
197 int
198 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
199
200 int
201 aoview_serial_getc(struct aoview_serial *serial);
202
203 void
204 aoview_dev_dialog_init(GladeXML *xml);
205
206 int
207 aoview_usb_scan(struct usbdev ***devs_ret);
208
209 void
210 aoview_usbdev_free(struct usbdev *usbdev);
211
212 void
213 aoview_state_notify(struct aodata *data);
214
215 void
216 aoview_state_new(void);
217
218 void
219 aoview_state_init(GladeXML *xml);
220
221 int16_t
222 aoview_pres_to_altitude(int16_t pres);
223
224 int16_t
225 aoview_altitude_to_pres(int16_t alt);
226
227 char *
228 aoview_fullname (char *dir, char *file);
229
230 char *
231 aoview_basename(char *file);
232
233 GtkTreeViewColumn *
234 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
235
236 int
237 aoview_mkdir(char *dir);
238
239 void
240 aoview_log_init(GladeXML *xml);
241
242 void
243 aoview_log_set_serial(int serial);
244
245 int
246 aoview_log_get_serial(void);
247
248 void
249 aoview_log_printf(char *format, ...);
250
251 void
252 aoview_log_new(void);
253
254 void
255 aoview_table_start(void);
256
257 void
258 aoview_table_add_row(int column, char *label, char *format, ...);
259
260 void
261 aoview_table_finish(void);
262
263 void
264 aoview_table_init(GladeXML *xml);
265
266 void
267 aoview_table_clear(void);
268
269 struct aoview_file;
270
271 extern char *aoview_file_dir;
272
273 void
274 aoview_file_finish(struct aoview_file *file);
275
276 gboolean
277 aoview_file_start(struct aoview_file *file);
278
279 const char *
280 aoview_file_name(struct aoview_file *file);
281
282 void
283 aoview_file_set_serial(struct aoview_file *file, int serial);
284
285 int
286 aoview_file_get_serial(struct aoview_file *file);
287
288 void
289 aoview_file_printf(struct aoview_file *file, char *format, ...);
290
291 void
292 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
293
294 struct aoview_file *
295 aoview_file_new(char *ext);
296
297 void
298 aoview_file_destroy(struct aoview_file *file);
299
300 void
301 aoview_file_init(GladeXML *xml);
302
303 /* aoview_eeprom.c */
304
305 gboolean
306 aoview_eeprom_save(const char *device);
307
308 void
309 aoview_eeprom_init(GladeXML *xml);
310
311 /* aoview_voice.c */
312 void aoview_voice_open(void);
313
314 void aoview_voice_close(void);
315
316 void aoview_voice_speak(char *format, ...);
317
318 /* aoview_label.c */
319
320 void aoview_label_init(GladeXML *xml);
321
322 void
323 aoview_label_show(struct aostate *state);
324
325 /* aoview_flite.c */
326
327 FILE *
328 aoview_flite_start(void);
329
330 void
331 aoview_flite_stop(void);
332
333 /* aoview_main.c */
334
335 extern char *aoview_tty;
336
337 #endif /* _AOVIEW_H_ */