Improve multi (#7136)
[opentx.git] / radio / src / translations / tts_pt.cpp
blob34a3ff75b8a3b102481cafe01145e2d6b201adb9
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 PT_PROMPT_MILLILITERS = PT_PROMPT_UNITS_BASE+UNIT_MILLILITERS,
80 PT_PROMPT_FLOZ = PT_PROMPT_UNITS_BASE+UNIT_FLOZ,
81 PT_PROMPT_FEET_PER_SECOND = PT_PROMPT_UNITS_BASE+UNIT_FEET_PER_SECOND,
85 #define PT_PUSH_UNIT_PROMPT(u) pt_pushUnitPrompt((u), id)
87 I18N_PLAY_FUNCTION(pt, pushUnitPrompt, uint8_t unitprompt)
89 PUSH_UNIT_PROMPT(unitprompt, 0);
92 I18N_PLAY_FUNCTION(pt, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
94 if (number < 0) {
95 PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
96 number = -number;
100 int8_t mode = MODE(att);
101 if (mode > 0) {
102 if (mode == 2) {
103 number /= 10;
105 div_t qr = div((int)number, 10);
106 if (qr.rem > 0) {
107 PLAY_NUMBER(qr.quot, 0, 0);
108 PUSH_NUMBER_PROMPT(PT_PROMPT_VIRGULA);
109 if (mode==2 && qr.rem < 10)
110 PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO);
111 PLAY_NUMBER(qr.rem, unit, 0);
113 else {
114 PLAY_NUMBER(qr.quot, unit, 0);
116 return;
119 if (number >= 1000) {
120 if (number >= 2000) {
121 PLAY_NUMBER(number / 1000, 0, 0);
122 PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
123 } else {
124 PUSH_NUMBER_PROMPT(PT_PROMPT_MIL);
126 number %= 1000;
127 if (number == 0)
128 number = -1;
130 if (number >= 100) {
131 PUSH_NUMBER_PROMPT(PT_PROMPT_CENTO + number/100);
132 number %= 100;
133 if (number == 0)
134 number = -1;
136 PUSH_NUMBER_PROMPT(PT_PROMPT_ZERO+number);
138 if (unit) {
139 PT_PUSH_UNIT_PROMPT(unit);
143 I18N_PLAY_FUNCTION(pt, playDuration, int seconds PLAY_DURATION_ATT)
145 if (seconds < 0) {
146 PUSH_NUMBER_PROMPT(PT_PROMPT_MENOS);
147 seconds = -seconds;
150 uint8_t ore = 0;
151 uint8_t tmp = seconds / 3600;
152 seconds %= 3600;
153 if (tmp > 0 || IS_PLAY_TIME()) {
154 ore=tmp;
155 if (tmp > 2) {
156 PLAY_NUMBER(tmp, 0, 0);
157 PUSH_UNIT_PROMPT(UNIT_HOURS, 1);
158 } else if (tmp==2) {
159 PUSH_NUMBER_PROMPT(PT_PROMPT_DUAS);
160 PUSH_UNIT_PROMPT(UNIT_HOURS, 1);
161 } else if (tmp==1) {
162 PUSH_NUMBER_PROMPT(PT_PROMPT_UMA);
163 PUSH_UNIT_PROMPT(UNIT_HOURS, 0);
167 tmp = seconds / 60;
168 seconds %= 60;
169 if (tmp > 0 || ore >0) {
170 if (tmp != 1) {
171 PLAY_NUMBER(tmp, 0, 0);
172 PUSH_UNIT_PROMPT(UNIT_MINUTES, 1);
173 } else {
174 PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE+1);
175 PUSH_UNIT_PROMPT(UNIT_MINUTES, 0);
177 PUSH_NUMBER_PROMPT(PT_PROMPT_E);
180 if (seconds != 1) {
181 PLAY_NUMBER(seconds, 0, 0);
182 PUSH_UNIT_PROMPT(UNIT_SECONDS, 1);
183 } else {
184 PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE+1);
185 PUSH_UNIT_PROMPT(UNIT_SECONDS, 0);
189 LANGUAGE_PACK_DECLARE(pt, "Portugues");