7824491228a4eb10dfb834961ae2311df1404525
[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 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <fcntl.h>
28 #include <err.h>
29 #include <errno.h>
30 #include <getopt.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <assert.h>
34
35 #include <gtk/gtk.h>
36 #include <glade/glade.h>
37 #include <gconf/gconf-client.h>
38
39 struct usbdev {
40         char    *sys;
41         char    *tty;
42         char    *manufacturer;
43         char    *product;
44         char    *serial;
45         int     idProduct;
46         int     idVendor;
47 };
48
49 struct aostate {
50         char    callsign[16];
51         int     serial;
52         int     rssi;
53         char    state[16];
54         int     tick;
55         int     accel;
56         int     pres;
57         int     temp;
58         int     batt;
59         int     drogue;
60         int     main;
61         int     nsat;
62         int     locked;
63         struct {
64                 int hour;
65                 int minute;
66                 int second;
67         } gps_time;
68         double  lat;
69         double  lon;
70         int     alt;
71 };
72
73 void
74 aoview_monitor_disconnect(void);
75
76 gboolean
77 aoview_monitor_connect(char *tty);
78
79 struct aoview_serial *
80 aoview_serial_open(const char *tty);
81
82 void
83 aoview_serial_close(struct aoview_serial *serial);
84
85 typedef void (*aoview_serial_callback)(gpointer user_data, struct aoview_serial *serial, gint revents);
86
87 void
88 aoview_serial_set_callback(struct aoview_serial *serial,
89                            aoview_serial_callback func,
90                            gpointer data,
91                            GDestroyNotify notify);
92
93 void
94 aoview_serial_printf(struct aoview_serial *serial, char *format, ...);
95
96 int
97 aoview_serial_read(struct aoview_serial *serial, char *buf, int len);
98
99 int
100 aoview_serial_getc(struct aoview_serial *serial);
101
102 void
103 aoview_dev_dialog_init(GladeXML *xml);
104
105 int
106 aoview_usb_scan(struct usbdev ***devs_ret);
107
108 void
109 aoview_usbdev_free(struct usbdev *usbdev);
110
111 void
112 aoview_state_notify(struct aostate *state);
113
114 void
115 aoview_state_new(void);
116
117 void
118 aoview_state_init(GladeXML *xml);
119
120 int16_t
121 aoview_pres_to_altitude(int16_t pres);
122
123 int16_t
124 aoview_altitude_to_pres(int16_t alt);
125
126 char *
127 aoview_fullname (char *dir, char *file);
128
129 char *
130 aoview_basename(char *file);
131
132 GtkTreeViewColumn *
133 aoview_add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column, gint width);
134
135 int
136 aoview_mkdir(char *dir);
137
138 void
139 aoview_log_init(GladeXML *xml);
140
141 void
142 aoview_log_set_serial(int serial);
143
144 int
145 aoview_log_get_serial(void);
146
147 void
148 aoview_log_printf(char *format, ...);
149
150 void
151 aoview_log_new(void);
152
153 void
154 aoview_table_start(void);
155
156 void
157 aoview_table_add_row(char *label, char *format, ...);
158
159 void
160 aoview_table_finish(void);
161
162 void
163 aoview_table_init(GladeXML *xml);
164
165 void
166 aoview_table_clear(void);
167
168 #endif /* _AOVIEW_H_ */