Audio problem on ersky9x board

This commit is contained in:
bsongis
2012-06-27 20:09:09 +00:00
parent d44a0a126e
commit 48e3a2ebf4
4 changed files with 16 additions and 21 deletions
+10 -6
View File
@@ -77,7 +77,7 @@ extern uint16_t Sine_values[];
void audioTask(void* pdata) void audioTask(void* pdata)
{ {
#ifndef SIMU #if defined(SDCARD) && !defined(SIMU)
static FIL wavFile; static FIL wavFile;
#endif #endif
@@ -86,7 +86,7 @@ void audioTask(void* pdata)
audioState = 1; // TODO #define audioState = 1; // TODO #define
#ifndef SIMU #if defined(SDCARD) && !defined(SIMU)
if (toneWavFile[0]) { if (toneWavFile[0]) {
FRESULT result = FR_OK; FRESULT result = FR_OK;
UINT read; UINT read;
@@ -205,20 +205,24 @@ void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
tone2Freq = tFreq; tone2Freq = tFreq;
tone2TimeLeft = tLen; tone2TimeLeft = tLen;
tone2Pause = tPause; tone2Pause = tPause;
if (audioState == 0) CoSetFlag(audioFlag); if (audioState == 0) {
audioState = 1;
CoSetFlag(audioFlag);
}
} }
else { else {
if (tFreq > 0) { //we dont add pitch if zero as this is a pause only event 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 tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
} }
tLen = getToneLength(tLen); tLen = getToneLength(tLen);
if ((tFlags & PLAY_NOW) || (audioState == 0 && audioEmpty())) { if ((tFlags & PLAY_NOW) || !audioBusy()) {
toneWavFile[0] = '\0'; toneWavFile[0] = '\0';
toneFreq = tFreq; toneFreq = tFreq;
toneTimeLeft = tLen; toneTimeLeft = tLen;
tonePause = tPause; tonePause = tPause;
toneFreqIncr = tFreqIncr; toneFreqIncr = tFreqIncr;
t_queueWidx = t_queueRidx; t_queueWidx = t_queueRidx;
audioState = 1;
CoSetFlag(audioFlag); CoSetFlag(audioFlag);
} }
else { else {
@@ -258,7 +262,7 @@ void audioEvent(uint8_t e, uint8_t f)
} }
if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) { if (g_eeGeneral.beeperMode>0 || (g_eeGeneral.beeperMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beeperMode>=-1 && e<=AU_ERROR)) {
if (e < AU_FRSKY_FIRST || audioEmpty()) { if (e < AU_FRSKY_FIRST || !audioBusy()) {
switch (e) { switch (e) {
// inactivity timer alert // inactivity timer alert
case AU_INACTIVITY: case AU_INACTIVITY:
@@ -266,7 +270,7 @@ void audioEvent(uint8_t e, uint8_t f)
break; break;
// low battery in tx // low battery in tx
case AU_TX_BATTERY_LOW: case AU_TX_BATTERY_LOW:
if (audioEmpty()) { if (!audioBusy()) {
play(60, 40, 6, 2, 1); play(60, 40, 6, 2, 1);
play(80, 40, 6, 2, -1); play(80, 40, 6, 2, -1);
} }
+4 -13
View File
@@ -35,19 +35,18 @@
#ifndef audio_h #ifndef audio_h
#define audio_h #define audio_h
#define AUDIO_QUEUE_LENGTH (100) #define AUDIO_QUEUE_LENGTH (20)
#define BEEP_DEFAULT_FREQ (70) #define BEEP_DEFAULT_FREQ (70)
#define BEEP_OFFSET (10) #define BEEP_OFFSET (10)
#define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5) #define BEEP_KEY_UP_FREQ (BEEP_DEFAULT_FREQ+5)
#define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5) #define BEEP_KEY_DOWN_FREQ (BEEP_DEFAULT_FREQ-5)
#define TONE1_RATE_LIMIT (10)
#define TONE2_RATE_LIMIT (10) extern uint8_t audioState;
extern uint8_t t_queueRidx; extern uint8_t t_queueRidx;
extern uint8_t t_queueWidx; extern uint8_t t_queueWidx;
extern uint8_t toneFreq; extern uint8_t toneFreq;
//int8_t toneFreqIncr;
extern uint8_t toneTimeLeft; extern uint8_t toneTimeLeft;
extern uint8_t tonePause; extern uint8_t tonePause;
@@ -73,25 +72,17 @@ void pause(uint8_t tLen);
inline bool audioBusy() inline bool audioBusy()
{ {
return (toneTimeLeft > 0); return (audioState != 0);
} }
void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ); void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
inline bool audioEmpty()
{
return (t_queueRidx == t_queueWidx);
}
#define AUDIO_KEYPAD_UP() audioEvent(AU_KEYPAD_UP) #define AUDIO_KEYPAD_UP() audioEvent(AU_KEYPAD_UP)
#define AUDIO_KEYPAD_DOWN() audioEvent(AU_KEYPAD_DOWN) #define AUDIO_KEYPAD_DOWN() audioEvent(AU_KEYPAD_DOWN)
#define AUDIO_MENUS() audioEvent(AU_MENUS) #define AUDIO_MENUS() audioEvent(AU_MENUS)
#define AUDIO_WARNING1() audioEvent(AU_WARNING1) #define AUDIO_WARNING1() audioEvent(AU_WARNING1)
#define AUDIO_WARNING2() audioEvent(AU_WARNING2) #define AUDIO_WARNING2() audioEvent(AU_WARNING2)
#define AUDIO_ERROR() audioEvent(AU_ERROR) #define AUDIO_ERROR() audioEvent(AU_ERROR)
#define IS_AUDIO_BUSY() audioBusy()
#define AUDIO_TIMER_30() audioEvent(AU_TIMER_30) #define AUDIO_TIMER_30() audioEvent(AU_TIMER_30)
#define AUDIO_TIMER_20() audioEvent(AU_TIMER_20) #define AUDIO_TIMER_20() audioEvent(AU_TIMER_20)
#define AUDIO_TIMER_10() audioEvent(AU_TIMER_10) #define AUDIO_TIMER_10() audioEvent(AU_TIMER_10)
+1 -1
View File
@@ -426,7 +426,7 @@ void lcd_filled_rect(uint8_t x, int8_t y, uint8_t w, uint8_t h, uint8_t pat, uin
{ {
for (int8_t i=y; i<y+h; i++) { for (int8_t i=y; i<y+h; i++) {
if (i>=0 && i<64) lcd_hlineStip(x, i, w, pat, att); if (i>=0 && i<64) lcd_hlineStip(x, i, w, pat, att);
if (pat != 0xff) pat = ~pat; pat = (pat >> 1) + ((pat & 1) << 7);
} }
} }
+1 -1
View File
@@ -510,7 +510,7 @@ void setupPulses()
init_ssc(); init_ssc();
break; break;
case PROTO_NONE: case PROTO_NONE:
init_main_ppm(3000, 0); // Initial period 1.5 mS, output on init_main_ppm(3000, 0); // Initial period 1.5 mS, output off
break; break;
default: default:
init_main_ppm(3000, 1); // Initial period 1.5 mS, output on init_main_ppm(3000, 1); // Initial period 1.5 mS, output on