Renamed UIStrings.h/.c to ui_strings.h/.c and refactored their content
This commit is contained in:
parent
8eca684a7d
commit
5840f459fa
|
|
@ -54,7 +54,7 @@ openrtx_src = ['openrtx/src/core/state.c',
|
|||
'openrtx/src/core/voicePrompts.c',
|
||||
'openrtx/src/core/voicePromptUtils.c',
|
||||
'openrtx/src/ui/ui.c',
|
||||
'openrtx/src/ui/UIStrings.c',
|
||||
'openrtx/src/ui/ui_strings.c',
|
||||
'openrtx/src/ui/ui_main.c',
|
||||
'openrtx/src/ui/ui_menu.c',
|
||||
'openrtx/src/rtx/rtx.cpp',
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#define VOICE_PROMPT_UTILS_H_INCLUDED
|
||||
|
||||
#include "cps.h"
|
||||
#include "ui/UIStrings.h"
|
||||
#include "ui/ui_strings.h"
|
||||
#include "voicePrompts.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@
|
|||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
#ifndef EnglishStrings_h_included
|
||||
#define EnglishStrings_h_included
|
||||
#include "ui/UIStrings.h"
|
||||
#ifndef ENGLISHSTRINGS_H
|
||||
#define ENGLISHSTRINGS_H
|
||||
|
||||
const stringsTable_t englishStrings = {
|
||||
#include "ui/ui_strings.h"
|
||||
|
||||
const stringsTable_t englishStrings =
|
||||
{
|
||||
.languageName = "English",
|
||||
.off = "OFF",
|
||||
.on = "ON",
|
||||
|
|
@ -87,4 +89,4 @@ const stringsTable_t englishStrings = {
|
|||
.forEmergencyUse = "For emergency use",
|
||||
.pressAnyButton = "press any button.",
|
||||
};
|
||||
#endif // EnglishStrings_h_included
|
||||
#endif // ENGLISHSTRINGS_H
|
||||
|
|
|
|||
|
|
@ -17,15 +17,16 @@
|
|||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
/*
|
||||
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
|
||||
#ifndef UI_STRINGS_H
|
||||
#define UI_STRINGS_H
|
||||
|
||||
#define NUM_LANGUAGES 1
|
||||
|
||||
/*
|
||||
* NOTE: 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.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char* languageName;
|
||||
|
|
@ -92,11 +93,20 @@ typedef struct
|
|||
const char* macroMenu;
|
||||
const char* forEmergencyUse;
|
||||
const char* pressAnyButton;
|
||||
} stringsTable_t;
|
||||
}
|
||||
stringsTable_t;
|
||||
|
||||
extern const stringsTable_t languages[];
|
||||
extern const stringsTable_t* currentLanguage;
|
||||
|
||||
int GetEnglishStringTableOffset(char* text);
|
||||
/**
|
||||
* Search for a given string into the string table and, if found, return its
|
||||
* offset with respect to the beginning.
|
||||
*
|
||||
* @param text: string to be searched.
|
||||
* @return text position inside the string table or -1 if the string is not
|
||||
* present.
|
||||
*/
|
||||
int GetEnglishStringTableOffset(const char* text);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
|
||||
#include "interfaces/keyboard.h"
|
||||
#include "ui/UIStrings.h"
|
||||
#include "ui/ui_strings.h"
|
||||
|
||||
const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056; //'VP'
|
||||
const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <stdint.h>
|
||||
#include <ui.h>
|
||||
#include <string.h>
|
||||
#include "ui/UIStrings.h"
|
||||
#include "ui/ui_strings.h"
|
||||
|
||||
void _ui_drawMainBackground()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <memory_profiling.h>
|
||||
#include <ui/UIStrings.h>
|
||||
#include <ui/ui_strings.h>
|
||||
#include <core/voicePromptUtils.h>
|
||||
|
||||
/* UI main screen helper functions, their implementation is in "ui_main.c" */
|
||||
|
|
|
|||
|
|
@ -17,33 +17,21 @@
|
|||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
/*
|
||||
This string table's order must not be altered as voice prompts will be indexed
|
||||
in the same order as these strings.
|
||||
*/
|
||||
#include "ui/UIStrings.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ui/ui_strings.h>
|
||||
#include <ui/EnglishStrings.h>
|
||||
|
||||
#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
|
||||
struct, or to announce an indexed voice prompt.
|
||||
*/
|
||||
int GetEnglishStringTableOffset(char* text)
|
||||
int GetEnglishStringTableOffset(const char* text)
|
||||
{
|
||||
if (!text || !*text) return -1; // error.
|
||||
if ((text == NULL) || (*text == '\0'))
|
||||
return -1;
|
||||
|
||||
uint8_t stringCount = sizeof(stringsTable_t) / sizeof(char*);
|
||||
uint8_t stringCount = sizeof(stringsTable_t) / sizeof(char *);
|
||||
|
||||
for (uint8_t i = 0; i < stringCount; ++i)
|
||||
{
|
||||
Loading…
Reference in New Issue