Fix doc path
[opentx.git] / radio / src / translations / tts_cz.cpp
blob971888431370f0bea54acd878fd77294b1ac81fc
1 /*
2 * Authors (alphabetical order)
3 * - Bertrand Songis <bsongis@gmail.com>
4 * - Martin Hotar <mhotar@gmail.com>
6 * opentx is based on code named
7 * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
8 * er9x by Erez Raviv: http://code.google.com/p/er9x/,
9 * and the original (and ongoing) project by
10 * Thomas Husterer, th9x: http://code.google.com/p/th9x/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
23 #include "opentx.h"
25 enum CzechPrompts {
26 CZ_PROMPT_NUMBERS_BASE = 0,
27 CZ_PROMPT_NULA = CZ_PROMPT_NUMBERS_BASE+0, // 0-99
28 CZ_PROMPT_STO = CZ_PROMPT_NUMBERS_BASE+100, // 100,200 .. 900
29 CZ_PROMPT_TISIC = CZ_PROMPT_NUMBERS_BASE+109, // 1000
30 CZ_PROMPT_TISICE = CZ_PROMPT_NUMBERS_BASE+110,
31 CZ_PROMPT_JEDEN = CZ_PROMPT_NUMBERS_BASE+111,
32 CZ_PROMPT_JEDNO = CZ_PROMPT_NUMBERS_BASE+112,
33 CZ_PROMPT_DVE = CZ_PROMPT_NUMBERS_BASE+113,
34 CZ_PROMPT_CELA = CZ_PROMPT_NUMBERS_BASE+114,
35 CZ_PROMPT_CELE = CZ_PROMPT_NUMBERS_BASE+115,
36 CZ_PROMPT_CELYCH = CZ_PROMPT_NUMBERS_BASE+116,
37 CZ_PROMPT_MINUS = CZ_PROMPT_NUMBERS_BASE+117,
39 CZ_PROMPT_UNITS_BASE = 118, // (jeden)volt,(dva)volty,(pet)voltu,(desetina)voltu
42 #if defined(VOICE)
44 #if defined(CPUARM)
45 #define CZ_PUSH_UNIT_PROMPT(u, p) cz_pushUnitPrompt((u), (p), id)
46 #else
47 #define CZ_PUSH_UNIT_PROMPT(u, p) pushUnitPrompt((u), (p))
48 #endif
50 #define MALE 0x80
51 #define FEMALE 0x81
52 #define NEUTRAL 0x82
54 I18N_PLAY_FUNCTION(cz, pushUnitPrompt, uint8_t unit, int16_t number)
56 #if defined(CPUARM)
57 TRACE("CZSAY unit:%d number:%d", unit, number);
58 if (number == 1)
59 PUSH_UNIT_PROMPT(unit, 0);
60 else if (number > 1 && number < 5)
61 PUSH_UNIT_PROMPT(unit, 1);
62 else
63 PUSH_UNIT_PROMPT(unit, 2);
64 #else
65 unitprompt = CZ_PROMPT_UNITS_BASE+((unit-1)*4);
66 if (number == 1)
67 PUSH_NUMBER_PROMPT(unit);
68 else if (number > 1 && number < 5)
69 PUSH_NUMBER_PROMPT(unit+1);
70 else
71 PUSH_NUMBER_PROMPT(unit+2);
72 #endif
75 I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
77 if (number < 0) {
78 PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
79 number = -number;
82 #if !defined(CPUARM)
83 if (unit) {
84 unit--;
85 convertUnit(number, unit);
86 if (IS_IMPERIAL_ENABLE()) {
87 if (unit == UNIT_DIST) {
88 unit = UNIT_FEET;
90 if (unit == UNIT_SPEED) {
91 unit = UNIT_KTS;
94 unit++;
96 #endif
98 int8_t mode = MODE(att);
99 if (mode > 0) {
100 #if defined(CPUARM)
101 if (mode == 2) {
102 number /= 10;
104 #else
105 // we assume that we are PREC1
106 #endif
107 div_t qr = div((int)number, 10);
108 if (qr.rem) {
109 PLAY_NUMBER(qr.quot, 0, FEMALE);
110 if (qr.quot < 2) {
111 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELA);
113 else if (qr.quot > 1 && qr.quot < 5) {
114 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELE);
116 else {
117 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELYCH);
119 PLAY_NUMBER(qr.rem, 0, FEMALE);
120 #if defined(CPUARM)
121 PUSH_UNIT_PROMPT(unit, 3);
122 #else
123 PUSH_NUMBER_PROMPT(CZ_PROMPT_UNITS_BASE+((unit-1)*4)+3);
124 #endif
125 return;
127 else {
128 number = qr.quot;
132 int16_t tmp = number;
133 switch(unit) {
134 case UNIT_RAW:
135 break;
136 case UNIT_FEET_PER_SECOND:
137 case UNIT_MPH:
138 case UNIT_FEET:
139 case UNIT_MAH:
140 case UNIT_RPMS:
141 case UNIT_FLOZ:
142 case UNIT_HOURS:
143 case UNIT_MINUTES:
144 case UNIT_SECONDS:
145 att = FEMALE;
146 break;
147 case UNIT_PERCENT:
148 case UNIT_G:
149 att = NEUTRAL;
150 break;
151 default:
152 att = MALE;
153 break;
156 if ((number == 1) && (att == MALE)) {
157 PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDEN);
158 number = -1;
161 if ((number == 1) && (att == NEUTRAL)) {
162 PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDNO);
163 number = -1;
166 if ((number == 2) && ((att == FEMALE) || (att == NEUTRAL))) {
167 PUSH_NUMBER_PROMPT(CZ_PROMPT_DVE);
168 number = -1;
171 if (number >= 1000) {
172 if (number >= 2000)
173 PLAY_NUMBER(number / 1000, 0, 0);
174 if (number >= 2000 && number < 5000)
175 PUSH_NUMBER_PROMPT(CZ_PROMPT_TISICE);
176 else
177 PUSH_NUMBER_PROMPT(CZ_PROMPT_TISIC);
178 number %= 1000;
179 if (number == 0)
180 number = -1;
182 if (number >= 100) {
183 PUSH_NUMBER_PROMPT(CZ_PROMPT_STO + (number/100)-1);
184 number %= 100;
185 if (number == 0)
186 number = -1;
189 if (number >= 0) {
190 PUSH_NUMBER_PROMPT(CZ_PROMPT_NULA+number);
193 if (unit) {
194 CZ_PUSH_UNIT_PROMPT(unit, tmp);
198 I18N_PLAY_FUNCTION(cz, playDuration, int seconds PLAY_DURATION_ATT)
200 if (seconds < 0) {
201 PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
202 seconds = -seconds;
205 uint8_t tmp = seconds / 3600;
206 seconds %= 3600;
207 if (tmp > 0 || IS_PLAY_TIME()) {
208 PLAY_NUMBER(tmp, UNIT_HOURS, FEMALE);
211 tmp = seconds / 60;
212 seconds %= 60;
213 if (tmp > 0) {
214 PLAY_NUMBER(tmp, UNIT_MINUTES, FEMALE);
217 if (seconds > 0) {
218 PLAY_NUMBER(seconds, UNIT_SECONDS, FEMALE);
222 LANGUAGE_PACK_DECLARE(cz, "Czech");
224 #endif