[Simulator] Asynchronous SimulatorInterface & a few new features. (#4738)
[opentx.git] / radio / src / buzzer.cpp
blob7ac4957d8dcfcd8b2513286e449f3b2d73c2617a
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 #include "opentx.h"
23 uint8_t g_beepCnt;
24 uint8_t beepAgain = 0;
25 uint8_t beepAgainOrig = 0;
26 uint8_t beepOn = false;
27 bool warble = false;
28 bool warbleC;
30 // The various "beep" tone lengths
31 static const pm_uint8_t beepTab[] PROGMEM = {
32 // key, trim, warn2, warn1, error
33 1, 1, 2, 10, 60, //xShort
34 1, 1, 4, 20, 80, //short
35 1, 1, 8, 30, 100, //normal
36 2, 2, 15, 40, 120, //long
37 5, 5, 30, 50, 150, //xLong
40 void beep(uint8_t val)
42 #if defined(HAPTIC) && !defined(AUDIO)
43 haptic.event(val==0 ? AU_KEYPAD_UP : (val==4 ? AU_ERROR : AU_TIMER_LT10+beepAgain));
44 #endif
46 #if !defined(AUDIO)
47 if (g_eeGeneral.alarmsFlash && val>1) flashCounter = FLASH_DURATION;
48 #endif
50 if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && val!=0) || (g_eeGeneral.beepMode==-1 && val>=3)) {
51 _beep(pgm_read_byte(beepTab+5*(2+g_eeGeneral.beepLength)+val));