From f22e79bedb1b0efb890f74c6188e0bd1f22e245a Mon Sep 17 00:00:00 2001 From: Wouter Date: Thu, 28 Sep 2023 14:41:56 +0200 Subject: [PATCH] Use ARRAY_SIZE and VOICE_ID_END instead of magic numbers. (#50) --- app/app.c | 2 +- audio.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app.c b/app/app.c index 13f5859..40a235a 100644 --- a/app/app.c +++ b/app/app.c @@ -1636,7 +1636,7 @@ Skip: gFlagPrepareTX = false; } if (gAnotherVoiceID != VOICE_ID_INVALID) { - if (gAnotherVoiceID < 76) { + if (gAnotherVoiceID < VOICE_ID_END) AUDIO_SetVoiceID(0, gAnotherVoiceID); } AUDIO_PlaySingleVoice(false); diff --git a/audio.c b/audio.c index 6cb8827..c559067 100644 --- a/audio.c +++ b/audio.c @@ -253,7 +253,7 @@ Bailout: void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID) { - if (Index >= 8) { + if (Index >= ARRAY_SIZE(gVoiceID)) { return; } if (Index == 0) { @@ -310,14 +310,14 @@ void AUDIO_PlayQueuedVoice(void) if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF) { VoiceID = gVoiceID[gVoiceReadIndex]; if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE) { - if (VoiceID < 58) { + if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese)) { Delay = VoiceClipLengthChinese[VoiceID]; VoiceID += VOICE_ID_CHI_BASE; } else { Skip = true; } } else { - if (VoiceID < 76) { + if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish)) { Delay = VoiceClipLengthEnglish[VoiceID]; VoiceID += VOICE_ID_ENG_BASE; } else {