Another optimizations on AUDIO
This commit is contained in:
+111
-172
@@ -19,12 +19,8 @@ audioQueue::audioQueue()
|
|||||||
aqinit();
|
aqinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should not be needed
|
|
||||||
void audioQueue::aqinit()
|
void audioQueue::aqinit()
|
||||||
{
|
{
|
||||||
//make sure haptic off by default
|
|
||||||
HAPTIC_OFF;
|
|
||||||
|
|
||||||
toneTimeLeft = 0;
|
toneTimeLeft = 0;
|
||||||
tonePause = 0;
|
tonePause = 0;
|
||||||
|
|
||||||
@@ -32,16 +28,10 @@ void audioQueue::aqinit()
|
|||||||
t_queueWidx = 0;
|
t_queueWidx = 0;
|
||||||
|
|
||||||
#ifdef HAPTIC
|
#ifdef HAPTIC
|
||||||
toneHaptic = 0;
|
|
||||||
hapticTick = 0;
|
hapticTick = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audioQueue::busy()
|
|
||||||
{
|
|
||||||
return (toneTimeLeft > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bool audioQueue::freeslots(uint8_t slots)
|
bool audioQueue::freeslots(uint8_t slots)
|
||||||
{
|
{
|
||||||
@@ -78,18 +68,19 @@ void audioQueue::heartbeat()
|
|||||||
SPEAKER_OFF;
|
SPEAKER_OFF;
|
||||||
HAPTIC_OFF;
|
HAPTIC_OFF;
|
||||||
|
|
||||||
if (tonePause-- <= 0) {
|
if (tonePause > 0) {
|
||||||
if (t_queueRidx != t_queueWidx) {
|
tonePause--;
|
||||||
toneFreq = queueToneFreq[t_queueRidx];
|
}
|
||||||
toneTimeLeft = queueToneLength[t_queueRidx];
|
else if (t_queueRidx != t_queueWidx) {
|
||||||
toneFreqIncr = queueToneFreqIncr[t_queueRidx];
|
toneFreq = queueToneFreq[t_queueRidx];
|
||||||
tonePause = queueTonePause[t_queueRidx];
|
toneTimeLeft = queueToneLength[t_queueRidx];
|
||||||
|
toneFreqIncr = queueToneFreqIncr[t_queueRidx];
|
||||||
|
tonePause = queueTonePause[t_queueRidx];
|
||||||
#if defined(HAPTIC)
|
#if defined(HAPTIC)
|
||||||
toneHaptic = queueToneHaptic[t_queueRidx];
|
toneHaptic = queueToneHaptic[t_queueRidx];
|
||||||
#endif
|
#endif
|
||||||
if (!queueToneRepeat[t_queueRidx]--) {
|
if (!queueToneRepeat[t_queueRidx]--) {
|
||||||
t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
|
t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,12 +144,107 @@ void audioQueue::playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FRSKY
|
// TODO check
|
||||||
void audioQueue::frskyevent(uint8_t e)
|
#define BEEP_NOKEYS 1
|
||||||
|
void audioQueue::event(uint8_t e, uint8_t f)
|
||||||
{
|
{
|
||||||
if (empty()) {
|
uint8_t beepVal = g_eeGeneral.beeperVal;
|
||||||
// example playASAP(tStart,tLen,tPause,tRepeat,tHaptic,tEnd);
|
|
||||||
switch(e) {
|
if (e < AU_FRSKY_FIRST || empty()) {
|
||||||
|
switch (e) {
|
||||||
|
// startup tune
|
||||||
|
case AU_TADA:
|
||||||
|
if (empty()) {
|
||||||
|
playASAP(50, 10, 5);
|
||||||
|
playASAP(90, 10, 5);
|
||||||
|
playASAP(110, 5, 4, 2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// warning one
|
||||||
|
case AU_WARNING1:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 10, 1, 0, 1);
|
||||||
|
break;
|
||||||
|
// warning two
|
||||||
|
case AU_WARNING2:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 20, 1, 0, 1);
|
||||||
|
break;
|
||||||
|
// warning three
|
||||||
|
case AU_WARNING3:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 30, 1, 0, 1);
|
||||||
|
break;
|
||||||
|
// error
|
||||||
|
case AU_ERROR:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 40, 1, 0, 1);
|
||||||
|
break;
|
||||||
|
// keypad up (seems to be used when going left/right through system menu options. 0-100 scales etc)
|
||||||
|
case AU_KEYPAD_UP:
|
||||||
|
if (beepVal != BEEP_NOKEYS) {
|
||||||
|
playNow(BEEP_KEY_UP_FREQ, 10, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// keypad down (seems to be used when going left/right through system menu options. 0-100 scales etc)
|
||||||
|
case AU_KEYPAD_DOWN:
|
||||||
|
if (beepVal != BEEP_NOKEYS) {
|
||||||
|
playNow(BEEP_KEY_DOWN_FREQ, 10, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// trim move
|
||||||
|
case AU_TRIM_MOVE:
|
||||||
|
playNow(f, 6, 1);
|
||||||
|
break;
|
||||||
|
// trim center
|
||||||
|
case AU_TRIM_MIDDLE:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 1);
|
||||||
|
break;
|
||||||
|
// menu display (also used by a few generic beeps)
|
||||||
|
case AU_MENUS:
|
||||||
|
if (beepVal != BEEP_NOKEYS) {
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// pot/stick center
|
||||||
|
case AU_POT_STICK_MIDDLE:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
// mix warning 1
|
||||||
|
case AU_MIX_WARNING_1:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 1, 1);
|
||||||
|
break;
|
||||||
|
// mix warning 2
|
||||||
|
case AU_MIX_WARNING_2:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 52, 10, 1, 2, 1);
|
||||||
|
break;
|
||||||
|
// mix warning 3
|
||||||
|
case AU_MIX_WARNING_3:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 54, 10, 1, 3, 1);
|
||||||
|
break;
|
||||||
|
// time 30 seconds left
|
||||||
|
case AU_TIMER_30:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 3, 1);
|
||||||
|
break;
|
||||||
|
// time 20 seconds left
|
||||||
|
case AU_TIMER_20:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 2, 1);
|
||||||
|
break;
|
||||||
|
// time 10 seconds left
|
||||||
|
case AU_TIMER_10:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 1, 1);
|
||||||
|
break;
|
||||||
|
// time <3 seconds left
|
||||||
|
case AU_TIMER_LT3:
|
||||||
|
playNow(BEEP_DEFAULT_FREQ, 20, 25, 1, 1);
|
||||||
|
break;
|
||||||
|
// inactivity timer alert
|
||||||
|
case AU_INACTIVITY:
|
||||||
|
playNow(70, 10, 2,2);
|
||||||
|
break;
|
||||||
|
// low battery in tx
|
||||||
|
case AU_TX_BATTERY_LOW:
|
||||||
|
if (empty()) {
|
||||||
|
playASAP(60, 20, 3, 2, 0, 1);
|
||||||
|
playASAP(80, 20, 3, 2, 1, -1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case AU_FRSKY_WARN1:
|
case AU_FRSKY_WARN1:
|
||||||
playASAP(BEEP_DEFAULT_FREQ+20,15,5,2,1);
|
playASAP(BEEP_DEFAULT_FREQ+20,15,5,2,1);
|
||||||
break;
|
break;
|
||||||
@@ -226,153 +312,6 @@ void audioQueue::frskyevent(uint8_t e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void audioQueue::event(uint8_t e, uint8_t f)
|
|
||||||
{
|
|
||||||
uint8_t beepVal = g_eeGeneral.beeperVal;
|
|
||||||
|
|
||||||
switch (e) {
|
|
||||||
//startup tune
|
|
||||||
// case 0:
|
|
||||||
case AU_TADA:
|
|
||||||
if (empty()) {
|
|
||||||
playASAP(50, 10, 5);
|
|
||||||
playASAP(90, 10, 5);
|
|
||||||
playASAP(110, 5, 4, 2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//warning one
|
|
||||||
// case 1:
|
|
||||||
case AU_WARNING1:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 10, 1, 0, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//warning two
|
|
||||||
//case 2:
|
|
||||||
case AU_WARNING2:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 20, 1, 0, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//warning three
|
|
||||||
//case 3:
|
|
||||||
case AU_WARNING3:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 30, 1, 0, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//error
|
|
||||||
//case 4:
|
|
||||||
case AU_ERROR:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 40, 1, 0, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//keypad up (seems to be used when going left/right through system menu options. 0-100 scales etc)
|
|
||||||
//case 5:
|
|
||||||
case AU_KEYPAD_UP:
|
|
||||||
if (beepVal != BEEP_NOKEYS) {
|
|
||||||
playNow(BEEP_KEY_UP_FREQ, 10, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//keypad down (seems to be used when going left/right through system menu options. 0-100 scales etc)
|
|
||||||
//case 6:
|
|
||||||
case AU_KEYPAD_DOWN:
|
|
||||||
if (beepVal != BEEP_NOKEYS) {
|
|
||||||
playNow(BEEP_KEY_DOWN_FREQ, 10, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//trim sticks move
|
|
||||||
//case 7:
|
|
||||||
case AU_TRIM_MOVE:
|
|
||||||
//if(beepVal != BEEP_NOKEYS){
|
|
||||||
playNow(f, 6, 1);
|
|
||||||
//}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//trim sticks center
|
|
||||||
//case 8:
|
|
||||||
case AU_TRIM_MIDDLE:
|
|
||||||
//if(beepVal != BEEP_NOKEYS){
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 1);
|
|
||||||
//}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//menu display (also used by a few generic beeps)
|
|
||||||
//case 9:
|
|
||||||
case AU_MENUS:
|
|
||||||
if (beepVal != BEEP_NOKEYS) {
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//pot/stick center
|
|
||||||
//case 10:
|
|
||||||
case AU_POT_STICK_MIDDLE:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 0, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//mix warning 1
|
|
||||||
//case 11:
|
|
||||||
case AU_MIX_WARNING_1:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 50, 10, 1, 1, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//mix warning 2
|
|
||||||
//case 12:
|
|
||||||
case AU_MIX_WARNING_2:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 52, 10, 1, 2, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//mix warning 3
|
|
||||||
//case 13:
|
|
||||||
case AU_MIX_WARNING_3:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 54, 10, 1, 3, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//time 30 seconds left
|
|
||||||
//case 14:
|
|
||||||
case AU_TIMER_30:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 3, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//time 20 seconds left
|
|
||||||
//case 15:
|
|
||||||
case AU_TIMER_20:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 2, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//time 10 seconds left
|
|
||||||
//case 16:
|
|
||||||
case AU_TIMER_10:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ + 50, 15, 3, 1, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//time <3 seconds left
|
|
||||||
//case 17:
|
|
||||||
case AU_TIMER_LT3:
|
|
||||||
playNow(BEEP_DEFAULT_FREQ, 20, 25, 1, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//inactivity timer alert
|
|
||||||
//case 18:
|
|
||||||
case AU_INACTIVITY:
|
|
||||||
playNow(70, 10, 2,2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
//low battery in tx
|
|
||||||
//case 19:
|
|
||||||
case AU_TX_BATTERY_LOW:
|
|
||||||
if (empty()) {
|
|
||||||
playASAP(60, 20, 3, 2, 0, 1);
|
|
||||||
playASAP(80, 20, 3, 2, 1, -1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void audioDefevent(uint8_t e)
|
void audioDefevent(uint8_t e)
|
||||||
{
|
{
|
||||||
|
|||||||
+45
-57
@@ -35,53 +35,45 @@
|
|||||||
#define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5)
|
#define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5)
|
||||||
|
|
||||||
/* make sure the defines below always go in numeric order */
|
/* make sure the defines below always go in numeric order */
|
||||||
#define AU_TADA (0)
|
enum AUDIO_SOUNDS {
|
||||||
#define AU_WARNING1 (1)
|
AU_TADA,
|
||||||
#define AU_WARNING2 (2)
|
AU_WARNING1,
|
||||||
#define AU_WARNING3 (3)
|
AU_WARNING2,
|
||||||
#define AU_ERROR (4)
|
AU_WARNING3,
|
||||||
#define AU_KEYPAD_UP (5)
|
AU_ERROR,
|
||||||
#define AU_KEYPAD_DOWN (6)
|
AU_KEYPAD_UP,
|
||||||
#define AU_TRIM_MOVE (7)
|
AU_KEYPAD_DOWN,
|
||||||
#define AU_TRIM_MIDDLE (8)
|
AU_TRIM_MOVE,
|
||||||
#define AU_MENUS (9)
|
AU_TRIM_MIDDLE,
|
||||||
#define AU_POT_STICK_MIDDLE (10)
|
AU_MENUS,
|
||||||
#define AU_MIX_WARNING_1 (11)
|
AU_POT_STICK_MIDDLE,
|
||||||
#define AU_MIX_WARNING_2 (12)
|
AU_MIX_WARNING_1,
|
||||||
#define AU_MIX_WARNING_3 (13)
|
AU_MIX_WARNING_2,
|
||||||
#define AU_TIMER_30 (14)
|
AU_MIX_WARNING_3,
|
||||||
#define AU_TIMER_20 (15)
|
AU_TIMER_30,
|
||||||
#define AU_TIMER_10 (16)
|
AU_TIMER_20,
|
||||||
#define AU_TIMER_LT3 (17)
|
AU_TIMER_10,
|
||||||
#define AU_INACTIVITY (18)
|
AU_TIMER_LT3,
|
||||||
#define AU_TX_BATTERY_LOW (19)
|
AU_INACTIVITY,
|
||||||
|
AU_TX_BATTERY_LOW,
|
||||||
#ifdef FRSKY
|
AU_FRSKY_FIRST,
|
||||||
#define AU_FRSKY_WARN1 (0)
|
AU_FRSKY_WARN1 = AU_FRSKY_FIRST,
|
||||||
#define AU_FRSKY_WARN2 (1)
|
AU_FRSKY_WARN2,
|
||||||
#define AU_FRSKY_CHEEP (2)
|
AU_FRSKY_CHEEP,
|
||||||
#define AU_FRSKY_RING (3)
|
AU_FRSKY_RING,
|
||||||
#define AU_FRSKY_SCIFI (4)
|
AU_FRSKY_SCIFI,
|
||||||
#define AU_FRSKY_ROBOT (5)
|
AU_FRSKY_ROBOT,
|
||||||
#define AU_FRSKY_CHIRP (6)
|
AU_FRSKY_CHIRP,
|
||||||
#define AU_FRSKY_TADA (7)
|
AU_FRSKY_TADA,
|
||||||
#define AU_FRSKY_CRICKET (8)
|
AU_FRSKY_CRICKET,
|
||||||
#define AU_FRSKY_SIREN (9)
|
AU_FRSKY_SIREN,
|
||||||
#define AU_FRSKY_ALARMC (10)
|
AU_FRSKY_ALARMC,
|
||||||
#define AU_FRSKY_RATATA (11)
|
AU_FRSKY_RATATA,
|
||||||
#define AU_FRSKY_TICK (12)
|
AU_FRSKY_TICK,
|
||||||
#define AU_FRSKY_HAPTIC1 (13)
|
AU_FRSKY_HAPTIC1,
|
||||||
#define AU_FRSKY_HAPTIC2 (14)
|
AU_FRSKY_HAPTIC2,
|
||||||
#define AU_FRSKY_HAPTIC3 (15)
|
AU_FRSKY_HAPTIC3
|
||||||
#endif
|
};
|
||||||
|
|
||||||
#define BEEP_QUIET (0)
|
|
||||||
#define BEEP_NOKEYS (1)
|
|
||||||
#define BEEP_XSHORT (2)
|
|
||||||
#define BEEP_SHORT (3)
|
|
||||||
#define BEEP_NORMAL (4)
|
|
||||||
#define BEEP_LONG (5)
|
|
||||||
#define BEEP_XLONG (6)
|
|
||||||
|
|
||||||
class audioQueue
|
class audioQueue
|
||||||
{
|
{
|
||||||
@@ -95,13 +87,9 @@ class audioQueue
|
|||||||
|
|
||||||
void playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, uint8_t tHaptic=0, int8_t tFreqIncr=0);
|
void playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tRepeat=0, uint8_t tHaptic=0, int8_t tFreqIncr=0);
|
||||||
|
|
||||||
bool busy();
|
inline bool busy() { return (toneTimeLeft > 0); }
|
||||||
|
|
||||||
void event(uint8_t e,uint8_t f=BEEP_DEFAULT_FREQ);
|
void event(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
|
||||||
|
|
||||||
#if defined(FRSKY)
|
|
||||||
void frskyevent(uint8_t e);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ISER9X)
|
#if defined(ISER9X)
|
||||||
inline void driver() {
|
inline void driver() {
|
||||||
@@ -173,13 +161,13 @@ class audioQueue
|
|||||||
uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH];
|
uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH];
|
||||||
|
|
||||||
#ifdef HAPTIC
|
#ifdef HAPTIC
|
||||||
uint8_t toneHaptic;
|
uint8_t toneHaptic;
|
||||||
uint8_t hapticTick;
|
uint8_t hapticTick;
|
||||||
uint8_t queueToneHaptic[AUDIO_QUEUE_LENGTH];
|
uint8_t queueToneHaptic[AUDIO_QUEUE_LENGTH];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSTD)
|
#if defined(PCBSTD)
|
||||||
uint8_t toneCounter;
|
uint8_t toneCounter;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user