Set all custom failsafe channels at once (#5834)
[opentx.git] / radio / src / translations / tts_se.cpp
blob27c1600a37483394171a1daf44f8a30d955e661a
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 * - Kjell Kernen
12 * - Karl Szmutny
13 * - Michael Blandford
14 * - Michal Hlavinka
15 * - Pat Mackenzie
16 * - Philip Moss
17 * - Rob Thomson
18 * - Romolo Manfredini <romolo.manfredini@gmail.com>
19 * - Thomas Husterer
21 * opentx is based on code named
22 * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
23 * er9x by Erez Raviv: http://code.google.com/p/er9x/,
24 * and the original (and ongoing) project by
25 * Thomas Husterer, th9x: http://code.google.com/p/th9x/
27 * This program is free software; you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License version 2 as
29 * published by the Free Software Foundation.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
38 #include "opentx.h"
40 enum SwedishPrompts {
41 SE_PROMPT_NUMBERS_BASE = 0,
42 SE_PROMPT_ZERO = SE_PROMPT_NUMBERS_BASE+0, //02-99
43 SE_PROMPT_HUNDRED = SE_PROMPT_NUMBERS_BASE+100, //100,200 .. 900
44 SE_PROMPT_THOUSAND = SE_PROMPT_NUMBERS_BASE+109, //1000
45 SE_PROMPT_AND = SE_PROMPT_NUMBERS_BASE+110,
46 SE_PROMPT_MINUS = SE_PROMPT_NUMBERS_BASE+111,
47 SE_PROMPT_POINT = SE_PROMPT_NUMBERS_BASE+112,
48 SE_PROMPT_UNITS_BASE = 113,
49 SE_PROMPT_POINT_BASE = 165, //.0 - .9
52 #if defined(VOICE)
54 #if defined(CPUARM)
55 #define SE_PUSH_UNIT_PROMPT(u, p) se_pushUnitPrompt((u), (p), id)
56 #else
57 #define SE_PUSH_UNIT_PROMPT(u, p) pushUnitPrompt((u), (p))
58 #endif
60 I18N_PLAY_FUNCTION(se, pushUnitPrompt, uint8_t unitprompt, int16_t number)
62 #if defined(CPUARM)
63 if (number == 1)
64 PUSH_UNIT_PROMPT(unitprompt, 0);
65 else
66 PUSH_UNIT_PROMPT(unitprompt, 1);
67 #else
68 unitprompt = SE_PROMPT_UNITS_BASE + unitprompt*2;
69 if (number == 1)
70 PUSH_NUMBER_PROMPT(unitprompt);
71 else
72 PUSH_NUMBER_PROMPT(unitprompt+1);
73 #endif
76 I18N_PLAY_FUNCTION(se, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
78 if (number < 0) {
79 PUSH_NUMBER_PROMPT(SE_PROMPT_MINUS);
80 number = -number;
83 #if !defined(CPUARM)
84 if (unit) {
85 unit--;
86 convertUnit(number, unit);
87 if (IS_IMPERIAL_ENABLE()) {
88 if (unit == UNIT_DIST) {
89 unit = UNIT_FEET;
91 if (unit == UNIT_SPEED) {
92 unit = UNIT_KTS;
95 unit++;
97 #endif
99 int8_t mode = MODE(att);
100 if (mode > 0) {
101 #if defined(CPUARM)
102 if (mode == 2) {
103 number /= 10;
105 #else
106 // we assume that we are PREC1
107 #endif
108 div_t qr = div((int)number, 10);
109 if (qr.rem) {
110 PLAY_NUMBER(qr.quot, 0, 0);
111 PUSH_NUMBER_PROMPT(SE_PROMPT_POINT_BASE + qr.rem);
112 number = -1;
114 else {
115 number = qr.quot;
119 int16_t tmpNumber = number;
121 if (number >= 1000) {
122 PLAY_NUMBER(number / 1000, 0, 0);
123 PUSH_NUMBER_PROMPT(SE_PROMPT_THOUSAND);
124 number %= 1000;
125 if (number == 0)
126 number = -1;
128 if (number >= 100) {
129 PUSH_NUMBER_PROMPT(SE_PROMPT_HUNDRED + (number/100)-1);
130 number %= 100;
131 if (number == 0)
132 number = -1;
134 if (number >= 0) {
135 PUSH_NUMBER_PROMPT(SE_PROMPT_ZERO + number);
138 if (unit) {
139 SE_PUSH_UNIT_PROMPT(unit, tmpNumber);
143 I18N_PLAY_FUNCTION(se, playDuration, int seconds PLAY_DURATION_ATT)
145 if (seconds < 0) {
146 PUSH_NUMBER_PROMPT(SE_PROMPT_MINUS);
147 seconds = -seconds;
150 uint8_t tmp = seconds / 3600;
151 seconds %= 3600;
152 if (tmp > 0 || IS_PLAY_TIME()) {
153 PLAY_NUMBER(tmp, UNIT_HOURS, 0);
156 tmp = seconds / 60;
157 seconds %= 60;
158 if (tmp > 0) {
159 PLAY_NUMBER(tmp, UNIT_MINUTES, 0);
160 if (seconds > 0)
161 PUSH_NUMBER_PROMPT(SE_PROMPT_AND);
164 if (seconds > 0) {
165 PLAY_NUMBER(seconds, UNIT_SECONDS, 0);
169 LANGUAGE_PACK_DECLARE(se, "Swedish");
171 #endif