altos: Write tracker logging from tracker thread directly
[fw/altos] / src / kernel / ao_tracker.h
1 /*
2  * Copyright © 2014 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 _AO_TRACKER_H_
19 #define _AO_TRACKER_H_
20
21 #define AO_CONFIG_DEFAULT_TRACKER_START_HORIZ   1000
22 #define AO_CONFIG_DEFAULT_TRACKER_START_VERT    100
23
24 /* Speeds for the various modes, 2m/s seems reasonable for 'not moving' */
25 #define AO_TRACKER_NOT_MOVING   200
26
27 extern int32_t  ao_tracker_start_latitude;
28 extern int32_t  ao_tracker_start_longitude;
29 extern int16_t  ao_tracker_start_altitude;
30
31 #define AO_TRACKER_RING 8
32
33 struct ao_tracker_data {
34         uint16_t                        tick;
35         uint8_t                         new;
36         uint8_t                         state;
37         struct ao_telemetry_location    gps_data;
38         struct ao_telemetry_satellite   gps_tracking_data;
39 };
40
41 extern struct ao_tracker_data   ao_tracker_data[AO_TRACKER_RING];
42 extern uint8_t                  ao_tracker_head;
43
44 #define ao_tracker_ring_next(n) (((n) + 1) & (AO_TRACKER_RING-1))
45 #define ao_tracker_ring_prev(n) (((n) - 1) & (AO_TRACKER_RING-1))
46
47 void
48 ao_tracker_init(void);
49
50 #endif /* _AO_TRACKER_H_ */