Various fixes around Companion trainer mode (#7116)
[opentx.git] / radio / src / buzzer.h
blobaa13746f81b966fe3856b2a50424244336362e49
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
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.
21 #ifndef _BUZZER_H_
22 #define _BUZZER_H_
24 #if defined(BUZZER)
25 extern uint8_t g_beepCnt;
26 extern uint8_t beepAgain;
27 extern uint8_t beepAgainOrig;
28 extern uint8_t beepOn;
29 extern bool warble;
30 extern bool warbleC;
31 #if defined(HAPTIC)
32 extern uint8_t hapticTick;
33 #endif /* HAPTIC */
34 #endif /* BUZZER */
36 #if defined(BUZZER)
38 #if defined(SIMU)
39 inline void _beep(uint8_t b)
41 g_beepCnt = b;
43 #else /* SIMU */
44 inline void _beep(uint8_t b)
46 buzzerSound(b);
48 #endif /* SIMU */
50 void beep(uint8_t val);
51 #else /* BUZZER */
52 inline void beep(uint8_t) { }
53 #endif /* BUZZER */
55 #if !defined(AUDIO)
57 #if defined(BUZZER)
58 #define AUDIO_HELLO() PUSH_SYSTEM_PROMPT(AUDIO_HELLO)
59 #define AUDIO_BYE()
60 #define AUDIO_TX_BATTERY_LOW() PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW)
61 #define AUDIO_INACTIVITY() PUSH_SYSTEM_PROMPT(AU_INACTIVITY)
62 #define AUDIO_ERROR_MESSAGE(e) PUSH_SYSTEM_PROMPT((e))
63 #define AUDIO_TIMER_MINUTE(t) playDuration(t)
64 // TODO
65 #define AUDIO_TIMER_30() PUSH_SYSTEM_PROMPT(AU_TIMER_30)
66 #define AUDIO_TIMER_20() PUSH_SYSTEM_PROMPT(AU_TIMER_20)
68 #define AUDIO_KEY_PRESS() beep(0)
69 #define AUDIO_KEY_ERROR() beep(2)
70 #define AUDIO_WARNING2() beep(2)
71 #define AUDIO_WARNING1() beep(3)
72 #define AUDIO_ERROR() beep(4)
73 #define AUDIO_MIX_WARNING(x) beep(1)
74 #define AUDIO_POT_MIDDLE() beep(2)
75 #define AUDIO_TIMER_COUNTDOWN(idx, val) beep(2)
76 #define AUDIO_TIMER_ELAPSED(idx) beep(3)
77 #define AUDIO_VARIO_UP() _beep(1)
78 #define AUDIO_VARIO_DOWN() _beep(1)
79 #define AUDIO_TRIM_PRESS(f) { if (!IS_KEY_FIRST(event)) warble = true; beep(1); }
80 #define AUDIO_TRIM_MIDDLE() beep(2)
81 #define AUDIO_TRIM_MIN() beep(2)
82 #define AUDIO_TRIM_MAX() beep(2)
83 #define AUDIO_PLAY(p) beep(3)
85 #define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
86 #else /* BUZZER */
87 #define AUDIO_HELLO()
88 #define AUDIO_BYE()
89 #define AUDIO_TX_BATTERY_LOW()
90 #define AUDIO_INACTIVITY()
91 #define AUDIO_ERROR_MESSAGE(e)
92 #define AUDIO_TIMER_MINUTE(t)
93 #define AUDIO_TIMER_30()
94 #define AUDIO_TIMER_20()
95 #define AUDIO_WARNING2()
96 #define AUDIO_WARNING1()
97 #define AUDIO_ERROR()
98 #define AUDIO_MIX_WARNING(x)
99 #define AUDIO_POT_MIDDLE()
100 #define AUDIO_TIMER_LT10(m, x)
101 #define AUDIO_TIMER_00(m)
102 #define AUDIO_VARIO_UP()
103 #define AUDIO_VARIO_DOWN()
104 #define AUDIO_TRIM(event, f)
105 #define AUDIO_TRIM_MIDDLE(f)
106 #define AUDIO_TRIM_END(f)
107 #define AUDIO_PLAY(p)
108 #define IS_AUDIO_BUSY() false
109 #endif /* BUZZER */
111 #define AUDIO_RESET()
112 #define AUDIO_FLUSH()
114 #define PLAY_PHASE_OFF(phase)
115 #define PLAY_PHASE_ON(phase)
116 #define PLAY_SWITCH_MOVED(sw)
117 #define PLAY_LOGICAL_SWITCH_OFF(sw)
118 #define PLAY_LOGICAL_SWITCH_ON(sw)
119 #define PLAY_MODEL_NAME()
120 #define START_SILENCE_PERIOD()
121 #endif /* !AUDIO */
124 #endif // _BUZZER_H_