2 * Authors (alphabetical order)
3 * - Bertrand Songis <bsongis@gmail.com>
4 * - Romolo Manfredini <romolo.manfredini@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.
26 IT_PROMPT_NUMBERS_BASE
= 0,
27 IT_PROMPT_ZERO
= IT_PROMPT_NUMBERS_BASE
+0,
28 IT_PROMPT_CENT
= IT_PROMPT_NUMBERS_BASE
+100,
29 IT_PROMPT_MILA
= IT_PROMPT_NUMBERS_BASE
+101,
30 IT_PROMPT_MILLE
= IT_PROMPT_NUMBERS_BASE
+102,
31 IT_PROMPT_VIRGOLA
= 103,
42 IT_PROMPT_UNITS_BASE
= 113,
43 IT_PROMPT_VOLTS
= IT_PROMPT_UNITS_BASE
+(UNIT_VOLTS
*2),
44 IT_PROMPT_AMPS
= IT_PROMPT_UNITS_BASE
+(UNIT_AMPS
*2),
45 IT_PROMPT_METERS_PER_SECOND
= IT_PROMPT_UNITS_BASE
+(UNIT_METERS_PER_SECOND
*2),
46 IT_PROMPT_SPARE1
= IT_PROMPT_UNITS_BASE
+(UNIT_RAW
*2),
47 IT_PROMPT_KMH
= IT_PROMPT_UNITS_BASE
+(UNIT_SPEED
*2),
48 IT_PROMPT_METERS
= IT_PROMPT_UNITS_BASE
+(UNIT_DIST
*2),
49 IT_PROMPT_DEGREES
= IT_PROMPT_UNITS_BASE
+(UNIT_TEMPERATURE
*2),
50 IT_PROMPT_PERCENT
= IT_PROMPT_UNITS_BASE
+(UNIT_PERCENT
*2),
51 IT_PROMPT_MILLIAMPS
= IT_PROMPT_UNITS_BASE
+(UNIT_MILLIAMPS
*2),
52 IT_PROMPT_MAH
= IT_PROMPT_UNITS_BASE
+(UNIT_MAH
*2),
53 IT_PROMPT_WATTS
= IT_PROMPT_UNITS_BASE
+(UNIT_WATTS
*2),
54 IT_PROMPT_FEET
= IT_PROMPT_UNITS_BASE
+(UNIT_FEET
*2),
55 IT_PROMPT_KTS
= IT_PROMPT_UNITS_BASE
+(UNIT_KTS
*2),
57 IT_PROMPT_MILLILITERS
= IT_PROMPT_UNITS_BASE
+(UNIT_MILLILITERS
*2),
58 IT_PROMPT_FLOZ
= IT_PROMPT_UNITS_BASE
+(UNIT_FLOZ
*2),
59 IT_PROMPT_FEET_PER_SECOND
= IT_PROMPT_UNITS_BASE
+(UNIT_FEET_PER_SECOND
*2),
66 #define IT_PUSH_UNIT_PROMPT(u, p) it_pushUnitPrompt((u), (p), id)
68 #define IT_PUSH_UNIT_PROMPT(u, p) pushUnitPrompt((u), (p))
71 I18N_PLAY_FUNCTION(it
, pushUnitPrompt
, uint8_t unitprompt
, int16_t number
)
75 PUSH_UNIT_PROMPT(unitprompt
, 0);
77 PUSH_UNIT_PROMPT(unitprompt
, 1);
79 unitprompt
= IT_PROMPT_UNITS_BASE
+ unitprompt
*2;
81 PUSH_NUMBER_PROMPT(unitprompt
);
83 PUSH_NUMBER_PROMPT(unitprompt
+1);
88 I18N_PLAY_FUNCTION(it
, playNumber
, getvalue_t number
, uint8_t unit
, uint8_t att
)
90 /* if digit >= 1000000000:
91 temp_digit, digit = divmod(digit, 1000000000)
92 prompts.extend(self.getNumberPrompt(temp_digit))
93 prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
95 temp_digit, digit = divmod(digit, 1000000)
96 prompts.extend(self.getNumberPrompt(temp_digit))
97 prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
99 getvalue_t orignumber
;
101 PUSH_NUMBER_PROMPT(IT_PROMPT_MENO
);
108 convertUnit(number
, unit
);
109 if (IS_IMPERIAL_ENABLE()) {
110 if (unit
== UNIT_DIST
) {
113 if (unit
== UNIT_SPEED
) {
121 int8_t mode
= MODE(att
);
128 // we assume that we are PREC1
130 div_t qr
= div((int)number
, 10);
132 PLAY_NUMBER(qr
.quot
, 0, 0);
133 PUSH_NUMBER_PROMPT(IT_PROMPT_VIRGOLA
);
134 if (mode
==2 && qr
.rem
< 10)
135 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO
);
136 PLAY_NUMBER(qr
.rem
, 0, 0);
140 PUSH_NUMBER_PROMPT(IT_PROMPT_UN
);
142 PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE
+(unit
*2));
146 PLAY_NUMBER(qr
.quot
, 0, 0);
150 if (orignumber
== 1 && unit
) {
151 PUSH_NUMBER_PROMPT(IT_PROMPT_UN
);
153 if (number
>= 1000) {
154 if (number
>= 2000) {
155 PLAY_NUMBER(number
/ 1000, 0, 0);
156 PUSH_NUMBER_PROMPT(IT_PROMPT_MILA
);
158 PUSH_NUMBER_PROMPT(IT_PROMPT_MILLE
);
166 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO
+ number
/100);
167 PUSH_NUMBER_PROMPT(IT_PROMPT_CENT
);
172 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO
+number
);
176 IT_PUSH_UNIT_PROMPT(unit
, orignumber
);
180 I18N_PLAY_FUNCTION(it
, playDuration
, int seconds PLAY_DURATION_ATT
)
183 PLAY_NUMBER(seconds
, 0, 0);
188 PUSH_NUMBER_PROMPT(IT_PROMPT_MENO
);
192 uint8_t tmp
= seconds
/ 3600;
194 if (tmp
> 0 || IS_PLAY_TIME()) {
195 PLAY_NUMBER(tmp
, UNIT_HOURS
, 0);
201 PLAY_NUMBER(tmp
, UNIT_MINUTES
, 0);
203 PUSH_NUMBER_PROMPT(IT_PROMPT_E
);
207 PLAY_NUMBER(seconds
, UNIT_SECONDS
, 0);
211 LANGUAGE_PACK_DECLARE(it
, "Italiano");