d49bd6f4968e656d45a5ecc4194f0773a605cf27
[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 };
115
116 /* GPS is 'stable' when we've seen at least this many samples */
117 #define MIN_PAD_SAMPLES 10
118
119 void
120 aoview_monitor_disconnect(void);
121
122 gboolean
123 aoview_monitor_connect(char *tty);
124
125 gboolean
126 aoview_monitor_parse(char *line);
127
128 struct aoview_serial *
129 aoview_serial_open(const char *tty);
130
131 void
132 aoview_serial_close(struct aoview_serial *serial);
133
134 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
135
136 void
137 aoview_serial_set_callback(struct aoview_serial *serial,
138                            aoview_serial_callback func,
139                            gpointer data,
140                            GDestroyNotify notify);
141
142 void
143 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
144
145 int
146 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
147
148 int
149 aoview_serial_getc(struct aoview_serial *serial);
150
151 void
152 aoview_dev_dialog_init(GladeXML *xml);
153
154 int
155 aoview_usb_scan(struct usbdev ***devs_ret);
156
157 void
158 aoview_usbdev_free(struct usbdev *usbdev);
159
160 void
161 aoview_state_notify(struct aostate *state);
162
163 void
164 aoview_state_new(void);
165
166 void
167 aoview_state_init(GladeXML *xml);
168
169 int16_t
170 aoview_pres_to_altitude(int16_t pres);
171
172 int16_t
173 aoview_altitude_to_pres(int16_t alt);
174
175 char *
176 aoview_fullname (char *dir, char *file);
177
178 char *
179 aoview_basename(char *file);
180
181 GtkTreeViewColumn *
182 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
183
184 int
185 aoview_mkdir(char *dir);
186
187 void
188 aoview_log_init(GladeXML *xml);
189
190 void
191 aoview_log_set_serial(int serial);
192
193 int
194 aoview_log_get_serial(void);
195
196 void
197 aoview_log_printf(char *format, ...);
198
199 void
200 aoview_log_new(void);
201
202 void
203 aoview_table_start(void);
204
205 void
206 aoview_table_add_row(char *label, char *format, ...);
207
208 void
209 aoview_table_finish(void);
210
211 void
212 aoview_table_init(GladeXML *xml);
213
214 void
215 aoview_table_clear(void);
216
217 struct aoview_file;
218
219 extern char *aoview_file_dir;
220
221 void
222 aoview_file_finish(struct aoview_file *file);
223
224 gboolean
225 aoview_file_start(struct aoview_file *file);
226
227 const char *
228 aoview_file_name(struct aoview_file *file);
229
230 void
231 aoview_file_set_serial(struct aoview_file *file, int serial);
232
233 int
234 aoview_file_get_serial(struct aoview_file *file);
235
236 void
237 aoview_file_printf(struct aoview_file *file, char *format, ...);
238
239 void
240 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
241
242 struct aoview_file *
243 aoview_file_new(char *ext);
244
245 void
246 aoview_file_destroy(struct aoview_file *file);
247
248 void
249 aoview_file_init(GladeXML *xml);
250
251 /* aoview_eeprom.c */
252
253 gboolean
254 aoview_eeprom_save(const char *device);
255
256 void
257 aoview_eeprom_init(GladeXML *xml);
258
259 /* aoview_voice.c */
260 void aoview_voice_open(void);
261
262 void aoview_voice_close(void);
263
264 void aoview_voice_speak(char *format, ...);
265
266 /* aoview_label.c */
267
268 void aoview_label_init(GladeXML *xml);
269
270 void
271 aoview_label_show(struct aostate *state);
272
273 #endif /* _AOVIEW_H_ */