From 1f71789a9d2b284ec122834cb05f8c457d81bda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Wed, 22 Jun 2022 20:21:18 +0200 Subject: [PATCH] Apply clang-format --- openrtx/include/core/voicePromptUtils.h | 46 +- openrtx/include/core/voicePrompts.h | 380 ++++----- openrtx/include/ui/EnglishStrings.h | 136 ++-- openrtx/include/ui/UIStrings.h | 137 ++-- openrtx/src/core/voicePromptUtils.c | 989 ++++++++++++------------ openrtx/src/core/voicePrompts.c | 549 ++++++------- openrtx/src/ui/UIStrings.c | 49 +- 7 files changed, 1153 insertions(+), 1133 deletions(-) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index f016f911..60369424 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -16,53 +16,57 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, see * ***************************************************************************/ - // This file contains functions for announcing radio operations using the - // building blocks in voicePrompts.h/c. - #ifndef VOICE_PROMPT_UTILS_H_INCLUDED - #define VOICE_PROMPT_UTILS_H_INCLUDED - - #include "voicePrompts.h" -#include "ui/UIStrings.h" +// This file contains functions for announcing radio operations using the +// building blocks in voicePrompts.h/c. +#ifndef VOICE_PROMPT_UTILS_H_INCLUDED +#define VOICE_PROMPT_UTILS_H_INCLUDED + #include "cps.h" +#include "ui/UIStrings.h" +#include "voicePrompts.h" /* Please Note! -Many of the functions take queue flags because sometimes messages must be -played in sequence (i.e. the announceXX functions may be called one after the -other) and thus the init must only be sent prior to the first message queued +Many of the functions take queue flags because sometimes messages must be +played in sequence (i.e. the announceXX functions may be called one after the +other) and thus the init must only be sent prior to the first message queued and the play must only be invoked after the last message queued. -When an announceXX function is called in isolation, vpqInit|vpqPlayImmediately -should be used to ensure that the message interupts the current prompt and +When an announceXX function is called in isolation, vpqInit|vpqPlayImmediately +should be used to ensure that the message interupts the current prompt and plays immediately. */ void announceVFO(); -void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags); +void announceChannelName(channel_t* channel, uint16_t channelIndex, + VoicePromptQueueFlags_T flags); void vpQueueFrequency(freq_t freq); void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags); void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags); void announceBandwidth(uint8_t bandwidth, VoicePromptQueueFlags_T flags); -void announceChannelSummary(channel_t* channel, uint16_t channelIndex, uint16_t bank); +void announceChannelSummary(channel_t* channel, uint16_t channelIndex, + uint16_t bank); void AnnounceInputChar(char ch); void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags); void ReplayLastPrompt(); void announceError(VoicePromptQueueFlags_T flags); -/* -This function first tries to see if we have a prompt for the text -passed in and if so, queues it, but if not, just spells the text +/* +This function first tries to see if we have a prompt for the text +passed in and if so, queues it, but if not, just spells the text character by character. */ -void announceText( char* text, VoicePromptQueueFlags_T flags); -void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, uint8_t txTone, VoicePromptQueueFlags_T flags); +void announceText(char* text, VoicePromptQueueFlags_T flags); +void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, + uint8_t txTone, VoicePromptQueueFlags_T flags); void anouncePower(float power, VoicePromptQueueFlags_T flags); void announceBrightness(uint8_t brightness, VoicePromptQueueFlags_T flags); void announceSquelch(uint8_t squelch, VoicePromptQueueFlags_T flags); void announceContact(contact_t* contact, VoicePromptQueueFlags_T flags); void announceContactWithIndex(uint16_t index, VoicePromptQueueFlags_T flags); void announceTimeslot(uint8_t timeslot, VoicePromptQueueFlags_T flags); -void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, VoicePromptQueueFlags_T flags); +void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, + VoicePromptQueueFlags_T flags); void announceBank(uint16_t bank, VoicePromptQueueFlags_T flags); void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags); #ifdef GPS_PRESENT @@ -76,4 +80,4 @@ void announceSettingsTimeDate(); #endif // RTC_PRESENT VoicePromptQueueFlags_T GetQueueFlagsForVoiceLevel(); -#endif //VOICE_PROMPT_UTILS_H_INCLUDED \ No newline at end of file +#endif // VOICE_PROMPT_UTILS_H_INCLUDED diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index 7382616d..1d2da3b8 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -23,218 +23,220 @@ #include /* -Please note, these prompts represent spoken words or phrases which are not in -the UI string table, for example letters of the alphabet, digits, and +Please note, these prompts represent spoken words or phrases which are not in +the UI string table, for example letters of the alphabet, digits, and descriptive words not displayed in the UI. -The voice prompt data file stores these first, then after the data for these +The voice prompt data file stores these first, then after the data for these prompts, the data for the indexed string table phrases. */ -/* Please note! this enum must match the order of prompts defined in the -wordlist.csv file in the voicePrompts generator project. +/* Please note! this enum must match the order of prompts defined in the +wordlist.csv file in the voicePrompts generator project. */ typedef enum { -PROMPT_SILENCE, // -PROMPT_0, // 0 -PROMPT_1, // 1 -PROMPT_2, // 2 -PROMPT_3, // 3 -PROMPT_4, // 4 -PROMPT_5, // 5 -PROMPT_6, // 6 -PROMPT_7, // 7 -PROMPT_8, // 8 -PROMPT_9, // 9 -PROMPT_A, // A -PROMPT_B, // B -PROMPT_C, // C -PROMPT_D, // D -PROMPT_E, // E -PROMPT_F, // F -PROMPT_G, // G -PROMPT_H, // H -PROMPT_I, // I -PROMPT_J, // J -PROMPT_K, // K -PROMPT_L, // L -PROMPT_M, // M -PROMPT_N, // N -PROMPT_O, // O -PROMPT_P, // P -PROMPT_Q, // Q -PROMPT_R, // R -PROMPT_S, // S -PROMPT_T, // T -PROMPT_U, // U -PROMPT_V, // V -PROMPT_W, // W -PROMPT_X, // X -PROMPT_Y, // Y -PROMPT_Z, // Zed -PROMPT_A_PHONETIC, // alpha -PROMPT_B_PHONETIC, // bravo -PROMPT_C_PHONETIC, // charlie -PROMPT_D_PHONETIC, // delta -PROMPT_E_PHONETIC, // echo -PROMPT_F_PHONETIC, // foxtrot -PROMPT_G_PHONETIC, // golf -PROMPT_H_PHONETIC, // hotel -PROMPT_I_PHONETIC, // india -PROMPT_J_PHONETIC, // juliet -PROMPT_K_PHONETIC, // kilo -PROMPT_L_PHONETIC, // lema -PROMPT_M_PHONETIC, // mike -PROMPT_N_PHONETIC, // november -PROMPT_O_PHONETIC, // oscar -PROMPT_P_PHONETIC, // papa -PROMPT_Q_PHONETIC, // quebec -PROMPT_R_PHONETIC, // romeo -PROMPT_S_PHONETIC, // siera -PROMPT_T_PHONETIC, // tango -PROMPT_U_PHONETIC, // uniform -PROMPT_V_PHONETIC, // victor -PROMPT_W_PHONETIC, // whisky -PROMPT_X_PHONETIC, // exray -PROMPT_Y_PHONETIC, // yankie -PROMPT_Z_PHONETIC, // zulu -PROMPT_CAP, // cap -PROMPT_HERTZ, // hertz -PROMPT_KILOHERTZ, // Kilohertz -PROMPT_MEGAHERTZ, // Megahertz -PROMPT_CHANNEL, -PROMPT_VFO, // V F O -PROMPT_MILLISECONDS, // Milliseconds -PROMPT_SECONDS, // Seconds -PROMPT_MINUTES, // Minutes -PROMPT_VOLTS, // Volts -PROMPT_MILLIWATTS, // Milliwatts -PROMPT_WATT, // Wattt -PROMPT_WATTS, // Watts -PROMPT_RECEIVE, // Receive -PROMPT_TRANSMIT, // Transmit -PROMPT_MODE, // Mode -PROMPT_BANDWIDTH, // bandwidth -PROMPT_POWER, // power -PROMPT_SQUELCH, // squelch -PROMPT_SOURCE_ID, // Source ID -PROMPT_DEST_ID, // Destination ID -PROMPT_DMR_ID, // DMR ID -PROMPT_TALKGROUP, // Talk group -PROMPT_TIMESLOT, // timeslot -PROMPT_COLORCODE, // color code -PROMPT_TONE, // tone -PROMPT_CONTACT, // contact -PROMPT_NORTH, // north -PROMPT_SOUTH, // south -PROMPT_EAST, // east -PROMPT_WEST, // west -PROMPT_LATITUDE, // latitude -PROMPT_LONGITUDE, // longitude -PROMPT_SPEED, // speed -PROMPT_ALTITUDE, // altitude -PROMPT_SATELLITES, // satellites -PROMPT_COMPASS, // compass -PROMPT_DEGREES, // degrees -PROMPT_VP_UNAVAILABLE, // Voice prompts will be unavailable during this operation. -PROMPT_CHARACTER, // character -PROMPT_SPACE, // space -PROMPT_PERCENT, // Percent -PROMPT_POINT, // POINT -PROMPT_PLUS, // Plus -PROMPT_MINUS, // Minus -PROMPT_STAR, // Star -PROMPT_HASH, // Hash -PROMPT_EXCLAIM, // exclaim -PROMPT_COMMA, // comma -PROMPT_AT, // at -PROMPT_COLON, // colon -PROMPT_QUESTION, // question -PROMPT_LEFT_PAREN, // left paren -PROMPT_RIGHT_PAREN, // right paren -PROMPT_TILDE, // tilde -PROMPT_SLASH, // slash -PROMPT_LEFT_BRACKET, // left bracket -PROMPT_RIGHT_BRACKET, // right bracket -PROMPT_LESS, // less -PROMPT_GREATER, // greater -PROMPT_EQUALS, // equals -PROMPT_DOLLAR, // dollar -PROMPT_APOSTROPHE, // apostrophe -PROMPT_GRAVE, // grave -PROMPT_AMPERSAND, // and -PROMPT_BAR, // bar -PROMPT_UNDERLINE, // underline -PROMPT_CARET, // caret -PROMPT_LEFT_BRACE, // left brace -PROMPT_CUSTOM1, // Hotspot -PROMPT_CUSTOM2, // ClearNode -PROMPT_CUSTOM3, // ShariNode -PROMPT_CUSTOM4, // MicroHub -PROMPT_CUSTOM5, // Openspot -PROMPT_CUSTOM6, // repeater -PROMPT_CUSTOM7, // BlindHams -PROMPT_CUSTOM8, // Allstar -PROMPT_CUSTOM9, // parrot -PROMPT_CUSTOM10, // unused -NUM_VOICE_PROMPTS, + PROMPT_SILENCE, // + PROMPT_0, // 0 + PROMPT_1, // 1 + PROMPT_2, // 2 + PROMPT_3, // 3 + PROMPT_4, // 4 + PROMPT_5, // 5 + PROMPT_6, // 6 + PROMPT_7, // 7 + PROMPT_8, // 8 + PROMPT_9, // 9 + PROMPT_A, // A + PROMPT_B, // B + PROMPT_C, // C + PROMPT_D, // D + PROMPT_E, // E + PROMPT_F, // F + PROMPT_G, // G + PROMPT_H, // H + PROMPT_I, // I + PROMPT_J, // J + PROMPT_K, // K + PROMPT_L, // L + PROMPT_M, // M + PROMPT_N, // N + PROMPT_O, // O + PROMPT_P, // P + PROMPT_Q, // Q + PROMPT_R, // R + PROMPT_S, // S + PROMPT_T, // T + PROMPT_U, // U + PROMPT_V, // V + PROMPT_W, // W + PROMPT_X, // X + PROMPT_Y, // Y + PROMPT_Z, // Zed + PROMPT_A_PHONETIC, // alpha + PROMPT_B_PHONETIC, // bravo + PROMPT_C_PHONETIC, // charlie + PROMPT_D_PHONETIC, // delta + PROMPT_E_PHONETIC, // echo + PROMPT_F_PHONETIC, // foxtrot + PROMPT_G_PHONETIC, // golf + PROMPT_H_PHONETIC, // hotel + PROMPT_I_PHONETIC, // india + PROMPT_J_PHONETIC, // juliet + PROMPT_K_PHONETIC, // kilo + PROMPT_L_PHONETIC, // lema + PROMPT_M_PHONETIC, // mike + PROMPT_N_PHONETIC, // november + PROMPT_O_PHONETIC, // oscar + PROMPT_P_PHONETIC, // papa + PROMPT_Q_PHONETIC, // quebec + PROMPT_R_PHONETIC, // romeo + PROMPT_S_PHONETIC, // siera + PROMPT_T_PHONETIC, // tango + PROMPT_U_PHONETIC, // uniform + PROMPT_V_PHONETIC, // victor + PROMPT_W_PHONETIC, // whisky + PROMPT_X_PHONETIC, // exray + PROMPT_Y_PHONETIC, // yankie + PROMPT_Z_PHONETIC, // zulu + PROMPT_CAP, // cap + PROMPT_HERTZ, // hertz + PROMPT_KILOHERTZ, // Kilohertz + PROMPT_MEGAHERTZ, // Megahertz + PROMPT_CHANNEL, + PROMPT_VFO, // V F O + PROMPT_MILLISECONDS, // Milliseconds + PROMPT_SECONDS, // Seconds + PROMPT_MINUTES, // Minutes + PROMPT_VOLTS, // Volts + PROMPT_MILLIWATTS, // Milliwatts + PROMPT_WATT, // Wattt + PROMPT_WATTS, // Watts + PROMPT_RECEIVE, // Receive + PROMPT_TRANSMIT, // Transmit + PROMPT_MODE, // Mode + PROMPT_BANDWIDTH, // bandwidth + PROMPT_POWER, // power + PROMPT_SQUELCH, // squelch + PROMPT_SOURCE_ID, // Source ID + PROMPT_DEST_ID, // Destination ID + PROMPT_DMR_ID, // DMR ID + PROMPT_TALKGROUP, // Talk group + PROMPT_TIMESLOT, // timeslot + PROMPT_COLORCODE, // color code + PROMPT_TONE, // tone + PROMPT_CONTACT, // contact + PROMPT_NORTH, // north + PROMPT_SOUTH, // south + PROMPT_EAST, // east + PROMPT_WEST, // west + PROMPT_LATITUDE, // latitude + PROMPT_LONGITUDE, // longitude + PROMPT_SPEED, // speed + PROMPT_ALTITUDE, // altitude + PROMPT_SATELLITES, // satellites + PROMPT_COMPASS, // compass + PROMPT_DEGREES, // degrees + PROMPT_VP_UNAVAILABLE, // Voice prompts will be unavailable during this + // operation. + PROMPT_CHARACTER, // character + PROMPT_SPACE, // space + PROMPT_PERCENT, // Percent + PROMPT_POINT, // POINT + PROMPT_PLUS, // Plus + PROMPT_MINUS, // Minus + PROMPT_STAR, // Star + PROMPT_HASH, // Hash + PROMPT_EXCLAIM, // exclaim + PROMPT_COMMA, // comma + PROMPT_AT, // at + PROMPT_COLON, // colon + PROMPT_QUESTION, // question + PROMPT_LEFT_PAREN, // left paren + PROMPT_RIGHT_PAREN, // right paren + PROMPT_TILDE, // tilde + PROMPT_SLASH, // slash + PROMPT_LEFT_BRACKET, // left bracket + PROMPT_RIGHT_BRACKET, // right bracket + PROMPT_LESS, // less + PROMPT_GREATER, // greater + PROMPT_EQUALS, // equals + PROMPT_DOLLAR, // dollar + PROMPT_APOSTROPHE, // apostrophe + PROMPT_GRAVE, // grave + PROMPT_AMPERSAND, // and + PROMPT_BAR, // bar + PROMPT_UNDERLINE, // underline + PROMPT_CARET, // caret + PROMPT_LEFT_BRACE, // left brace + PROMPT_CUSTOM1, // Hotspot + PROMPT_CUSTOM2, // ClearNode + PROMPT_CUSTOM3, // ShariNode + PROMPT_CUSTOM4, // MicroHub + PROMPT_CUSTOM5, // Openspot + PROMPT_CUSTOM6, // repeater + PROMPT_CUSTOM7, // BlindHams + PROMPT_CUSTOM8, // Allstar + PROMPT_CUSTOM9, // parrot + PROMPT_CUSTOM10, // unused + NUM_VOICE_PROMPTS, } voicePrompt_t; -// PROMPT_VOICE_NAME is always the very last prompt after the indexed prompts +// PROMPT_VOICE_NAME is always the very last prompt after the indexed prompts // from the strings table. -#define PROMPT_VOICE_NAME (NUM_VOICE_PROMPTS + (sizeof(stringsTable_t)/sizeof(char*))) +#define PROMPT_VOICE_NAME \ + (NUM_VOICE_PROMPTS + (sizeof(stringsTable_t) / sizeof(char*))) /* These flags govern how vpQueueString operates. -For example, when editing, it is desireable to hear spaces, capitals and +For example, when editing, it is desireable to hear spaces, capitals and extended symbols. -When just arrowing through menus, spaces, extended symbols etc should not be +When just arrowing through menus, spaces, extended symbols etc should not be announced. */ typedef enum { - vpAnnounceCaps=0x01, - vpAnnounceCustomPrompts=0x02, - vpAnnounceSpace=0x04, - vpAnnounceCommonSymbols=0x08, - vpAnnounceLessCommonSymbols=0x10, - vpAnnounceASCIIValueForUnknownChars=0x20, - vpAnnouncePhoneticRendering=0x40, + vpAnnounceCaps = 0x01, + vpAnnounceCustomPrompts = 0x02, + vpAnnounceSpace = 0x04, + vpAnnounceCommonSymbols = 0x08, + vpAnnounceLessCommonSymbols = 0x10, + vpAnnounceASCIIValueForUnknownChars = 0x20, + vpAnnouncePhoneticRendering = 0x40, } VoicePromptFlags_T; /* -These queuing flags determine if speech is interrupted, played +These queuing flags determine if speech is interrupted, played immediately, whether prompts are queued for values, etc. -They are necessary because for example if you call the announceXX functions -consecutively, it is only desireable to initially stop speech in +They are necessary because for example if you call the announceXX functions +consecutively, it is only desireable to initially stop speech in progress and only play after the last prompt is queued. -If however calling an announceXX function in isolation, normally any prompt in +If however calling an announceXX function in isolation, normally any prompt in progress should be interrupted and play should be called immediately. -At Voice level 1, changing channels in memory mode or frequencies in VFO mode -is indicated by a beep however if F1 is pressed, we will still say the current -channel name or frequency. This is accomplished by queueing but not playing a +At Voice level 1, changing channels in memory mode or frequencies in VFO mode +is indicated by a beep however if F1 is pressed, we will still say the current +channel name or frequency. This is accomplished by queueing but not playing a prompt. */ typedef enum { - vpqDefault = 0, - vpqInit=0x01, // stop any voice prompts already in progress. - vpqPlayImmediately=0x02, // call play after queue at all levels. - vpqPlayImmediatelyAtMediumOrHigher =0x04, - vpqIncludeDescriptions=0x08, - vpqAddSeparatingSilence=0x10 + vpqDefault = 0, + vpqInit = 0x01, // stop any voice prompts already in progress. + vpqPlayImmediately = 0x02, // call play after queue at all levels. + vpqPlayImmediatelyAtMediumOrHigher = 0x04, + vpqIncludeDescriptions = 0x08, + vpqAddSeparatingSilence = 0x10 } VoicePromptQueueFlags_T; typedef enum { - vpNone=0, - vpBeep, - vpLow, - vpMedium, - vpHigh + vpNone = 0, + vpBeep, + vpLow, + vpMedium, + vpHigh } VoicePromptVerbosity_T; typedef struct { - const char* userWord; - const voicePrompt_t vp; + const char* userWord; + const voicePrompt_t vp; } userDictEntry; extern bool vpDataIsLoaded; @@ -246,25 +248,25 @@ void vpCacheInit(void); void vpTick(void); // Call before building the prompt sequence to clear prompt in progress. void vpInit(void); -// This function appends an individual prompt item to the prompt queue. +// This function appends an individual prompt item to the prompt queue. // This can be a single letter, number, or a phrase. void vpQueuePrompt(uint16_t prompt); // This function appends the spelling of a complete string to the queue. -// It is used to pronounce strings for which we do not have a recorded voice -//prompt. -void vpQueueString(char *promptString, VoicePromptFlags_T flags); - // This function appends a signed integer to the queue. +// It is used to pronounce strings for which we do not have a recorded voice +// prompt. +void vpQueueString(char* promptString, VoicePromptFlags_T flags); +// This function appends a signed integer to the queue. void vpQueueInteger(int32_t value); // This function appends a text string from the current language to the queue. // e.g. currentLanguage->off -// These are recorded prompts which correspond to the strings in the strings +// These are recorded prompts which correspond to the strings in the strings // table. -void vpQueueStringTableEntry(const char * const *); +void vpQueueStringTableEntry(const char* const*); -void vpPlay(void);// Starts prompt playback +void vpPlay(void); // Starts prompt playback extern bool vpIsPlaying(void); bool vpHasDataToPlay(void); void vpTerminate(void); -bool vpCheckHeader(uint32_t *bufferAddress); - +bool vpCheckHeader(uint32_t* bufferAddress); + #endif \ No newline at end of file diff --git a/openrtx/include/ui/EnglishStrings.h b/openrtx/include/ui/EnglishStrings.h index c056bdce..2436c110 100644 --- a/openrtx/include/ui/EnglishStrings.h +++ b/openrtx/include/ui/EnglishStrings.h @@ -3,7 +3,7 @@ * Niccolò Izzo IU2KIN * * Frederik Saraci IU2NRO * * Silvano Seva IU2KWO * - * Joseph Stephen VK7JS * + * Joseph Stephen VK7JS * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * @@ -20,71 +20,71 @@ #ifndef EnglishStrings_h_included #define EnglishStrings_h_included #include "ui/UIStrings.h" -const stringsTable_t englishStrings = -{ - .languageName = "English", - .off = "OFF", - .on = "ON", - .banks = "Banks", - .channels = "Channels", - .contacts = "Contacts", - .gps = "GPS", - .settings = "Settings", - .backupAndRestore = "Backup & Restore", - .info = "Info", - .about = "About", - .display = "Display", - .timeAndDate = "Time & Date", - .fm = "FM", - .m17 = "M17", - .dmr = "DMR", - .defaultSettings = "Default Settings", - .brightness = "Brightness", - .contrast = "Contrast", - .timer = "Timer", - .gpsEnabled = "GPS Enabled", - .gpsSetTime = "GPS Set Time", - .UTCTimeZone = "UTC Timezone", - .voice = "Voice", - .level = "Level", - .phonetic = "Phonetic", - .beep = "Beep", - .backup = "Backup", - .restore = "Restore", - .batteryVoltage = "Bat. Voltage", - .batteryCharge = "Bat. Charge", - .RSSI = "RSSI", - .model = "Model", - .band = "Band", - .VHF = "VHF", - .UHF = "UHF", - .LCDType = "LCD Type", - .Niccolo = "Niccolo' IU2KIN", - .Silvano = "Silvano IU2KWO", - .Federico = "Federico IU2NUO", - .Fred = "Fred IU2NRO", - .Joseph = "Joseph VK7JS", - .allChannels = "All channels", - .menu= "Menu", - .gpsOff = "GPS OFF", - .noFix = "No Fix", - .fixLost = "Fix Lost", - .error = "ERROR", - .flashBackup = "Flash Backup", - .connectToRTXTool = "Connect to RTXTool", - .toBackupFlashAnd = "to backup flash and", - .pressPTTToStart = "press PTT to start.", - .flashRestore = "Flash Restore", - .toRestoreFlashAnd = "to restore flash and", - .openRTX = "OpenRTX", - .gpsSettings = "GPS Settings", - .m17settings = "M17 Settings", - .callsign = "Callsign:", - .resetToDefaults = "Reset to Defaults", - .toReset = "To reset:", - .pressEnterTwice = "Press Enter twice", - .macroMenu = "Macro Menu", - .forEmergencyUse = "For emergency use", - .pressAnyButton = "press any button.", + +const stringsTable_t englishStrings = { + .languageName = "English", + .off = "OFF", + .on = "ON", + .banks = "Banks", + .channels = "Channels", + .contacts = "Contacts", + .gps = "GPS", + .settings = "Settings", + .backupAndRestore = "Backup & Restore", + .info = "Info", + .about = "About", + .display = "Display", + .timeAndDate = "Time & Date", + .fm = "FM", + .m17 = "M17", + .dmr = "DMR", + .defaultSettings = "Default Settings", + .brightness = "Brightness", + .contrast = "Contrast", + .timer = "Timer", + .gpsEnabled = "GPS Enabled", + .gpsSetTime = "GPS Set Time", + .UTCTimeZone = "UTC Timezone", + .voice = "Voice", + .level = "Level", + .phonetic = "Phonetic", + .beep = "Beep", + .backup = "Backup", + .restore = "Restore", + .batteryVoltage = "Bat. Voltage", + .batteryCharge = "Bat. Charge", + .RSSI = "RSSI", + .model = "Model", + .band = "Band", + .VHF = "VHF", + .UHF = "UHF", + .LCDType = "LCD Type", + .Niccolo = "Niccolo' IU2KIN", + .Silvano = "Silvano IU2KWO", + .Federico = "Federico IU2NUO", + .Fred = "Fred IU2NRO", + .Joseph = "Joseph VK7JS", + .allChannels = "All channels", + .menu = "Menu", + .gpsOff = "GPS OFF", + .noFix = "No Fix", + .fixLost = "Fix Lost", + .error = "ERROR", + .flashBackup = "Flash Backup", + .connectToRTXTool = "Connect to RTXTool", + .toBackupFlashAnd = "to backup flash and", + .pressPTTToStart = "press PTT to start.", + .flashRestore = "Flash Restore", + .toRestoreFlashAnd = "to restore flash and", + .openRTX = "OpenRTX", + .gpsSettings = "GPS Settings", + .m17settings = "M17 Settings", + .callsign = "Callsign:", + .resetToDefaults = "Reset to Defaults", + .toReset = "To reset:", + .pressEnterTwice = "Press Enter twice", + .macroMenu = "Macro Menu", + .forEmergencyUse = "For emergency use", + .pressAnyButton = "press any button.", }; -#endif //EnglishStrings_h_included +#endif // EnglishStrings_h_included diff --git a/openrtx/include/ui/UIStrings.h b/openrtx/include/ui/UIStrings.h index 9b40f122..bd04b8ec 100644 --- a/openrtx/include/ui/UIStrings.h +++ b/openrtx/include/ui/UIStrings.h @@ -3,7 +3,7 @@ * Niccolò Izzo IU2KIN * * Frederik Saraci IU2NRO * * Silvano Seva IU2KWO * - * Joseph Stephen VK7JS * + * Joseph Stephen VK7JS * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * @@ -18,8 +18,9 @@ * along with this program; if not, see * ***************************************************************************/ /* -This string table's order must not be altered as voice prompts will be indexed in the same order as these strings. -Also, menus may be printed using string table offsets. +This string table's order must not be altered as voice prompts will be indexed +in the same order as these strings. Also, menus may be printed using string +table offsets. */ #ifndef UIStrings_h_included #define UIStrings_h_included @@ -27,75 +28,75 @@ Also, menus may be printed using string table offsets. typedef struct { - const char* languageName; - const char* off; - const char* on; - const char* banks; - const char* channels; - const char* contacts; - const char* gps; - const char* settings; - const char* backupAndRestore; - const char* info; - const char* about; - const char* display; - const char* timeAndDate; - const char* fm; - const char* m17; - const char* dmr; - const char* defaultSettings; - const char* brightness; - const char* contrast; - const char* timer; - const char* gpsEnabled; - const char* gpsSetTime; - const char* UTCTimeZone; - const char* voice; - const char* level; - const char* phonetic; - const char* beep; - const char* backup; - const char* restore; - const char* batteryVoltage; - const char* batteryCharge; - const char* RSSI; - const char* model; - const char* band; - const char* VHF; - const char* UHF; - const char* LCDType; - const char* Niccolo; - const char* Silvano; - const char* Federico; - const char* Fred; - const char* Joseph; - const char* allChannels; - const char* menu; - const char* gpsOff; - const char* noFix; - const char* fixLost; - const char* error; - const char* flashBackup; - const char* connectToRTXTool; - const char* toBackupFlashAnd; - const char* pressPTTToStart; - const char* flashRestore; - const char* toRestoreFlashAnd; - const char* openRTX; - const char* gpsSettings; - const char* callsign; - const char* m17settings; - const char* resetToDefaults; - const char* toReset; - const char* pressEnterTwice; - const char* macroMenu; - const char* forEmergencyUse; - const char* pressAnyButton; + const char* languageName; + const char* off; + const char* on; + const char* banks; + const char* channels; + const char* contacts; + const char* gps; + const char* settings; + const char* backupAndRestore; + const char* info; + const char* about; + const char* display; + const char* timeAndDate; + const char* fm; + const char* m17; + const char* dmr; + const char* defaultSettings; + const char* brightness; + const char* contrast; + const char* timer; + const char* gpsEnabled; + const char* gpsSetTime; + const char* UTCTimeZone; + const char* voice; + const char* level; + const char* phonetic; + const char* beep; + const char* backup; + const char* restore; + const char* batteryVoltage; + const char* batteryCharge; + const char* RSSI; + const char* model; + const char* band; + const char* VHF; + const char* UHF; + const char* LCDType; + const char* Niccolo; + const char* Silvano; + const char* Federico; + const char* Fred; + const char* Joseph; + const char* allChannels; + const char* menu; + const char* gpsOff; + const char* noFix; + const char* fixLost; + const char* error; + const char* flashBackup; + const char* connectToRTXTool; + const char* toBackupFlashAnd; + const char* pressPTTToStart; + const char* flashRestore; + const char* toRestoreFlashAnd; + const char* openRTX; + const char* gpsSettings; + const char* callsign; + const char* m17settings; + const char* resetToDefaults; + const char* toReset; + const char* pressEnterTwice; + const char* macroMenu; + const char* forEmergencyUse; + const char* pressAnyButton; } stringsTable_t; extern const stringsTable_t languages[]; extern const stringsTable_t* currentLanguage; -int GetEnglishStringTableOffset( char* text); +int GetEnglishStringTableOffset(char* text); #endif \ No newline at end of file diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 180ec1c9..220577e8 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -16,642 +16,641 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, see * ***************************************************************************/ - // This file contains functions for announcing radio functions using the building blocks in voicePrompts.h/c. + +/** + * This file contains functions for announcing radio functions using the + * building blocks in voicePrompts.h/c. + */ + +#include "core/voicePromptUtils.h" + +#include #include #include #include -#include + #include "interfaces/cps_io.h" -#include "core/voicePromptUtils.h" static void vpInitIfNeeded(VoicePromptQueueFlags_T flags) { - if (flags & vpqInit) - vpInit(); + if (flags & vpqInit) vpInit(); } static void vpPlayIfNeeded(VoicePromptQueueFlags_T flags) { - uint8_t vpLevel = state.settings.vpLevel; - - if ((flags & vpqPlayImmediately) - || ((flags & vpqPlayImmediatelyAtMediumOrHigher) && (vpLevel >= vpMedium))) - vpPlay(); + uint8_t vpLevel = state.settings.vpLevel; + + if ((flags & vpqPlayImmediately) || + ((flags & vpqPlayImmediatelyAtMediumOrHigher) && (vpLevel >= vpMedium))) + vpPlay(); } static void addSilenceIfNeeded(VoicePromptQueueFlags_T flags) { - if ((flags & vpqAddSeparatingSilence) == 0) - return; - - vpQueuePrompt(PROMPT_SILENCE); - vpQueuePrompt(PROMPT_SILENCE); + if ((flags & vpqAddSeparatingSilence) == 0) return; + + vpQueuePrompt(PROMPT_SILENCE); + vpQueuePrompt(PROMPT_SILENCE); } -static void removeUnnecessaryZerosFromVoicePrompts(char *str) +static void removeUnnecessaryZerosFromVoicePrompts(char* str) { - const int NUM_DECIMAL_PLACES = 1; - int len = strlen(str); - for(int i = len; i > 2; i--) - { - if ((str[i - 1] != '0') || (str[i - (NUM_DECIMAL_PLACES + 1)] == '.')) - { - str[i] = 0; - return; - } - } + const int NUM_DECIMAL_PLACES = 1; + int len = strlen(str); + for (int i = len; i > 2; i--) + { + if ((str[i - 1] != '0') || (str[i - (NUM_DECIMAL_PLACES + 1)] == '.')) + { + str[i] = 0; + return; + } + } } void announceVFO() { - vpInit(); - - vpQueuePrompt(PROMPT_VFO); - - vpPlay(); + vpInit(); + + vpQueuePrompt(PROMPT_VFO); + + vpPlay(); } -void announceChannelName(channel_t* channel, uint16_t channelIndex, -VoicePromptQueueFlags_T flags) +void announceChannelName(channel_t* channel, uint16_t channelIndex, + VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - { - vpQueuePrompt(PROMPT_CHANNEL); - } - vpQueueInteger(channelIndex); - - // Only queue the name if it is not the same as the raw number. - // Otherwise the radio will say channel 1 1 for channel 1. - char numAsStr[16]="\0"; + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) + { + vpQueuePrompt(PROMPT_CHANNEL); + } + vpQueueInteger(channelIndex); + + // Only queue the name if it is not the same as the raw number. + // Otherwise the radio will say channel 1 1 for channel 1. + char numAsStr[16] = "\0"; snprintf(numAsStr, 16, "%d", channelIndex); - if (strcmp(numAsStr, channel->name) != 0) - vpQueueString(channel->name, vpAnnounceCommonSymbols); - - vpPlayIfNeeded(flags); + if (strcmp(numAsStr, channel->name) != 0) + vpQueueString(channel->name, vpAnnounceCommonSymbols); + + vpPlayIfNeeded(flags); } void vpQueueFrequency(freq_t freq) { - char buffer[16]; - int mhz = (freq / 1000000); - int khz = ((freq%1000000) / 10); - - snprintf(buffer, 16, "%d.%05d", mhz, khz); - removeUnnecessaryZerosFromVoicePrompts(buffer); - - vpQueueString(buffer, vpAnnounceCommonSymbols); + char buffer[16]; + int mhz = (freq / 1000000); + int khz = ((freq % 1000000) / 10); - vpQueuePrompt(PROMPT_MEGAHERTZ); + snprintf(buffer, 16, "%d.%05d", mhz, khz); + removeUnnecessaryZerosFromVoicePrompts(buffer); + + vpQueueString(buffer, vpAnnounceCommonSymbols); + + vpQueuePrompt(PROMPT_MEGAHERTZ); } void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - // if rx and tx frequencies differ, announce both, otherwise just announce - // one. - if (rx == tx) - vpQueueFrequency(rx); - else - { - vpQueuePrompt(PROMPT_RECEIVE); - vpQueueFrequency(rx); - vpQueuePrompt(PROMPT_TRANSMIT); - vpQueueFrequency(tx); - } - vpPlayIfNeeded(flags); -} + vpInitIfNeeded(flags); + // If rx and tx frequencies differ, announce both, otherwise just one + if (rx == tx) + vpQueueFrequency(rx); + else + { + vpQueuePrompt(PROMPT_RECEIVE); + vpQueueFrequency(rx); + vpQueuePrompt(PROMPT_TRANSMIT); + vpQueueFrequency(tx); + } + vpPlayIfNeeded(flags); +} void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); + vpInitIfNeeded(flags); - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_MODE); - - switch(mode) - { - case OPMODE_DMR: - vpQueueStringTableEntry(¤tLanguage->dmr); - break; - case OPMODE_FM: - vpQueueStringTableEntry(¤tLanguage->fm); - break; - case OPMODE_M17: - vpQueueStringTableEntry(¤tLanguage->m17); - break; - } - - vpPlayIfNeeded(flags); + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_MODE); + + switch (mode) + { + case OPMODE_DMR: + vpQueueStringTableEntry(¤tLanguage->dmr); + break; + case OPMODE_FM: + vpQueueStringTableEntry(¤tLanguage->fm); + break; + case OPMODE_M17: + vpQueueStringTableEntry(¤tLanguage->m17); + break; + } + + vpPlayIfNeeded(flags); } void announceBandwidth(uint8_t bandwidth, VoicePromptQueueFlags_T flags) { - if (bandwidth > BW_25) - bandwidth = BW_25; // should probably never happen! + if (bandwidth > BW_25) bandwidth = BW_25; // Should probably never happen! - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_BANDWIDTH); - - char* bandwidths[]={"12.5", "20", "25"}; - vpQueueString(bandwidths[bandwidth], vpAnnounceCommonSymbols); - vpQueuePrompt(PROMPT_KILOHERTZ); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_BANDWIDTH); + + char* bandwidths[] = {"12.5", "20", "25"}; + vpQueueString(bandwidths[bandwidth], vpAnnounceCommonSymbols); + vpQueuePrompt(PROMPT_KILOHERTZ); + + vpPlayIfNeeded(flags); } void anouncePower(float power, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - char buffer[16] = "\0"; - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_POWER); - - snprintf(buffer, 16, "%1.1f", power); - vpQueueString(buffer, vpAnnounceCommonSymbols); - vpQueuePrompt(PROMPT_WATTS); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + char buffer[16] = "\0"; + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_POWER); + + snprintf(buffer, 16, "%1.1f", power); + vpQueueString(buffer, vpAnnounceCommonSymbols); + vpQueuePrompt(PROMPT_WATTS); + + vpPlayIfNeeded(flags); } -void announceChannelSummary(channel_t* channel, uint16_t channelIndex, uint16_t bank) +void announceChannelSummary(channel_t* channel, uint16_t channelIndex, + uint16_t bank) { - if (!channel) return; - - vpInit(); - - VoicePromptQueueFlags_T localFlags= vpqAddSeparatingSilence; - // Force on the descriptions for level 3. - if (state.settings.vpLevel == vpHigh) - localFlags |= vpqIncludeDescriptions; - // if VFO mode, announce VFO. - // channelIndex will be 0 if called from VFO mode. - if (channelIndex == 0) - vpQueuePrompt(PROMPT_VFO); - else - announceChannelName(channel, channelIndex, localFlags); - announceFrequencies(channel->rx_frequency , channel->tx_frequency, localFlags); - announceRadioMode(channel->mode, localFlags); - - if (channel->mode == OPMODE_FM) - { - announceBandwidth(channel->bandwidth, localFlags); - addSilenceIfNeeded(localFlags); - - if (channel->fm.rxToneEn || channel->fm.txToneEn) - { - announceCTCSS(channel->fm.rxToneEn, channel->fm.rxTone, - channel->fm.txToneEn, channel->fm.txTone, - localFlags); - } - } - else if (channel->mode == OPMODE_M17) - { - addSilenceIfNeeded(localFlags); - announceM17Info(channel, localFlags); - } - else if (channel->mode == OPMODE_DMR) - { - addSilenceIfNeeded(localFlags); - announceContactWithIndex(channel->dmr.contact_index, localFlags); - // Force announcement of the words timeslot and colorcode to avoid ambiguity. - announceTimeslot(channel->dmr.dmr_timeslot, (localFlags | vpqIncludeDescriptions)); - announceColorCode(channel->dmr.rxColorCode, channel->dmr.txColorCode, (localFlags | vpqIncludeDescriptions)); - } - addSilenceIfNeeded(localFlags); + if (!channel) return; - anouncePower(channel->power, localFlags); - addSilenceIfNeeded(localFlags); + vpInit(); - if (channelIndex > 0) // i.e. not called from VFO. - announceBank(bank, localFlags); - - vpPlay(); + VoicePromptQueueFlags_T localFlags = vpqAddSeparatingSilence; + // Force on the descriptions for level 3. + if (state.settings.vpLevel == vpHigh) localFlags |= vpqIncludeDescriptions; + // If VFO mode, announce VFO. + // channelIndex will be 0 if called from VFO mode. + if (channelIndex == 0) + vpQueuePrompt(PROMPT_VFO); + else + announceChannelName(channel, channelIndex, localFlags); + announceFrequencies(channel->rx_frequency, channel->tx_frequency, + localFlags); + announceRadioMode(channel->mode, localFlags); + if (channel->mode == OPMODE_FM) + { + announceBandwidth(channel->bandwidth, localFlags); + addSilenceIfNeeded(localFlags); + + if (channel->fm.rxToneEn || channel->fm.txToneEn) + { + announceCTCSS(channel->fm.rxToneEn, channel->fm.rxTone, + channel->fm.txToneEn, channel->fm.txTone, localFlags); + } + } + else if (channel->mode == OPMODE_M17) + { + addSilenceIfNeeded(localFlags); + announceM17Info(channel, localFlags); + } + else if (channel->mode == OPMODE_DMR) + { + addSilenceIfNeeded(localFlags); + announceContactWithIndex(channel->dmr.contact_index, localFlags); + // Force announcement of the words timeslot and colorcode to avoid + // ambiguity. + announceTimeslot(channel->dmr.dmr_timeslot, + (localFlags | vpqIncludeDescriptions)); + announceColorCode(channel->dmr.rxColorCode, channel->dmr.txColorCode, + (localFlags | vpqIncludeDescriptions)); + } + addSilenceIfNeeded(localFlags); + + anouncePower(channel->power, localFlags); + addSilenceIfNeeded(localFlags); + + if (channelIndex > 0) // i.e. not called from VFO. + announceBank(bank, localFlags); + + vpPlay(); } void AnnounceInputChar(char ch) { - char buf[2] = "\0"; - buf[0] = ch; - - vpInit(); - - uint8_t flags = vpAnnounceCaps | vpAnnounceSpace | vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols; - - vpQueueString(buf, flags); - - vpPlay(); + char buf[2] = "\0"; + buf[0] = ch; + + vpInit(); + + uint8_t flags = vpAnnounceCaps | vpAnnounceSpace | vpAnnounceCommonSymbols | + vpAnnounceLessCommonSymbols; + + vpQueueString(buf, flags); + + vpPlay(); } void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (tx) - vpQueuePrompt(PROMPT_TRANSMIT); - else - vpQueuePrompt(PROMPT_RECEIVE); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (tx) + vpQueuePrompt(PROMPT_TRANSMIT); + else + vpQueuePrompt(PROMPT_RECEIVE); + + vpPlayIfNeeded(flags); } void ReplayLastPrompt() { - if (vpIsPlaying()) - vpTerminate(); - else - vpPlay(); + if (vpIsPlaying()) + vpTerminate(); + else + vpPlay(); } void announceError(VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - vpQueueStringTableEntry(¤tLanguage->error); - - vpPlayIfNeeded(flags); -} + vpInitIfNeeded(flags); -void announceText( char* text, VoicePromptQueueFlags_T flags) -{ - if (!text || !*text) - return; - - vpInitIfNeeded(flags); - // see if we have a prompt for this string. - int offset = GetEnglishStringTableOffset(text); - - if (offset != -1) - vpQueueStringTableEntry((const char* const *)(¤tLanguage->languageName + offset)); - else // just spel it out - vpQueueString(text, vpAnnounceCommonSymbols); - - vpPlayIfNeeded(flags); + vpQueueStringTableEntry(¤tLanguage->error); + + vpPlayIfNeeded(flags); } -void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, uint8_t txTone, VoicePromptQueueFlags_T flags) +void announceText(char* text, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (!rxToneEnabled && !txToneEnabled) - { - vpQueuePrompt(PROMPT_TONE); - vpQueueStringTableEntry(¤tLanguage->off); - vpPlayIfNeeded(flags); - return; - } - - char buffer[16] = "\0"; + if (!text || !*text) return; - // If the rx and tx tones are the same and both are enabled, just say Tone. - if ((rxToneEnabled && txToneEnabled) && (rxTone == txTone)) - { - vpQueuePrompt(PROMPT_TONE); - snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone]/10.0f); - vpQueueString(buffer, vpqDefault); - vpQueuePrompt(PROMPT_HERTZ); - vpPlayIfNeeded(flags); - return; - } - // speak the individual rx and tx tones. - if (rxToneEnabled) - { - vpQueuePrompt(PROMPT_RECEIVE); - vpQueuePrompt(PROMPT_TONE); - snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone]/10.0f); - vpQueueString(buffer, vpqDefault); - vpQueuePrompt(PROMPT_HERTZ); - } - if (txToneEnabled) - { - vpQueuePrompt(PROMPT_TRANSMIT); - vpQueuePrompt(PROMPT_TONE); - snprintf(buffer, 16, "%3.1f", ctcss_tone[txTone]/10.0f); - vpQueueString(buffer, vpqDefault); - vpQueuePrompt(PROMPT_HERTZ); - } - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + // See if we have a prompt for this string. + int offset = GetEnglishStringTableOffset(text); + + if (offset != -1) + vpQueueStringTableEntry( + (const char* const*)(¤tLanguage->languageName + offset)); + else // Just spell it out + vpQueueString(text, vpAnnounceCommonSymbols); + + vpPlayIfNeeded(flags); +} + +void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, + uint8_t txTone, VoicePromptQueueFlags_T flags) +{ + vpInitIfNeeded(flags); + + if (!rxToneEnabled && !txToneEnabled) + { + vpQueuePrompt(PROMPT_TONE); + vpQueueStringTableEntry(¤tLanguage->off); + vpPlayIfNeeded(flags); + return; + } + + char buffer[16] = "\0"; + + // If the rx and tx tones are the same and both are enabled, just say Tone. + if ((rxToneEnabled && txToneEnabled) && (rxTone == txTone)) + { + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone] / 10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + vpPlayIfNeeded(flags); + return; + } + // Speak the individual rx and tx tones. + if (rxToneEnabled) + { + vpQueuePrompt(PROMPT_RECEIVE); + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone] / 10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + } + if (txToneEnabled) + { + vpQueuePrompt(PROMPT_TRANSMIT); + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[txTone] / 10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + } + + vpPlayIfNeeded(flags); } void announceBrightness(uint8_t brightness, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueueStringTableEntry(¤tLanguage->brightness); - - vpQueueInteger(brightness); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) + vpQueueStringTableEntry(¤tLanguage->brightness); + + vpQueueInteger(brightness); + + vpPlayIfNeeded(flags); } void announceSquelch(uint8_t squelch, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_SQUELCH); - - vpQueueInteger(squelch); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_SQUELCH); + + vpQueueInteger(squelch); + + vpPlayIfNeeded(flags); } void announceContact(contact_t* contact, VoicePromptQueueFlags_T flags) { - if (!contact) - return; - - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_CONTACT); - - if (contact->name[0]) - vpQueueString(contact->name, vpAnnounceCommonSymbols); + if (!contact) return; - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_CONTACT); + + if (contact->name[0]) vpQueueString(contact->name, vpAnnounceCommonSymbols); + + vpPlayIfNeeded(flags); } void announceContactWithIndex(uint16_t index, VoicePromptQueueFlags_T flags) { - if (index == 0) - return; - - contact_t contact; - - if (cps_readContact(&contact, index) == -1) - return; - - announceContact(&contact, flags); + if (index == 0) return; + + contact_t contact; + + if (cps_readContact(&contact, index) == -1) return; + + announceContact(&contact, flags); } void announceTimeslot(uint8_t timeslot, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_TIMESLOT); - - vpQueueInteger(timeslot); - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_TIMESLOT); + + vpQueueInteger(timeslot); + + vpPlayIfNeeded(flags); } -void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, VoicePromptQueueFlags_T flags) +void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, + VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_COLORCODE); - - if (rxColorCode == txColorCode) - { - vpQueueInteger(rxColorCode); - } - else - { - vpQueuePrompt(PROMPT_RECEIVE); - vpQueueInteger(rxColorCode); - vpQueuePrompt(PROMPT_TRANSMIT); - vpQueueInteger(txColorCode); - } - - vpPlayIfNeeded(flags); + vpInitIfNeeded(flags); + + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_COLORCODE); + + if (rxColorCode == txColorCode) + { + vpQueueInteger(rxColorCode); + } + else + { + vpQueuePrompt(PROMPT_RECEIVE); + vpQueueInteger(rxColorCode); + vpQueuePrompt(PROMPT_TRANSMIT); + vpQueueInteger(txColorCode); + } + + vpPlayIfNeeded(flags); } void announceBank(uint16_t bank, VoicePromptQueueFlags_T flags) { - vpInitIfNeeded(flags); - if (flags & vpqIncludeDescriptions) - vpQueueStringTableEntry(¤tLanguage->banks); + vpInitIfNeeded(flags); + if (flags & vpqIncludeDescriptions) + vpQueueStringTableEntry(¤tLanguage->banks); - if (state.bank_enabled) - { - bankHdr_t bank_hdr = { 0 }; - cps_readBankHeader(&bank_hdr, bank); - vpQueueString(bank_hdr.name, vpAnnounceCommonSymbols); - } - else - vpQueueStringTableEntry(¤tLanguage->allChannels); - - vpPlayIfNeeded(flags); + if (state.bank_enabled) + { + bankHdr_t bank_hdr = {0}; + cps_readBankHeader(&bank_hdr, bank); + vpQueueString(bank_hdr.name, vpAnnounceCommonSymbols); + } + else + vpQueueStringTableEntry(¤tLanguage->allChannels); + + vpPlayIfNeeded(flags); } void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags) { - if (!channel) return; - - vpInitIfNeeded(flags); - if (state.m17_data.dst_addr[0]) - { - if (flags & vpqIncludeDescriptions) - vpQueuePrompt(PROMPT_DEST_ID); - vpQueueString(state.m17_data.dst_addr, vpAnnounceCommonSymbols); - } - else if (channel->m17.contact_index) - announceContactWithIndex(channel->m17.contact_index, flags); - - vpPlayIfNeeded(flags); + if (!channel) return; + + vpInitIfNeeded(flags); + if (state.m17_data.dst_addr[0]) + { + if (flags & vpqIncludeDescriptions) vpQueuePrompt(PROMPT_DEST_ID); + vpQueueString(state.m17_data.dst_addr, vpAnnounceCommonSymbols); + } + else if (channel->m17.contact_index) + announceContactWithIndex(channel->m17.contact_index, flags); + + vpPlayIfNeeded(flags); } #ifdef GPS_PRESENT void announceGPSInfo() { - if (!state.settings.gps_enabled) - return; - - vpInit(); - VoicePromptQueueFlags_T flags = vpqIncludeDescriptions | vpqAddSeparatingSilence; - - vpQueueStringTableEntry(¤tLanguage->gps); + if (!state.settings.gps_enabled) return; - switch (state.gps_data.fix_quality) - { - case 0: - vpQueueStringTableEntry(¤tLanguage->noFix); - break; - case 1: - vpQueueString("SPS", vpAnnounceCommonSymbols); - break; - case 2: - vpQueueString("DGPS", vpAnnounceCommonSymbols); - break; - case 3: - vpQueueString("PPS", vpAnnounceCommonSymbols); - break; - case 6: - vpQueueStringTableEntry(¤tLanguage->fixLost); - break; - default: - vpQueueStringTableEntry(¤tLanguage->error); - - vpPlay(); - - return; - } - addSilenceIfNeeded(flags); - - switch(state.gps_data.fix_type) - { - case 2: - vpQueueString("2D", vpAnnounceCommonSymbols); - break; - case 3: - vpQueueString("3D", vpAnnounceCommonSymbols); - break; - } - addSilenceIfNeeded(flags); - // lat/long - char buffer[16] = "\0"; - vpQueuePrompt(PROMPT_LATITUDE); - snprintf(buffer, 16, "%8.6f", state.gps_data.latitude); - vpQueueString(buffer, vpAnnounceCommonSymbols); - vpQueuePrompt(PROMPT_NORTH); - float longitude = state.gps_data.longitude; - voicePrompt_t direction = (longitude < 0) ? PROMPT_WEST : PROMPT_EAST; - longitude = (longitude < 0) ? -longitude : longitude; - snprintf(buffer, 16, "%8.6f", longitude); - vpQueuePrompt(PROMPT_LONGITUDE); - vpQueueString(buffer, vpAnnounceCommonSymbols); - vpQueuePrompt(direction); - addSilenceIfNeeded(flags); - // speed/altitude: - vpQueuePrompt(PROMPT_SPEED); - snprintf(buffer, 16, "%4.1fkm/h", state.gps_data.speed); - vpQueueString(buffer, vpAnnounceCommonSymbols); - vpQueuePrompt(PROMPT_ALTITUDE); - snprintf(buffer, 16, "%4.1fm", state.gps_data.altitude); - vpQueueString(buffer, vpAnnounceCommonSymbols); - addSilenceIfNeeded(flags); + vpInit(); + VoicePromptQueueFlags_T flags = + vpqIncludeDescriptions | vpqAddSeparatingSilence; - vpQueuePrompt(PROMPT_COMPASS); - snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true); - vpQueueString(buffer, vpAnnounceCommonSymbols); - vpQueuePrompt(PROMPT_DEGREES); - addSilenceIfNeeded(flags); + vpQueueStringTableEntry(¤tLanguage->gps); - vpQueuePrompt(PROMPT_SATELLITES); - vpQueueInteger(__builtin_popcount(state.gps_data.active_sats)); - - vpPlay(); + switch (state.gps_data.fix_quality) + { + case 0: + vpQueueStringTableEntry(¤tLanguage->noFix); + break; + case 1: + vpQueueString("SPS", vpAnnounceCommonSymbols); + break; + case 2: + vpQueueString("DGPS", vpAnnounceCommonSymbols); + break; + case 3: + vpQueueString("PPS", vpAnnounceCommonSymbols); + break; + case 6: + vpQueueStringTableEntry(¤tLanguage->fixLost); + break; + default: + vpQueueStringTableEntry(¤tLanguage->error); + + vpPlay(); + + return; + } + addSilenceIfNeeded(flags); + + switch (state.gps_data.fix_type) + { + case 2: + vpQueueString("2D", vpAnnounceCommonSymbols); + break; + case 3: + vpQueueString("3D", vpAnnounceCommonSymbols); + break; + } + addSilenceIfNeeded(flags); + // lat/long + char buffer[16] = "\0"; + vpQueuePrompt(PROMPT_LATITUDE); + snprintf(buffer, 16, "%8.6f", state.gps_data.latitude); + vpQueueString(buffer, vpAnnounceCommonSymbols); + vpQueuePrompt(PROMPT_NORTH); + float longitude = state.gps_data.longitude; + voicePrompt_t direction = (longitude < 0) ? PROMPT_WEST : PROMPT_EAST; + longitude = (longitude < 0) ? -longitude : longitude; + snprintf(buffer, 16, "%8.6f", longitude); + vpQueuePrompt(PROMPT_LONGITUDE); + vpQueueString(buffer, vpAnnounceCommonSymbols); + vpQueuePrompt(direction); + addSilenceIfNeeded(flags); + // speed/altitude: + vpQueuePrompt(PROMPT_SPEED); + snprintf(buffer, 16, "%4.1fkm/h", state.gps_data.speed); + vpQueueString(buffer, vpAnnounceCommonSymbols); + vpQueuePrompt(PROMPT_ALTITUDE); + snprintf(buffer, 16, "%4.1fm", state.gps_data.altitude); + vpQueueString(buffer, vpAnnounceCommonSymbols); + addSilenceIfNeeded(flags); + + vpQueuePrompt(PROMPT_COMPASS); + snprintf(buffer, 16, "%3.1f", state.gps_data.tmg_true); + vpQueueString(buffer, vpAnnounceCommonSymbols); + vpQueuePrompt(PROMPT_DEGREES); + addSilenceIfNeeded(flags); + + vpQueuePrompt(PROMPT_SATELLITES); + vpQueueInteger(__builtin_popcount(state.gps_data.active_sats)); + + vpPlay(); } #endif // GPS_PRESENT void announceAboutScreen() { - vpInit(); - - vpQueueStringTableEntry(¤tLanguage->openRTX); - - vpQueueStringTableEntry(¤tLanguage->Niccolo); - vpQueueStringTableEntry(¤tLanguage->Silvano); - vpQueueStringTableEntry(¤tLanguage->Federico); - vpQueueStringTableEntry(¤tLanguage->Fred); - vpQueueStringTableEntry(¤tLanguage->Joseph); - - vpPlay(); + vpInit(); + + vpQueueStringTableEntry(¤tLanguage->openRTX); + + vpQueueStringTableEntry(¤tLanguage->Niccolo); + vpQueueStringTableEntry(¤tLanguage->Silvano); + vpQueueStringTableEntry(¤tLanguage->Federico); + vpQueueStringTableEntry(¤tLanguage->Fred); + vpQueueStringTableEntry(¤tLanguage->Joseph); + + vpPlay(); } void announceBackupScreen() { - vpInit(); - - vpQueueStringTableEntry(¤tLanguage->flashBackup); - - vpQueueStringTableEntry(¤tLanguage->connectToRTXTool); - vpQueueStringTableEntry(¤tLanguage->toBackupFlashAnd); - vpQueueStringTableEntry(¤tLanguage->pressPTTToStart); - vpQueuePrompt(PROMPT_VP_UNAVAILABLE); - - vpPlay(); + vpInit(); + + vpQueueStringTableEntry(¤tLanguage->flashBackup); + + vpQueueStringTableEntry(¤tLanguage->connectToRTXTool); + vpQueueStringTableEntry(¤tLanguage->toBackupFlashAnd); + vpQueueStringTableEntry(¤tLanguage->pressPTTToStart); + vpQueuePrompt(PROMPT_VP_UNAVAILABLE); + + vpPlay(); } void announceRestoreScreen() { - vpInit(); - - vpQueueStringTableEntry(¤tLanguage->flashRestore); - - vpQueueStringTableEntry(¤tLanguage->connectToRTXTool); - vpQueueStringTableEntry(¤tLanguage->toRestoreFlashAnd); - vpQueueStringTableEntry(¤tLanguage->pressPTTToStart); - vpQueuePrompt(PROMPT_VP_UNAVAILABLE); - - vpPlay(); + vpInit(); + + vpQueueStringTableEntry(¤tLanguage->flashRestore); + + vpQueueStringTableEntry(¤tLanguage->connectToRTXTool); + vpQueueStringTableEntry(¤tLanguage->toRestoreFlashAnd); + vpQueueStringTableEntry(¤tLanguage->pressPTTToStart); + vpQueuePrompt(PROMPT_VP_UNAVAILABLE); + + vpPlay(); } #ifdef RTC_PRESENT void announceSettingsTimeDate() { - vpInit(); - - vpQueueStringTableEntry(¤tLanguage->timeAndDate); - - datetime_t local_time = utcToLocalTime(state.time, state.settings.utc_timezone); + vpInit(); - char buffer[16] = "\0"; - snprintf(buffer, 16, "%02d/%02d/%02d", - local_time.date, local_time.month, local_time.year); - vpQueueString(buffer, (vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols)); + vpQueueStringTableEntry(¤tLanguage->timeAndDate); - snprintf(buffer, 16, "%02d:%02d:%02d", - local_time.hour, local_time.minute, local_time.second); - vpQueueString(buffer, (vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols)); - - vpPlay(); + datetime_t local_time = utcToLocalTime(state.time, state.settings.utc_timezone); + + char buffer[16] = "\0"; + snprintf(buffer, 16, "%02d/%02d/%02d", local_time.date, local_time.month, + local_time.year); + vpQueueString(buffer, + (vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols)); + + snprintf(buffer, 16, "%02d:%02d:%02d", local_time.hour, local_time.minute, + local_time.second); + vpQueueString(buffer, + (vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols)); + + vpPlay(); } #endif // RTC_PRESENT /* -there are 5 levels of verbosity: + * There are 5 levels of verbosity: + * + * vpNone: no voice or beeps. + * vpBeep: beeps only. + * vpLow: menus talk, but channel and frequency changes are indicated with a + * beep and only voiced on demand with f1. + * vpMedium: menus, channel and frequency changes talk but with extra + * descriptions eliminated unless ambiguity would result. E.g. We'd say "FM" + * rather than "Mode: FM" in the channel summary. + * vpHigh: like vpMedium except with extra descriptions: e.g. "Mode fm". + * + * Also, if a voice prompt is in progress, e.g. changing a menu item, the + * descriptions are eliminated, e.g., changing ctcss tones would not repeat + * "ctcss" when arrowing through the options rapidly. + */ -vpNone: no voice or beeps. -vpBeep: beeps only. -vpLow: menus talk, but channel and frequency changes are indicated with a beep -and only voiced on demand with f1. -vpMedium: menus, channel and frequency changes talk but with extra -descriptions eliminated unless ambiguity would result. E.g. We'd say "FM" -rather than "Mode: FM" in the channel summary. -vpHigh: like vpMedium except with extra descriptions: e.g. "Mode fm". -Also, if a voice prompt is in progress, e.g. changing a menu item, the descriptions are eliminated. -e.g. changing ctcss tones would not repeat "ctcss" when arrowing through the -options rapidly. -*/ VoicePromptQueueFlags_T GetQueueFlagsForVoiceLevel() { - VoicePromptQueueFlags_T flags = vpqInit | vpqAddSeparatingSilence; - - uint8_t vpLevel = state.settings.vpLevel; - switch (vpLevel) - { - case vpNone: - case vpBeep: - return vpqDefault; - // play some immediately, other things on demand. - case vpLow: - flags |= vpqPlayImmediatelyAtMediumOrHigher; - break; - // play all immediatley but without extra descriptions - case vpMedium: - { - flags |= vpqPlayImmediately; - break; - } - // play immediatley with descriptions unless speech is in progress. - case vpHigh: - flags |= vpqPlayImmediately; - if (!vpIsPlaying()) - flags |= vpqIncludeDescriptions; - break; - } - -return flags; + VoicePromptQueueFlags_T flags = vpqInit | vpqAddSeparatingSilence; + + uint8_t vpLevel = state.settings.vpLevel; + switch (vpLevel) + { + case vpNone: + case vpBeep: + return vpqDefault; + // Play some immediately, other things on demand. + case vpLow: + flags |= vpqPlayImmediatelyAtMediumOrHigher; + break; + // Play all immediately but without extra descriptions + case vpMedium: + { + flags |= vpqPlayImmediately; + break; + } + // Play immediately with descriptions unless speech is in progress. + case vpHigh: + flags |= vpqPlayImmediately; + if (!vpIsPlaying()) flags |= vpqIncludeDescriptions; + break; + } + + return flags; } diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index e5c56760..6ed4dfee 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -17,47 +17,52 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, see * ***************************************************************************/ +#include "core/voicePrompts.h" + +#include +#include +#include #include #include -#include -#include -#include "interfaces/keyboard.h" -#include "core/voicePrompts.h" -#include "ui/UIStrings.h" -#include -const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056;//'VP' -const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX +#include "interfaces/keyboard.h" +#include "ui/UIStrings.h" + +const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056; //'VP' +const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX // Must match the number of voice prompts allowed by the generator script. #define VOICE_PROMPTS_TOC_SIZE 350 // This gets the data for a voice prompt to be demodulated using Codec2. // The offset is relative to the start of the voice prompt data. -// The length is the length in bytes of the data. -static void GetCodec2Data(int offset,int length); +// The length is the length in bytes of the data. +static void GetCodec2Data(int offset, int length); typedef struct { - uint32_t magic; - uint32_t version; + uint32_t magic; + uint32_t version; } voicePromptsDataHeader_t; // ToDo: may be a file on flashdisk. // ToDo figure this out for OpenRTX // Address of voice prompt header for checking version etc. -const uint32_t VOICE_PROMPTS_FLASH_HEADER_ADDRESS = 0x8F400; +const uint32_t VOICE_PROMPTS_FLASH_HEADER_ADDRESS = 0x8F400; // Start of actual voice prompt data. -static uint32_t vpFlashDataAddress;// = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t) + sizeof(uint32_t)*VOICE_PROMPTS_TOC_SIZE ; +static uint32_t + vpFlashDataAddress; // = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + + // sizeof(voicePromptsDataHeader_t) + + // sizeof(uint32_t)*VOICE_PROMPTS_TOC_SIZE ; // TODO figure out Codec2 frame equivalent. // 76 x 27 byte Codec2 frames -#define Codec2DataBufferSize 2052 +#define Codec2DataBufferSize 2052 bool vpDataIsLoaded = false; - + static bool voicePromptIsActive = false; // Uninitialized is -1. -static int promptDataPosition = -1; +static int promptDataPosition = -1; static int currentPromptLength = -1; // Number of ms from end of playing prompt to disabling amp. -#define PROMPT_TAIL 30 +#define PROMPT_TAIL 30 static int promptTail = 0; static uint8_t Codec2Data[Codec2DataBufferSize]; @@ -66,335 +71,343 @@ static uint8_t Codec2Data[Codec2DataBufferSize]; typedef struct { - uint16_t Buffer[VOICE_PROMPTS_SEQUENCE_BUFFER_SIZE]; - int Pos; - int Length; + uint16_t Buffer[VOICE_PROMPTS_SEQUENCE_BUFFER_SIZE]; + int Pos; + int Length; } vpSequence_t; -static vpSequence_t vpCurrentSequence = -{ - .Pos = 0, - .Length = 0 -}; +static vpSequence_t vpCurrentSequence = {.Pos = 0, .Length = 0}; uint32_t tableOfContents[VOICE_PROMPTS_TOC_SIZE]; -const userDictEntry userDictionary[]= -{ - {"hotspot", PROMPT_CUSTOM1}, // Hotspot - {"clearnode", PROMPT_CUSTOM2}, // ClearNode - {"sharinode", PROMPT_CUSTOM3}, // ShariNode - {"microhub", PROMPT_CUSTOM4}, // MicroHub - {"openspot", PROMPT_CUSTOM5}, // Openspot - {"repeater", PROMPT_CUSTOM6}, // repeater - {"blindhams", PROMPT_CUSTOM7}, // BlindHams - {"allstar", PROMPT_CUSTOM8}, // Allstar - {"parrot", PROMPT_CUSTOM9}, // Parrot - {"channel",PROMPT_CHANNEL}, - {0, 0} -}; +const userDictEntry userDictionary[] = { + {"hotspot", PROMPT_CUSTOM1}, // Hotspot + {"clearnode", PROMPT_CUSTOM2}, // ClearNode + {"sharinode", PROMPT_CUSTOM3}, // ShariNode + {"microhub", PROMPT_CUSTOM4}, // MicroHub + {"openspot", PROMPT_CUSTOM5}, // Openspot + {"repeater", PROMPT_CUSTOM6}, // repeater + {"blindhams", PROMPT_CUSTOM7}, // BlindHams + {"allstar", PROMPT_CUSTOM8}, // Allstar + {"parrot", PROMPT_CUSTOM9}, // Parrot + {"channel", PROMPT_CHANNEL}, {0, 0}}; void vpCacheInit(void) { - voicePromptsDataHeader_t header; -// ToDo not sure where this is coming from yet. - //SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS,(uint8_t *)&header,sizeof(voicePromptsDataHeader_t)); + voicePromptsDataHeader_t header; + // ToDo not sure where this is coming from yet. + // SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS,(uint8_t + // *)&header,sizeof(voicePromptsDataHeader_t)); - if (vpCheckHeader((uint32_t *)&header)) - {// ToDo see above - vpDataIsLoaded = false; //SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t), (uint8_t *)&tableOfContents, sizeof(uint32_t) * VOICE_PROMPTS_TOC_SIZE); - vpFlashDataAddress = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t) + sizeof(uint32_t)*VOICE_PROMPTS_TOC_SIZE ; - } - if (vpDataIsLoaded) - {// if the hash key is down, set vpLevel to high, if beep or less. - if ((kbd_getKeys() & KEY_HASH) && (state.settings.vpLevel <= vpBeep)) - state.settings.vpLevel = vpHigh; - } - else - { // ensure we at least have beeps in the event no voice prompts are loaded. - if (state.settings.vpLevel > vpBeep) - state.settings.vpLevel = vpBeep; - } + if (vpCheckHeader((uint32_t*)&header)) + { // ToDo see above + vpDataIsLoaded = false; // SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS + // + sizeof(voicePromptsDataHeader_t), (uint8_t + // *)&tableOfContents, sizeof(uint32_t) * + // VOICE_PROMPTS_TOC_SIZE); + vpFlashDataAddress = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + + sizeof(voicePromptsDataHeader_t) + + sizeof(uint32_t) * VOICE_PROMPTS_TOC_SIZE; + } + if (vpDataIsLoaded) + { // if the hash key is down, set vpLevel to high, if beep or less. + if ((kbd_getKeys() & KEY_HASH) && (state.settings.vpLevel <= vpBeep)) + state.settings.vpLevel = vpHigh; + } + else + { // ensure we at least have beeps in the event no voice prompts are + // loaded. + if (state.settings.vpLevel > vpBeep) state.settings.vpLevel = vpBeep; + } } -bool vpCheckHeader(uint32_t *bufferAddress) +bool vpCheckHeader(uint32_t* bufferAddress) { - voicePromptsDataHeader_t *header = (voicePromptsDataHeader_t *)bufferAddress; + voicePromptsDataHeader_t* header = (voicePromptsDataHeader_t*)bufferAddress; - return ((header->magic == VOICE_PROMPTS_DATA_MAGIC) && (header->version == VOICE_PROMPTS_DATA_VERSION)); + return ((header->magic == VOICE_PROMPTS_DATA_MAGIC) && + (header->version == VOICE_PROMPTS_DATA_VERSION)); } -static void GetCodec2Data(int offset,int length) +static void GetCodec2Data(int offset, int length) { - if ((offset >= 0) && (length <= Codec2DataBufferSize)) - {// ToDo where are we reading this from? - // Just so we can build, - ; - //SPI_Flash_read(vpFlashDataAddress + offset, (uint8_t *)&Codec2Data, length); - } + if ((offset >= 0) && (length <= Codec2DataBufferSize)) + { // ToDo where are we reading this from? + // Just so we can build, + ; + // SPI_Flash_read(vpFlashDataAddress + offset, (uint8_t *)&Codec2Data, + // length); + } } void vpTick(void) { - if (voicePromptIsActive) - { - if (promptDataPosition < currentPromptLength) - {// ToDo figure out buffering. - //if (wavbuffer_count <= (WAV_BUFFER_COUNT / 2)) - { -// codecDecode((uint8_t *)&Codec2Data[promptDataPosition], 3); - promptDataPosition += 27; - } + if (voicePromptIsActive) + { + if (promptDataPosition < currentPromptLength) + { // ToDo figure out buffering. + // if (wavbuffer_count <= (WAV_BUFFER_COUNT / 2)) + { + // codecDecode((uint8_t + // *)&Codec2Data[promptDataPosition], 3); + promptDataPosition += 27; + } - //soundTickRXBuffer(); - } - else - { - if ( vpCurrentSequence.Pos < (vpCurrentSequence.Length - 1)) - { - vpCurrentSequence.Pos++; - promptDataPosition = 0; + // soundTickRXBuffer(); + } + else + { + if (vpCurrentSequence.Pos < (vpCurrentSequence.Length - 1)) + { + vpCurrentSequence.Pos++; + promptDataPosition = 0; - int promptNumber = vpCurrentSequence.Buffer[vpCurrentSequence.Pos]; - currentPromptLength = tableOfContents[promptNumber + 1] - tableOfContents[promptNumber]; - GetCodec2Data(tableOfContents[promptNumber], currentPromptLength); - } - else - { - // wait for wave buffer to empty when prompt has finished playing + int promptNumber = + vpCurrentSequence.Buffer[vpCurrentSequence.Pos]; + currentPromptLength = tableOfContents[promptNumber + 1] - + tableOfContents[promptNumber]; + GetCodec2Data(tableOfContents[promptNumber], + currentPromptLength); + } + else + { + // wait for wave buffer to empty when prompt has finished + // playing -// if (wavbuffer_count == 0) - { - vpTerminate(); - } - } - } - } - else - { - if (promptTail > 0) - { - promptTail--; + // if (wavbuffer_count == 0) + { + vpTerminate(); + } + } + } + } + else + { + if (promptTail > 0) + { + promptTail--; - /*if ((promptTail == 0) && trxCarrierDetected() && (trxGetMode() == RADIO_MODE_ANALOG)) - {// ToDo enable amp. - //GPIO_PinWrite(GPIO_RX_audio_mux, Pin_RX_audio_mux, 1); // Set the audio path to AT1846 -> audio amp. - }*/ - } - } + /*if ((promptTail == 0) && trxCarrierDetected() && (trxGetMode() == + RADIO_MODE_ANALOG)) + {// ToDo enable amp. + //GPIO_PinWrite(GPIO_RX_audio_mux, Pin_RX_audio_mux, 1); // Set + the audio path to AT1846 -> audio amp. + }*/ + } + } } void vpTerminate(void) { - if (voicePromptIsActive) - { - //disableAudioAmp(AUDIO_AMP_MODE_PROMPT); + if (voicePromptIsActive) + { + // disableAudioAmp(AUDIO_AMP_MODE_PROMPT); - vpCurrentSequence.Pos = 0; - //soundTerminateSound(); - //soundInit(); - promptTail = PROMPT_TAIL; + vpCurrentSequence.Pos = 0; + // soundTerminateSound(); + // soundInit(); + promptTail = PROMPT_TAIL; - voicePromptIsActive = false; - } + voicePromptIsActive = false; + } } void vpInit(void) { - if (voicePromptIsActive) - { - vpTerminate(); - } - - vpCurrentSequence.Length = 0; - vpCurrentSequence.Pos = 0; + if (voicePromptIsActive) + { + vpTerminate(); + } + + vpCurrentSequence.Length = 0; + vpCurrentSequence.Pos = 0; } void vpQueuePrompt(uint16_t prompt) { - if (state.settings.vpLevel < vpLow) - return; - - if (voicePromptIsActive) - { - vpInit(); - } - if (vpCurrentSequence.Length < VOICE_PROMPTS_SEQUENCE_BUFFER_SIZE) - { - vpCurrentSequence.Buffer[vpCurrentSequence.Length] = prompt; - vpCurrentSequence.Length++; - } + if (state.settings.vpLevel < vpLow) return; + + if (voicePromptIsActive) + { + vpInit(); + } + if (vpCurrentSequence.Length < VOICE_PROMPTS_SEQUENCE_BUFFER_SIZE) + { + vpCurrentSequence.Buffer[vpCurrentSequence.Length] = prompt; + vpCurrentSequence.Length++; + } } static uint16_t UserDictLookup(char* ptr, int* advanceBy) { - if (!ptr || !*ptr) return 0; - - for (int index=0; userDictionary[index].userWord!=0; ++index) - { - int len=strlen(userDictionary[index].userWord); - if (strncasecmp(userDictionary[index].userWord, ptr, len)==0) - { - *advanceBy=len; - return userDictionary[index].vp; - } - } + if (!ptr || !*ptr) return 0; - return 0; + for (int index = 0; userDictionary[index].userWord != 0; ++index) + { + int len = strlen(userDictionary[index].userWord); + if (strncasecmp(userDictionary[index].userWord, ptr, len) == 0) + { + *advanceBy = len; + return userDictionary[index].vp; + } + } + + return 0; } -static bool GetSymbolVPIfItShouldBeAnnounced(char symbol, -VoicePromptFlags_T flags, voicePrompt_t* vp) +static bool GetSymbolVPIfItShouldBeAnnounced(char symbol, + VoicePromptFlags_T flags, + voicePrompt_t* vp) { - *vp=PROMPT_SILENCE; - - const char indexedSymbols[] = "%.+-*#!,@:?()~/[]<>=$'`&|_^{}"; // Must match order of symbols in voicePrompt_t enum. - const char commonSymbols[] = "%.+-*#"; - - bool announceCommonSymbols = (flags & vpAnnounceCommonSymbols) ? true : false; - bool announceLessCommonSymbols=(flags & vpAnnounceLessCommonSymbols) ? true : false; - - char* symbolPtr = strchr(indexedSymbols, symbol); - - if (symbolPtr == NULL) - {// we don't have a prompt for this character. - return (flags&vpAnnounceASCIIValueForUnknownChars) ? true : false; - } - - bool commonSymbol= strchr(commonSymbols, symbol) != NULL; - - *vp = PROMPT_PERCENT+(symbolPtr-indexedSymbols); - - return ((commonSymbol && announceCommonSymbols) || (!commonSymbol && announceLessCommonSymbols)); + *vp = PROMPT_SILENCE; + + const char indexedSymbols[] = + "%.+-*#!,@:?()~/[]<>=$'`&|_^{}"; // Must match order of symbols in + // voicePrompt_t enum. + const char commonSymbols[] = "%.+-*#"; + + bool announceCommonSymbols = + (flags & vpAnnounceCommonSymbols) ? true : false; + bool announceLessCommonSymbols = + (flags & vpAnnounceLessCommonSymbols) ? true : false; + + char* symbolPtr = strchr(indexedSymbols, symbol); + + if (symbolPtr == NULL) + { // we don't have a prompt for this character. + return (flags & vpAnnounceASCIIValueForUnknownChars) ? true : false; + } + + bool commonSymbol = strchr(commonSymbols, symbol) != NULL; + + *vp = PROMPT_PERCENT + (symbolPtr - indexedSymbols); + + return ((commonSymbol && announceCommonSymbols) || + (!commonSymbol && announceLessCommonSymbols)); } // This function spells out a string letter by letter. -void vpQueueString(char *promptString, VoicePromptFlags_T flags) +void vpQueueString(char* promptString, VoicePromptFlags_T flags) { - if (state.settings.vpLevel < vpLow) - return; + if (state.settings.vpLevel < vpLow) return; - if (voicePromptIsActive) - { - vpInit(); - } - - if (state.settings.vpPhoneticSpell) - flags|=vpAnnouncePhoneticRendering; - while (*promptString != 0) - { - int advanceBy=0; - voicePrompt_t vp = UserDictLookup(promptString, &advanceBy); - if (vp) - { - vpQueuePrompt(vp); - promptString += advanceBy; - continue; - } - else if ((*promptString >= '0') && (*promptString <= '9')) - { - vpQueuePrompt(*promptString - '0' + PROMPT_0); - } - else if ((*promptString >= 'A') && (*promptString <= 'Z')) - { - if (flags&vpAnnounceCaps) - vpQueuePrompt(PROMPT_CAP); - if (flags&vpAnnouncePhoneticRendering) - vpQueuePrompt((*promptString - 'A') + PROMPT_A_PHONETIC); - else - vpQueuePrompt(*promptString - 'A' + PROMPT_A); - } - else if ((*promptString >= 'a') && (*promptString <= 'z')) - { - if (flags&vpAnnouncePhoneticRendering) - vpQueuePrompt((*promptString - 'a') + PROMPT_A_PHONETIC); - else - vpQueuePrompt(*promptString - 'a' + PROMPT_A); - } - else if ((*promptString==' ') && (flags&vpAnnounceSpace)) - { - vpQueuePrompt(PROMPT_SPACE); - } - else if (GetSymbolVPIfItShouldBeAnnounced(*promptString, flags, &vp)) - { - if (vp != PROMPT_SILENCE) - vpQueuePrompt(vp); - else // announce ASCII - { - int32_t val = *promptString; - vpQueuePrompt(PROMPT_CHARACTER); // just the word "code" as we don't have character. - vpQueueInteger(val); - } - } - else - { - // otherwise just add silence - vpQueuePrompt(PROMPT_SILENCE); - } - - promptString++; - } - if (flags & vpqAddSeparatingSilence) - vpQueuePrompt(PROMPT_SILENCE); + if (voicePromptIsActive) + { + vpInit(); + } + if (state.settings.vpPhoneticSpell) flags |= vpAnnouncePhoneticRendering; + while (*promptString != 0) + { + int advanceBy = 0; + voicePrompt_t vp = UserDictLookup(promptString, &advanceBy); + if (vp) + { + vpQueuePrompt(vp); + promptString += advanceBy; + continue; + } + else if ((*promptString >= '0') && (*promptString <= '9')) + { + vpQueuePrompt(*promptString - '0' + PROMPT_0); + } + else if ((*promptString >= 'A') && (*promptString <= 'Z')) + { + if (flags & vpAnnounceCaps) vpQueuePrompt(PROMPT_CAP); + if (flags & vpAnnouncePhoneticRendering) + vpQueuePrompt((*promptString - 'A') + PROMPT_A_PHONETIC); + else + vpQueuePrompt(*promptString - 'A' + PROMPT_A); + } + else if ((*promptString >= 'a') && (*promptString <= 'z')) + { + if (flags & vpAnnouncePhoneticRendering) + vpQueuePrompt((*promptString - 'a') + PROMPT_A_PHONETIC); + else + vpQueuePrompt(*promptString - 'a' + PROMPT_A); + } + else if ((*promptString == ' ') && (flags & vpAnnounceSpace)) + { + vpQueuePrompt(PROMPT_SPACE); + } + else if (GetSymbolVPIfItShouldBeAnnounced(*promptString, flags, &vp)) + { + if (vp != PROMPT_SILENCE) + vpQueuePrompt(vp); + else // announce ASCII + { + int32_t val = *promptString; + vpQueuePrompt(PROMPT_CHARACTER); // just the word "code" as we + // don't have character. + vpQueueInteger(val); + } + } + else + { + // otherwise just add silence + vpQueuePrompt(PROMPT_SILENCE); + } + + promptString++; + } + if (flags & vpqAddSeparatingSilence) vpQueuePrompt(PROMPT_SILENCE); } void vpQueueInteger(int32_t value) { - if (state.settings.vpLevel < vpLow) - return; + if (state.settings.vpLevel < vpLow) return; - char buf[12] = {0}; // min: -2147483648, max: 2147483647 + char buf[12] = {0}; // min: -2147483648, max: 2147483647 snprintf(buf, 12, "%d", value); - vpQueueString(buf, 0); + vpQueueString(buf, 0); } // This function looks up a voice prompt corresponding to a string table entry. -// These are stored in the voice data after the voice prompts with no +// These are stored in the voice data after the voice prompts with no // corresponding string table entry, hence the offset calculation: // NUM_VOICE_PROMPTS + (stringTableStringPtr - currentLanguage->languageName) -void vpQueueStringTableEntry(const char * const *stringTableStringPtr) +void vpQueueStringTableEntry(const char* const* stringTableStringPtr) { - if (state.settings.vpLevel < vpLow) - return; + if (state.settings.vpLevel < vpLow) return; - if (stringTableStringPtr == NULL) - { - return; - } - vpQueuePrompt(NUM_VOICE_PROMPTS + (stringTableStringPtr - ¤tLanguage->languageName)); + if (stringTableStringPtr == NULL) + { + return; + } + vpQueuePrompt(NUM_VOICE_PROMPTS + + (stringTableStringPtr - ¤tLanguage->languageName)); } void vpPlay(void) { - if (state.settings.vpLevel < vpLow) - return; + if (state.settings.vpLevel < vpLow) return; - if ((voicePromptIsActive == false) && (vpCurrentSequence.Length > 0)) - { - voicePromptIsActive = true;// Start the playback - int promptNumber = vpCurrentSequence.Buffer[0]; + if ((voicePromptIsActive == false) && (vpCurrentSequence.Length > 0)) + { + voicePromptIsActive = true; // Start the playback + int promptNumber = vpCurrentSequence.Buffer[0]; - vpCurrentSequence.Pos = 0; - - currentPromptLength = tableOfContents[promptNumber + 1] - tableOfContents[promptNumber]; - GetCodec2Data(tableOfContents[promptNumber], currentPromptLength); - -// GPIO_PinWrite(GPIO_RX_audio_mux, Pin_RX_audio_mux, 0);// set the audio mux HR-C6000 -> audio amp - //enableAudioAmp(AUDIO_AMP_MODE_PROMPT); + vpCurrentSequence.Pos = 0; - //codecInit(true); - promptDataPosition = 0; + currentPromptLength = + tableOfContents[promptNumber + 1] - tableOfContents[promptNumber]; + GetCodec2Data(tableOfContents[promptNumber], currentPromptLength); - } + // GPIO_PinWrite(GPIO_RX_audio_mux, Pin_RX_audio_mux, 0);// set + // the audio mux HR-C6000 -> audio amp + // enableAudioAmp(AUDIO_AMP_MODE_PROMPT); + + // codecInit(true); + promptDataPosition = 0; + } } inline bool vpIsPlaying(void) { - return (voicePromptIsActive || (promptTail > 0)); + return (voicePromptIsActive || (promptTail > 0)); } bool vpHasDataToPlay(void) { - return (vpCurrentSequence.Length > 0); + return (vpCurrentSequence.Length > 0); } diff --git a/openrtx/src/ui/UIStrings.c b/openrtx/src/ui/UIStrings.c index c78fbbca..919afe17 100644 --- a/openrtx/src/ui/UIStrings.c +++ b/openrtx/src/ui/UIStrings.c @@ -18,41 +18,42 @@ * along with this program; if not, see * ***************************************************************************/ /* -This string table's order must not be altered as voice prompts will be indexed in the same order as these strings. +This string table's order must not be altered as voice prompts will be indexed +in the same order as these strings. */ -#include #include "ui/UIStrings.h" - #include "ui/EnglishStrings.h" - #include - // add more languages here. - const stringsTable_t languages[NUM_LANGUAGES]={ englishStrings }; - // default to English. - const stringsTable_t* currentLanguage=&languages[0]; +#include +#include +#include "ui/EnglishStrings.h" + +// add more languages here. +const stringsTable_t languages[NUM_LANGUAGES] = {englishStrings}; +// default to English. +const stringsTable_t* currentLanguage = &languages[0]; /* Given an english string such as a menu item or value, search the english string table and return the offset if found. -This can then be used to look up the localized string in the currentLanguages +This can then be used to look up the localized string in the currentLanguages struct, or to announce an indexed voice prompt. */ -int GetEnglishStringTableOffset( char* text) +int GetEnglishStringTableOffset(char* text) { - if (!text || !*text) - return -1; // error. - - uint8_t stringCount =sizeof(stringsTable_t)/sizeof(char*); - - for (uint8_t i = 0; i < stringCount; ++i) - { + if (!text || !*text) return -1; // error. + + uint8_t stringCount = sizeof(stringsTable_t) / sizeof(char*); + + for (uint8_t i = 0; i < stringCount; ++i) + { const char* strPtr = ((const char **)&englishStrings)[i]; - if (strcmp(text, strPtr) == 0) - { - return (i * sizeof(char *)); - } - } - - return -1; + if (strcmp(text, strPtr) == 0) + { + return (i * sizeof(char *)); + } + } + + return -1; }