From 82fe7c61b1663bfcc02cfb4b5d3afa0c2afd1f68 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 6 Jun 2012 10:06:36 +0000 Subject: [PATCH] SOMO-14D work for the gruvin9x board --- src/Makefile | 2 +- src/eeprom_arm.cpp | 1 - src/eeprom_avr.cpp | 1 - src/frsky.cpp | 2 +- src/frsky.h | 2 + src/gruvin9x/somo14d.cpp | 7 +- src/gruvin9x/somo14d.h | 6 +- src/model_menus.cpp | 6 +- src/myeeprom.h | 7 +- src/open9x.cpp | 93 ++++++++++++++- src/open9x.h | 10 +- src/{o9xstrings.cpp => translations.cpp} | 6 + src/{o9xstrings.h => translations.h} | 9 +- src/translations/cz.h | 37 +++--- src/translations/de.h | 15 ++- src/translations/en.cpp | 138 ++++++++++++++++++++++ src/translations/en.h | 12 +- src/translations/fr.cpp | 140 +++++++++++++++++++++++ src/translations/fr.h | 11 +- src/translations/it.h | 11 +- src/translations/se.h | 11 +- 21 files changed, 470 insertions(+), 57 deletions(-) rename src/{o9xstrings.cpp => translations.cpp} (96%) rename src/{o9xstrings.h => translations.h} (96%) create mode 100644 src/translations/en.cpp create mode 100644 src/translations/fr.cpp diff --git a/src/Makefile b/src/Makefile index 3f1a4205e..efb085f81 100644 --- a/src/Makefile +++ b/src/Makefile @@ -191,7 +191,7 @@ FORMAT = ihex TARGET = open9x # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = open9x.cpp $(PULSESSRC) stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp $(EEPROMSRC) lcd.cpp drivers.cpp o9xstrings.cpp +CPPSRC = open9x.cpp $(PULSESSRC) stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp $(EEPROMSRC) lcd.cpp drivers.cpp translations.cpp ifeq ($(EXT), JETI) CPPSRC += jeti.cpp diff --git a/src/eeprom_arm.cpp b/src/eeprom_arm.cpp index cbc4eee9e..1b2895a7f 100644 --- a/src/eeprom_arm.cpp +++ b/src/eeprom_arm.cpp @@ -913,7 +913,6 @@ uint32_t unprotect_eeprom() #if defined(SDCARD) FATFS g_FATFS_Obj; // TODO not here -#define FILENAME_MAXLEN 8 const pm_char * eeBackupModel(uint8_t i_fileSrc) { char *buf = reusableBuffer.models.mainname; diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index ba0d8e05e..ea4f1cbfb 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -531,7 +531,6 @@ bool RlcFile::copy(uint8_t i_fileDst, uint8_t i_fileSrc) } #if defined(SDCARD) -#define FILENAME_MAXLEN 8 const pm_char * eeBackupModel(uint8_t i_fileSrc) { char *buf = reusableBuffer.models.mainname; diff --git a/src/frsky.cpp b/src/frsky.cpp index 912f56d95..89ae54229 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -915,7 +915,7 @@ int16_t convertTelemValue(uint8_t channel, uint8_t value) return result; } -static const pm_uint8_t bchunit_ar[] PROGMEM = { +const pm_uint8_t bchunit_ar[] PROGMEM = { UNIT_METERS, // Alt UNIT_RAW, // Rpm UNIT_PERCENT, // Fuel diff --git a/src/frsky.h b/src/frsky.h index da1d4e855..c02826409 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -182,6 +182,8 @@ uint8_t maxTelemValue(uint8_t channel); int16_t convertTelemValue(uint8_t channel, uint8_t value); NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm); +extern const pm_uint8_t bchunit_ar[]; +int16_t applyChannelRatio(uint8_t channel, int16_t val); void putsTelemetryChannel(uint8_t x, uint8_t y, uint8_t channel, int16_t val, uint8_t att); #endif diff --git a/src/gruvin9x/somo14d.cpp b/src/gruvin9x/somo14d.cpp index 744116c6d..cd12fc61d 100644 --- a/src/gruvin9x/somo14d.cpp +++ b/src/gruvin9x/somo14d.cpp @@ -150,9 +150,14 @@ ISR(TIMER4_COMPA_vect) //Every 0.5ms return BUSY; } -void somoPushPrompt(uint16_t prompt) +void pushPrompt(uint16_t prompt) { somo14playlist[somo14WIdx] = prompt; somo14WIdx = (somo14WIdx + 1) % QUEUE_LENGTH; TIMSK4 |= (1<func == FUNC_PLAY_SOMO) { + else if (sd->func == FUNC_PLAY_TRACK) { lcd_outdezAtt(21*FW, y, val_displayed, attr); } + else if (sd->func == FUNC_PLAY_VALUE) { + val_max = NUM_XCHNPLAY; + putsChnRaw(17*FW, y, val_displayed, attr); + } #endif else if (sd->func == FUNC_RESET) { val_max = 3; diff --git a/src/myeeprom.h b/src/myeeprom.h index e98fd7dbc..43ad51669 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -292,11 +292,12 @@ enum Functions { FUNC_INSTANT_TRIM, FUNC_PLAY_SOUND, FUNC_HAPTIC, -#if defined(PCBV4) - FUNC_PLAY_SOMO, -#endif FUNC_RESET, FUNC_VARIO, +#if defined(SOMO) + FUNC_PLAY_TRACK, + FUNC_PLAY_VALUE, +#endif #if defined(PCBV4) FUNC_LOGS, #endif diff --git a/src/open9x.cpp b/src/open9x.cpp index daf78543e..34790876c 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -1457,6 +1457,85 @@ void testFunc() uint16_t active_functions = 0; MASK_FSW_TYPE active_switches = 0; +#if defined(SOMO) +void playValue(uint8_t idx) +{ + int16_t val = getValue(idx); + switch (idx) { + case NUM_XCHNRAW+TELEM_TM1-1: + case NUM_XCHNRAW+TELEM_TM2-1: + playDuration(val); + break; + case NUM_XCHNRAW+TELEM_MIN_A1-1: + case NUM_XCHNRAW+TELEM_MIN_A2-1: + idx -= TELEM_MIN_A1-1-MAX_TIMERS; + // no break + case NUM_XCHNRAW+TELEM_A1-1: + case NUM_XCHNRAW+TELEM_A2-1: + idx -= NUM_XCHNRAW+MAX_TIMERS; + // A1 and A2 + { + uint8_t att = 0; + int16_t converted_value = applyChannelRatio(idx, val); + if (g_model.frsky.channels[idx].type >= UNIT_RAW) { + converted_value /= 10; + } + else { + if (converted_value < 1000) { + att |= PREC2; + } + else { + converted_value /= 10; + att |= PREC1; + } + } + playNumber(converted_value, UNIT_VOLTS, att); + break; + } + + case NUM_XCHNRAW+TELEM_CELL-1: + playNumber(val, UNIT_VOLTS, PREC2); + break; + + case NUM_XCHNRAW+TELEM_ACCx-1: + case NUM_XCHNRAW+TELEM_ACCy-1: + case NUM_XCHNRAW+TELEM_ACCz-1: + case NUM_XCHNRAW+TELEM_VSPD-1: + playNumber(val, UNIT_RAW, PREC2); + break; + + case NUM_XCHNRAW+TELEM_RSSI_TX-1: + case NUM_XCHNRAW+TELEM_RSSI_RX-1: + playNumber(val); + break; + + #if defined(IMPERIAL_UNITS) + case NUM_XCHNRAW+TELEM_ALT-1: + case NUM_XCHNRAW+TELEM_MIN_ALT-1: + case NUM_XCHNRAW+TELEM_MAX_ALT-1: + if (g_model.frsky.usrProto == USR_PROTO_WS_HOW_HIGH) { + playNumber(val, UNIT_FEET); + break; + } + // no break + #endif + + default: + { + uint8_t unit; + if (idx <= NUM_XCHNRAW+TELEM_GPSALT-1) + unit = idx - NUM_XCHNRAW - 6; + else if (idx >= NUM_XCHNRAW+TELEM_MAX_T1-1 && idx <= NUM_XCHNRAW+TELEM_MAX_DIST-1) + unit = idx - NUM_XCHNRAW - 22; + else + unit = 1; + playNumber(val, pgm_read_byte(bchunit_ar+unit)); + break; + } + } +} +#endif + void evalFunctions() { assert((int)(sizeof(active_functions)*8) > (int)(FUNC_MAX-NUM_CHNOUT)); @@ -1531,8 +1610,18 @@ void evalFunctions() #endif #if defined(SOMO) - if (sd->func == FUNC_PLAY_SOMO) { - somoPushPrompt(sd->param); + if (sd->func == FUNC_PLAY_TRACK || sd->func == FUNC_PLAY_VALUE) { + if (!isPlaying()) { + static uint16_t s_last_play = 0; + uint16_t tmr10ms = get_tmr10ms(); + if (tmr10ms - s_last_play >= 100) { + s_last_play = tmr10ms; + if (sd->func == FUNC_PLAY_TRACK) + pushPrompt(PROMPT_CUSTOM_BASE+sd->param); + else + playValue(sd->param); + } + } } #endif diff --git a/src/open9x.h b/src/open9x.h index 97617bae8..baec4e7d5 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -416,9 +416,10 @@ extern Key keys[NUM_KEYS]; #define NUM_TELEMETRY TELEM_TM2 #endif -#define NUM_XCHNRAW (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1/*MAX*/+1/*ID3*/+NUM_CYC+NUM_PPM+NUM_CHNOUT) -#define NUM_XCHNCSW (NUM_XCHNRAW+NUM_TELEMETRY) -#define NUM_XCHNMIX (NUM_XCHNRAW+MAX_SWITCH) +#define NUM_XCHNRAW (NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS+NUM_STICKS+1/*MAX*/+1/*ID3*/+NUM_CYC+NUM_PPM+NUM_CHNOUT) +#define NUM_XCHNCSW (NUM_XCHNRAW+NUM_TELEMETRY) +#define NUM_XCHNMIX (NUM_XCHNRAW+MAX_SWITCH) +#define NUM_XCHNPLAY (NUM_XCHNRAW+TELEM_DISPLAY_MAX) #define DSW_THR 1 #define DSW_RUD 2 @@ -746,7 +747,7 @@ extern volatile uint8_t g_blinkTmr10ms; extern uint8_t g_beepCnt; extern uint8_t g_beepVal[5]; -#include "o9xstrings.h" +#include "translations.h" extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1 extern int16_t g_ppmIns[8]; @@ -881,6 +882,7 @@ enum AUDIO_SOUNDS { #endif #if defined(SDCARD) +#define FILENAME_MAXLEN 8 #include "gruvin9x/sdcard.h" #endif diff --git a/src/o9xstrings.cpp b/src/translations.cpp similarity index 96% rename from src/o9xstrings.cpp rename to src/translations.cpp index 899e4c3cb..1be89387f 100644 --- a/src/o9xstrings.cpp +++ b/src/translations.cpp @@ -354,3 +354,9 @@ const pm_uchar font_dblsize[] PROGMEM = { #include "font_dblsize_fr.lbm" #endif }; + +#if defined(TRANSLATIONS_FR) +#include "fr.cpp" +#else +#include "en.cpp" +#endif diff --git a/src/o9xstrings.h b/src/translations.h similarity index 96% rename from src/o9xstrings.h rename to src/translations.h index 05fbbcbb2..5c685cd67 100644 --- a/src/o9xstrings.h +++ b/src/translations.h @@ -31,8 +31,8 @@ * */ -#ifndef o9xstrings_h -#define o9xstrings_h +#ifndef translations_h +#define translations_h #if defined(TRANSLATIONS_FR) #include "translations/fr.h" @@ -405,4 +405,9 @@ extern const pm_char STR_THROTTLEWARN[]; extern const pm_char STR_ALARMSWARN[]; extern const pm_char STR_SWITCHWARN[]; +#if defined(SOMO) +void playNumber(int16_t number, uint8_t unit=0, uint8_t att=0); +void playDuration(int16_t seconds); +#endif + #endif diff --git a/src/translations/cz.h b/src/translations/cz.h index dd581c4ab..856aa15de 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -12,7 +12,7 @@ #define TR_VBEEPMODE "Tich\212""Alarm""BezKL""V\207e " #define LEN_VBEEPLEN "\005" -#define TR_VBEEPLEN "O====""=O===""==O==""===O=""====O" +#define TR_VBEEPLEN "0====""=0===""==0==""===0=""====0" #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "Ne REaREb" @@ -113,20 +113,23 @@ #define TR_SDCLOGS "[SDCARD Logs]" #endif #if defined(SOMO) -#define TR_SOMO "P\206ehr\200t stopu" +#define TR_PLAY_TRACK "P\206ehr\200t stopu" +#define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SOMO "[Hr\200t stopu]\0" +#define TR_PLAY_TRACK "[Hr\200t stopu]\0" +#define TR_PLAY_VALUE "[Play Value]\0" #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE #endif #ifdef DEBUG #define TR_TEST "Test\0 " #else #define TR_TEST #endif -#define TR_VFSWFUNC "Bezpe\201\0 ""Tren\202r\0 ""Instant Trim " TR_SOUND TR_HAPTIC TR_SOMO "Reset\0 " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "Bezpe\201\0 ""Tren\202r\0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""Vse ""Telem." @@ -338,7 +341,7 @@ #define TR_CH "CH" #define TR_MODEL "MODEL" #define TR_FP "FP" -#define TR_EEPROMLOWMEM "Doch\200z\204 EEPROM" +#define TR_EEPROMLOWMEM "EEPROM low mem" #define TR_ALERT "\003(!)POZOR" #define TR_PRESSANYKEYTOSKIP "Kl\200vesa >>> p\206esko\201it" #define TR_THROTTLENOTIDLE "P\200ka plynu je pohnut\200." @@ -381,20 +384,20 @@ #define TR_LONGITUDE "Longitude" #define TR_GPSCOORD "Gps Sou\206adnice" #define TR_VARIO "Vario" -#define TR_SHUTDOWN "Vyp\204n\200n\204.." +#define TR_SHUTDOWN "SHUTTING DOWN" #define TR_BATT_CALIB "Kalibrace Bat" -#define TR_CURRENT_CALIB "Kalib. Proudu" -#define TR_CURRENT "Proud" -#define TR_SELECT_MODEL "Vyber Model" -#define TR_CREATE_MODEL "Vytvo\206 Model" -#define TR_BACKUP_MODEL "Z\200lohuj Model" -#define TR_DELETE_MODEL "Sma\217 Model" // TODO merged into DELETEMODEL? -#define TR_RESTORE_MODEL "Obnov Model" -#define TR_SDCARD_ERROR "Chyba SDkarty" -#define TR_NO_SDCARD "Nen\204 SDkarta" +#define TR_CURRENT_CALIB "Current Calib" +#define TR_CURRENT "Current" +#define TR_SELECT_MODEL "Select Model" +#define TR_CREATE_MODEL "Create Model" +#define TR_BACKUP_MODEL "Backup Model" +#define TR_DELETE_MODEL "Delete Model" // TODO merged into DELETEMODEL? +#define TR_RESTORE_MODEL "Restore Model" +#define TR_SDCARD_ERROR "SDCARD Error" +#define TR_NO_SDCARD "No SDCARD" #define TR_WARNING "KONTROLA" #define TR_EEPROMWARN "EEPROM" #define TR_THROTTLEWARN "PLYNU" #define TR_ALARMSWARN "ALARMU" #define TR_SWITCHWARN "POZICE" -#define TR_INVERT_THR "Invertovat Plyn?" +#define TR_INVERT_THR "Invert Thr?" diff --git a/src/translations/de.h b/src/translations/de.h index 2590f82c0..50856ffa8 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -11,8 +11,8 @@ #define LEN_VBEEPMODE "\005" #define TR_VBEEPMODE "Stumm""Alarm""NoKey""Alle " -#define LEN_VBEEPLEN "\005" -#define TR_VBEEPLEN "0====""=0===""==0==""===0=""====0" +#define LEN_VBEEPLEN "\005" +#define TR_VBEEPLEN "0====""=0===""==0==""===0=""====0" #define LEN_VRENAVIG "\003" #define TR_VRENAVIG "No REaREb" @@ -108,20 +108,23 @@ #define TR_SDCLOGS "[SDCARD Logs]" #endif #if defined(SOMO) -#define TR_SOMO "Play Track\0 " +#define TR_PLAY_TRACK "Play Track\0 " +#define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SOMO "[Play Track]\0" +#define TR_PLAY_TRACK "[Play Track]\0" +#define TR_PLAY_VALUE "[Play Value]\0" #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE #endif #ifdef DEBUG #define TR_TEST "Test\0 " #else #define TR_TEST #endif -#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC TR_SOMO "Reset\0 " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""Alle ""Telem." diff --git a/src/translations/en.cpp b/src/translations/en.cpp new file mode 100644 index 000000000..4cef858c1 --- /dev/null +++ b/src/translations/en.cpp @@ -0,0 +1,138 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x 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 "../open9x.h" + +enum EnglishPrompts { + PROMPT_NUMBERS_BASE = 0, + PROMPT_ZERO = PROMPT_NUMBERS_BASE+0, + /* ... */ + PROMPT_TWENTY = PROMPT_NUMBERS_BASE+20, + PROMPT_THIRTY = PROMPT_NUMBERS_BASE+21, + /* ... */ + PROMPT_NINETY = PROMPT_NUMBERS_BASE+27, + PROMPT_HUNDRED = PROMPT_NUMBERS_BASE+28, + PROMPT_THOUSAND = PROMPT_NUMBERS_BASE+29, + + PROMPT_HOUR = 40, + PROMPT_HOURS = 41, + PROMPT_MINUTE = 42, + PROMPT_MINUTES = 43, + PROMPT_SECOND = 44, + PROMPT_SECONDS = 45, + + PROMPT_AND = 47, + PROMPT_MINUS = 48, + + PROMPT_UNITS_BASE = 50, + 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, +}; + +#if defined(SOMO) + +void playNumber(int16_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 >= 1000) { + playNumber(number / 1000); + pushPrompt(PROMPT_THOUSAND); + number %= 1000; + if (number == 0) + return; + } + if (number >= 100) { + pushPrompt(PROMPT_ZERO + number/100); + pushPrompt(PROMPT_HUNDRED); + number %= 100; + if (number == 0) + return; + } + if (number >= 20) { + pushPrompt(PROMPT_TWENTY + (number-20)/10); + number %= 10; + if (number == 0) + return; + } + pushPrompt(PROMPT_ZERO+number); + + if (unit) { + pushPrompt(PROMPT_UNITS_BASE+unit-1); + } +} + +void playDuration(int16_t seconds) +{ + if (seconds < 0) { + pushPrompt(PROMPT_MINUS); + seconds = -seconds; + } + + uint8_t tmp = seconds / 3600; + seconds %= 3600; + if (tmp > 0) { + playNumber(tmp); + pushPrompt(tmp == 1 ? PROMPT_HOUR : PROMPT_HOURS); + } + + tmp = seconds / 60; + seconds %= 60; + if (tmp > 0) { + playNumber(tmp); + pushPrompt(tmp == 1 ? PROMPT_MINUTE : PROMPT_MINUTES); + if (seconds > 0) + pushPrompt(PROMPT_AND); + } + + if (seconds > 0) { + playNumber(seconds); + pushPrompt(tmp == 1 ? PROMPT_SECOND : PROMPT_SECONDS); + } +} + +#endif diff --git a/src/translations/en.h b/src/translations/en.h index fe94732a7..6a1749818 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -113,20 +113,24 @@ #define TR_SDCLOGS "[SDCARD Logs]" #endif #if defined(SOMO) -#define TR_SOMO "Play Track\0 " +#define TR_PLAY_TRACK "Play Track\0 " +#define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SOMO "[Play Track]\0" +#define TR_PLAY_TRACK "[Play Track]\0" +#define TR_PLAY_VALUE "[Play Value]\0" #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE + #endif #ifdef DEBUG #define TR_TEST "Test\0" #else #define TR_TEST #endif -#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC TR_SOMO "Reset\0 " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "Safety\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""All ""Telem." diff --git a/src/translations/fr.cpp b/src/translations/fr.cpp new file mode 100644 index 000000000..91f10e53b --- /dev/null +++ b/src/translations/fr.cpp @@ -0,0 +1,140 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x 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 "../open9x.h" + +enum FrenchPrompts { + PROMPT_NUMBERS_BASE = 0, + PROMPT_ZERO = PROMPT_NUMBERS_BASE+0, + /* ... */ + PROMPT_VINGT = PROMPT_NUMBERS_BASE+20, + PROMPT_TRENTE = PROMPT_NUMBERS_BASE+21, + /* ... */ + PROMPT_QUATREVINGTDIX = PROMPT_NUMBERS_BASE+27, + PROMPT_CENT = PROMPT_NUMBERS_BASE+28, + PROMPT_MILLE = PROMPT_NUMBERS_BASE+29, + + PROMPT_HOUR = 40, + PROMPT_HOURS = 41, + PROMPT_MINUTE = 42, + PROMPT_MINUTES = 43, + PROMPT_SECOND = 44, + PROMPT_SECONDS = 45, + + PROMPT_AND = 47, + PROMPT_MINUS = 48, + + PROMPT_UNITS_BASE = 50, + 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, +}; + +#if defined(SOMO) + +void playNumber(int16_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 >= 1000) { + if (number >= 2000) + playNumber(number / 1000); + pushPrompt(PROMPT_MILLE); + number %= 1000; + if (number == 0) + return; + } + if (number >= 100) { + if (number >= 200) + pushPrompt(PROMPT_ZERO + number/100); + pushPrompt(PROMPT_CENT); + number %= 100; + if (number == 0) + return; + } + if (number >= 20) { + pushPrompt(PROMPT_VINGT + (number-20)/10); + number %= 10; + if (number == 0) + return; + } + pushPrompt(PROMPT_ZERO+number); + + if (unit) { + pushPrompt(PROMPT_UNITS_BASE+unit-1); + } +} + +void playDuration(int16_t seconds) +{ + if (seconds < 0) { + pushPrompt(PROMPT_MINUS); + seconds = -seconds; + } + + uint8_t tmp = seconds / 3600; + seconds %= 3600; + if (tmp > 0) { + playNumber(tmp); + pushPrompt(tmp == 1 ? PROMPT_HOUR : PROMPT_HOURS); + } + + tmp = seconds / 60; + seconds %= 60; + if (tmp > 0) { + playNumber(tmp); + pushPrompt(tmp == 1 ? PROMPT_MINUTE : PROMPT_MINUTES); + if (seconds > 0) + pushPrompt(PROMPT_AND); + } + + if (seconds > 0) { + playNumber(seconds); + pushPrompt(tmp == 1 ? PROMPT_SECOND : PROMPT_SECONDS); + } +} + +#endif diff --git a/src/translations/fr.h b/src/translations/fr.h index 9325e0314..0953a00a0 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -108,20 +108,23 @@ #define TR_SDCLOGS "[Logs SD] " #endif #if defined(SOMO) -#define TR_SOMO "Jouer fichier" +#define TR_PLAY_TRACK "Jouer fichier" +#define TR_PLAY_VALUE "Jouer valeur " #else -#define TR_SOMO "[Jouer fich.]" +#define TR_PLAY_TRACK "[Jouer fich.]" +#define TR_PLAY_VALUE "[Jouer val.] " #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE #endif #ifdef DEBUG #define TR_TEST "Test\0 " #else #define TR_TEST #endif -#define TR_VFSWFUNC "S\200cur.\0 ""Ecolage \0 ""Trim instant." TR_SOUND TR_HAPTIC TR_SOMO "Reset\0 " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "S\200cur.\0 ""Ecolage \0 ""Trim instant." TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""Tout ""T\200l\200m." diff --git a/src/translations/it.h b/src/translations/it.h index a5f4c0aab..a7db10d14 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -113,20 +113,23 @@ #define TR_SDCLOGS "[SDCARD Logs]" #endif #if defined(SOMO) -#define TR_SOMO "Brano\0 " +#define TR_PLAY_TRACK "Brano\0 " +#define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SOMO "[Brano]\0 " +#define TR_PLAY_TRACK "[Brano]\0 " +#define TR_PLAY_VALUE "[Play Value]\0" #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE #endif #ifdef DEBUG #define TR_TEST "Test\0 " #else #define TR_TEST #endif -#define TR_VFSWFUNC "Blocco\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC TR_SOMO "Reset\0 " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "Blocco\0 ""Trainer \0 ""Instant Trim " TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""Tutto ""Telem." diff --git a/src/translations/se.h b/src/translations/se.h index b23969b0f..bc8f63b38 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -108,20 +108,23 @@ #define TR_SDCLOGS "[SDCARD Logg]" #endif #if defined(SOMO) -#define TR_SOMO "Spela Sp\200r\0 " +#define TR_PLAY_TRACK "Spela Sp\200r\0 " +#define TR_PLAY_VALUE "Play Value\0 " #else -#define TR_SOMO "[Spela Sp\200r]\0" +#define TR_PLAY_TRACK "[Spela Sp\200r]\0" +#define TR_PLAY_VALUE "[Play Value]\0" #endif #else #define TR_SDCLOGS -#define TR_SOMO +#define TR_PLAY_TRACK +#define TR_PLAY_VALUE #endif #ifdef DEBUG #define TR_TEST "Test\0 " #else #define TR_TEST #endif -#define TR_VFSWFUNC "S\201kra\0 ""Trainer\0 ""S\201tt Trim " TR_SOUND TR_HAPTIC TR_SOMO "Nollst\201ll " TR_VVARIO TR_SDCLOGS TR_TEST +#define TR_VFSWFUNC "S\201kra\0 ""Trainer\0 ""S\201tt Trim " TR_SOUND TR_HAPTIC "Nollst\201ll " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_TEST #define LEN_VFSWRESET "\006" #define TR_VFSWRESET "Timer1""Timer2""Allt ""Telem."