diff --git a/locale/lv_i18n.c b/locale/lv_i18n.c index bb1c584..1080f64 100644 --- a/locale/lv_i18n.c +++ b/locale/lv_i18n.c @@ -1,6 +1,5 @@ #include "./lv_i18n.h" - //////////////////////////////////////////////////////////////////////////////// // Define plural operands // http://unicode.org/reports/tr35/tr35-numbers.html#Operands @@ -9,30 +8,53 @@ #define UNUSED(x) (void)(x) -static inline uint32_t op_n(int32_t val) { return (uint32_t)(val < 0 ? -val : val); } -static inline uint32_t op_i(uint32_t val) { return val; } +static inline uint32_t op_n(int32_t val) +{ + return (uint32_t)(val < 0 ? -val : val); +} +static inline uint32_t op_i(uint32_t val) +{ + return val; +} // always zero, when decimal part not exists. -static inline uint32_t op_v(uint32_t val) { UNUSED(val); return 0;} -static inline uint32_t op_w(uint32_t val) { UNUSED(val); return 0; } -static inline uint32_t op_f(uint32_t val) { UNUSED(val); return 0; } -static inline uint32_t op_t(uint32_t val) { UNUSED(val); return 0; } +static inline uint32_t op_v(uint32_t val) +{ + UNUSED(val); + return 0; +} +static inline uint32_t op_w(uint32_t val) +{ + UNUSED(val); + return 0; +} +static inline uint32_t op_f(uint32_t val) +{ + UNUSED(val); + return 0; +} +static inline uint32_t op_t(uint32_t val) +{ + UNUSED(val); + return 0; +} static uint8_t en_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); - - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); + + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t en_lang = { - .locale_name = "en", - +static const lv_i18n_lang_t en_lang = {.locale_name = "en", - .locale_plural_fn = en_plural_fn -}; + .locale_plural_fn = en_plural_fn}; static lv_i18n_phrase_t de_singulars[] = { {"User name: %s", "Benutzer: %s"}, @@ -155,34 +177,32 @@ static lv_i18n_phrase_t de_singulars[] = { }; static lv_i18n_phrase_t de_plurals_one[] = { - {"%d active chat(s)", "%d aktives Gespräch"}, - {"%d of %d nodes online", "1 Gerät online"}, - {NULL, NULL} // End mark + {"%d active chat(s)", "%d aktives Gespräch"}, {"%d of %d nodes online", "1 Gerät online"}, {NULL, NULL} // End mark }; static lv_i18n_phrase_t de_plurals_other[] = { - {"%d active chat(s)", "%d aktive Gespräche"}, - {"%d of %d nodes online", "%d / %d Geräte online"}, - {NULL, NULL} // End mark + {"%d active chat(s)", "%d aktive Gespräche"}, {"%d of %d nodes online", "%d / %d Geräte online"}, {NULL, NULL} // End mark }; static uint8_t de_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); - - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); + + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t de_lang = { - .locale_name = "de", - .singulars = de_singulars, - .plurals[LV_I18N_PLURAL_TYPE_ONE] = de_plurals_one, - .plurals[LV_I18N_PLURAL_TYPE_OTHER] = de_plurals_other, - .locale_plural_fn = de_plural_fn -}; +static const lv_i18n_lang_t de_lang = {.locale_name = "de", + .singulars = de_singulars, + .plurals[LV_I18N_PLURAL_TYPE_ONE] = de_plurals_one, + .plurals[LV_I18N_PLURAL_TYPE_OTHER] = de_plurals_other, + .locale_plural_fn = de_plural_fn}; static lv_i18n_phrase_t es_singulars[] = { {"no new messages", "Sin mensajes nuevos"}, @@ -250,8 +270,10 @@ static lv_i18n_phrase_t es_singulars[] = { {"Start", "Iniciar"}, {"Theme: %s", "Tema: %s"}, {"Packet Statistics", "Estadísticas"}, - {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", "LONG FAST\nLONG SLOW\n-- obsoleto --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Client\nClient Mute\nRouter\n-- obsoleto --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, + {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", + "LONG FAST\nLONG SLOW\n-- obsoleto --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Client\nClient Mute\nRouter\n-- obsoleto --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, {"Dark\nLight", "Oscuro\nClaro"}, {"Cancel", "Cancelar"}, {"Brightness: %d%%", "Brillo : %d%%"}, @@ -307,23 +329,20 @@ static lv_i18n_phrase_t es_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t es_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); + uint32_t n = op_n(num); + UNUSED(n); - - if ((n == 1)) return LV_I18N_PLURAL_TYPE_ONE; + if ((n == 1)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t es_lang = { - .locale_name = "es", - .singulars = es_singulars, +static const lv_i18n_lang_t es_lang = {.locale_name = "es", + .singulars = es_singulars, - .locale_plural_fn = es_plural_fn -}; + .locale_plural_fn = es_plural_fn}; static lv_i18n_phrase_t fi_singulars[] = { {"no new messages", "ei uusia viestejä"}, @@ -436,40 +455,40 @@ static lv_i18n_phrase_t fi_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t fi_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); - - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); + + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t fi_lang = { - .locale_name = "fi", - .singulars = fi_singulars, +static const lv_i18n_lang_t fi_lang = {.locale_name = "fi", + .singulars = fi_singulars, - .locale_plural_fn = fi_plural_fn -}; + .locale_plural_fn = fi_plural_fn}; static uint8_t fr_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); - if ((((i == 0) || (i == 1)))) return LV_I18N_PLURAL_TYPE_ONE; + if ((((i == 0) || (i == 1)))) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t fr_lang = { - .locale_name = "fr", +static const lv_i18n_lang_t fr_lang = {.locale_name = "fr", - - .locale_plural_fn = fr_plural_fn -}; + .locale_plural_fn = fr_plural_fn}; static lv_i18n_phrase_t it_singulars[] = { {"no new messages", "nessun messaggio"}, @@ -510,7 +529,9 @@ static lv_i18n_phrase_t it_singulars[] = { {"Short Name", "Nome breve"}, {"Long Name", "Nome lungo"}, {"", ""}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Client\nClient Muto\nRouter\n-- deprecato --\nRipetitore\nTracker\nSensore\nTAK\nClient Nascosto\nOggetti Smarriti\nTAK Tracker"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Client\nClient Muto\nRouter\n-- deprecato --\nRipetitore\nTracker\nSensore\nTAK\nClient Nascosto\nOggetti Smarriti\nTAK " + "Tracker"}, {"Brightness: 60%", "Luminosità: 60%"}, {"Dark\nLight", "Scuro\nChiaro"}, {"Screen Lock", "Blocco schermo"}, @@ -603,34 +624,32 @@ static lv_i18n_phrase_t it_singulars[] = { }; static lv_i18n_phrase_t it_plurals_one[] = { - {"%d active chat(s)", "%d chat attiva"}, - {"%d of %d nodes online", "1 nodo online"}, - {NULL, NULL} // End mark + {"%d active chat(s)", "%d chat attiva"}, {"%d of %d nodes online", "1 nodo online"}, {NULL, NULL} // End mark }; static lv_i18n_phrase_t it_plurals_other[] = { - {"%d active chat(s)", "%d chat attive"}, - {"%d of %d nodes online", "%d di %d nodi online"}, - {NULL, NULL} // End mark + {"%d active chat(s)", "%d chat attive"}, {"%d of %d nodes online", "%d di %d nodi online"}, {NULL, NULL} // End mark }; static uint8_t it_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); - - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); + + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t it_lang = { - .locale_name = "it", - .singulars = it_singulars, - .plurals[LV_I18N_PLURAL_TYPE_ONE] = it_plurals_one, - .plurals[LV_I18N_PLURAL_TYPE_OTHER] = it_plurals_other, - .locale_plural_fn = it_plural_fn -}; +static const lv_i18n_lang_t it_lang = {.locale_name = "it", + .singulars = it_singulars, + .plurals[LV_I18N_PLURAL_TYPE_ONE] = it_plurals_one, + .plurals[LV_I18N_PLURAL_TYPE_OTHER] = it_plurals_other, + .locale_plural_fn = it_plural_fn}; static lv_i18n_phrase_t nl_singulars[] = { {"no new messages", "0 nieuwe berichten"}, @@ -671,8 +690,10 @@ static lv_i18n_phrase_t nl_singulars[] = { {"Short Name", "Korte Naam"}, {"Long Name", "Lange Naam"}, {"", ""}, - {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", "LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, + {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", + "LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, {"Brightness: 60%", "Helderheid: 60%"}, {"Dark\nLight", "Donker\nLicht"}, {"Timeout: 60s", "Timeout: 60s"}, @@ -771,24 +792,24 @@ static lv_i18n_phrase_t nl_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t nl_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); - - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); + + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t nl_lang = { - .locale_name = "nl", - .singulars = nl_singulars, +static const lv_i18n_lang_t nl_lang = {.locale_name = "nl", + .singulars = nl_singulars, - .locale_plural_fn = nl_plural_fn -}; + .locale_plural_fn = nl_plural_fn}; static lv_i18n_phrase_t pl_singulars[] = { {"no new messages", "Brak wiadomości"}, @@ -894,27 +915,30 @@ static lv_i18n_phrase_t pl_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t pl_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); uint32_t i10 = i % 10; uint32_t i100 = i % 100; - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; - if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14)))) return LV_I18N_PLURAL_TYPE_FEW; - if ((v == 0 && i != 1 && (0 <= i10 && i10 <= 1)) || (v == 0 && (5 <= i10 && i10 <= 9)) || (v == 0 && (12 <= i100 && i100 <= 14))) return LV_I18N_PLURAL_TYPE_MANY; + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; + if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14)))) + return LV_I18N_PLURAL_TYPE_FEW; + if ((v == 0 && i != 1 && (0 <= i10 && i10 <= 1)) || (v == 0 && (5 <= i10 && i10 <= 9)) || + (v == 0 && (12 <= i100 && i100 <= 14))) + return LV_I18N_PLURAL_TYPE_MANY; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t pl_lang = { - .locale_name = "pl", - .singulars = pl_singulars, +static const lv_i18n_lang_t pl_lang = {.locale_name = "pl", + .singulars = pl_singulars, - .locale_plural_fn = pl_plural_fn -}; + .locale_plural_fn = pl_plural_fn}; static lv_i18n_phrase_t pt_singulars[] = { {"no new messages", "Nenhuma mensagem nova"}, @@ -954,8 +978,11 @@ static lv_i18n_phrase_t pt_singulars[] = { {"Short Name", "Nome Curto"}, {"Long Name", "Nome Longo"}, {"", ""}, - {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", "LONG FAST\nLONG SLOW\n-- desativado --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Cliente\nCliente Mudo\nRoteador\n-- desativado --\nRepetidor\nRastreador\nSensor\nTAK\nCliente Oculto\nAchados e Perdidos\nRastreador TAK"}, + {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", + "LONG FAST\nLONG SLOW\n-- desativado --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Cliente\nCliente Mudo\nRoteador\n-- desativado --\nRepetidor\nRastreador\nSensor\nTAK\nCliente Oculto\nAchados e " + "Perdidos\nRastreador TAK"}, {"Brightness: 60%", "Brilho de Tela: 60%"}, {"Dark\nLight", "Escuro\nClaro"}, {"Timeout: 60s", "Tempo Máximo: 60s"}, @@ -1039,41 +1066,42 @@ static lv_i18n_phrase_t pt_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t pt_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); - if (((0 <= i && i <= 1))) return LV_I18N_PLURAL_TYPE_ONE; + if (((0 <= i && i <= 1))) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t pt_lang = { - .locale_name = "pt", - .singulars = pt_singulars, +static const lv_i18n_lang_t pt_lang = {.locale_name = "pt", + .singulars = pt_singulars, - .locale_plural_fn = pt_plural_fn -}; + .locale_plural_fn = pt_plural_fn}; static uint8_t ro_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t i = op_i(n); UNUSED(i); - uint32_t v = op_v(n); UNUSED(v); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t v = op_v(n); + UNUSED(v); uint32_t n100 = n % 100; - if ((i == 1 && v == 0)) return LV_I18N_PLURAL_TYPE_ONE; - if ((v != 0) || (n == 0) || (n != 1 && (1 <= n100 && n100 <= 19))) return LV_I18N_PLURAL_TYPE_FEW; + if ((i == 1 && v == 0)) + return LV_I18N_PLURAL_TYPE_ONE; + if ((v != 0) || (n == 0) || (n != 1 && (1 <= n100 && n100 <= 19))) + return LV_I18N_PLURAL_TYPE_FEW; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t ro_lang = { - .locale_name = "ro", - +static const lv_i18n_lang_t ro_lang = {.locale_name = "ro", - .locale_plural_fn = ro_plural_fn -}; + .locale_plural_fn = ro_plural_fn}; static lv_i18n_phrase_t ru_singulars[] = { {"no new messages", "нет новых сообщений"}, @@ -1140,8 +1168,10 @@ static lv_i18n_phrase_t ru_singulars[] = { {"Start", "Начать"}, {"Theme: %s", "Тема: %s"}, {"Packet Statistics", "Статистика пакетов"}, - {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", "LONG FAST\nLONG SLOW\n-- устарело --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Client\nClient Mute\nRouter\n-- устарело --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, + {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", + "LONG FAST\nLONG SLOW\n-- устарело --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Client\nClient Mute\nRouter\n-- устарело --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker"}, {"Dark\nLight", "Тёмная\nСветлая"}, {"Cancel", "Отмена"}, {"Brightness: %d%%", "Яркость: %d%%"}, @@ -1178,27 +1208,29 @@ static lv_i18n_phrase_t ru_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t ru_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t v = op_v(n); UNUSED(v); - uint32_t i = op_i(n); UNUSED(i); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t v = op_v(n); + UNUSED(v); + uint32_t i = op_i(n); + UNUSED(i); uint32_t i10 = i % 10; uint32_t i100 = i % 100; - if ((v == 0 && i10 == 1 && i100 != 11)) return LV_I18N_PLURAL_TYPE_ONE; - if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14)))) return LV_I18N_PLURAL_TYPE_FEW; - if ((v == 0 && i10 == 0) || (v == 0 && (5 <= i10 && i10 <= 9)) || (v == 0 && (11 <= i100 && i100 <= 14))) return LV_I18N_PLURAL_TYPE_MANY; + if ((v == 0 && i10 == 1 && i100 != 11)) + return LV_I18N_PLURAL_TYPE_ONE; + if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14)))) + return LV_I18N_PLURAL_TYPE_FEW; + if ((v == 0 && i10 == 0) || (v == 0 && (5 <= i10 && i10 <= 9)) || (v == 0 && (11 <= i100 && i100 <= 14))) + return LV_I18N_PLURAL_TYPE_MANY; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t ru_lang = { - .locale_name = "ru", - .singulars = ru_singulars, +static const lv_i18n_lang_t ru_lang = {.locale_name = "ru", + .singulars = ru_singulars, - .locale_plural_fn = ru_plural_fn -}; + .locale_plural_fn = ru_plural_fn}; static lv_i18n_phrase_t se_singulars[] = { {"no new messages", "inga nya meddelanden"}, @@ -1236,8 +1268,12 @@ static lv_i18n_phrase_t se_singulars[] = { {"Short Name", "Kort Namn"}, {"Long Name", "Lånt Namn"}, {"", ""}, - {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", "Lång räckvidd / Snabb\nLång räckvidd / Långsam\n-- utfasad --\nMedium Räckvidd / Långsam\nMedium räckvidd / Snabb\nKort räckvidd / Långsam\nKort räckvidd / Snabb\nLång räckvidd / Måttlig\nKort räckvidd / Turbo"}, - {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", "Klient\nKlient Stum\nRouter\n-- utfasad --\nRelästation\nSpårare\nSensor\nTAK\nKlient Gömd\nFörlorad & hittad\nTAK Spårare"}, + {"LONG FAST\nLONG SLOW\n-- deprecated --\nMEDIUM SLOW\nMEDIUM FAST\nSHORT SLOW\nSHORT FAST\nLONG MODERATE\nSHORT TURBO", + "Lång räckvidd / Snabb\nLång räckvidd / Långsam\n-- utfasad --\nMedium Räckvidd / Långsam\nMedium räckvidd / Snabb\nKort " + "räckvidd / Långsam\nKort räckvidd / Snabb\nLång räckvidd / Måttlig\nKort räckvidd / Turbo"}, + {"Client\nClient Mute\nRouter\n-- deprecated --\nRepeater\nTracker\nSensor\nTAK\nClient Hidden\nLost & Found\nTAK Tracker", + "Klient\nKlient Stum\nRouter\n-- utfasad --\nRelästation\nSpårare\nSensor\nTAK\nKlient Gömd\nFörlorad & hittad\nTAK " + "Spårare"}, {"Brightness: 60%", "Ljusstyrka: 60%"}, {"Dark\nLight", "Mörkt\nLjust"}, {"Screen Lock", "Bildskärms Lås"}, @@ -1329,24 +1365,22 @@ static lv_i18n_phrase_t se_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t se_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); + uint32_t n = op_n(num); + UNUSED(n); - - if ((n == 1)) return LV_I18N_PLURAL_TYPE_ONE; - if ((n == 2)) return LV_I18N_PLURAL_TYPE_TWO; + if ((n == 1)) + return LV_I18N_PLURAL_TYPE_ONE; + if ((n == 2)) + return LV_I18N_PLURAL_TYPE_TWO; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t se_lang = { - .locale_name = "se", - .singulars = se_singulars, +static const lv_i18n_lang_t se_lang = {.locale_name = "se", + .singulars = se_singulars, - .locale_plural_fn = se_plural_fn -}; + .locale_plural_fn = se_plural_fn}; static lv_i18n_phrase_t sr_singulars[] = { {"no new messages", "nema novih poruka"}, @@ -1475,71 +1509,58 @@ static lv_i18n_phrase_t sr_singulars[] = { {NULL, NULL} // End mark }; - - static uint8_t sr_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - uint32_t v = op_v(n); UNUSED(v); - uint32_t i = op_i(n); UNUSED(i); - uint32_t f = op_f(n); UNUSED(f); + uint32_t n = op_n(num); + UNUSED(n); + uint32_t v = op_v(n); + UNUSED(v); + uint32_t i = op_i(n); + UNUSED(i); + uint32_t f = op_f(n); + UNUSED(f); uint32_t i10 = i % 10; uint32_t i100 = i % 100; uint32_t f10 = f % 10; uint32_t f100 = f % 100; - if ((v == 0 && i10 == 1 && i100 != 11) || (f10 == 1 && f100 != 11)) return LV_I18N_PLURAL_TYPE_ONE; - if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14))) || ((2 <= f10 && f10 <= 4) && (!(12 <= f100 && f100 <= 14)))) return LV_I18N_PLURAL_TYPE_FEW; + if ((v == 0 && i10 == 1 && i100 != 11) || (f10 == 1 && f100 != 11)) + return LV_I18N_PLURAL_TYPE_ONE; + if ((v == 0 && (2 <= i10 && i10 <= 4) && (!(12 <= i100 && i100 <= 14))) || + ((2 <= f10 && f10 <= 4) && (!(12 <= f100 && f100 <= 14)))) + return LV_I18N_PLURAL_TYPE_FEW; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t sr_lang = { - .locale_name = "sr", - .singulars = sr_singulars, +static const lv_i18n_lang_t sr_lang = {.locale_name = "sr", + .singulars = sr_singulars, - .locale_plural_fn = sr_plural_fn -}; + .locale_plural_fn = sr_plural_fn}; static uint8_t tr_plural_fn(int32_t num) { - uint32_t n = op_n(num); UNUSED(n); - + uint32_t n = op_n(num); + UNUSED(n); - if ((n == 1)) return LV_I18N_PLURAL_TYPE_ONE; + if ((n == 1)) + return LV_I18N_PLURAL_TYPE_ONE; return LV_I18N_PLURAL_TYPE_OTHER; } -static const lv_i18n_lang_t tr_lang = { - .locale_name = "tr", +static const lv_i18n_lang_t tr_lang = {.locale_name = "tr", - - .locale_plural_fn = tr_plural_fn -}; + .locale_plural_fn = tr_plural_fn}; const lv_i18n_language_pack_t lv_i18n_language_pack[] = { - &en_lang, - &de_lang, - &es_lang, - &fi_lang, - &fr_lang, - &it_lang, - &nl_lang, - &pl_lang, - &pt_lang, - &ro_lang, - &ru_lang, - &se_lang, - &sr_lang, - &tr_lang, + &en_lang, &de_lang, &es_lang, &fi_lang, &fr_lang, &it_lang, &nl_lang, + &pl_lang, &pt_lang, &ro_lang, &ru_lang, &se_lang, &sr_lang, &tr_lang, NULL // End mark }; //////////////////////////////////////////////////////////////////////////////// - // Internal state -static const lv_i18n_language_pack_t * current_lang_pack; -static const lv_i18n_lang_t * current_lang; - +static const lv_i18n_language_pack_t *current_lang_pack; +static const lv_i18n_lang_t *current_lang; /** * Reset internal state. For testing. @@ -1554,13 +1575,15 @@ void __lv_i18n_reset(void) * Set the languages for internationalization * @param langs pointer to the array of languages. (Last element has to be `NULL`) */ -int lv_i18n_init(const lv_i18n_language_pack_t * langs) +int lv_i18n_init(const lv_i18n_language_pack_t *langs) { - if(langs == NULL) return -1; - if(langs[0] == NULL) return -1; + if (langs == NULL) + return -1; + if (langs[0] == NULL) + return -1; current_lang_pack = langs; - current_lang = langs[0]; /*Automatically select the first language*/ + current_lang = langs[0]; /*Automatically select the first language*/ return 0; } @@ -1568,15 +1591,16 @@ int lv_i18n_init(const lv_i18n_language_pack_t * langs) * Change the localization (language) * @param l_name name of the translation locale to use. E.g. "en-GB" */ -int lv_i18n_set_locale(const char * l_name) +int lv_i18n_set_locale(const char *l_name) { - if(current_lang_pack == NULL) return -1; + if (current_lang_pack == NULL) + return -1; uint16_t i; - for(i = 0; current_lang_pack[i] != NULL; i++) { + for (i = 0; current_lang_pack[i] != NULL; i++) { // Found -> finish - if(strcmp(current_lang_pack[i]->locale_name, l_name) == 0) { + if (strcmp(current_lang_pack[i]->locale_name, l_name) == 0) { current_lang = current_lang_pack[i]; return 0; } @@ -1585,47 +1609,50 @@ int lv_i18n_set_locale(const char * l_name) return -1; } - -static const char * __lv_i18n_get_text_core(lv_i18n_phrase_t * trans, const char * msg_id) +static const char *__lv_i18n_get_text_core(lv_i18n_phrase_t *trans, const char *msg_id) { uint16_t i; - for(i = 0; trans[i].msg_id != NULL; i++) { - if(strcmp(trans[i].msg_id, msg_id) == 0) { + for (i = 0; trans[i].msg_id != NULL; i++) { + if (strcmp(trans[i].msg_id, msg_id) == 0) { /*The msg_id has found. Check the translation*/ - if(trans[i].translation) return trans[i].translation; + if (trans[i].translation) + return trans[i].translation; } } return NULL; } - /** * Get the translation from a message ID * @param msg_id message ID * @return the translation of `msg_id` on the set local */ -const char * lv_i18n_get_text(const char * msg_id) +const char *lv_i18n_get_text(const char *msg_id) { - if(current_lang == NULL) return msg_id; + if (current_lang == NULL) + return msg_id; - const lv_i18n_lang_t * lang = current_lang; - const void * txt; + const lv_i18n_lang_t *lang = current_lang; + const void *txt; // Search in current locale - if(lang->singulars != NULL) { + if (lang->singulars != NULL) { txt = __lv_i18n_get_text_core(lang->singulars, msg_id); - if (txt != NULL) return txt; + if (txt != NULL) + return txt; } // Try to fallback - if(lang == current_lang_pack[0]) return msg_id; + if (lang == current_lang_pack[0]) + return msg_id; lang = current_lang_pack[0]; // Repeat search for default locale - if(lang->singulars != NULL) { + if (lang->singulars != NULL) { txt = __lv_i18n_get_text_core(lang->singulars, msg_id); - if (txt != NULL) return txt; + if (txt != NULL) + return txt; } return msg_id; @@ -1637,35 +1664,39 @@ const char * lv_i18n_get_text(const char * msg_id) * @param num an integer to select the correct plural form * @return the translation of `msg_id` on the set local */ -const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num) +const char *lv_i18n_get_text_plural(const char *msg_id, int32_t num) { - if(current_lang == NULL) return msg_id; + if (current_lang == NULL) + return msg_id; - const lv_i18n_lang_t * lang = current_lang; - const void * txt; + const lv_i18n_lang_t *lang = current_lang; + const void *txt; lv_i18n_plural_type_t ptype; // Search in current locale - if(lang->locale_plural_fn != NULL) { + if (lang->locale_plural_fn != NULL) { ptype = lang->locale_plural_fn(num); - if(lang->plurals[ptype] != NULL) { + if (lang->plurals[ptype] != NULL) { txt = __lv_i18n_get_text_core(lang->plurals[ptype], msg_id); - if (txt != NULL) return txt; + if (txt != NULL) + return txt; } } // Try to fallback - if(lang == current_lang_pack[0]) return msg_id; + if (lang == current_lang_pack[0]) + return msg_id; lang = current_lang_pack[0]; // Repeat search for default locale - if(lang->locale_plural_fn != NULL) { + if (lang->locale_plural_fn != NULL) { ptype = lang->locale_plural_fn(num); - if(lang->plurals[ptype] != NULL) { + if (lang->plurals[ptype] != NULL) { txt = __lv_i18n_get_text_core(lang->plurals[ptype], msg_id); - if (txt != NULL) return txt; + if (txt != NULL) + return txt; } } @@ -1676,8 +1707,9 @@ const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num) * Get the name of the currently used locale. * @return name of the currently used locale. E.g. "en-GB" */ -const char * lv_i18n_get_current_locale(void) +const char *lv_i18n_get_current_locale(void) { - if(!current_lang) return NULL; + if (!current_lang) + return NULL; return current_lang->locale_name; } diff --git a/source/TFTView_320x240.cpp b/source/TFTView_320x240.cpp index d33a975..7655a65 100644 --- a/source/TFTView_320x240.cpp +++ b/source/TFTView_320x240.cpp @@ -77,9 +77,9 @@ TFTView_320x240 *TFTView_320x240::instance(const DisplayDriverConfig &cfg) } TFTView_320x240::TFTView_320x240(const DisplayDriverConfig *cfg, DisplayDriver *driver) - : MeshtasticView(cfg, driver, new ViewController), screensInitialised(false), nodesFiltered(0), processingFilter(false), packetLogEnabled(false), - detectorRunning(false), packetCounter(0), actTime(0), uptime(0), hasPosition(false), topNodeLL(nullptr), scans(0), - selectedHops(0), chooseNodeSignalScanner(false), chooseNodeTraceRoute(false), db{} + : MeshtasticView(cfg, driver, new ViewController), screensInitialised(false), nodesFiltered(0), processingFilter(false), + packetLogEnabled(false), detectorRunning(false), packetCounter(0), actTime(0), uptime(0), hasPosition(false), + topNodeLL(nullptr), scans(0), selectedHops(0), chooseNodeSignalScanner(false), chooseNodeTraceRoute(false), db{} { filter.active = false; highlight.active = false; @@ -118,7 +118,7 @@ void TFTView_320x240::init(IClientBase *client) /** * @brief initialize UI with persistent data */ -void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig& uiconfig) +void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig &uiconfig) { if (uiconfig.version == 1) { ILOG_INFO("setupUIConfig version %d", uiconfig.version); @@ -127,8 +127,7 @@ void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig& uiconfig) db.uiConfig.screen_timeout = 30; controller->storeUIConfig(db.uiConfig); } - } - else { + } else { ILOG_WARN("invalid uiconfig version %d, reset UI settings to default", uiconfig.version); db.uiConfig.version = 1; db.uiConfig.screen_brightness = 153; @@ -146,8 +145,8 @@ void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig& uiconfig) // set language setLanguage(db.uiConfig.language); - //TODO: set virtual keyboard according language - // setKeyboard(db.uiConfig.language); + // TODO: set virtual keyboard according language + // setKeyboard(db.uiConfig.language); // set theme setTheme(db.uiConfig.theme); @@ -167,7 +166,8 @@ void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig& uiconfig) // set screen/settings lock char buf[32]; - lv_snprintf(buf, 32, _("Lock: %s/%s"), db.uiConfig.screen_lock ? _("on") : _("off"), db.uiConfig.settings_lock ? _("on") : _("off")); + lv_snprintf(buf, 32, _("Lock: %s/%s"), db.uiConfig.screen_lock ? _("on") : _("off"), + db.uiConfig.settings_lock ? _("on") : _("off")); lv_label_set_text(objects.basic_settings_screen_lock_label, buf); // set node filter options @@ -176,7 +176,7 @@ void TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig& uiconfig) lv_obj_set_state(objects.nodes_filter_offline_switch, LV_STATE_CHECKED, filter.offline_switch); lv_obj_set_state(objects.nodes_filter_public_key_switch, LV_STATE_CHECKED, filter.public_key_switch); lv_dropdown_set_selected(objects.nodes_filter_hops_dropdown, filter.hops_away); - //lv_obj_set_state(objects.nodes_filter_mqtt_switch, LV_STATE_CHECKED, filter.mqtt_switch); + // lv_obj_set_state(objects.nodes_filter_mqtt_switch, LV_STATE_CHECKED, filter.mqtt_switch); lv_obj_set_state(objects.nodes_filter_position_switch, LV_STATE_CHECKED, filter.position_switch); lv_textarea_set_text(objects.nodes_filter_name_area, filter.node_name); @@ -248,7 +248,7 @@ void TFTView_320x240::init_screens(void) lv_obj_add_flag(objects.basic_settings_alert_button, LV_OBJ_FLAG_HIDDEN); #endif - //signal scanner scale + // signal scanner scale #if defined(USE_SX127x) lv_label_set_text(objects.signal_scanner_rssi_scale_label, "-50\n-60\n-70\n-80\n-90\n-100\n-110\n-120\n-130\n-140\n-150"); lv_slider_set_range(objects.rssi_slider, -150, -50); @@ -314,8 +314,7 @@ void TFTView_320x240::ui_set_active(lv_obj_t *b, lv_obj_t *p, lv_obj_t *tp) lv_obj_remove_state(objects.message_input_area, LV_STATE_FOCUSED); unreadMessages = 0; // TODO: not all messages may be actually read updateUnreadMessages(); - } - else if (activePanel == objects.node_options_panel) { + } else if (activePanel == objects.node_options_panel) { // we're moving away from node options panel, so save latest settings storeNodeOptions(); } @@ -380,9 +379,9 @@ void TFTView_320x240::apply_hotfix(void) uint32_t v = lv_display_get_vertical_resolution(displaydriver->getDisplay()); // resize buttons on larger display (assuming 480x480) if (h > 320 && v > 320) { - lv_obj_t *button[] = { objects.home_button, objects.nodes_button, objects.groups_button, - objects.messages_button, objects.map_button, objects.settings_button }; - for (int i=0; i<6; i++) { + lv_obj_t *button[] = {objects.home_button, objects.nodes_button, objects.groups_button, + objects.messages_button, objects.map_button, objects.settings_button}; + for (int i = 0; i < 6; i++) { lv_obj_set_size(button[i], 72, 72); } } @@ -747,8 +746,7 @@ void TFTView_320x240::ui_event_SettingsButton(lv_event_t *e) lv_obj_add_flag(objects.tab_page_basic_settings, LV_OBJ_FLAG_HIDDEN); THIS->ui_set_active(objects.settings_button, objects.controller_panel, objects.top_settings_panel); lv_screen_load_anim(objects.lock_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); - } - else { + } else { THIS->ui_set_active(objects.settings_button, objects.controller_panel, objects.top_settings_panel); } } else if (event_code == LV_EVENT_LONG_PRESSED && !advancedMode && THIS->activeSettings == eNone) { @@ -951,8 +949,7 @@ void TFTView_320x240::ui_event_BellButton(lv_event_t *e) THIS->db.uiConfig.alert_enabled = true; THIS->controller->sendConfig(ringtone[THIS->db.ringtoneId].rtttl, THIS->ownNode); objects.home_bell_button->user_data = (void *)false; - } - else { + } else { THIS->db.silent = true; THIS->db.uiConfig.alert_enabled = false; THIS->controller->sendConfig(ringtone[0].rtttl, THIS->ownNode); @@ -1007,7 +1004,7 @@ void TFTView_320x240::ui_event_WLANButton(lv_event_t *e) THIS->disablePanel(objects.home_panel); THIS->activeSettings = eWifi; } - else + else #endif if (event_code == LV_EVENT_LONG_PRESSED && THIS->db.config.has_network) { // toggle WLAN on/off @@ -1399,8 +1396,7 @@ void TFTView_320x240::ui_event_alert_button(lv_event_t *e) lv_event_code_t event_code = lv_event_get_code(e); if (event_code == LV_EVENT_CLICKED && THIS->activeSettings == eNone && THIS->db.module_config.has_external_notification) { bool alert_enabled = THIS->db.module_config.external_notification.alert_message_buzzer && - THIS->db.module_config.external_notification.enabled && - !THIS->db.silent; + THIS->db.module_config.external_notification.enabled && !THIS->db.silent; if (alert_enabled) { lv_obj_add_state(objects.settings_alert_buzzer_switch, LV_STATE_CHECKED); } else { @@ -1727,8 +1723,7 @@ void TFTView_320x240::ui_event_trace_route(lv_event_t *e) // remove old route except first button and spinner panel ILOG_DEBUG("removing old route: %d %d %d", lv_obj_get_child_cnt(objects.trace_route_panel), - lv_obj_get_child_cnt(objects.route_towards_panel), - lv_obj_get_child_cnt(objects.route_back_panel)); + lv_obj_get_child_cnt(objects.route_towards_panel), lv_obj_get_child_cnt(objects.route_back_panel)); uint16_t children = lv_obj_get_child_cnt(objects.trace_route_panel) - 1; while (children > 1) { @@ -1805,7 +1800,7 @@ void TFTView_320x240::ui_event_trace_route_start(lv_event_t *e) uint8_t ch = (uint8_t)(unsigned long)currentPanel->user_data; // trial: hoplimit optimization for direct messages int8_t hopsAway = (signed long)THIS->nodes[to]->LV_OBJ_IDX(node_sig_idx)->user_data; - if (hopsAway < 0) + if (hopsAway < 0) hopsAway = 5; uint8_t hopLimit = (hopsAway < THIS->db.config.lora.hop_limit ? hopsAway + 1 : hopsAway); requestId = THIS->requests.addRequest(to, ResponseHandler::TraceRouteRequest); @@ -1821,9 +1816,9 @@ void TFTView_320x240::ui_event_trace_route_start(lv_event_t *e) } void TFTView_320x240::ui_event_trace_route_node(lv_event_t *e) -{ +{ // navigate to node in node list - lv_obj_t *panel = (lv_obj_t*)e->user_data; + lv_obj_t *panel = (lv_obj_t *)e->user_data; THIS->ui_set_active(objects.nodes_button, objects.nodes_panel, objects.top_nodes_panel); lv_obj_scroll_to_view(panel, LV_ANIM_ON); } @@ -2046,11 +2041,10 @@ void TFTView_320x240::updateStatistics(const meshtastic_MeshPacket &p) uint16_t nbr; uint32_t sum; - bool operator==(const Stats& rhs) const { - return id == rhs.id; - } + bool operator==(const Stats &rhs) const { return id == rhs.id; } - Stats& operator+=(const Stats& rhs) { + Stats &operator+=(const Stats &rhs) + { this->tel += rhs.tel; this->pos += rhs.pos; this->inf += rhs.inf; @@ -2061,8 +2055,9 @@ void TFTView_320x240::updateStatistics(const meshtastic_MeshPacket &p) return *this; } - bool operator<(const Stats& rhs) const { - return sum > rhs.sum; // sort reverse but skip equal values + bool operator<(const Stats &rhs) const + { + return sum > rhs.sum; // sort reverse but skip equal values } }; static std::list stats; @@ -2070,8 +2065,8 @@ void TFTView_320x240::updateStatistics(const meshtastic_MeshPacket &p) if (p.from == 0) { // clear table stats.clear(); - for (int i=1; i::iterator it = std::find(stats.begin(), stats.end(), stat); if (it == stats.end()) { stat.row = stats.size(); stat.sum = 1; - //TODO: stop if memory limit is reached + // TODO: stop if memory limit is reached stats.push_back(stat); - } - else { + } else { *it += stat; } @@ -2172,8 +2166,7 @@ void TFTView_320x240::updateStatistics(const meshtastic_MeshPacket &p) if (row != it2.row) { it2.row = row; move = true; - } - else { + } else { break; } } @@ -2185,15 +2178,15 @@ void TFTView_320x240::updateStatistics(const meshtastic_MeshPacket &p) void TFTView_320x240::ui_event_statistics_table(lv_event_t *e) { - lv_draw_task_t * draw_task = lv_event_get_draw_task(e); - lv_draw_dsc_base_t * base_dsc = (lv_draw_dsc_base_t *)lv_draw_task_get_draw_dsc(draw_task); + lv_draw_task_t *draw_task = lv_event_get_draw_task(e); + lv_draw_dsc_base_t *base_dsc = (lv_draw_dsc_base_t *)lv_draw_task_get_draw_dsc(draw_task); // if the cells are drawn... - if(base_dsc->part == LV_PART_ITEMS) { + if (base_dsc->part == LV_PART_ITEMS) { // make the texts in the first cell blueish - lv_draw_fill_dsc_t * fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task); - if(fill_draw_dsc) { + lv_draw_fill_dsc_t *fill_draw_dsc = lv_draw_task_get_fill_dsc(draw_task); + if (fill_draw_dsc) { uint32_t row = base_dsc->id1; - if(row == 0) { + if (row == 0) { fill_draw_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_BLUE), fill_draw_dsc->color, LV_OPA_20); } // make every 2nd row grayish @@ -2202,12 +2195,11 @@ void TFTView_320x240::ui_event_statistics_table(lv_event_t *e) } } } - } uint32_t TFTView_320x240::language2val(meshtastic_Language lang) { - switch(lang) { + switch (lang) { case meshtastic_Language_ENGLISH: return 0; case meshtastic_Language_FRENCH: @@ -2247,7 +2239,7 @@ uint32_t TFTView_320x240::language2val(meshtastic_Language lang) meshtastic_Language TFTView_320x240::val2language(uint32_t val) { - switch(val) { + switch (val) { case 0: return meshtastic_Language_ENGLISH; case 3: @@ -2274,8 +2266,8 @@ meshtastic_Language TFTView_320x240::val2language(uint32_t val) return meshtastic_Language_RUSSIAN; case 5: return meshtastic_Language_DUTCH; -// case 2: -// return meshtastic_Language_GREEK; + // case 2: + // return meshtastic_Language_GREEK; case 13: return meshtastic_Language_SIMPLIFIED_CHINESE; case 14: @@ -2431,7 +2423,7 @@ void TFTView_320x240::storeNodeOptions(void) filter.offline_switch = lv_obj_has_state(objects.nodes_filter_offline_switch, LV_STATE_CHECKED); filter.public_key_switch = lv_obj_has_state(objects.nodes_filter_public_key_switch, LV_STATE_CHECKED); filter.hops_away = lv_dropdown_get_selected(objects.nodes_filter_hops_dropdown); - //filter.mqtt_switch = lv_obj_has_state(objects.nodes_filter_mqtt_switch, LV_STATE_CHECKED); + // filter.mqtt_switch = lv_obj_has_state(objects.nodes_filter_mqtt_switch, LV_STATE_CHECKED); filter.position_switch = lv_obj_has_state(objects.nodes_filter_position_switch, LV_STATE_CHECKED); strncpy(filter.node_name, lv_textarea_get_text(objects.nodes_filter_name_area), sizeof(filter.node_name)); @@ -2478,15 +2470,15 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) } case eDeviceRole: { meshtastic_Config_DeviceConfig &device = THIS->db.config.device; - meshtastic_Config_DeviceConfig_Role role = - (meshtastic_Config_DeviceConfig_Role)lv_dropdown_get_selected(objects.settings_device_role_dropdown); + meshtastic_Config_DeviceConfig_Role role = + (meshtastic_Config_DeviceConfig_Role)lv_dropdown_get_selected(objects.settings_device_role_dropdown); if (role != device.role) { char buf1[30], buf2[40]; lv_dropdown_get_selected_str(objects.settings_device_role_dropdown, buf1, sizeof(buf1)); lv_snprintf(buf2, sizeof(buf2), _("Device Role: %s"), buf1); lv_label_set_text(objects.basic_settings_role_label, buf2); - + device.role = role; THIS->controller->sendConfig(meshtastic_Config_DeviceConfig{device}, THIS->ownNode); THIS->notifyReboot(true); @@ -2511,7 +2503,7 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) lv_dropdown_get_selected_str(objects.settings_region_dropdown, buf1, sizeof(buf1)); lv_snprintf(buf2, sizeof(buf2), _("Region: %s"), buf1); lv_label_set_text(objects.basic_settings_region_label, buf2); - + meshtastic_Config_LoRaConfig &lora = THIS->db.config.lora; uint32_t defaultSlot = LoRaPresets::getDefaultSlot(region, THIS->db.config.lora.modem_preset); lora.region = region; @@ -2533,7 +2525,7 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) lv_dropdown_get_selected_str(objects.settings_modem_preset_dropdown, buf1, sizeof(buf1)); lv_snprintf(buf2, sizeof(buf2), _("Modem Preset: %s"), buf1); lv_label_set_text(objects.basic_settings_modem_preset_label, buf2); - + lora.use_preset = true; lora.modem_preset = preset; lora.channel_num = channelNum; @@ -2577,7 +2569,7 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) THIS->controller->sendConfig(meshtastic_Config_NetworkConfig{THIS->db.config.network}, THIS->ownNode); THIS->notifyReboot(true); } - //THIS->enablePanel(objects.home_panel); + // THIS->enablePanel(objects.home_panel); lv_obj_add_flag(objects.settings_wifi_panel, LV_OBJ_FLAG_HIDDEN); lv_group_focus_obj(objects.basic_settings_wifi_button); break; @@ -2616,7 +2608,7 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) if ((screenLock || settingsLock) && (atol(pin) == 0 || strlen(pin) != 6)) return; // require pin != "000000" if ((screenLock != THIS->db.uiConfig.screen_lock) || settingsLock != THIS->db.uiConfig.settings_lock || - atol(pin) != THIS->db.uiConfig.pin_code) { + atol(pin) != THIS->db.uiConfig.pin_code) { THIS->db.uiConfig.screen_lock = screenLock; THIS->db.uiConfig.settings_lock = settingsLock; THIS->db.uiConfig.pin_code = atol(pin); @@ -2825,7 +2817,7 @@ void TFTView_320x240::ui_event_cancel(lv_event_t *e) } case TFTView_320x240::eWifi: { lv_obj_add_flag(objects.settings_wifi_panel, LV_OBJ_FLAG_HIDDEN); - //THIS->enablePanel(objects.home_panel); + // THIS->enablePanel(objects.home_panel); lv_group_focus_obj(objects.home_wlan_button); break; @@ -2956,8 +2948,7 @@ void TFTView_320x240::ui_event_modem_preset_dropdown(lv_event_t *e) void TFTView_320x240::ui_event_device_role_dropdown(lv_event_t *e) { lv_obj_t *dropdown = lv_event_get_target_obj(e); - meshtastic_Config_DeviceConfig_Role role = - (meshtastic_Config_DeviceConfig_Role)lv_dropdown_get_selected(dropdown); + meshtastic_Config_DeviceConfig_Role role = (meshtastic_Config_DeviceConfig_Role)lv_dropdown_get_selected(dropdown); if (role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT) { // role deprecated, revert lv_dropdown_set_selected(dropdown, THIS->db.config.device.role); @@ -3762,7 +3753,7 @@ void TFTView_320x240::handlePositionResponse(uint32_t from, uint32_t request_id, #if defined(USE_SX127x) int p_snr = ((std::max(rx_snr, -19.0f) + 19.0f) / 33.0f) * 100.0f; // range -19..14 - int p_rssi = ((std::max(rx_rssi, -145L) + 145) * 100) / 90; // range -145..-55 + int p_rssi = ((std::max(rx_rssi, -145L) + 145) * 100) / 90; // range -145..-55 #else int p_snr = ((std::max(rx_snr, -18.0f) + 18.0f) / 26.0f) * 100.0f; // range -18..8 int p_rssi = ((std::max(rx_rssi, -125) + 125) * 100) / 100; // range -125..-25 @@ -3784,12 +3775,11 @@ void TFTView_320x240::handleTraceRouteResponse(const meshtastic_Routing &routing if (routing.error_reason != meshtastic_Routing_Error_NONE) { lv_label_set_text(objects.trace_route_start_label, _("Start")); removeSpinner(); - } - else { + } else { // we got a first ACK to our route request if (spinnerButton) { - lv_obj_set_style_outline_color(objects.trace_route_start_button, - lv_color_hex(0xDBD251), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_outline_color(objects.trace_route_start_button, lv_color_hex(0xDBD251), + LV_PART_MAIN | LV_STATE_DEFAULT); } } } @@ -3863,8 +3853,7 @@ void TFTView_320x240::addNodeToTraceRoute(uint32_t nodeNum, lv_obj_t *panel) if (nodeNum != ownNode) { lv_obj_add_event_cb(btn, ui_event_trace_route_node, LV_EVENT_CLICKED, nodePanel); lv_label_set_text(label, lv_label_get_text(nodePanel->LV_OBJ_IDX(node_lbs_idx))); - } - else { + } else { lv_label_set_text(label, lv_label_get_text(nodePanel->LV_OBJ_IDX(node_lbl_idx))); } } else { @@ -4125,8 +4114,7 @@ void TFTView_320x240::screenSaving(bool enabled) if (enabled) { // overlay main screen with blank screen to prevent accidentally pressing buttons lv_screen_load_anim(objects.blank_screen, LV_SCR_LOAD_ANIM_FADE_OUT, 0, 0, false); - } - else { + } else { if (THIS->db.uiConfig.screen_lock) lv_screen_load_anim(objects.lock_screen, LV_SCR_LOAD_ANIM_NONE, 0, 0, false); else if (objects.main_screen) @@ -4272,8 +4260,7 @@ void TFTView_320x240::showLoRaFrequency(const meshtastic_Config_LoRaConfig &cfg) float frequency = LoRaPresets::getRadioFreq(cfg.region, cfg.modem_preset, cfg.channel_num); if (frequency > 1.0 && frequency < 10000.0) { sprintf(loraFreq, "LoRa %g MHz\n[%s kHz]", frequency, LoRaPresets::getBandwidthString(cfg.modem_preset)); - } - else { + } else { strcpy(loraFreq, _("region unset")); } lv_label_set_text(objects.home_lora_label, loraFreq); @@ -4281,8 +4268,7 @@ void TFTView_320x240::showLoRaFrequency(const meshtastic_Config_LoRaConfig &cfg) Themes::recolorText(objects.home_lora_label, cfg.tx_enabled); if (!cfg.tx_enabled) { lv_obj_clear_flag(objects.top_lora_tx_panel, LV_OBJ_FLAG_HIDDEN); - } - else { + } else { lv_obj_add_flag(objects.top_lora_tx_panel, LV_OBJ_FLAG_HIDDEN); } } @@ -4291,20 +4277,19 @@ void TFTView_320x240::setBellText(bool banner, bool sound) { if (banner && sound) { lv_label_set_text(objects.home_bell_label, _("Banner & Sound")); - } - else if (banner) { + } else if (banner) { lv_label_set_text(objects.home_bell_label, _("Banner only")); - } - else if (sound) { + } else if (sound) { lv_label_set_text(objects.home_bell_label, _("Sound only")); - } - else { + } else { lv_label_set_text(objects.home_bell_label, _("silent")); } char buf[40]; - lv_snprintf(buf, sizeof(buf), _("Message Alert: %s"), - db.module_config.external_notification.alert_message_buzzer ? (!sound ? _("silent") : ringtone[db.ringtoneId].name) : "off"); + lv_snprintf(buf, sizeof(buf), _("Message Alert: %s"), + db.module_config.external_notification.alert_message_buzzer + ? (!sound ? _("silent") : ringtone[db.ringtoneId].name) + : "off"); lv_label_set_text(objects.basic_settings_alert_label, buf); Themes::recolorButton(objects.home_bell_button, banner || sound); @@ -4374,10 +4359,11 @@ void TFTView_320x240::updateRingtone(const char rtttl[231]) db.ringtoneId = 1; db.silent = rtIndex == 0; -// char buf[32]; -// lv_snprintf(buf, sizeof(buf), _("Message Alert: %s"), -// db.module_config.external_notification.alert_message_buzzer ? (rtIndex == 0 ? _("silent") : ringtone[rtIndex].name) : "off"); -// lv_label_set_text(objects.basic_settings_alert_label, buf); + // char buf[32]; + // lv_snprintf(buf, sizeof(buf), _("Message Alert: %s"), + // db.module_config.external_notification.alert_message_buzzer ? (rtIndex == 0 ? _("silent") : ringtone[rtIndex].name) + // : "off"); + // lv_label_set_text(objects.basic_settings_alert_label, buf); // update home panel bell text setBellText(db.uiConfig.alert_enabled, !db.silent); @@ -5113,8 +5099,8 @@ void TFTView_320x240::task_handler(void) if (startTime) { if (curtime - startTime > 30) { lv_label_set_text(objects.trace_route_start_label, _("Start")); - lv_obj_set_style_outline_color(objects.trace_route_start_button, - lv_color_hex(0xff67ea94), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_outline_color(objects.trace_route_start_button, lv_color_hex(0xff67ea94), + LV_PART_MAIN | LV_STATE_DEFAULT); removeSpinner(); } else { char buf[16]; @@ -5126,7 +5112,7 @@ void TFTView_320x240::task_handler(void) if (curtime - lastrun10 >= 10) { // call every 10s lastrun10 = curtime; updateFreeMem(); - + if ((db.config.network.wifi_enabled || db.module_config.mqtt.enabled) && !displaydriver->isPowersaving()) { controller->requestDeviceConnectionStatus(); } @@ -5134,17 +5120,16 @@ void TFTView_320x240::task_handler(void) if (curtime - lastrun60 >= 60) { // call every 60s lastrun60 = curtime; updateAllLastHeard(); - + if (detectorRunning) { controller->sendPing(); } } - + if (processingFilter) { updateNodesFiltered(false); } - } - else { + } else { updateBootMessage(); } }