From 4149361de88b153fe1d50cb5dabb9d500a855999 Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 13 Jun 2014 10:32:23 +0200 Subject: [PATCH] Hungarian voice added --- .../firmwares/opentx/opentxSky9xsimulator.cpp | 1 + .../opentx/opentxTaranisSimulator.cpp | 2 +- .../src/firmwares/opentx/opentxinterface.h | 1 + radio/src/Makefile | 4 +- radio/src/gui/menu_general.cpp | 6 +- radio/src/translations/tts_hu.cpp | 182 ++++++++++++++++++ 6 files changed, 191 insertions(+), 5 deletions(-) create mode 100755 radio/src/translations/tts_hu.cpp diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp index 1cd866971..9842eee9a 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp @@ -120,6 +120,7 @@ namespace Open9xSky9x { #include "radio/src/translations/tts_pt.cpp" #include "radio/src/translations/tts_sk.cpp" #include "radio/src/translations/tts_pl.cpp" +#include "radio/src/translations/tts_hu.cpp" int16_t g_anas[NUM_STICKS+BOARD_9X_NUM_POTS]; diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 5b2e4ff4c..2c7e89034 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -129,7 +129,7 @@ inline int geteepromsize() { #include "radio/src/translations/tts_pt.cpp" #include "radio/src/translations/tts_sk.cpp" #include "radio/src/translations/tts_pl.cpp" - +#include "radio/src/translations/tts_hu.cpp" #include "radio/src/lua.cpp" #include "radio/src/lua/src/lapi.c" #include "radio/src/lua/src/lcode.c" diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index ee3b71793..b2b52a205 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -103,6 +103,7 @@ class OpenTxFirmware: public FirmwareInterface { addTTSLanguage("pl"); addTTSLanguage("pt"); addTTSLanguage("es"); + addTTSLanguage("hu"); } virtual QString getStampUrl(); diff --git a/radio/src/Makefile b/radio/src/Makefile index 285ae7b60..13e004380 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -226,7 +226,7 @@ IRPROTOS = NO TRANSLATIONS = EN # TTS -# Values = en, fr +# Values = en, fr, hu TTS = $(TRANSLATIONS) # UNITS @@ -753,7 +753,7 @@ TARGET = opentx # List C++ source files here. (C dependencies are automatically generated.) ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO TARANIS)) - TTS_SRC = translations/tts_cz.cpp translations/tts_de.cpp translations/tts_en.cpp translations/tts_es.cpp translations/tts_fr.cpp translations/tts_it.cpp translations/tts_pt.cpp translations/tts_sk.cpp translations/tts_se.cpp translations/tts_pl.cpp + TTS_SRC = translations/tts_cz.cpp translations/tts_de.cpp translations/tts_en.cpp translations/tts_es.cpp translations/tts_fr.cpp translations/tts_it.cpp translations/tts_pt.cpp translations/tts_sk.cpp translations/tts_se.cpp translations/tts_pl.cpp translations/tts_hu.cpp else STD_TTS_SRC = translations/tts_$(shell sh -c "echo $(TTS) | tr '[:upper:]' '[:lower:]'").cpp TTS_SRC = $(shell sh -c "if test -f $(STD_TTS_SRC); then echo $(STD_TTS_SRC); else echo translations/tts_en.cpp; fi") diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 3ce5166fe..a27eef12c 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -51,19 +51,21 @@ extern LanguagePack plLanguagePack; extern LanguagePack ptLanguagePack; extern LanguagePack skLanguagePack; extern LanguagePack seLanguagePack; +extern LanguagePack huLanguagePack; LanguagePack * languagePacks[] = { // alphabetical order &czLanguagePack, + &deLanguagePack, &enLanguagePack, &esLanguagePack, &frLanguagePack, - &deLanguagePack, + &huLanguagePack, &itLanguagePack, &plLanguagePack, &ptLanguagePack, - &skLanguagePack, &seLanguagePack, + &skLanguagePack, NULL }; #endif diff --git a/radio/src/translations/tts_hu.cpp b/radio/src/translations/tts_hu.cpp new file mode 100755 index 000000000..edade13b9 --- /dev/null +++ b/radio/src/translations/tts_hu.cpp @@ -0,0 +1,182 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../opentx.h" + +enum HungarianPrompts { + HU_PROMPT_NUMBERS_BASE = 0, + HU_PROMPT_ZERO = HU_PROMPT_NUMBERS_BASE+0, //02-99 + HU_PROMPT_HUNDRED = HU_PROMPT_NUMBERS_BASE+100, //100,200 .. 900 + HU_PROMPT_THOUSAND = HU_PROMPT_NUMBERS_BASE+109, //1000 + HU_PROMPT_AND = HU_PROMPT_NUMBERS_BASE+110, + HU_PROMPT_MINUS = HU_PROMPT_NUMBERS_BASE+111, + HU_PROMPT_POINT = HU_PROMPT_NUMBERS_BASE+112, + + HU_PROMPT_UNITS_BASE = 115, + HU_PROMPT_VOLTS = HU_PROMPT_UNITS_BASE+UNIT_VOLTS, //(one)volt,(two)volts + HU_PROMPT_AMPS = HU_PROMPT_UNITS_BASE+(UNIT_AMPS*2), + HU_PROMPT_METERS_PER_SECOND = HU_PROMPT_UNITS_BASE+(UNIT_METERS_PER_SECOND*2), + HU_PROMPT_SPARE1 = HU_PROMPT_UNITS_BASE+(UNIT_RAW*2), + HU_PROMPT_KMH = HU_PROMPT_UNITS_BASE+(UNIT_SPEED*2), + HU_PROMPT_METERS = HU_PROMPT_UNITS_BASE+(UNIT_DIST*2), + HU_PROMPT_DEGREES = HU_PROMPT_UNITS_BASE+(UNIT_TEMPERATURE*2), + HU_PROMPT_PERCENT = HU_PROMPT_UNITS_BASE+(UNIT_PERCENT*2), + HU_PROMPT_MILLIAMPS = HU_PROMPT_UNITS_BASE+(UNIT_MILLIAMPS*2), + HU_PROMPT_MAH = HU_PROMPT_UNITS_BASE+(UNIT_MAH*2), + HU_PROMPT_WATTS = HU_PROMPT_UNITS_BASE+(UNIT_WATTS*2), + HU_PROMPT_DB = HU_PROMPT_UNITS_BASE+(UNIT_DBM*2), + HU_PROMPT_FEET = HU_PROMPT_UNITS_BASE+(UNIT_FEET*2), + HU_PROMPT_MPH = HU_PROMPT_UNITS_BASE+(UNIT_KTS*2), + HU_PROMPT_HOURS = HU_PROMPT_UNITS_BASE+(UNIT_HOURS*2), + HU_PROMPT_MINUTES = HU_PROMPT_UNITS_BASE+(UNIT_MINUTES*2), + HU_PROMPT_SECONDS = HU_PROMPT_UNITS_BASE+(UNIT_SECONDS*2), + HU_PROMPT_RPMS = HU_PROMPT_UNITS_BASE+(UNIT_RPMS*2), + HU_PROMPT_G = HU_PROMPT_UNITS_BASE+(UNIT_G*2), + + HU_PROMPT_POINT_BASE = 160, //.0 - .9 + +}; + +#if defined(VOICE) + +#if defined(CPUARM) + #define HU_PUSH_UNIT_PROMPT(p, u) hu_pushUnitPrompt((p), (u), id) +#else + #define HU_PUSH_UNIT_PROMPT(p, u) pushUnitPrompt((p), (u)) +#endif + +I18N_PLAY_FUNCTION(hu, pushUnitPrompt, int16_t number, uint8_t unitprompt) +{ + if (number == 1) + PUSH_NUMBER_PROMPT(unitprompt); + else + PUSH_NUMBER_PROMPT(unitprompt+1); +} + +I18N_PLAY_FUNCTION(hu, playNumber, getvalue_t number, uint8_t unit, uint8_t att) +{ + if (number < 0) { + PUSH_NUMBER_PROMPT(HU_PROMPT_MINUS); + number = -number; + } + + if (unit) { + unit--; + convertUnit(number, unit); + if (IS_IMPERIAL_ENABLE()) { + if (unit == UNIT_DIST) { + unit = UNIT_FEET; + } + if (unit == UNIT_SPEED) { + unit = UNIT_KTS; + } + } +#if defined(CPUARM) + if ((att & PREC1) && (unit == UNIT_FEET || (unit == UNIT_DIST && number >= 100))) { + number = div10_and_round(number); + att -= PREC1; + } +#endif + unit++; + } + + int8_t mode = MODE(att); + if (mode > 0) { + // we assume that we are PREC1 + div_t qr = div(number, 10); + if (qr.rem) { + PLAY_NUMBER(qr.quot, 0, 0); + PUSH_NUMBER_PROMPT(HU_PROMPT_POINT_BASE + qr.rem); + number = -1; + } + else { + number = qr.quot; + } + } + + int16_t tmp = number; + + if (number >= 1000) { + PLAY_NUMBER(number / 1000, 0, 0); + PUSH_NUMBER_PROMPT(HU_PROMPT_THOUSAND); + number %= 1000; + if (number == 0) + number = -1; + } + if (number >= 100) { + PUSH_NUMBER_PROMPT(HU_PROMPT_HUNDRED + (number/100)-1); + number %= 100; + if (number == 0) + number = -1; + } + if (number >= 0) { + PUSH_NUMBER_PROMPT(HU_PROMPT_ZERO + number); + } + + if (unit) { + HU_PUSH_UNIT_PROMPT(tmp, (HU_PROMPT_UNITS_BASE+((unit-1)*2))); + } +} + +I18N_PLAY_FUNCTION(hu, playDuration, int seconds PLAY_DURATION_ATT) +{ + if (seconds < 0) { + PUSH_NUMBER_PROMPT(HU_PROMPT_MINUS); + seconds = -seconds; + } + + uint8_t tmp = seconds / 3600; + seconds %= 3600; + if (tmp > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(tmp, UNIT_HOURS+1 , 0); + } + + tmp = seconds / 60; + seconds %= 60; + if (tmp > 0) { + PLAY_NUMBER(tmp, UNIT_MINUTES+1 , 0); + if (seconds > 0) + PUSH_NUMBER_PROMPT(HU_PROMPT_AND); + } + + if (seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS+1 , 0); + } +} + +LANGUAGE_PACK_DECLARE(hu, "Hungarian"); + +#endif