diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 6a6d84010..686c000f3 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -318,10 +318,12 @@ bool isAudioFileReferenced(uint32_t i, char * filename) return false; } +tmr10ms_t timeAutomaticPromptsSilence = 0; + void playModelEvent(uint8_t category, uint8_t index, uint8_t event) { char filename[AUDIO_FILENAME_MAXLEN+1]; - if (isAudioFileReferenced((category << 24) + (index << 16) + event, filename)) { + if ((get_tmr10ms()-timeAutomaticPromptsSilence > 10) && isAudioFileReferenced((category << 24) + (index << 16) + event, filename)) { audioQueue.playFile(filename); } } diff --git a/radio/src/audio_arm.h b/radio/src/audio_arm.h index 8c67fad5e..3f5ee974c 100644 --- a/radio/src/audio_arm.h +++ b/radio/src/audio_arm.h @@ -305,14 +305,21 @@ void pushPrompt(uint16_t prompt, uint8_t id=0); #define AUDIO_RESET() audioQueue.reset() #if defined(SDCARD) + extern tmr10ms_t timeAutomaticPromptsSilence; void playModelEvent(uint8_t category, uint8_t index, uint8_t event=0); - #define PLAY_PHASE_OFF(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_OFF) - #define PLAY_PHASE_ON(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_ON) - #define PLAY_SWITCH_MOVED(sw) playModelEvent(SWITCH_AUDIO_CATEGORY, sw) + #define PLAY_PHASE_OFF(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_OFF) + #define PLAY_PHASE_ON(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_ON) + #define PLAY_SWITCH_MOVED(sw) playModelEvent(SWITCH_AUDIO_CATEGORY, sw) + #define PLAY_LOGICAL_SWITCH_OFF(sw) playModelEvent(LOGICAL_SWITCH_AUDIO_CATEGORY, sw, AUDIO_EVENT_OFF) + #define PLAY_LOGICAL_SWITCH_ON(sw) playModelEvent(LOGICAL_SWITCH_AUDIO_CATEGORY, sw, AUDIO_EVENT_ON) + #define SKIP_AUTOMATIC_PROMPTS() timeAutomaticPromptsSilence = get_tmr10ms() #else #define PLAY_PHASE_OFF(phase) #define PLAY_PHASE_ON(phase) #define PLAY_SWITCH_MOVED(sw) + #define PLAY_LOGICAL_SWITCH_OFF(sw) + #define PLAY_LOGICAL_SWITCH_ON(sw) + #define SKIP_AUTOMATIC_PROMPTS() #endif void referenceSystemAudioFiles(); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index c35f84ccb..2cb2b37a8 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1327,7 +1327,7 @@ uint32_t switchesPos = 0; tmr10ms_t potsLastposStart[NUM_XPOTS]; uint8_t potsPos[NUM_XPOTS]; -uint32_t check2PosSwitchPosition(EnumKeys sw, bool startup) +uint32_t check2PosSwitchPosition(EnumKeys sw) { uint32_t result; uint32_t index; @@ -1339,7 +1339,7 @@ uint32_t check2PosSwitchPosition(EnumKeys sw, bool startup) result = (1 << index); - if (!startup && !(switchesPos & result)) { + if (!(switchesPos & result)) { PLAY_SWITCH_MOVED(index); } @@ -1375,14 +1375,14 @@ uint32_t check3PosSwitchPosition(uint8_t idx, EnumKeys sw, bool startup) result = (switchesPos & (0x7 << (sw - SW_SA0))); } - if (!startup && !(switchesPos & result)) { + if (!(switchesPos & result)) { PLAY_SWITCH_MOVED(index); } return result; } -#define CHECK_2POS(sw) newPos |= check2PosSwitchPosition(sw ## 0, startup) +#define CHECK_2POS(sw) newPos |= check2PosSwitchPosition(sw ## 0) #define CHECK_3POS(idx, sw) newPos |= check3PosSwitchPosition(idx, sw ## 0, startup) void getSwitchesPosition(bool startup) @@ -1412,7 +1412,7 @@ void getSwitchesPosition(bool startup) else if (startup || (tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > DELAY_SWITCH_3POS) { potsLastposStart[i] = 0; potsPos[i] = (pos << 4) | pos; - if (!startup && previousStoredPos != pos) { + if (previousStoredPos != pos) { PLAY_SWITCH_MOVED(SWSRC_LAST_SWITCH+i*POTS_POS_COUNT+pos); } } @@ -1650,10 +1650,14 @@ bool getSwitch(int8_t swtch) } #endif - if (result) + if (result) { + PLAY_LOGICAL_SWITCH_ON(cs_idx); s_last_switch_value |= mask; - else + } + else { + PLAY_LOGICAL_SWITCH_OFF(cs_idx); s_last_switch_value &= ~mask; + } } } @@ -2998,11 +3002,14 @@ void resetAll() #if defined(FRSKY) resetTelemetry(); #endif - for (uint8_t i=0; i