From 545478dd02eaeff6a65d318e722b1e4fce5e01b4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 14 Apr 2009 21:24:25 -0700 Subject: [PATCH] Keep reporting flight state while it changes --- ao_report.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ao_report.c b/ao_report.c index 1cc883be..0753df47 100644 --- a/ao_report.c +++ b/ao_report.c @@ -38,10 +38,12 @@ static const char * __xdata flight_reports[] = { #endif #define pause(time) ao_delay(time) +static __xdata enum ao_flight_state ao_report_state; + static void -ao_report_state(void) +ao_report_beep(void) { - char *r = flight_reports[ao_flight_state]; + char *r = flight_reports[ao_report_state]; char c; if (!r) @@ -53,22 +55,26 @@ ao_report_state(void) signal(AO_MS_TO_TICKS(600)); pause(AO_MS_TO_TICKS(200)); } + pause(AO_MS_TO_TICKS(400)); } -static __xdata ao_report_wait; - void ao_report_notify(void) { - ao_wakeup(&ao_report_wait); + ao_wakeup(&ao_report_state); } void ao_report(void) { + ao_report_state = ao_flight_state; for(;;) { - ao_report_state(); - ao_sleep(&ao_report_wait); + ao_report_beep(); + __critical { + while (ao_report_state == ao_flight_state) + ao_sleep(&ao_report_state); + ao_report_state = ao_flight_state; + } } } -- 2.30.2