Use ARRAY_SIZE and VOICE_ID_END instead of magic numbers. (#50)

This commit is contained in:
Wouter 2023-09-28 14:41:56 +02:00 committed by GitHub
parent 93f221126f
commit f22e79bedb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -1636,7 +1636,7 @@ Skip:
gFlagPrepareTX = false; gFlagPrepareTX = false;
} }
if (gAnotherVoiceID != VOICE_ID_INVALID) { if (gAnotherVoiceID != VOICE_ID_INVALID) {
if (gAnotherVoiceID < 76) { if (gAnotherVoiceID < VOICE_ID_END)
AUDIO_SetVoiceID(0, gAnotherVoiceID); AUDIO_SetVoiceID(0, gAnotherVoiceID);
} }
AUDIO_PlaySingleVoice(false); AUDIO_PlaySingleVoice(false);

View File

@ -253,7 +253,7 @@ Bailout:
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID) void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
{ {
if (Index >= 8) { if (Index >= ARRAY_SIZE(gVoiceID)) {
return; return;
} }
if (Index == 0) { if (Index == 0) {
@ -310,14 +310,14 @@ void AUDIO_PlayQueuedVoice(void)
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF) { if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF) {
VoiceID = gVoiceID[gVoiceReadIndex]; VoiceID = gVoiceID[gVoiceReadIndex];
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) { if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) {
if (VoiceID < 58) { if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese)) {
Delay = VoiceClipLengthChinese[VoiceID]; Delay = VoiceClipLengthChinese[VoiceID];
VoiceID += VOICE_ID_CHI_BASE; VoiceID += VOICE_ID_CHI_BASE;
} else { } else {
Skip = true; Skip = true;
} }
} else { } else {
if (VoiceID < 76) { if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish)) {
Delay = VoiceClipLengthEnglish[VoiceID]; Delay = VoiceClipLengthEnglish[VoiceID];
VoiceID += VOICE_ID_ENG_BASE; VoiceID += VOICE_ID_ENG_BASE;
} else { } else {