b937df7c51575eee2482e8e2d424c85f3bbbedcb
[fw/altos] / ao-tools / 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 "cc.h"
41
42 #include <gtk/gtk.h>
43 #include <glade/glade.h>
44 #include <gconf/gconf-client.h>
45
46 struct aostate {
47         struct cc_telem data;
48
49         /* derived data */
50
51         struct cc_telem prev_data;
52
53         double          report_time;
54
55         gboolean        ascent; /* going up? */
56
57         int     ground_altitude;
58         int     height;
59         double  speed;
60         double  acceleration;
61         double  battery;
62         double  temperature;
63         double  main_sense;
64         double  drogue_sense;
65         double  baro_speed;
66
67         int     max_height;
68         double  max_acceleration;
69         double  max_speed;
70
71         struct cc_gps   gps;
72         struct cc_gps_tracking  gps_tracking;
73
74         int     gps_valid;
75         double  pad_lat;
76         double  pad_lon;
77         double  pad_alt;
78         double  pad_lat_total;
79         double  pad_lon_total;
80         double  pad_alt_total;
81         int     npad;
82         int     prev_npad;
83
84         double  distance;
85         double  bearing;
86         int     gps_height;
87
88         int     speak_tick;
89         int     speak_altitude;
90 };
91
92 extern struct aostate aostate;
93
94 /* GPS is 'stable' when we've seen at least this many samples */
95 #define MIN_PAD_SAMPLES 10
96
97 void
98 aoview_monitor_disconnect(void);
99
100 gboolean
101 aoview_monitor_connect(char *tty);
102
103 gboolean
104 aoview_monitor_parse(const char *line);
105
106 void
107 aoview_monitor_set_channel(int channel);
108
109 void
110 aoview_monitor_reset(void);
111
112 struct aoview_serial *
113 aoview_serial_open(const char *tty);
114
115 void
116 aoview_serial_close(struct aoview_serial *serial);
117
118 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
119
120 void
121 aoview_serial_set_callback(struct aoview_serial *serial,
122                            aoview_serial_callback func);
123
124 void
125 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
126
127 int
128 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
129
130 int
131 aoview_serial_getc(struct aoview_serial *serial);
132
133 void
134 aoview_dev_dialog_init(GladeXML *xml);
135
136 void
137 aoview_state_notify(struct cc_telem *data);
138
139 void
140 aoview_state_new(void);
141
142 void
143 aoview_state_init(GladeXML *xml);
144
145 int16_t
146 aoview_pres_to_altitude(int16_t pres);
147
148 int16_t
149 aoview_altitude_to_pres(int16_t alt);
150
151 char *
152 aoview_fullname (char *dir, char *file);
153
154 char *
155 aoview_basename(char *file);
156
157 GtkTreeViewColumn *
158 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
159
160 int
161 aoview_mkdir(char *dir);
162
163 void
164 aoview_log_init(GladeXML *xml);
165
166 void
167 aoview_log_set_serial(int serial);
168
169 int
170 aoview_log_get_serial(void);
171
172 void
173 aoview_log_printf(char *format, ...);
174
175 void
176 aoview_log_new(void);
177
178 void
179 aoview_table_start(void);
180
181 void
182 aoview_table_add_row(int column, char *label, char *format, ...);
183
184 void
185 aoview_table_finish(void);
186
187 void
188 aoview_table_init(GladeXML *xml);
189
190 void
191 aoview_table_clear(void);
192
193 struct aoview_file;
194
195 extern char *aoview_file_dir;
196
197 void
198 aoview_file_finish(struct aoview_file *file);
199
200 gboolean
201 aoview_file_start(struct aoview_file *file);
202
203 const char *
204 aoview_file_name(struct aoview_file *file);
205
206 void
207 aoview_file_set_serial(struct aoview_file *file, int serial);
208
209 int
210 aoview_file_get_serial(struct aoview_file *file);
211
212 void
213 aoview_file_printf(struct aoview_file *file, char *format, ...);
214
215 void
216 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
217
218 struct aoview_file *
219 aoview_file_new(char *ext);
220
221 void
222 aoview_file_destroy(struct aoview_file *file);
223
224 void
225 aoview_file_init(GladeXML *xml);
226
227 /* aoview_eeprom.c */
228
229 gboolean
230 aoview_eeprom_save(const char *device);
231
232 void
233 aoview_eeprom_init(GladeXML *xml);
234
235 /* aoview_voice.c */
236 void aoview_voice_open(void);
237
238 void aoview_voice_close(void);
239
240 void aoview_voice_speak(char *format, ...);
241
242 /* aoview_label.c */
243
244 void aoview_label_init(GladeXML *xml);
245
246 void
247 aoview_label_show(struct aostate *state);
248
249 /* aoview_flite.c */
250
251 FILE *
252 aoview_flite_start(void);
253
254 void
255 aoview_flite_stop(void);
256
257 /* aoview_main.c */
258
259 extern char *aoview_tty;
260
261 /* aoview_channel.c */
262
263 int
264 aoview_channel_current(void);
265
266 void
267 aoview_channel_init(GladeXML *xml);
268
269 #endif /* _AOVIEW_H_ */