Crossfire baudrate selection for X7 support ( fixes #4922 ) (#5194)
[opentx.git] / radio / src / translations / tts_pt.cpp
blobd55af8758c2a5787ee9d5604499225ba546af3ed
1 /*
2 * Authors (alphabetical order)
3 * - Andre Bernet <bernet.andre@gmail.com>
4 * - Andreas Weitl
5 * - Bertrand Songis <bsongis@gmail.com>
6 * - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
7 * - Cameron Weeks <th9xer@gmail.com>
8 * - Erez Raviv
9 * - Gabriel Birkus
10 * - Jean-Pierre Parisy
11 * - Karl Szmutny
12 * - Michael Blandford
13 * - Michal Hlavinka
14 * - Pat Mackenzie
15 * - Philip Moss
16 * - Rob Thomson
17 * - Romolo Manfredini <romolo.manfredini@gmail.com>
18 * - Thomas Husterer
20 * opentx is based on code named
21 * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
22 * er9x by Erez Raviv: http://code.google.com/p/er9x/,
23 * and the original (and ongoing) project by
24 * Thomas Husterer, th9x: http://code.google.com/p/th9x/
26 * This program is free software; you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License version 2 as
28 * published by the Free Software Foundation.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
37 #include "opentx.h"
39 enum PortuguesePrompts {
40 PT_PROMPT_NUMBERS_BASE = 0,
41 PT_PROMPT_ZERO = PT_PROMPT_NUMBERS_BASE+0,
42 PT_PROMPT_CEM = PT_PROMPT_NUMBERS_BASE+100,
43 PT_PROMPT_CENTO = PT_PROMPT_NUMBERS_BASE+101,
44 PT_PROMPT_DUZENTOS = PT_PROMPT_NUMBERS_BASE+102,
45 PT_PROMPT_TREZCENTOS,
46 PT_PROMPT_QUATROCENTOS,
47 PT_PROMPT_QUINHENTOS,
48 PT_PROMPT_SEISCENTOS,
49 PT_PROMPT_SETECENTOS,
50 PT_PROMPT_OITOCENTOS,
51 PT_PROMPT_NUEVECENTOS,
52 PT_PROMPT_MIL = PT_PROMPT_NUMBERS_BASE+110,
53 PT_PROMPT_VIRGULA = 111,
54 PT_PROMPT_UMA,
55 PT_PROMPT_DUAS,
56 PT_PROMPT_E,
57 PT_PROMPT_MENOS,
58 PT_PROMPT_HORA,
59 PT_PROMPT_HORAS,
60 PT_PROMPT_MINUTO,
61 PT_PROMPT_MINUTOS,
62 PT_PROMPT_SEGUNDO,
63 PT_PROMPT_SEGUNDOS,
65 PT_PROMPT_UNITS_BASE = 122,
66 PT_PROMPT_VOLTS = PT_PROMPT_UNITS_BASE+UNIT_VOLTS,
67 PT_PROMPT_AMPS = PT_PROMPT_UNITS_BASE+UNIT_AMPS,
68 PT_PROMPT_METERS_PER_SECOND = PT_PROMPT_UNITS_BASE+UNIT_METERS_PER_SECOND,
69 PT_PROMPT_SPARE1 = PT_PROMPT_UNITS_BASE+UNIT_RAW,
70 PT_PROMPT_KMH = PT_PROMPT_UNITS_BASE+UNIT_SPEED,
71 PT_PROMPT_METERS = PT_PROMPT_UNITS_BASE+UNIT_DIST,
72 PT_PROMPT_DEGREES = PT_PROMPT_UNITS_BASE+UNIT_TEMPERATURE,
73 PT_PROMPT_PERCENT = PT_PROMPT_UNITS_BASE+UNIT_PERCENT,
74 PT_PROMPT_MILLIAMPS = PT_PROMPT_UNITS_BASE+UNIT_MILLIAMPS,
75 PT_PROMPT_MAH = PT_PROMPT_UNITS_BASE+UNIT_MAH,
76 PT_PROMPT_WATTS = PT_PROMPT_UNITS_BASE+UNIT_WATTS,
77 PT_PROMPT_FEET = PT_PROMPT_UNITS_BASE+UNIT_FEET,
78 PT_PROMPT_KTS = PT_PROMPT_UNITS_BASE+UNIT_KTS,
79 #if defined(CPUARM)
80 PT_PROMPT_MILLILITERS = PT_PROMPT_UNITS_BASE+UNIT_MILLILITERS,
81 PT_PROMPT_FLOZ = PT_PROMPT_UNITS_BASE+UNIT_FLOZ,
82 PT_PROMPT_FEET_PER_SECOND = PT_PROMPT_UNITS_BASE+UNIT_FEET_PER_SECOND,
83 #endif
86 #if defined(VOICE)
88 #if defined(CPUARM)
89 #define PT_PUSH_UNIT_PROMPT(u) pt_pushUnitPrompt((u), id)
90 #else
91 #define PT_PUSH_UNIT_PROMPT(u) pushUnitPrompt((u))
92 #endif
94 I18N_PLAY_FUNCTION(pt, pushUnitPrompt, uint8_t unitprompt)
96 #if defined(CPUARM)
97 PUSH_UNIT_PROMPT(unitprompt, 0);
98 #else
99 unitprompt = PT_PROMPT_UNITS_BASE + unitprompt*2;
100 PUSH_NUMBER_PROMPT(unitprompt);
101 #endif
104 I18N_PLAY_FUNCTION(pt, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
106 if (number < 0) {
107 PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
108 number = -number;
111 #if !defined(CPUARM)
112 if (unit) {
113 unit--;
114 convertUnit(number, unit);
115 if (IS_IMPERIAL_ENABLE()) {
116 if (unit == UNIT_DIST) {
117 unit = UNIT_FEET;
119 if (unit == UNIT_SPEED) {
120 unit = UNIT_KTS;
123 unit++;
125 #endif
127 int8_t mode = MODE(att);
128 if (mode > 0) {
129 #if defined(CPUARM)
130 if (mode == 2) {
131 number /= 10;
133 #else
134 // we assume that we are PREC1
135 #endif
136 div_t qr = div((int)number, 10);
137 if (qr.rem > 0) {
138 PLAY_NUMBER(qr.quot, 0, 0);
139 PUSH_NUMBER_PROMPT(PT_PROMPT_VIRGULA);
140 if (mode==2 && qr.rem < 10)
141 PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO);
142 PLAY_NUMBER(qr.rem, unit, 0);
144 else {
145 PLAY_NUMBER(qr.quot, unit, 0);
147 return;
150 if (number >= 1000) {
151 if (number >= 2000) {
152 PLAY_NUMBER(number / 1000, 0, 0);
153 PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
154 } else {
155 PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
157 number %= 1000;
158 if (number == 0)
159 number = -1;
161 if (number >= 100) {
162 PUSH_NUMBER_PROMPT(PT_PROMPT_CENTO + number/100);
163 number %= 100;
164 if (number == 0)
165 number = -1;
167 PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO+number);
169 if (unit) {
170 PT_PUSH_UNIT_PROMPT(unit);
174 I18N_PLAY_FUNCTION(pt, playDuration, int seconds PLAY_DURATION_ATT)
176 if (seconds < 0) {
177 PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
178 seconds = -seconds;
181 uint8_t ore = 0;
182 uint8_t tmp = seconds / 3600;
183 seconds %= 3600;
184 if (tmp > 0 || IS_PLAY_TIME()) {
185 ore=tmp;
186 if (tmp > 2) {
187 PLAY_NUMBER(tmp, 0, 0);
188 #if defined(CPUARM)
189 PUSH_UNIT_PROMPT(UNIT_HOURS, 1);
190 #else
191 PUSH_NUMBER_PROMPT(PT_PROMPT_HORAS);
192 #endif
193 } else if (tmp==2) {
194 PUSH_NUMBER_PROMPT(PT_PROMPT_DUAS);
195 #if defined(CPUARM)
196 PUSH_UNIT_PROMPT(UNIT_HOURS, 1);
197 #else
198 PUSH_NUMBER_PROMPT(PT_PROMPT_HORAS);
199 #endif
200 } else if (tmp==1) {
201 PUSH_NUMBER_PROMPT(PT_PROMPT_UMA);
202 #if defined(CPUARM)
203 PUSH_UNIT_PROMPT(UNIT_HOURS, 0);
204 #else
205 PUSH_NUMBER_PROMPT(PT_PROMPT_HORAS);
206 #endif
210 tmp = seconds / 60;
211 seconds %= 60;
212 if (tmp > 0 || ore >0) {
213 if (tmp != 1) {
214 PLAY_NUMBER(tmp, 0, 0);
215 #if defined(CPUARM)
216 PUSH_UNIT_PROMPT(UNIT_MINUTES, 1);
217 #else
218 PUSH_NUMBER_PROMPT(PT_PROMPT_MINUTOS);
219 #endif
220 } else {
221 PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE+1);
222 #if defined(CPUARM)
223 PUSH_UNIT_PROMPT(UNIT_MINUTES, 0);
224 #else
225 PUSH_NUMBER_PROMPT(PT_PROMPT_MINUTO);
226 #endif
228 PUSH_NUMBER_PROMPT(PT_PROMPT_E);
231 if (seconds != 1) {
232 PLAY_NUMBER(seconds, 0, 0);
233 #if defined(CPUARM)
234 PUSH_UNIT_PROMPT(UNIT_SECONDS, 1);
235 #else
236 PUSH_NUMBER_PROMPT(PT_PROMPT_SEGUNDOS);
237 #endif
238 } else {
239 PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE+1);
240 #if defined(CPUARM)
241 PUSH_UNIT_PROMPT(UNIT_SECONDS, 0);
242 #else
243 PUSH_NUMBER_PROMPT(PT_PROMPT_SEGUNDO);
244 #endif
248 LANGUAGE_PACK_DECLARE(pt, "Portugues");
250 #endif