From 689fd7c0d7e89c921697600298a11a75ecc8ba92 Mon Sep 17 00:00:00 2001 From: Phil Mitchell Date: Fri, 3 Mar 2023 13:59:34 +1100 Subject: [PATCH] Announce timer value as hours and minutes when played from special function. --- radio/src/translations/tts_cn.cpp | 40 ++++++++--------- radio/src/translations/tts_cz.cpp | 37 ++++++++-------- radio/src/translations/tts_da.cpp | 34 +++++++-------- radio/src/translations/tts_de.cpp | 72 ++++++++++++++----------------- radio/src/translations/tts_en.cpp | 40 ++++++++--------- radio/src/translations/tts_es.cpp | 67 ++++++++++++++-------------- radio/src/translations/tts_fr.cpp | 54 +++++++++++------------ radio/src/translations/tts_hu.cpp | 40 ++++++++--------- radio/src/translations/tts_it.cpp | 40 ++++++++--------- radio/src/translations/tts_nl.cpp | 40 ++++++++--------- radio/src/translations/tts_pl.cpp | 37 ++++++++-------- radio/src/translations/tts_pt.cpp | 66 ++++++++++++++-------------- radio/src/translations/tts_ru.cpp | 41 +++++++++--------- radio/src/translations/tts_se.cpp | 40 ++++++++--------- radio/src/translations/tts_sk.cpp | 37 ++++++++-------- 15 files changed, 335 insertions(+), 350 deletions(-) diff --git a/radio/src/translations/tts_cn.cpp b/radio/src/translations/tts_cn.cpp index 5ac7248c9fe..8cd90abf77a 100644 --- a/radio/src/translations/tts_cn.cpp +++ b/radio/src/translations/tts_cn.cpp @@ -104,28 +104,28 @@ I18N_PLAY_FUNCTION(cn, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(CN_PROMPT_AND); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(CN_PROMPT_AND); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_cz.cpp b/radio/src/translations/tts_cz.cpp index f62ea4326a2..87c96446d8b 100644 --- a/radio/src/translations/tts_cz.cpp +++ b/radio/src/translations/tts_cz.cpp @@ -163,27 +163,26 @@ I18N_PLAY_FUNCTION(cz, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, FEMALE); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, FEMALE); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, FEMALE); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, FEMALE); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, FEMALE); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS, FEMALE); } } diff --git a/radio/src/translations/tts_da.cpp b/radio/src/translations/tts_da.cpp index 4591586429a..fbe46f6631f 100644 --- a/radio/src/translations/tts_da.cpp +++ b/radio/src/translations/tts_da.cpp @@ -99,27 +99,27 @@ I18N_PLAY_FUNCTION(da, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } + + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(DA_PROMPT_AND); + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); } - if (seconds > 0) { + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(DA_PROMPT_AND); PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_de.cpp b/radio/src/translations/tts_de.cpp index ef3c0d1a2b2..ed89eab25ec 100644 --- a/radio/src/translations/tts_de.cpp +++ b/radio/src/translations/tts_de.cpp @@ -161,55 +161,47 @@ I18N_PLAY_FUNCTION(de, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) - { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; } - else - { - tmp = seconds / 3600; - seconds %= 3600; - - if (tmp > 0 || IS_PLAY_TIME()) { - if (tmp > 1) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_NUMBER_PROMPT(DE_PROMPT_STUNDEN); - } else { - PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); - PUSH_NUMBER_PROMPT(DE_PROMPT_STUNDE); - } - if (seconds > 0) { - PUSH_NUMBER_PROMPT(DE_PROMPT_UND); - } - } - tmp = seconds / 60; - seconds %= 60; + if (hours > 0 || IS_PLAY_TIME()) { + if (hours > 1) { + PLAY_NUMBER(hours, 0, 0); + PUSH_NUMBER_PROMPT(DE_PROMPT_STUNDEN); + } else { + PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); + PUSH_NUMBER_PROMPT(DE_PROMPT_STUNDE); + } + } - if (tmp > 0) { - if (tmp > 1) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_NUMBER_PROMPT(DE_PROMPT_MINUTEN); - } else { - PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); - PUSH_NUMBER_PROMPT(DE_PROMPT_MINUTE); - } - if (seconds > 0) { - PUSH_NUMBER_PROMPT(DE_PROMPT_UND); - } + if (minutes > 0) { + if (hours) + PUSH_NUMBER_PROMPT(DE_PROMPT_UND); + if (minutes > 1) { + PLAY_NUMBER(minutes, 0, 0); + PUSH_NUMBER_PROMPT(DE_PROMPT_MINUTEN); + } else { + PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); + PUSH_NUMBER_PROMPT(DE_PROMPT_MINUTE); } + } + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(DE_PROMPT_UND); if (seconds > 1) { PLAY_NUMBER(seconds, 0, 0); PUSH_NUMBER_PROMPT(DE_PROMPT_SEKUNDEN); } else { - if (seconds == 1) { - PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); - PUSH_NUMBER_PROMPT(DE_PROMPT_SEKUNDE); - } + PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); + PUSH_NUMBER_PROMPT(DE_PROMPT_SEKUNDE); } } } diff --git a/radio/src/translations/tts_en.cpp b/radio/src/translations/tts_en.cpp index 551e01b92da..f8ad5f53bc2 100644 --- a/radio/src/translations/tts_en.cpp +++ b/radio/src/translations/tts_en.cpp @@ -104,28 +104,28 @@ I18N_PLAY_FUNCTION(en, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(EN_PROMPT_AND); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(EN_PROMPT_AND); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_es.cpp b/radio/src/translations/tts_es.cpp index 7f9bccfb676..5a845277c8f 100644 --- a/radio/src/translations/tts_es.cpp +++ b/radio/src/translations/tts_es.cpp @@ -153,44 +153,43 @@ I18N_PLAY_FUNCTION(es, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - if (tmp > 1) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_UNIT_PROMPT(UNIT_HOURS, 1); - } else { - PUSH_NUMBER_PROMPT(ES_PROMPT_UNA); - PUSH_UNIT_PROMPT(UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } + + if (hours > 0 || IS_PLAY_TIME()) { + if (hours > 1) { + PLAY_NUMBER(hours, 0, 0); + PUSH_UNIT_PROMPT(UNIT_HOURS, 1); + } else { + PUSH_NUMBER_PROMPT(ES_PROMPT_UNA); + PUSH_UNIT_PROMPT(UNIT_HOURS, 0); } + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - if (tmp != 1) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_UNIT_PROMPT(UNIT_MINUTES, 1); - } else { - PUSH_NUMBER_PROMPT(ES_PROMPT_UN); - PUSH_UNIT_PROMPT(UNIT_MINUTES, 0); - } + if (minutes > 0) { + if (minutes > 1) { + PLAY_NUMBER(minutes, 0, 0); + PUSH_UNIT_PROMPT(UNIT_MINUTES, 1); + } else { + PUSH_NUMBER_PROMPT(ES_PROMPT_UN); + PUSH_UNIT_PROMPT(UNIT_MINUTES, 0); } + } - if (seconds > 0) { - if (seconds != 1) { - PLAY_NUMBER(seconds, 0, 0); - PUSH_UNIT_PROMPT(UNIT_SECONDS, 1); - } else { - PUSH_NUMBER_PROMPT(ES_PROMPT_UN); - PUSH_UNIT_PROMPT(UNIT_SECONDS, 0); - } + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (seconds > 1) { + PLAY_NUMBER(seconds, 0, 0); + PUSH_UNIT_PROMPT(UNIT_SECONDS, 1); + } else { + PUSH_NUMBER_PROMPT(ES_PROMPT_UN); + PUSH_UNIT_PROMPT(UNIT_SECONDS, 0); } } } diff --git a/radio/src/translations/tts_fr.cpp b/radio/src/translations/tts_fr.cpp index c8c44afe93e..1b15e2e3f88 100644 --- a/radio/src/translations/tts_fr.cpp +++ b/radio/src/translations/tts_fr.cpp @@ -135,37 +135,37 @@ I18N_PLAY_FUNCTION(fr, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (IS_PLAY_TIME() && tmp == 0) { - PUSH_NUMBER_PROMPT(FR_PROMPT_MINUIT); - } else if (IS_PLAY_TIME() && tmp == 12) { - PUSH_NUMBER_PROMPT(FR_PROMPT_MIDI); - } else if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_HOURS, FEMININ); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - if (IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, 0, tmp == 1 ? FEMININ : 0); - } else { - PLAY_NUMBER(tmp, UNIT_MINUTES, FEMININ); - if (seconds > 0) PUSH_NUMBER_PROMPT(FR_PROMPT_ET); - } - } + if (IS_PLAY_TIME() && hours == 0) { + PUSH_NUMBER_PROMPT(FR_PROMPT_MINUIT); + } else if (IS_PLAY_TIME() && hours == 12) { + PUSH_NUMBER_PROMPT(FR_PROMPT_MIDI); + } else if (hours > 0) { + PLAY_NUMBER(hours, UNIT_HOURS, FEMININ); + } - if (!IS_PLAY_TIME() && seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, FEMININ); + if (minutes > 0) { + if (IS_PLAY_TIME()) { + PLAY_NUMBER(minutes, 0, minutes == 1 ? FEMININ : 0); + } else { + PLAY_NUMBER(minutes, UNIT_MINUTES, FEMININ); } } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(FR_PROMPT_ET); + PLAY_NUMBER(seconds, UNIT_SECONDS, FEMININ); + } } LANGUAGE_PACK_DECLARE(fr, TR_VOICE_FRANCAIS); diff --git a/radio/src/translations/tts_hu.cpp b/radio/src/translations/tts_hu.cpp index 0224e6307e1..64189920244 100644 --- a/radio/src/translations/tts_hu.cpp +++ b/radio/src/translations/tts_hu.cpp @@ -104,30 +104,26 @@ I18N_PLAY_FUNCTION(hu, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - // This is not necessary in the Hungarian - // if (seconds > 0) - // PUSH_NUMBER_PROMPT(HU_PROMPT_AND); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_it.cpp b/radio/src/translations/tts_it.cpp index 803f6d5e3ad..892c499fda7 100644 --- a/radio/src/translations/tts_it.cpp +++ b/radio/src/translations/tts_it.cpp @@ -154,28 +154,28 @@ I18N_PLAY_FUNCTION(it, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(IT_PROMPT_E); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(IT_PROMPT_E); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_nl.cpp b/radio/src/translations/tts_nl.cpp index 1f9e1720add..a5de9259ffa 100644 --- a/radio/src/translations/tts_nl.cpp +++ b/radio/src/translations/tts_nl.cpp @@ -106,28 +106,28 @@ I18N_PLAY_FUNCTION(nl, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(NL_PROMPT_AND); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(NL_PROMPT_AND); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_pl.cpp b/radio/src/translations/tts_pl.cpp index c2f1911c0d4..597f26202f5 100644 --- a/radio/src/translations/tts_pl.cpp +++ b/radio/src/translations/tts_pl.cpp @@ -211,27 +211,26 @@ I18N_PLAY_FUNCTION(pl, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, ZENSKI); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, ZENSKI); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, ZENSKI); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, ZENSKI); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, ZENSKI); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS, ZENSKI); } } diff --git a/radio/src/translations/tts_pt.cpp b/radio/src/translations/tts_pt.cpp index b7345a014f4..d06153784ca 100644 --- a/radio/src/translations/tts_pt.cpp +++ b/radio/src/translations/tts_pt.cpp @@ -138,43 +138,43 @@ I18N_PLAY_FUNCTION(pt, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t ore = 0; - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - ore = tmp; - if (tmp > 2) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_UNIT_PROMPT(UNIT_HOURS, 1); - } else if (tmp == 2) { - PUSH_NUMBER_PROMPT(PT_PROMPT_DUAS); - PUSH_UNIT_PROMPT(UNIT_HOURS, 1); - } else if (tmp == 1) { - PUSH_NUMBER_PROMPT(PT_PROMPT_UMA); - PUSH_UNIT_PROMPT(UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } + + if (hours > 0 || IS_PLAY_TIME()) { + if (hours > 2) { + PLAY_NUMBER(hours, 0, 0); + PUSH_UNIT_PROMPT(UNIT_HOURS, 1); + } else if (hours == 2) { + PUSH_NUMBER_PROMPT(PT_PROMPT_DUAS); + PUSH_UNIT_PROMPT(UNIT_HOURS, 1); + } else if (hours == 1) { + PUSH_NUMBER_PROMPT(PT_PROMPT_UMA); + PUSH_UNIT_PROMPT(UNIT_HOURS, 0); } + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0 || ore > 0) { - if (tmp != 1) { - PLAY_NUMBER(tmp, 0, 0); - PUSH_UNIT_PROMPT(UNIT_MINUTES, 1); - } else { - PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE + 1); - PUSH_UNIT_PROMPT(UNIT_MINUTES, 0); - } - PUSH_NUMBER_PROMPT(PT_PROMPT_E); + if (hours > 0 || minutes > 0) { + if (minutes > 1) { + PLAY_NUMBER(minutes, 0, 0); + PUSH_UNIT_PROMPT(UNIT_MINUTES, 1); + } else { + PUSH_NUMBER_PROMPT(PT_PROMPT_NUMBERS_BASE + 1); + PUSH_UNIT_PROMPT(UNIT_MINUTES, 0); } + } - if (seconds != 1) { + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (hours || minutes) + PUSH_NUMBER_PROMPT(PT_PROMPT_E); + if (seconds > 1) { PLAY_NUMBER(seconds, 0, 0); PUSH_UNIT_PROMPT(UNIT_SECONDS, 1); } else { diff --git a/radio/src/translations/tts_ru.cpp b/radio/src/translations/tts_ru.cpp index 112dc328e69..dffcc48e206 100644 --- a/radio/src/translations/tts_ru.cpp +++ b/radio/src/translations/tts_ru.cpp @@ -163,27 +163,28 @@ I18N_PLAY_FUNCTION(ru, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(RU_PROMPT_AND); - } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } + + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(RU_PROMPT_AND); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_se.cpp b/radio/src/translations/tts_se.cpp index dece0d103b4..75633d6ff48 100644 --- a/radio/src/translations/tts_se.cpp +++ b/radio/src/translations/tts_se.cpp @@ -99,28 +99,28 @@ I18N_PLAY_FUNCTION(se, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, 0); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - if (seconds > 0) PUSH_NUMBER_PROMPT(SE_PROMPT_AND); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, 0); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, 0); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, 0); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + if (minutes) + PUSH_NUMBER_PROMPT(SE_PROMPT_AND); + PLAY_NUMBER(seconds, UNIT_SECONDS, 0); } } diff --git a/radio/src/translations/tts_sk.cpp b/radio/src/translations/tts_sk.cpp index 914a26bd9f7..4bec113e4c6 100644 --- a/radio/src/translations/tts_sk.cpp +++ b/radio/src/translations/tts_sk.cpp @@ -161,27 +161,26 @@ I18N_PLAY_FUNCTION(sk, playDuration, int seconds PLAY_DURATION_ATT) seconds = -seconds; } - uint8_t tmp; - if (IS_PLAY_LONG_TIMER()) { - tmp = seconds / 60; - if (seconds % 60 >= 30) tmp += 1; - if (tmp > 0) PLAY_NUMBER(tmp, UNIT_MINUTES, 0); - } else { - tmp = seconds / 3600; - seconds %= 3600; - if (tmp > 0 || IS_PLAY_TIME()) { - PLAY_NUMBER(tmp, UNIT_HOURS, ZENSKY); - } + int hours, minutes; + hours = seconds / 3600; + seconds = seconds % 3600; + minutes = seconds / 60; + seconds = seconds % 60; + + if (IS_PLAY_LONG_TIMER() && seconds >= 30) { + minutes += 1; + } - tmp = seconds / 60; - seconds %= 60; - if (tmp > 0) { - PLAY_NUMBER(tmp, UNIT_MINUTES, ZENSKY); - } + if (hours > 0 || IS_PLAY_TIME()) { + PLAY_NUMBER(hours, UNIT_HOURS, ZENSKY); + } - if (seconds > 0) { - PLAY_NUMBER(seconds, UNIT_SECONDS, ZENSKY); - } + if (minutes > 0) { + PLAY_NUMBER(minutes, UNIT_MINUTES, ZENSKY); + } + + if (!IS_PLAY_LONG_TIMER() && seconds > 0) { + PLAY_NUMBER(seconds, UNIT_SECONDS, ZENSKY); } }