Adjustments from Rob on all sounds to match the new algorithm.

Haptic strength bug
Haptic on v4
This commit is contained in:
bsongis
2012-02-01 11:07:10 +00:00
parent 3b49bc9d6a
commit 4d459edcf8
4 changed files with 124 additions and 115 deletions
+53 -54
View File
@@ -77,7 +77,7 @@ void audioQueue::heartbeat()
#if defined(HAPTIC)
if (toneHaptic){
if (hapticTick-- >= 0) {
if (hapticTick-- > 0) {
HAPTIC_ON; // haptic output 'high'
}
else {
@@ -133,7 +133,7 @@ void audioQueue::playNow(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
uint8_t tRepeat, uint8_t tHaptic, int8_t tFreqIncr)
{
if (g_eeGeneral.beeperVal) {
toneFreq = tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
toneFreq = (tFreq ? tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET : 0); // add pitch compensator
toneTimeLeft = getToneLength(tLen);
tonePause = tPause;
#if defined(HAPTIC)
@@ -153,7 +153,7 @@ void audioQueue::playASAP(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
uint8_t tRepeat, uint8_t tHaptic, int8_t tFreqIncr)
{
if (g_eeGeneral.beeperVal) {
queueToneFreq[t_queueWidx] = tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
queueToneFreq[t_queueWidx] = (tFreq ? tFreq + g_eeGeneral.speakerPitch + BEEP_OFFSET : 0); // add pitch compensator
queueToneLength[t_queueWidx] = getToneLength(tLen);
queueTonePause[t_queueWidx] = tPause;
#if defined(HAPTIC)
@@ -183,67 +183,67 @@ void audioQueue::frskyevent(uint8_t e)
// example playASAP(tStart,tLen,tPause,tRepeat,tHaptic,tEnd);
switch(e) {
case AU_FRSKY_WARN1:
playASAP(BEEP_DEFAULT_FREQ+20,25,5,2,1);
playASAP(BEEP_DEFAULT_FREQ+20,15,5,2,1);
break;
case AU_FRSKY_WARN2:
playASAP(BEEP_DEFAULT_FREQ+30,25,5,2,1);
playASAP(BEEP_DEFAULT_FREQ+30,15,5,2,1);
break;
case AU_FRSKY_CHEEP:
playASAP(BEEP_DEFAULT_FREQ+30,20,2,2,1,BEEP_DEFAULT_FREQ+25);
playASAP(BEEP_DEFAULT_FREQ+30,10,2,2,1,2);
break;
case AU_FRSKY_RING:
playASAP(BEEP_DEFAULT_FREQ+25,2,2,10,1);
playASAP(BEEP_DEFAULT_FREQ+25,2,10,1,1);
playASAP(BEEP_DEFAULT_FREQ+25,2,2,10,1);
playASAP(BEEP_DEFAULT_FREQ+25,15,2,10,1);
playASAP(BEEP_DEFAULT_FREQ+25,15,10,1,1);
playASAP(BEEP_DEFAULT_FREQ+25,15,2,10,1);
break;
case AU_FRSKY_SCIFI:
playASAP(80,4,3,2,0,70);
playASAP(60,4,3,2,0,70);
playASAP(70,2,1,0,2);
playASAP(80,10,3,2,0,-1);
playASAP(60,10,3,2,0,1);
playASAP(70,10,1,0,2);
break;
case AU_FRSKY_ROBOT:
playASAP(70,2,1,1,1);
playASAP(50,6,2,1,1);
playASAP(80,6,2,1,1);
playASAP(70,5,1,1,1);
playASAP(50,15,2,1,1);
playASAP(80,15,2,1,1);
break;
case AU_FRSKY_CHIRP:
playASAP(BEEP_DEFAULT_FREQ+40,2,1,2,1);
playASAP(BEEP_DEFAULT_FREQ+54,2,1,3,1);
playASAP(BEEP_DEFAULT_FREQ+40,5,1,2,1);
playASAP(BEEP_DEFAULT_FREQ+54,5,1,3,1);
break;
case AU_FRSKY_TADA:
playASAP(50,10,5);
playASAP(90,10,5);
playASAP(110,6,4,2);
playASAP(50,5,5);
playASAP(90,5,5);
playASAP(110,3,4,2);
break;
case AU_FRSKY_CRICKET:
playASAP(80,1,10,3,1);
playASAP(80,1,20,1,1);
playASAP(80,1,10,3,1);
playASAP(80,15,10,3,1);
playASAP(80,15,20,1,1);
playASAP(80,15,10,3,1);
break;
case AU_FRSKY_SIREN:
playASAP(10,5,5,2,1,40);
playASAP(10,20,5,2,1,1);
break;
case AU_FRSKY_ALARMC:
playASAP(50,5,10,2,1);
playASAP(70,5,20,1,1);
playASAP(50,5,10,2,1);
playASAP(70,5,20,1,1);
playASAP(50,15,10,2,1);
playASAP(70,15,20,1,1);
playASAP(50,15,10,2,1);
playASAP(70,10,20,1,1);
break;
case AU_FRSKY_RATATA:
playASAP(BEEP_DEFAULT_FREQ+50,2,10,10,1);
playASAP(BEEP_DEFAULT_FREQ+50,5,10,10,1);
break;
case AU_FRSKY_TICK:
playASAP(BEEP_DEFAULT_FREQ+50,2,50,2,1);
playASAP(BEEP_DEFAULT_FREQ+50,5,50,2,1);
break;
case AU_FRSKY_HAPTIC1:
playASAP(0,2,10,1,1);
playASAP(0,20,10,1,1);
break;
case AU_FRSKY_HAPTIC2:
playASAP(0,2,10,2,1);
playASAP(0,20,10,2,1);
break;
case AU_FRSKY_HAPTIC3:
playASAP(0,2,10,3,1);
playASAP(0,20,10,3,1);
break;
default:
break;
@@ -262,38 +262,38 @@ void audioQueue::event(uint8_t e, uint8_t f) {
case AU_TADA:
playASAP(50, 10, 5);
playASAP(90, 10, 5);
playASAP(110, 6, 4, 2);
playASAP(110, 5, 4, 2);
break;
//warning one
// case 1:
case AU_WARNING1:
playNow(BEEP_DEFAULT_FREQ, 25, 1, 0, 1);
playNow(BEEP_DEFAULT_FREQ, 10, 1, 0, 1);
break;
//warning two
//case 2:
case AU_WARNING2:
playNow(BEEP_DEFAULT_FREQ, 34, 1, 0, 1);
playNow(BEEP_DEFAULT_FREQ, 20, 1, 0, 1);
break;
//warning three
//case 3:
case AU_WARNING3:
playNow(BEEP_DEFAULT_FREQ, 15, 1, 0, 1);
playNow(BEEP_DEFAULT_FREQ, 30, 1, 0, 1);
break;
//error
//case 4:
case AU_ERROR:
playNow(BEEP_DEFAULT_FREQ, 30, 1, 0, 1);
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, 2, 1);
playNow(BEEP_KEY_UP_FREQ, 10, 1);
}
break;
@@ -301,7 +301,7 @@ void audioQueue::event(uint8_t e, uint8_t f) {
//case 6:
case AU_KEYPAD_DOWN:
if (beepVal != BEEP_NOKEYS) {
playNow(BEEP_KEY_DOWN_FREQ, 2, 1);
playNow(BEEP_KEY_DOWN_FREQ, 10, 1);
}
break;
@@ -309,7 +309,7 @@ void audioQueue::event(uint8_t e, uint8_t f) {
//case 7:
case AU_TRIM_MOVE:
//if(beepVal != BEEP_NOKEYS){
playNow(f, 2, 1);
playNow(f, 6, 1);
//}
break;
@@ -325,69 +325,68 @@ void audioQueue::event(uint8_t e, uint8_t f) {
//case 9:
case AU_MENUS:
if (beepVal != BEEP_NOKEYS) {
playNow(BEEP_DEFAULT_FREQ, 2, 2, 0, 1);
playNow(BEEP_DEFAULT_FREQ, 10, 2, 0, 0);
}
break;
//pot/stick center
//case 10:
case AU_POT_STICK_MIDDLE:
playNow(BEEP_DEFAULT_FREQ + 50, 3, 1, 0, 1);
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, 2, 1, 1, 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, 2, 1, 2, 1);
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, 2, 1, 3, 1);
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, 5, 3, 3, 1);
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, 5, 3, 2, 1);
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, 5, 3, 1, 1);
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, 5, 1, 1);
playNow(BEEP_DEFAULT_FREQ, 20, 25, 1, 1);
break;
//inactivity timer alert
//case 18:
case AU_INACTIVITY:
playASAP(70, 3, 2);
playASAP(50, 3, 5);
playNow(70, 10, 2,2);
break;
//low battery in tx
//case 19:
case AU_TX_BATTERY_LOW:
playASAP(60, 4, 3, 2, 1, 2);
playASAP(80, 4, 3, 2, 1, -2);
playASAP(60, 20, 3, 2, 0, 1);
playASAP(80, 20, 3, 2, 1, -1);
break;
default:
+66 -53
View File
@@ -17,19 +17,11 @@
//audio
#define AUDIO_QUEUE_LENGTH (8) //8 seems to suit most alerts
#define BEEP_DEFAULT_FREQ (70)
#define BEEP_OFFSET (10)
#define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5)
#define BEEP_DEFAULT_FREQ (70)
#define BEEP_OFFSET (10)
#define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5)
#define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5)
#ifdef HAPTIC
#define HAPTIC_ON PORTG |= (1<<2)
#define HAPTIC_OFF PORTG &= ~(1<<2)
#else
#define HAPTIC_ON
#define HAPTIC_OFF
#endif
/* make sure the defines below always go in numeric order */
#define AU_TADA (0)
#define AU_WARNING1 (1)
@@ -80,67 +72,84 @@
#define BEEP_LONG (5)
#define BEEP_XLONG (6)
struct audioQueue
class audioQueue
{
uint8_t t_queueRidx;
uint8_t t_queueWidx;
public:
//queue general vars
uint8_t toneFreq;
int8_t toneFreqIncr;
uint8_t toneTimeLeft;
uint8_t tonePause;
audioQueue();
#ifdef HAPTIC
uint8_t toneHaptic;
uint8_t hapticTick;
// only difference between these two functions is that one does the
// interupt queue (Now) and the other queues for playing ASAP.
void playNow(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();
void event(uint8_t e,uint8_t f=BEEP_DEFAULT_FREQ);
#if defined(FRSKY)
void frskyevent(uint8_t e);
void frskyeventSample(uint8_t e);
#endif
#if defined(PCBSTD)
inline void driver() {
if (toneTimeLeft > 0) {
toneCounter += toneFreq;
if ((toneCounter & 0x80) == 0x80)
PORTE |= (1 << OUT_E_BUZZER);
else
PORTE &= ~(1 << OUT_E_BUZZER);
}
}
#endif
// heartbeat is responsibile for issueing the audio tones and general square waves
// it is essentially the life of the class.
void heartbeat();
// TODO bool freeslots(uint8_t slots);
protected:
void aqinit(); // To stop constructor being compiled twice
inline uint8_t getToneLength(uint8_t tLen);
private:
uint8_t t_queueRidx;
uint8_t t_queueWidx;
uint8_t toneFreq;
int8_t toneFreqIncr;
uint8_t toneTimeLeft;
uint8_t tonePause;
// queue arrays
uint8_t queueToneFreq[AUDIO_QUEUE_LENGTH];
int8_t queueToneFreqIncr[AUDIO_QUEUE_LENGTH];
uint8_t queueToneLength[AUDIO_QUEUE_LENGTH];
uint8_t queueTonePause[AUDIO_QUEUE_LENGTH];
uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH];
#ifdef FRSKY
uint8_t frskySample;
#endif
// queue arrays
uint8_t queueToneFreq[AUDIO_QUEUE_LENGTH];
int8_t queueToneFreqIncr[AUDIO_QUEUE_LENGTH];
uint8_t queueToneLength[AUDIO_QUEUE_LENGTH];
uint8_t queueTonePause[AUDIO_QUEUE_LENGTH];
uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH];
#ifdef HAPTIC
uint8_t toneHaptic;
uint8_t hapticTick;
uint8_t queueToneHaptic[AUDIO_QUEUE_LENGTH];
#endif
audioQueue();
void aqinit(); // To stop constructor being compiled twice
inline uint8_t getToneLength(uint8_t tLen);
//only difference between these two functions is that one does the
//interupt queue (Now) and the other queues for playing ASAP.
void playNow(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();
void event(uint8_t e,uint8_t f=BEEP_DEFAULT_FREQ);
#ifdef FRSKY
void frskyevent(uint8_t e);
void frskyeventSample(uint8_t e);
#if defined(PCBSTD)
uint8_t toneCounter;
#endif
//heartbeat is responsibile for issueing the audio tones and general square waves
// it is essentially the life of the class.
void heartbeat();
// TODO bool freeslots(uint8_t slots);
};
//wrapper function - dirty but results in a space saving!!!
extern audioQueue audio;
//void audioevent(uint8_t e,uint8_t f=BEEP_DEFAULT_FREQ);
void audioDefevent(uint8_t e);
#define AUDIO_KEYPAD_UP() audioDefevent(AU_KEYPAD_UP)
@@ -161,6 +170,10 @@ void audioDefevent(uint8_t e);
#define AUDIO_MIX_WARNING_1() audioDefevent(AU_MIX_WARNING_1)
#define AUDIO_MIX_WARNING_3() audioDefevent(AU_MIX_WARNING_3)
#if defined(PCBSTD)
#define AUDIO_DRIVER() audio.driver()
#endif
#define AUDIO_HEARTBEAT() audio.heartbeat()
#endif // audio_h
-3
View File
@@ -51,9 +51,6 @@ extern void beep(uint8_t val);
FORCEINLINE void AUDIO_HEARTBEAT()
{
//cnt >/=0
//beepon/off
//beepagain y/n
if(g_beepCnt) {
if(!beepAgainOrig) {
beepAgainOrig = g_beepCnt;
+5 -5
View File
@@ -96,9 +96,9 @@ void menuProcSetup(uint8_t event)
#ifdef AUDIO
if(s_pgOfs<subN) {
lcd_puts_P(0, y, PSTR("Speaker Pitch"));
lcd_outdezAtt(PARAM_OFS,y,g_eeGeneral.speakerPitch,(sub==subN ? INVERS : 0)|LEFT);
if(sub==subN) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 1, 100);
lcd_outdezAtt(PARAM_OFS, y, g_eeGeneral.speakerPitch,(sub==subN ? INVERS : 0)|LEFT);
if (sub==subN) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 100);
}
if((y+=FH)>7*FH) return;
}subN++;
@@ -107,8 +107,8 @@ void menuProcSetup(uint8_t event)
#ifdef HAPTIC
if(s_pgOfs<subN) {
lcd_puts_P(0, y, PSTR("Haptic Strength"));
lcd_outdezAtt(PARAM_OFS,y,g_eeGeneral.hapticStrength,(sub==subN ? INVERS : 0)|LEFT);
if(sub==subN) {
lcd_outdezAtt(PARAM_OFS, y, g_eeGeneral.hapticStrength, (sub==subN ? INVERS : 0)|LEFT);
if (sub==subN) {
CHECK_INCDEC_GENVAR(event, g_eeGeneral.hapticStrength, 0, 5);
}
if((y+=FH)>7*FH) return;