Post pause feature from previous update ported to stock/gruvin board.
Have tested on stock - can a gruvin board user test?
This commit is contained in:
+35
-10
@@ -53,15 +53,20 @@ void audioQueue::heartbeat()
|
||||
#endif
|
||||
|
||||
if (toneTimeLeft > 0) {
|
||||
#if defined(PCBV4)
|
||||
if (toneFreq) {
|
||||
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
|
||||
SPEAKER_ON;
|
||||
}
|
||||
#endif
|
||||
toneTimeLeft--; //time gets counted down
|
||||
toneFreq += toneFreqIncr;
|
||||
// TODO tone2TimeLeft = 0?
|
||||
if(toneFreq == 0){ //pause only events
|
||||
SPEAKER_OFF;
|
||||
} else {
|
||||
#if defined(PCBV4)
|
||||
if (toneFreq) {
|
||||
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
|
||||
SPEAKER_ON;
|
||||
}
|
||||
#endif
|
||||
|
||||
toneFreq += toneFreqIncr;
|
||||
// TODO tone2TimeLeft = 0?
|
||||
}
|
||||
toneTimeLeft--; //time gets counted down
|
||||
}
|
||||
else {
|
||||
if (tonePause > 0) {
|
||||
@@ -111,6 +116,10 @@ inline uint8_t audioQueue::getToneLength(uint8_t tLen)
|
||||
return result;
|
||||
}
|
||||
|
||||
void audioQueue::pause(uint8_t tLen){
|
||||
play(0,tLen,5); // a pause
|
||||
}
|
||||
|
||||
void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
||||
uint8_t tFlags, int8_t tFreqIncr)
|
||||
{
|
||||
@@ -120,7 +129,10 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
||||
tone2Pause = tPause;
|
||||
}
|
||||
else {
|
||||
tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
|
||||
if(tFreq > 0) //we dont add pitch if zero as this is a pause only event
|
||||
{
|
||||
tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
|
||||
}
|
||||
tLen = getToneLength(tLen);
|
||||
if (tFlags & PLAY_NOW || (!busy() && empty())) {
|
||||
toneFreq = tFreq;
|
||||
@@ -245,56 +257,69 @@ void audioQueue::event(uint8_t e, uint8_t f)
|
||||
break;
|
||||
case AU_FRSKY_WARN1:
|
||||
play(BEEP_DEFAULT_FREQ+20,15,5,2);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_WARN2:
|
||||
play(BEEP_DEFAULT_FREQ+30,15,5,2);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_CHEEP:
|
||||
play(BEEP_DEFAULT_FREQ+30,10,2,2,2);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_RING:
|
||||
play(BEEP_DEFAULT_FREQ+25,5,2,10);
|
||||
play(BEEP_DEFAULT_FREQ+25,5,10,1);
|
||||
play(BEEP_DEFAULT_FREQ+25,5,2,10);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_SCIFI:
|
||||
play(80,10,3,2,-1);
|
||||
play(60,10,3,2,1);
|
||||
play(70,10,1,0);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_ROBOT:
|
||||
play(70,5,1,1);
|
||||
play(50,15,2,1);
|
||||
play(80,15,2,1);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_CHIRP:
|
||||
play(BEEP_DEFAULT_FREQ+40,5,1,2);
|
||||
play(BEEP_DEFAULT_FREQ+54,5,1,3);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_TADA:
|
||||
play(50,5,5);
|
||||
play(90,5,5);
|
||||
play(110,3,4,2);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_CRICKET:
|
||||
play(80,5,10,3);
|
||||
play(80,5,20,1);
|
||||
play(80,5,10,3);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_SIREN:
|
||||
play(10,20,5,2,1);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_ALARMC:
|
||||
play(50,4,10,2);
|
||||
play(70,8,20,1);
|
||||
play(50,8,10,2);
|
||||
play(70,4,20,1);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_RATATA:
|
||||
play(BEEP_DEFAULT_FREQ+50,5,10,10);
|
||||
pause(200);
|
||||
break;
|
||||
case AU_FRSKY_TICK:
|
||||
play(BEEP_DEFAULT_FREQ+50,5,50,2);
|
||||
pause(200);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+2
-1
@@ -54,7 +54,8 @@ class audioQueue
|
||||
audioQueue();
|
||||
|
||||
void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags=0, int8_t tFreqIncr=0);
|
||||
|
||||
void pause(uint8_t tLen);
|
||||
|
||||
inline bool busy() { return (toneTimeLeft > 0); }
|
||||
|
||||
void event(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
|
||||
|
||||
Reference in New Issue
Block a user