[all] Throttle Trace resetted when changing Model

[sky9x] Background music stopped when changing Model
This commit is contained in:
bsongis
2012-10-04 19:24:16 +00:00
parent 2b78b499f4
commit b4b00ecddc
9 changed files with 33 additions and 19 deletions
+1
View File
@@ -84,6 +84,7 @@ extern void beep(uint8_t val);
#define AUDIO_PLAY(p) beep(3) #define AUDIO_PLAY(p) beep(3)
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn) #define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
#define AUDIO_RESET()
#if !defined(PCBSKY9X) #if !defined(PCBSKY9X)
FORCEINLINE void AUDIO_HEARTBEAT() FORCEINLINE void AUDIO_HEARTBEAT()
+2 -1
View File
@@ -498,6 +498,8 @@ void eeLoadModel(uint8_t id)
read32_eeprom_data( ( File_system[id+1].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&g_model, size) ; read32_eeprom_data( ( File_system[id+1].block_no << 12) + sizeof( struct t_eeprom_header), ( uint8_t *)&g_model, size) ;
} }
resetAll();
if (pulsesStarted()) { if (pulsesStarted()) {
checkTHR(); checkTHR();
checkSwitches(); checkSwitches();
@@ -509,7 +511,6 @@ void eeLoadModel(uint8_t id)
activeFunctionSwitches = 0; activeFunctionSwitches = 0;
resetProto(); resetProto();
resetAll();
for (uint8_t i=0; i<MAX_TIMERS; i++) { for (uint8_t i=0; i<MAX_TIMERS; i++) {
if (g_model.timersXtra[i].remanent) { if (g_model.timersXtra[i].remanent) {
+2 -1
View File
@@ -868,6 +868,8 @@ void eeLoadModel(uint8_t id)
eeCheck(true); eeCheck(true);
} }
resetAll();
if (pulsesStarted()) { if (pulsesStarted()) {
checkAll(); checkAll();
resumePulses(); resumePulses();
@@ -878,7 +880,6 @@ void eeLoadModel(uint8_t id)
activeFunctionSwitches = 0; activeFunctionSwitches = 0;
resetProto(); resetProto();
resetAll();
#if defined(PCBGRUVIN9X) #if defined(PCBGRUVIN9X)
for (uint8_t i=0; i<MAX_TIMERS; i++) { for (uint8_t i=0; i<MAX_TIMERS; i++) {
+4 -6
View File
@@ -422,10 +422,6 @@ void menuGeneralSetup(uint8_t event)
} }
} }
#if defined(PCBSKY9X)
extern uint32_t sdAvailableAudioFiles; // TODO move that!
#endif
#if defined(SDCARD) #if defined(SDCARD)
void menuGeneralSdManagerInfo(uint8_t event) void menuGeneralSdManagerInfo(uint8_t event)
{ {
@@ -650,10 +646,12 @@ void menuGeneralSdManager(uint8_t event)
} }
else if (result == STR_SD_FORMAT) { else if (result == STR_SD_FORMAT) {
displayPopup(STR_FORMATTING); displayPopup(STR_FORMATTING);
if (f_mkfs(0, 1, 0) == FR_OK) { closeLogs();
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
sdAvailableAudioFiles = 0; Card_state = SD_ST_DATA;
audioQueue.stopSD();
#endif #endif
if (f_mkfs(0, 1, 0) == FR_OK) {
f_chdir("/"); f_chdir("/");
reusableBuffer.sd.offset = -1; reusableBuffer.sd.offset = -1;
} }
+8 -2
View File
@@ -1557,14 +1557,20 @@ void resetTimer(uint8_t idx)
void resetAll() void resetAll()
{ {
// TODO s_traceCnt to be reset? AUDIO_RESET();
resetTimer(0); resetTimer(0);
resetTimer(1); resetTimer(1);
#ifdef FRSKY #if defined(FRSKY)
resetTelemetry(); resetTelemetry();
#endif #endif
for (uint8_t i=0; i<NUM_CSW; i++) for (uint8_t i=0; i<NUM_CSW; i++)
csLastValue[i] = -32668; csLastValue[i] = -32668;
#if defined(THRTRACE)
s_traceCnt = 0;
s_traceWr = 0;
#endif
} }
static uint8_t lastSwPos[2] = {0, 0}; static uint8_t lastSwPos[2] = {0, 0};
+11 -5
View File
@@ -527,15 +527,21 @@ void AudioQueue::stopPlay(uint8_t id)
void AudioQueue::stopSD() void AudioQueue::stopSD()
{ {
sdAvailableAudioFiles = 0; sdAvailableAudioFiles = 0;
reset();
CoEnterMutexSection(audioMutex);
widx = ridx; // clean the queue
CoLeaveMutexSection(audioMutex);
play(0, 0, 100, PLAY_NOW); // insert a 100ms pause play(0, 0, 100, PLAY_NOW); // insert a 100ms pause
} }
#endif #endif
void AudioQueue::reset()
{
CoEnterMutexSection(audioMutex);
widx = ridx; // clean the queue
memset(&currentContext.fragment, 0, sizeof(AudioFragment));
memset(&backgroundContext.fragment, 0, sizeof(AudioFragment));
CoLeaveMutexSection(audioMutex);
}
void audioEvent(uint8_t e, uint8_t f) void audioEvent(uint8_t e, uint8_t f)
{ {
#ifdef SDCARD #ifdef SDCARD
+3
View File
@@ -111,6 +111,8 @@ class AudioQueue {
return ridx == widx; return ridx == widx;
} }
void reset();
protected: protected:
void wakeup(); void wakeup();
@@ -178,5 +180,6 @@ extern void pushPrompt(uint16_t prompt, uint8_t id=0);
#define PLAY_VALUE(v, id) playValue((v), (id)) #define PLAY_VALUE(v, id) playValue((v), (id))
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id)) #define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id))
#define STOP_PLAY(id) audioQueue.stopPlay((id)) #define STOP_PLAY(id) audioQueue.stopPlay((id))
#define AUDIO_RESET() audioQueue.reset()
#endif #endif
+1 -3
View File
@@ -489,7 +489,7 @@ const char * sdCmd9()
#define SDMMC_SELECT_CARD (7 | HSMCI_CMDR_TRCMD_NO_DATA \ #define SDMMC_SELECT_CARD (7 | HSMCI_CMDR_TRCMD_NO_DATA \
| HSMCI_CMDR_SPCMD_STD \ | HSMCI_CMDR_SPCMD_STD \
| HSMCI_CMDR_RSPTYP_R1B \ | HSMCI_CMDR_RSPTYP_R1B \
| HSMCI_CMDR_MAXLAT /* TODO not the same */ ) | HSMCI_CMDR_MAXLAT )
const char * sdCmd7() const char * sdCmd7()
{ {
@@ -1362,8 +1362,6 @@ DRESULT disk_write (
if ( sd_card_ready() == 0 ) return RES_NOTRDY; if ( sd_card_ready() == 0 ) return RES_NOTRDY;
// TODO if (Stat & STA_PROTECT) return RES_WRPRT;
do { do {
while (1) { while (1) {
+1 -1
View File
@@ -149,4 +149,4 @@ void audioDefevent(uint8_t e);
#define AUDIO_DRIVER() audio.driver() #define AUDIO_DRIVER() audio.driver()
#define AUDIO_HEARTBEAT() audio.heartbeat() #define AUDIO_HEARTBEAT() audio.heartbeat()
#define IS_AUDIO_BUSY() audio.busy() #define IS_AUDIO_BUSY() audio.busy()
#define AUDIO_RESET()