Bold introduced in many menus

PlayTrack for ersky9x
Volume for ersky9x
Names for Mixes and Expos
This commit is contained in:
bsongis
2012-06-29 17:17:48 +00:00
parent 48e3a2ebf4
commit 6b6c945f59
30 changed files with 890 additions and 456 deletions
+83 -1
View File
@@ -33,6 +33,83 @@
#include "../open9x.h"
const char * audioFilenames[] = {
"inactiv",
"lowbatt",
"error",
"keyup",
"keydown",
"menus",
"trim",
"warning1",
"warning2",
"warning3",
"midtrim",
"tada",
"midpot",
"mixwarn1",
"mixwarn2",
"mixwarn3",
"timerlt3",
"timer10",
"timer20",
"timer30"
#if 0
AU_FRSKY_WARN1 = AU_FRSKY_FIRST,
AU_FRSKY_WARN2,
AU_FRSKY_CHEEP,
AU_FRSKY_RING,
AU_FRSKY_SCIFI,
AU_FRSKY_ROBOT,
AU_FRSKY_CHIRP,
AU_FRSKY_TADA,
AU_FRSKY_CRICKET,
AU_FRSKY_SIREN,
AU_FRSKY_ALARMC,
AU_FRSKY_RATATA,
AU_FRSKY_TICK,
#endif
};
uint32_t sdAvailableAudioFiles;
#define AUDIO_FILENAME_PATTERN "/9XSOUNDS/xxxxxxxx.wav"
#if defined(SDCARD)
void retrieveAvailableAudioFiles()
{
FILINFO info;
char filename[] = AUDIO_FILENAME_PATTERN;
assert(sizeof(audioFilenames)==AU_FRSKY_FIRST*sizeof(char *));
assert(sizeof(sdAvailableAudioFiles)*8 > AU_FRSKY_FIRST);
sdAvailableAudioFiles = 0;
for (uint32_t i=0; i<AU_FRSKY_FIRST; i++) {
strcpy(filename+10/*TODO sizeof(...)*/, audioFilenames[i]);
strcat(filename+10, ".wav");
if (f_stat(filename, &info) == FR_OK)
sdAvailableAudioFiles |= ((uint32_t)1 << i);
}
}
inline bool isAudioFileAvailable(uint8_t i, char * filename)
{
if (sdAvailableAudioFiles & ((uint32_t)1 << i)) {
strcpy(filename+10/*TODO sizeof(...)*/, audioFilenames[i]);
strcat(filename+10, ".wav");
return true;
}
else {
return false;
}
}
#else
#define isAudioFileAvailable(i, f) false
#endif
uint8_t audioState = 0;
uint8_t t_queueRidx;
@@ -252,6 +329,8 @@ void playFile(const char *filename)
void audioEvent(uint8_t e, uint8_t f)
{
char filename[] = AUDIO_FILENAME_PATTERN;
#ifdef HAPTIC
haptic.event(e); //do this before audio to help sync timings
#endif
@@ -262,7 +341,10 @@ 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 || !audioBusy()) {
if (e < AU_FRSKY_FIRST && isAudioFileAvailable(e, filename)) {
playFile(filename);
}
else if (e < AU_FRSKY_FIRST || !audioBusy()) {
switch (e) {
// inactivity timer alert
case AU_INACTIVITY:
+1
View File
@@ -65,6 +65,7 @@ extern uint8_t queueTonePause[AUDIO_QUEUE_LENGTH];
extern uint8_t queueToneRepeat[AUDIO_QUEUE_LENGTH];
void initAudio();
extern "C" void retrieveAvailableAudioFiles();
void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags=0, int8_t tFreqIncr=0);
void playFile(const char *filename);
+3 -2
View File
@@ -85,7 +85,7 @@ uint32_t Sd_128_resp[4] ;
uint32_t Sd_rca ;
uint32_t Cmd_8_resp ;
uint32_t Cmd_A41_resp ;
uint8_t cardType;
uint8_t cardType;
/**
* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is
@@ -808,7 +808,7 @@ void sdInit()
extern FATFS g_FATFS_Obj;
void sd_poll_10mS()
void sdPoll10mS()
{
if (!CardIsConnected()) {
Card_state = SD_ST_EMPTY;
@@ -857,6 +857,7 @@ void sd_poll_10mS()
sdAcmd6(); // Set bus width to 4 bits, and speed to 9 MHz
// Should check the card can do this ****
f_mount(0, &g_FATFS_Obj);
retrieveAvailableAudioFiles();
break;
}
}
+25 -30
View File
@@ -225,53 +225,48 @@ void init_twi()
TWI0->TWI_CR = TWI_CR_MSEN | TWI_CR_SVDIS ; // Master mode enable
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
NVIC_EnableIRQ(TWI0_IRQn) ;
set_volume( 2 ) ;
setVolume(2) ;
}
static int16_t Volume_required ;
static int16_t volumeRequiredIrq ;
static const uint8_t Volume_scale[NUM_VOL_LEVELS] =
{
0, 2, 4, 6, 8, 10, 13, 17, 22, 27, 33, 40,
64, 82, 96, 105, 112, 117, 120, 122, 124, 125, 126, 127
} ;
void set_volume( register uint8_t volume )
void setVolume( register uint8_t volume )
{
// PMC->PMC_PCER0 |= 0x00080000L ; // Enable peripheral clock to TWI0
if ( volume >= NUM_VOL_LEVELS )
{
volume = NUM_VOL_LEVELS - 1 ;
}
volume = Volume_scale[volume] ;
if (volume >= NUM_VOL_LEVELS) {
volume = NUM_VOL_LEVELS - 1 ;
}
__disable_irq() ;
if ( TWI0->TWI_IMR & TWI_IMR_TXCOMP )
{
Volume_required = volume ;
}
else
{
TWI0->TWI_THR = volume ; // Send data
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
TWI0->TWI_IER = TWI_IER_TXCOMP ;
volume = Volume_scale[volume] ;
}
__enable_irq() ;
__disable_irq() ;
if ( TWI0->TWI_IMR & TWI_IMR_TXCOMP ) {
volumeRequiredIrq = volume ;
}
else {
TWI0->TWI_THR = volume ; // Send data
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
TWI0->TWI_IER = TWI_IER_TXCOMP ;
}
__enable_irq() ;
}
extern "C" void TWI0_IRQHandler()
{
if ( Volume_required >= 0 )
{
TWI0->TWI_THR = Volume_required ; // Send data
Volume_required = -1 ;
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
}
else
{
TWI0->TWI_IDR = TWI_IDR_TXCOMP ;
}
if ( volumeRequiredIrq >= 0 ) {
TWI0->TWI_THR = volumeRequiredIrq ; // Send data
volumeRequiredIrq = -1 ;
TWI0->TWI_CR = TWI_CR_STOP ; // Stop Tx
}
else {
TWI0->TWI_IDR = TWI_IDR_TXCOMP ;
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ inline void toneStop()
extern volatile uint8_t Buzzer_count ;
extern void init_twi( void ) ;
extern void set_volume( register uint8_t volume ) ;
extern void setVolume( register uint8_t volume ) ;
extern "C" void TWI0_IRQHandler (void) ;
#endif