Audio problem on ersky9x board
This commit is contained in:
+10
-6
@@ -77,7 +77,7 @@ extern uint16_t Sine_values[];
|
||||
|
||||
void audioTask(void* pdata)
|
||||
{
|
||||
#ifndef SIMU
|
||||
#if defined(SDCARD) && !defined(SIMU)
|
||||
static FIL wavFile;
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,7 @@ void audioTask(void* pdata)
|
||||
|
||||
audioState = 1; // TODO #define
|
||||
|
||||
#ifndef SIMU
|
||||
#if defined(SDCARD) && !defined(SIMU)
|
||||
if (toneWavFile[0]) {
|
||||
FRESULT result = FR_OK;
|
||||
UINT read;
|
||||
@@ -205,20 +205,24 @@ void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
||||
tone2Freq = tFreq;
|
||||
tone2TimeLeft = tLen;
|
||||
tone2Pause = tPause;
|
||||
if (audioState == 0) CoSetFlag(audioFlag);
|
||||
if (audioState == 0) {
|
||||
audioState = 1;
|
||||
CoSetFlag(audioFlag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
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) || (audioState == 0 && audioEmpty())) {
|
||||
if ((tFlags & PLAY_NOW) || !audioBusy()) {
|
||||
toneWavFile[0] = '\0';
|
||||
toneFreq = tFreq;
|
||||
toneTimeLeft = tLen;
|
||||
tonePause = tPause;
|
||||
toneFreqIncr = tFreqIncr;
|
||||
t_queueWidx = t_queueRidx;
|
||||
audioState = 1;
|
||||
CoSetFlag(audioFlag);
|
||||
}
|
||||
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 (e < AU_FRSKY_FIRST || audioEmpty()) {
|
||||
if (e < AU_FRSKY_FIRST || !audioBusy()) {
|
||||
switch (e) {
|
||||
// inactivity timer alert
|
||||
case AU_INACTIVITY:
|
||||
@@ -266,7 +270,7 @@ void audioEvent(uint8_t e, uint8_t f)
|
||||
break;
|
||||
// low battery in tx
|
||||
case AU_TX_BATTERY_LOW:
|
||||
if (audioEmpty()) {
|
||||
if (!audioBusy()) {
|
||||
play(60, 40, 6, 2, 1);
|
||||
play(80, 40, 6, 2, -1);
|
||||
}
|
||||
|
||||
+4
-13
@@ -35,19 +35,18 @@
|
||||
#ifndef audio_h
|
||||
#define audio_h
|
||||
|
||||
#define AUDIO_QUEUE_LENGTH (100)
|
||||
#define AUDIO_QUEUE_LENGTH (20)
|
||||
#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)
|
||||
#define TONE1_RATE_LIMIT (10)
|
||||
#define TONE2_RATE_LIMIT (10)
|
||||
|
||||
extern uint8_t audioState;
|
||||
|
||||
extern uint8_t t_queueRidx;
|
||||
extern uint8_t t_queueWidx;
|
||||
|
||||
extern uint8_t toneFreq;
|
||||
//int8_t toneFreqIncr;
|
||||
extern uint8_t toneTimeLeft;
|
||||
extern uint8_t tonePause;
|
||||
|
||||
@@ -73,25 +72,17 @@ void pause(uint8_t tLen);
|
||||
|
||||
inline bool audioBusy()
|
||||
{
|
||||
return (toneTimeLeft > 0);
|
||||
return (audioState != 0);
|
||||
}
|
||||
|
||||
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_DOWN() audioEvent(AU_KEYPAD_DOWN)
|
||||
#define AUDIO_MENUS() audioEvent(AU_MENUS)
|
||||
#define AUDIO_WARNING1() audioEvent(AU_WARNING1)
|
||||
#define AUDIO_WARNING2() audioEvent(AU_WARNING2)
|
||||
#define AUDIO_ERROR() audioEvent(AU_ERROR)
|
||||
|
||||
#define IS_AUDIO_BUSY() audioBusy()
|
||||
|
||||
#define AUDIO_TIMER_30() audioEvent(AU_TIMER_30)
|
||||
#define AUDIO_TIMER_20() audioEvent(AU_TIMER_20)
|
||||
#define AUDIO_TIMER_10() audioEvent(AU_TIMER_10)
|
||||
|
||||
+1
-1
@@ -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++) {
|
||||
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
@@ -510,7 +510,7 @@ void setupPulses()
|
||||
init_ssc();
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
init_main_ppm(3000, 1); // Initial period 1.5 mS, output on
|
||||
|
||||
Reference in New Issue
Block a user