2 * Copyright © 2011 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 static __data uint16_t ao_log_tiny_interval;
22 #define AO_LOG_TINY_INTERVAL_ASCENT AO_MS_TO_TICKS(100)
23 #define AO_LOG_TINY_INTERVAL_DEFAULT AO_MS_TO_TICKS(1000)
26 ao_log_tiny_set_interval(uint16_t ticks)
28 ao_log_tiny_interval = ticks;
31 static __xdata uint16_t ao_log_tiny_data_temp;
33 static void ao_log_tiny_data(uint16_t d)
35 if (ao_log_current_pos >= ao_log_end_pos && ao_log_running)
38 ao_log_tiny_data_temp = (d);
39 ao_storage_write(ao_log_current_pos, &ao_log_tiny_data_temp, 2);
40 ao_log_current_pos += 2;
49 enum ao_flight_state ao_log_tiny_state;
55 ao_log_tiny_state = ao_flight_invalid;
56 ao_log_tiny_interval = AO_LOG_TINY_INTERVAL_DEFAULT;
57 while (!ao_log_running)
58 ao_sleep(&ao_log_running);
61 ao_log_tiny_data(ao_flight_number);
63 if (ao_flight_state != ao_log_tiny_state) {
64 ao_log_tiny_data(ao_flight_state | 0x8000);
65 ao_log_tiny_state = ao_flight_state;
66 ao_log_tiny_interval = AO_LOG_TINY_INTERVAL_DEFAULT;
67 if (ao_log_tiny_state <= ao_flight_coast)
68 ao_log_tiny_interval = AO_LOG_TINY_INTERVAL_ASCENT;
69 if (ao_log_tiny_state == ao_flight_landed)
72 ao_log_tiny_data(ao_height);
73 time += ao_log_tiny_interval;
74 delay = time - ao_time();
77 /* Stop logging when told to */
78 while (!ao_log_running)
79 ao_sleep(&ao_log_running);
84 ao_log_flight(uint8_t slot)
86 static __xdata uint16_t flight;
89 ao_storage_read(0, &flight, 2);