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:
rob@marotori.com
2012-05-11 11:37:29 +00:00
parent aacca8434a
commit fe45498199
2 changed files with 37 additions and 11 deletions
+35 -10
View File
@@ -53,15 +53,20 @@ void audioQueue::heartbeat()
#endif #endif
if (toneTimeLeft > 0) { if (toneTimeLeft > 0) {
#if defined(PCBV4) if(toneFreq == 0){ //pause only events
if (toneFreq) { SPEAKER_OFF;
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?). } else {
SPEAKER_ON; #if defined(PCBV4)
} if (toneFreq) {
#endif OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
toneTimeLeft--; //time gets counted down SPEAKER_ON;
toneFreq += toneFreqIncr; }
// TODO tone2TimeLeft = 0? #endif
toneFreq += toneFreqIncr;
// TODO tone2TimeLeft = 0?
}
toneTimeLeft--; //time gets counted down
} }
else { else {
if (tonePause > 0) { if (tonePause > 0) {
@@ -111,6 +116,10 @@ inline uint8_t audioQueue::getToneLength(uint8_t tLen)
return result; 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, void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
uint8_t tFlags, int8_t tFreqIncr) uint8_t tFlags, int8_t tFreqIncr)
{ {
@@ -120,7 +129,10 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
tone2Pause = tPause; tone2Pause = tPause;
} }
else { 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); tLen = getToneLength(tLen);
if (tFlags & PLAY_NOW || (!busy() && empty())) { if (tFlags & PLAY_NOW || (!busy() && empty())) {
toneFreq = tFreq; toneFreq = tFreq;
@@ -245,56 +257,69 @@ void audioQueue::event(uint8_t e, uint8_t f)
break; break;
case AU_FRSKY_WARN1: case AU_FRSKY_WARN1:
play(BEEP_DEFAULT_FREQ+20,15,5,2); play(BEEP_DEFAULT_FREQ+20,15,5,2);
pause(200);
break; break;
case AU_FRSKY_WARN2: case AU_FRSKY_WARN2:
play(BEEP_DEFAULT_FREQ+30,15,5,2); play(BEEP_DEFAULT_FREQ+30,15,5,2);
pause(200);
break; break;
case AU_FRSKY_CHEEP: case AU_FRSKY_CHEEP:
play(BEEP_DEFAULT_FREQ+30,10,2,2,2); play(BEEP_DEFAULT_FREQ+30,10,2,2,2);
pause(200);
break; break;
case AU_FRSKY_RING: case AU_FRSKY_RING:
play(BEEP_DEFAULT_FREQ+25,5,2,10); play(BEEP_DEFAULT_FREQ+25,5,2,10);
play(BEEP_DEFAULT_FREQ+25,5,10,1); play(BEEP_DEFAULT_FREQ+25,5,10,1);
play(BEEP_DEFAULT_FREQ+25,5,2,10); play(BEEP_DEFAULT_FREQ+25,5,2,10);
pause(200);
break; break;
case AU_FRSKY_SCIFI: case AU_FRSKY_SCIFI:
play(80,10,3,2,-1); play(80,10,3,2,-1);
play(60,10,3,2,1); play(60,10,3,2,1);
play(70,10,1,0); play(70,10,1,0);
pause(200);
break; break;
case AU_FRSKY_ROBOT: case AU_FRSKY_ROBOT:
play(70,5,1,1); play(70,5,1,1);
play(50,15,2,1); play(50,15,2,1);
play(80,15,2,1); play(80,15,2,1);
pause(200);
break; break;
case AU_FRSKY_CHIRP: case AU_FRSKY_CHIRP:
play(BEEP_DEFAULT_FREQ+40,5,1,2); play(BEEP_DEFAULT_FREQ+40,5,1,2);
play(BEEP_DEFAULT_FREQ+54,5,1,3); play(BEEP_DEFAULT_FREQ+54,5,1,3);
pause(200);
break; break;
case AU_FRSKY_TADA: case AU_FRSKY_TADA:
play(50,5,5); play(50,5,5);
play(90,5,5); play(90,5,5);
play(110,3,4,2); play(110,3,4,2);
pause(200);
break; break;
case AU_FRSKY_CRICKET: case AU_FRSKY_CRICKET:
play(80,5,10,3); play(80,5,10,3);
play(80,5,20,1); play(80,5,20,1);
play(80,5,10,3); play(80,5,10,3);
pause(200);
break; break;
case AU_FRSKY_SIREN: case AU_FRSKY_SIREN:
play(10,20,5,2,1); play(10,20,5,2,1);
pause(200);
break; break;
case AU_FRSKY_ALARMC: case AU_FRSKY_ALARMC:
play(50,4,10,2); play(50,4,10,2);
play(70,8,20,1); play(70,8,20,1);
play(50,8,10,2); play(50,8,10,2);
play(70,4,20,1); play(70,4,20,1);
pause(200);
break; break;
case AU_FRSKY_RATATA: case AU_FRSKY_RATATA:
play(BEEP_DEFAULT_FREQ+50,5,10,10); play(BEEP_DEFAULT_FREQ+50,5,10,10);
pause(200);
break; break;
case AU_FRSKY_TICK: case AU_FRSKY_TICK:
play(BEEP_DEFAULT_FREQ+50,5,50,2); play(BEEP_DEFAULT_FREQ+50,5,50,2);
pause(200);
break; break;
default: default:
break; break;
+1
View File
@@ -54,6 +54,7 @@ class audioQueue
audioQueue(); audioQueue();
void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags=0, int8_t tFreqIncr=0); 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); } inline bool busy() { return (toneTimeLeft > 0); }