Use flite to announce flight state
[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
88 void
89 aoview_monitor_disconnect(void);
90
91 gboolean
92 aoview_monitor_connect(char *tty);
93
94 struct aoview_serial *
95 aoview_serial_open(const char *tty);
96
97 void
98 aoview_serial_close(struct aoview_serial *serial);
99
100 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
101
102 void
103 aoview_serial_set_callback(struct aoview_serial *serial,
104                            aoview_serial_callback func,
105                            gpointer data,
106                            GDestroyNotify notify);
107
108 void
109 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
110
111 int
112 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
113
114 int
115 aoview_serial_getc(struct aoview_serial *serial);
116
117 void
118 aoview_dev_dialog_init(GladeXML *xml);
119
120 int
121 aoview_usb_scan(struct usbdev ***devs_ret);
122
123 void
124 aoview_usbdev_free(struct usbdev *usbdev);
125
126 void
127 aoview_state_notify(struct aostate *state);
128
129 void
130 aoview_state_new(void);
131
132 void
133 aoview_state_init(GladeXML *xml);
134
135 int16_t
136 aoview_pres_to_altitude(int16_t pres);
137
138 int16_t
139 aoview_altitude_to_pres(int16_t alt);
140
141 char *
142 aoview_fullname (char *dir, char *file);
143
144 char *
145 aoview_basename(char *file);
146
147 GtkTreeViewColumn *
148 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
149
150 int
151 aoview_mkdir(char *dir);
152
153 void
154 aoview_log_init(GladeXML *xml);
155
156 void
157 aoview_log_set_serial(int serial);
158
159 int
160 aoview_log_get_serial(void);
161
162 void
163 aoview_log_printf(char *format, ...);
164
165 void
166 aoview_log_new(void);
167
168 void
169 aoview_table_start(void);
170
171 void
172 aoview_table_add_row(char *label, char *format, ...);
173
174 void
175 aoview_table_finish(void);
176
177 void
178 aoview_table_init(GladeXML *xml);
179
180 void
181 aoview_table_clear(void);
182
183 struct aoview_file;
184
185 void
186 aoview_file_finish(struct aoview_file *file);
187
188 gboolean
189 aoview_file_start(struct aoview_file *file);
190
191 const char *
192 aoview_file_name(struct aoview_file *file);
193
194 void
195 aoview_file_set_serial(struct aoview_file *file, int serial);
196
197 int
198 aoview_file_get_serial(struct aoview_file *file);
199
200 void
201 aoview_file_printf(struct aoview_file *file, char *format, ...);
202
203 void
204 aoview_file_vprintf(struct aoview_file *file, char *format, va_list ap);
205
206 struct aoview_file *
207 aoview_file_new(char *ext);
208
209 void
210 aoview_file_destroy(struct aoview_file *file);
211
212 void
213 aoview_file_init(GladeXML *xml);
214
215 /* aoview_eeprom.c */
216
217 gboolean
218 aoview_eeprom_save(const char *device);
219
220 void
221 aoview_eeprom_init(GladeXML *xml);
222
223 /* aoview_voice.c */
224 void aoview_voice_open(void);
225
226 void aoview_voice_close(void);
227
228 void aoview_voice_speak(char *format, ...);
229
230 #endif /* _AOVIEW_H_ */