2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
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.
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.
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.
20 __xdata uint8_t ao_rdf = 0;
21 __xdata uint16_t ao_rdf_time;
22 __xdata uint16_t ao_telemetry_tiny_interval = 0;
24 #define AO_RDF_INTERVAL_TICKS AO_SEC_TO_TICKS(5)
25 #define AO_RDF_LENGTH_MS 500
28 ao_telemetry_tiny(void)
32 static __xdata struct ao_telemetry_tiny telemetry_tiny;
35 while (!ao_flight_number)
36 ao_sleep(&ao_flight_number);
37 memcpy(telemetry_tiny.callsign, ao_config.callsign, AO_MAX_CALLSIGN);
38 telemetry_tiny.serial = ao_serial_number;
39 telemetry_tiny.flight = ao_log_full() ? 0 : ao_flight_number;
41 while (ao_telemetry_tiny_interval == 0)
42 ao_sleep(&ao_telemetry_tiny_interval);
43 time = ao_rdf_time = ao_time();
44 while (ao_telemetry_tiny_interval) {
45 telemetry_tiny.flight_state = ao_flight_state;
46 telemetry_tiny.height = ao_height;
47 telemetry_tiny.speed = ao_speed;
48 telemetry_tiny.accel = ao_accel;
49 telemetry_tiny.ground_pres = ao_ground_pres;
50 ao_adc_get(&telemetry_tiny.adc);
51 ao_radio_send(&telemetry_tiny, sizeof (telemetry_tiny));
53 (int16_t) (ao_time() - ao_rdf_time) >= 0)
55 ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
56 ao_radio_rdf(AO_RDF_LENGTH_MS);
58 time += ao_telemetry_tiny_interval;
59 delay = time - ao_time();
69 ao_telemetry_set_interval(uint16_t interval)
71 ao_telemetry_tiny_interval = interval;
72 ao_wakeup(&ao_telemetry_tiny_interval);
76 ao_rdf_set(uint8_t rdf)
82 ao_rdf_time = ao_time();
85 __xdata struct ao_task ao_telemetry_tiny_task;
88 ao_telemetry_tiny_init()
90 ao_add_task(&ao_telemetry_tiny_task, ao_telemetry_tiny, "telemetry_tiny");