altos: Make panic beeps use fixed frequencies
authorKeith Packard <keithp@keithp.com>
Fri, 16 Mar 2018 21:53:14 +0000 (14:53 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 16 Mar 2018 21:53:14 +0000 (14:53 -0700)
This ensures that the beeps will work even before the configuration
has been loaded.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_beep.h
src/kernel/ao_panic.c

index 085dd5b12f42d27ff27745eb6adf4c4ba81bcad2..1306af627e5a630e8ef286eb20ad5af289a8bf09 100644 (file)
 #else
 #define AO_BEEP_MID    AO_BEEP_MID_DEFAULT
 #endif
+
+#define AO_BEEP_MID_PANIC      AO_BEEP_MID_DEFAULT
+
 #define AO_BEEP_LOW    AO_BEEP_MID * 150 / 94  /* 2500Hz */
 #define AO_BEEP_HIGH   AO_BEEP_MID * 75 / 94   /* 5000Hz */
 
+#define AO_BEEP_LOW_PANIC      (AO_BEEP_MID_PANIC * 150 / 94)
+#define AO_BEEP_HIGH_PANIC     (AO_BEEP_MID_PANIC * 75 / 94)
+
 #define AO_BEEP_OFF    0       /* off */
 
 #define AO_BEEP_g      240     /* 1562.5Hz */
index 3feecd5afd219c91b53877a971c0a3740db47196..bd55eb9cc8d148549fded82cb352a3f716039834 100644 (file)
@@ -64,9 +64,9 @@ ao_panic(uint8_t reason)
                ao_panic_delay(20);
 #if HAS_BEEP
                for (n = 0; n < 5; n++) {
-                       ao_beep(AO_BEEP_HIGH);
+                       ao_beep(AO_BEEP_HIGH_PANIC);
                        ao_panic_delay(1);
-                       ao_beep(AO_BEEP_LOW);
+                       ao_beep(AO_BEEP_LOW_PANIC);
                        ao_panic_delay(1);
                }
                ao_beep(AO_BEEP_OFF);
@@ -78,7 +78,7 @@ ao_panic(uint8_t reason)
 #endif
                if (reason & 0x40) {
                        ao_led_on(AO_LED_PANIC);
-                       ao_beep(AO_BEEP_HIGH);
+                       ao_beep(AO_BEEP_HIGH_PANIC);
                        ao_panic_delay(40);
                        ao_led_off(AO_LED_PANIC);
                        ao_beep(AO_BEEP_OFF);
@@ -86,7 +86,7 @@ ao_panic(uint8_t reason)
                }
                for (n = 0; n < (reason & 0x3f); n++) {
                        ao_led_on(AO_LED_PANIC);
-                       ao_beep(AO_BEEP_MID);
+                       ao_beep(AO_BEEP_MID_PANIC);
                        ao_panic_delay(10);
                        ao_led_off(AO_LED_PANIC);
                        ao_beep(AO_BEEP_OFF);