5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
25 #define speakerOn() buzzerOn()
26 #define speakerOff() toneFreq=0; buzzerOff()
30 #define AUDIO_QUEUE_LENGTH (8) // 8 seems to suit most alerts
31 #define BEEP_DEFAULT_FREQ (70)
32 #define BEEP_OFFSET (10)
40 void play(uint8_t tFreq
, uint8_t tLen
, uint8_t tPause
, uint8_t tFlags
=0);
41 void pause(uint8_t tLen
);
43 inline bool busy() { return (toneTimeLeft
> 0); }
45 void event(uint8_t e
);
47 inline void driver() {
49 toneCounter
+= toneFreq
;
50 if ((toneCounter
& 0x80) == 0x80)
57 // heartbeat is responsibile for issueing the audio tones and general square waves
58 // it is essentially the life of the class.
62 return (t_queueRidx
== t_queueWidx
);
66 inline uint8_t getToneLength(uint8_t tLen
);
77 // vario has less priority
79 uint8_t tone2TimeLeft
;
82 uint8_t queueToneFreq
[AUDIO_QUEUE_LENGTH
];
83 int8_t queueToneFreqIncr
[AUDIO_QUEUE_LENGTH
];
84 uint8_t queueToneLength
[AUDIO_QUEUE_LENGTH
];
85 uint8_t queueTonePause
[AUDIO_QUEUE_LENGTH
];
86 uint8_t queueToneRepeat
[AUDIO_QUEUE_LENGTH
];
92 extern audioQueue audio
;
94 void audioDefevent(uint8_t e
);
96 #if defined(AUDIO) && defined(BUZZER)
97 #define AUDIO_BUZZER(a, b) do { a; b; } while(0)
99 #define AUDIO_BUZZER(a, b) a
101 #define AUDIO_BUZZER(a, b) b
105 #define VOICE_AUDIO_BUZZER(v, a, b) v
107 #define VOICE_AUDIO_BUZZER(v, a, b) AUDIO_BUZZER(a, b)
110 void audioKeyPress();
111 void audioKeyError();
112 void audioTrimPress(int16_t value
);
113 void audioTimerCountdown(uint8_t timer
, int value
);
115 #define AUDIO_KEY_PRESS() audioKeyPress()
116 #define AUDIO_KEY_ERROR() AUDIO_WARNING2()
117 #define AUDIO_WARNING1() AUDIO_BUZZER(audioDefevent(AU_WARNING1), beep(3))
118 #define AUDIO_WARNING2() AUDIO_BUZZER(audioDefevent(AU_WARNING2), beep(2))
119 #define AUDIO_ERROR() AUDIO_BUZZER(audioDefevent(AU_ERROR), beep(4))
120 #define AUDIO_HELLO() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AUDIO_HELLO),,)
122 #define AUDIO_TX_BATTERY_LOW() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW), audioDefevent(AU_TX_BATTERY_LOW), beep(4))
123 #define AUDIO_INACTIVITY() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_INACTIVITY), audioDefevent(AU_INACTIVITY), beep(3))
124 #define AUDIO_ERROR_MESSAGE(e) VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT((e)), audioDefevent(AU_ERROR), beep(4))
125 #define AUDIO_TIMER_MINUTE(t) VOICE_AUDIO_BUZZER(playDuration(t), audioDefevent(AU_WARNING1), beep(2))
126 #define AUDIO_TIMER_COUNTDOWN(idx, val) audioTimerCountdown(idx, val)
127 #define AUDIO_TIMER_ELAPSED(idx) AUDIO_BUZZER(audioTimerCountdown(idx, 0), beep(3))
129 //#define AUDIO_TIMER_30() // VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_30), audioDefevent(AU_TIMER_30), { beepAgain=2; beep(2); })
130 //#define AUDIO_TIMER_20() // VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TIMER_20), audioDefevent(AU_TIMER_20), { beepAgain=1; beep(2); })
131 //#define AUDIO_TIMER_LT10(m, x) // AUDIO_BUZZER(audioDefevent(AU_TIMER_LT10), beep(2))
132 //#define AUDIO_TIMER_00(m) // AUDIO_BUZZER(audioDefevent(AU_TIMER_00), beep(3))
133 #define AUDIO_MIX_WARNING(x) AUDIO_BUZZER(audioDefevent(AU_MIX_WARNING_1+x-1), beep(1))
134 #define AUDIO_POT_MIDDLE() AUDIO_BUZZER(audioDefevent(AU_POT_MIDDLE), beep(2))
135 #define AUDIO_VARIO_UP() // audioDefevent(AU_KEYPAD_UP)
136 #define AUDIO_VARIO_DOWN() // audioDefevent(AU_KEYPAD_DOWN)
137 #define AUDIO_TRIM_MIDDLE() // AUDIO_BUZZER(audio.event(AU_TRIM_MIDDLE, f), beep(2))
138 #define AUDIO_TRIM_MIN() // AUDIO_BUZZER(audioDefevent(f), beep(2))
139 #define AUDIO_TRIM_MAX() // AUDIO_BUZZER(audioDefevent(f), beep(2))
140 #define AUDIO_TRIM_PRESS(val) audioTrimPress(val)
141 #define AUDIO_PLAY(p) audio.event(p)
142 #define AUDIO_VARIO(f, t) audio.play(f, t, 0, PLAY_BACKGROUND)
144 #define AUDIO_DRIVER() audio.driver()
145 #define AUDIO_HEARTBEAT() audio.heartbeat()
146 #define IS_AUDIO_BUSY() audio.busy()
147 #define AUDIO_RESET()
148 #define AUDIO_FLUSH()
150 #define PLAY_PHASE_OFF(phase)
151 #define PLAY_PHASE_ON(phase)
152 #define PLAY_SWITCH_MOVED(sw)
153 #define PLAY_LOGICAL_SWITCH_OFF(sw)
154 #define PLAY_LOGICAL_SWITCH_ON(sw)
155 #define PLAY_MODEL_NAME()
156 #define START_SILENCE_PERIOD()
158 #endif // _AUDIO_AVR_H_