189 lines
5.6 KiB
C++
189 lines
5.6 KiB
C++
/*
|
|
* Authors (alphabetical order)
|
|
* - Andre Bernet <bernet.andre@gmail.com>
|
|
* - Bertrand Songis <bsongis@gmail.com>
|
|
*
|
|
* opentx is based on code named
|
|
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
|
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
|
* and the original (and ongoing) project by
|
|
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include "../opentx.h"
|
|
|
|
enum FrenchPrompts {
|
|
PROMPT_NUMBERS_BASE = 0,
|
|
PROMPT_ZERO = PROMPT_NUMBERS_BASE+0,
|
|
PROMPT_CENT = PROMPT_NUMBERS_BASE+100,
|
|
PROMPT_DEUX_CENT = PROMPT_CENT+1,
|
|
PROMPT_MILLE = PROMPT_CENT+9,
|
|
|
|
PROMPT_UNE = 110,
|
|
PROMPT_ONZE,
|
|
PROMPT_VINGT_ET_UNE,
|
|
PROMPT_TRENTE_ET_UNE,
|
|
PROMPT_QUARANTE_ET_UNE,
|
|
PROMPT_CINQUANTE_ET_UNE,
|
|
PROMPT_SOIXANTE_ET_UNE,
|
|
PROMPT_SOIXANTE_ET_ONZE,
|
|
PROMPT_QUATRE_VINGT_UNE,
|
|
|
|
PROMPT_VIRGULE = 119,
|
|
PROMPT_ET = 120,
|
|
PROMPT_MOINS = 121,
|
|
|
|
PROMPT_UNITS_BASE = 125,
|
|
PROMPT_VOLTS = PROMPT_UNITS_BASE+UNIT_VOLTS,
|
|
PROMPT_AMPS = PROMPT_UNITS_BASE+UNIT_AMPS,
|
|
PROMPT_METERS_PER_SECOND = PROMPT_UNITS_BASE+UNIT_METERS_PER_SECOND,
|
|
PROMPT_SPARE1 = PROMPT_UNITS_BASE+UNIT_RAW,
|
|
PROMPT_KMH = PROMPT_UNITS_BASE+UNIT_KMH,
|
|
PROMPT_METERS = PROMPT_UNITS_BASE+UNIT_METERS,
|
|
PROMPT_DEGREES = PROMPT_UNITS_BASE+UNIT_DEGREES,
|
|
PROMPT_PERCENT = PROMPT_UNITS_BASE+UNIT_PERCENT,
|
|
PROMPT_MILLIAMPS = PROMPT_UNITS_BASE+UNIT_MILLIAMPS,
|
|
PROMPT_MAH = PROMPT_UNITS_BASE+UNIT_MAH,
|
|
PROMPT_WATTS = PROMPT_UNITS_BASE+UNIT_WATTS,
|
|
PROMPT_FEET = PROMPT_UNITS_BASE+UNIT_FEET,
|
|
PROMPT_KTS = PROMPT_UNITS_BASE+UNIT_KTS,
|
|
PROMPT_HEURE = PROMPT_UNITS_BASE+UNIT_HOURS,
|
|
PROMPT_MINUTE = PROMPT_UNITS_BASE+UNIT_MINUTES,
|
|
PROMPT_SECONDE = PROMPT_UNITS_BASE+UNIT_SECONDS,
|
|
|
|
PROMPT_LABELS_BASE = 145,
|
|
PROMPT_TIMER1 = PROMPT_LABELS_BASE+TELEM_TM1,
|
|
PROMPT_TIMER2 = PROMPT_LABELS_BASE+TELEM_TM2,
|
|
PROMPT_RSSI_TX = PROMPT_LABELS_BASE+TELEM_RSSI_TX,
|
|
PROMPT_RSSI_RX = PROMPT_LABELS_BASE+TELEM_RSSI_RX,
|
|
PROMPT_A1 = PROMPT_LABELS_BASE+TELEM_A1,
|
|
PROMPT_A2 = PROMPT_LABELS_BASE+TELEM_A2,
|
|
PROMPT_ALTITUDE = PROMPT_LABELS_BASE+TELEM_ALT,
|
|
PROMPT_RPM = PROMPT_LABELS_BASE+TELEM_RPM,
|
|
PROMPT_ESSENCE = PROMPT_LABELS_BASE+TELEM_FUEL,
|
|
PROMPT_T1 = PROMPT_LABELS_BASE+TELEM_T1,
|
|
PROMPT_T2 = PROMPT_LABELS_BASE+TELEM_T2,
|
|
PROMPT_VITESSE = PROMPT_LABELS_BASE+TELEM_SPEED,
|
|
PROMPT_DISTANCE = PROMPT_LABELS_BASE+TELEM_DIST,
|
|
PROMPT_GPSALTITUDE = PROMPT_LABELS_BASE+TELEM_GPSALT,
|
|
PROMPT_ELEMENTS_LIPO = PROMPT_LABELS_BASE+TELEM_CELL,
|
|
PROMPT_TOTAL_LIPO = PROMPT_LABELS_BASE+TELEM_CELLS_SUM,
|
|
PROMPT_VFAS = PROMPT_LABELS_BASE+TELEM_VFAS,
|
|
PROMPT_COURANT = PROMPT_LABELS_BASE+TELEM_CURRENT,
|
|
PROMPT_CONSOMMATION = PROMPT_LABELS_BASE+TELEM_CONSUMPTION,
|
|
PROMPT_PUISSANCE = PROMPT_LABELS_BASE+TELEM_POWER,
|
|
PROMPT_ACCELx = PROMPT_LABELS_BASE+TELEM_ACCx,
|
|
PROMPT_ACCELy = PROMPT_LABELS_BASE+TELEM_ACCy,
|
|
PROMPT_ACCELz = PROMPT_LABELS_BASE+TELEM_ACCz,
|
|
PROMPT_HDG = PROMPT_LABELS_BASE+TELEM_HDG,
|
|
PROMPT_VARIO = PROMPT_LABELS_BASE+TELEM_VSPD,
|
|
|
|
PROMPT_VIRGULE_BASE = 180, //,0 - ,9
|
|
};
|
|
|
|
#if defined(VOICE)
|
|
|
|
#define FEMININ 0x80
|
|
|
|
PLAY_FUNCTION(playNumber, getvalue_t number, uint8_t unit, uint8_t att)
|
|
{
|
|
/* if digit >= 1000000000:
|
|
temp_digit, digit = divmod(digit, 1000000000)
|
|
prompts.extend(self.getNumberPrompt(temp_digit))
|
|
prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
|
|
if digit >= 1000000:
|
|
temp_digit, digit = divmod(digit, 1000000)
|
|
prompts.extend(self.getNumberPrompt(temp_digit))
|
|
prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
|
|
*/
|
|
|
|
if (number < 0) {
|
|
PUSH_NUMBER_PROMPT(PROMPT_MOINS);
|
|
number = -number;
|
|
}
|
|
|
|
convertUnit(number, unit);
|
|
|
|
int8_t mode = MODE(att);
|
|
if (mode > 0) {
|
|
// we assume that we are PREC1
|
|
div_t qr = div(number, 10);
|
|
if (qr.rem) {
|
|
PLAY_NUMBER(qr.quot, 0, 0);
|
|
PUSH_NUMBER_PROMPT(PROMPT_VIRGULE_BASE + qr.rem);
|
|
number = -1;
|
|
}
|
|
else {
|
|
number = qr.quot;
|
|
}
|
|
}
|
|
|
|
if (number >= 1000) {
|
|
if (number >= 2000)
|
|
PLAY_NUMBER(number / 1000, 0, 0);
|
|
PUSH_NUMBER_PROMPT(PROMPT_MILLE);
|
|
number %= 1000;
|
|
if (number == 0)
|
|
number = -1;
|
|
}
|
|
if (number >= 100) {
|
|
if (number >= 200)
|
|
PUSH_NUMBER_PROMPT(PROMPT_ZERO + number/100);
|
|
PUSH_NUMBER_PROMPT(PROMPT_CENT);
|
|
number %= 100;
|
|
if (number == 0)
|
|
number = -1;
|
|
}
|
|
if (((number % 10) == 1) && number < 90 && (att & FEMININ)) {
|
|
PUSH_NUMBER_PROMPT(PROMPT_UNE+(number/10));
|
|
}
|
|
else if (number >= 0) {
|
|
PUSH_NUMBER_PROMPT(PROMPT_ZERO+number);
|
|
}
|
|
|
|
if (unit) {
|
|
PUSH_NUMBER_PROMPT(PROMPT_UNITS_BASE+unit-1);
|
|
}
|
|
}
|
|
|
|
PLAY_FUNCTION(playDuration, int16_t seconds)
|
|
{
|
|
if (seconds < 0) {
|
|
PUSH_NUMBER_PROMPT(PROMPT_MOINS);
|
|
seconds = -seconds;
|
|
}
|
|
|
|
uint8_t tmp = seconds / 3600;
|
|
seconds %= 3600;
|
|
if (tmp > 0) {
|
|
PLAY_NUMBER(tmp, 0, FEMININ);
|
|
PUSH_NUMBER_PROMPT(PROMPT_HEURE);
|
|
}
|
|
|
|
tmp = seconds / 60;
|
|
seconds %= 60;
|
|
if (tmp > 0) {
|
|
PLAY_NUMBER(tmp, 0, FEMININ);
|
|
PUSH_NUMBER_PROMPT(PROMPT_MINUTE);
|
|
if (seconds > 0)
|
|
PUSH_NUMBER_PROMPT(PROMPT_ET);
|
|
}
|
|
|
|
if (seconds > 0) {
|
|
PLAY_NUMBER(seconds, 0, FEMININ);
|
|
PUSH_NUMBER_PROMPT(PROMPT_SECONDE);
|
|
}
|
|
}
|
|
|
|
#endif
|