]> git.gag.com Git - fw/altos/blob - ao-tools/ao-view/aoview.h
telebt-v4.0: initial creation of firmware for new product, no BT yet
[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; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AOVIEW_H_
20 #define _AOVIEW_H_
21
22 #define _GNU_SOURCE
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <unistd.h>
32 #include <fcntl.h>
33 #include <err.h>
34 #include <errno.h>
35 #include <getopt.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <assert.h>
39 #include <math.h>
40
41 #include "cc.h"
42
43 #include <gtk/gtk.h>
44 #include <glade/glade.h>
45 #include <gconf/gconf-client.h>
46
47 struct aostate {
48         struct cc_telem data;
49
50         /* derived data */
51
52         struct cc_telem prev_data;
53
54         double          report_time;
55
56         gboolean        ascent; /* going up? */
57
58         int     ground_altitude;
59         int     height;
60         double  speed;
61         double  acceleration;
62         double  battery;
63         double  temperature;
64         double  main_sense;
65         double  drogue_sense;
66         double  baro_speed;
67
68         int     max_height;
69         double  max_acceleration;
70         double  max_speed;
71
72         struct cc_gps   gps;
73         struct cc_gps_tracking  gps_tracking;
74
75         int     gps_valid;
76         double  pad_lat;
77         double  pad_lon;
78         double  pad_alt;
79         double  pad_lat_total;
80         double  pad_lon_total;
81         double  pad_alt_total;
82         int     npad;
83         int     prev_npad;
84
85         double  distance;
86         double  bearing;
87         int     gps_height;
88
89         int     speak_tick;
90         int     speak_altitude;
91 };
92
93 extern struct aostate aostate;
94
95 /* GPS is 'stable' when we've seen at least this many samples */
96 #define MIN_PAD_SAMPLES 10
97
98 void
99 aoview_monitor_disconnect(void);
100
101 gboolean
102 aoview_monitor_connect(char *tty);
103
104 gboolean
105 aoview_monitor_parse(const char *line);
106
107 void
108 aoview_monitor_set_channel(int channel);
109
110 void
111 aoview_monitor_reset(void);
112
113 struct aoview_serial *
114 aoview_serial_open(const char *tty);
115
116 void
117 aoview_serial_close(struct aoview_serial *serial);
118
119 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
120
121 void
122 aoview_serial_set_callback(struct aoview_serial *serial,
123                            aoview_serial_callback func);
124
125 void
126 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
127
128 int
129 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
130
131 int
132 aoview_serial_getc(struct aoview_serial *serial);
133
134 void
135 aoview_dev_dialog_init(GladeXML *xml);
136
137 void
138 aoview_state_notify(struct cc_telem *data);
139
140 void
141 aoview_state_new(void);
142
143 void
144 aoview_state_init(GladeXML *xml);
145
146 int16_t
147 aoview_pres_to_altitude(int16_t pres);
148
149 int16_t
150 aoview_altitude_to_pres(int16_t alt);
151
152 char *
153 aoview_fullname (char *dir, char *file);
154
155 char *
156 aoview_basename(char *file);
157
158 GtkTreeViewColumn *
159 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
160
161 int
162 aoview_mkdir(char *dir);
163
164 void
165 aoview_log_init(GladeXML *xml);
166
167 void
168 aoview_log_set_serial(int serial);
169
170 int
171 aoview_log_get_serial(void);
172
173 void
174 aoview_log_printf(char *format, ...);
175
176 void
177 aoview_log_new(void);
178
179 void
180 aoview_table_start(void);
181
182 void
183 aoview_table_add_row(int column, char *label, char *format, ...);
184
185 void
186 aoview_table_finish(void);
187
188 void
189 aoview_table_init(GladeXML *xml);
190
191 void
192 aoview_table_clear(void);
193
194 struct aoview_file;
195
196 extern char *aoview_file_dir;
197
198 void
199 aoview_file_finish(struct aoview_file *file);
200
201 gboolean
202 aoview_file_start(struct aoview_file *file);
203
204 const char *
205 aoview_file_name(struct aoview_file *file);
206
207 void
208 aoview_file_set_serial(struct aoview_file *file, int serial);
209
210 int
211 aoview_file_get_serial(struct aoview_file *file);
212
213 void
214 aoview_file_printf(struct aoview_file *file, char *format, ...);
215
216 void
217 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
218
219 struct aoview_file *
220 aoview_file_new(char *ext);
221
222 void
223 aoview_file_destroy(struct aoview_file *file);
224
225 void
226 aoview_file_init(GladeXML *xml);
227
228 /* aoview_eeprom.c */
229
230 gboolean
231 aoview_eeprom_save(const char *device);
232
233 void
234 aoview_eeprom_init(GladeXML *xml);
235
236 /* aoview_voice.c */
237 void aoview_voice_open(void);
238
239 void aoview_voice_close(void);
240
241 void aoview_voice_speak(char *format, ...);
242
243 /* aoview_label.c */
244
245 void aoview_label_init(GladeXML *xml);
246
247 void
248 aoview_label_show(struct aostate *state);
249
250 /* aoview_flite.c */
251
252 FILE *
253 aoview_flite_start(void);
254
255 void
256 aoview_flite_stop(void);
257
258 /* aoview_main.c */
259
260 extern char *aoview_tty;
261
262 /* aoview_channel.c */
263
264 int
265 aoview_channel_current(void);
266
267 void
268 aoview_channel_init(GladeXML *xml);
269
270 #endif /* _AOVIEW_H_ */