diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 45192d55..4a8a5dec 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -162,6 +162,7 @@ set(CPPSRC ${COMMON}/ui_painter.cpp ${COMMON}/ui_text.cpp ${COMMON}/ui_widget.cpp + ${COMMON}/ui_language.cpp ${COMMON}/utility.cpp ${COMMON}/wm8731.cpp ${COMMON}/performance_counter.cpp @@ -250,8 +251,7 @@ set(CPPSRC apps/capture_app.cpp apps/ert_app.cpp apps/gps_sim_app.cpp - apps/lge_app.cpp - apps/lge_app.cpp + # apps/lge_app.cpp apps/pocsag_app.cpp # apps/replay_app.cpp apps/soundboard_app.cpp @@ -264,7 +264,7 @@ set(CPPSRC apps/ui_aprs_tx.cpp apps/ui_bht_tx.cpp apps/ui_btle_rx.cpp - apps/ui_coasterp.cpp + # apps/ui_coasterp.cpp apps/ui_debug.cpp apps/ui_dfu_menu.cpp apps/ui_encoders.cpp @@ -275,7 +275,7 @@ set(CPPSRC apps/ui_iq_trim.cpp apps/ui_jammer.cpp # apps/ui_keyfob.cpp - apps/ui_lcr.cpp + # apps/ui_lcr.cpp apps/ui_level.cpp apps/ui_looking_glass_app.cpp apps/ui_mictx.cpp @@ -314,7 +314,7 @@ set(CPPSRC protocols/bht.cpp protocols/dcs.cpp protocols/encoders.cpp - protocols/lcr.cpp + # protocols/lcr.cpp protocols/modems.cpp protocols/rds.cpp # ui_handwrite.cpp diff --git a/firmware/application/external/afsk_rx/ui_afsk_rx.hpp b/firmware/application/external/afsk_rx/ui_afsk_rx.hpp index 30f480cb..188cd5df 100644 --- a/firmware/application/external/afsk_rx/ui_afsk_rx.hpp +++ b/firmware/application/external/afsk_rx/ui_afsk_rx.hpp @@ -24,6 +24,7 @@ #define __UI_AFSK_RX_H__ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_navigation.hpp" #include "ui_receiver.hpp" #include "ui_freq_field.hpp" @@ -92,16 +93,16 @@ class AFSKRxView : public View { Checkbox check_log{ {0 * 8, 1 * 16}, 3, - "LOG", + LanguageHelper::currentMessages[LANG_LOG], false}; Text text_debug{ {0 * 8, 12 + 2 * 16, screen_width, 16}, - "DEBUG"}; + LanguageHelper::currentMessages[LANG_DEBUG]}; Button button_modem_setup{ {screen_width - 12 * 8, 1 * 16, 96, 24}, - "Modem setup"}; + LanguageHelper::currentMessages[LANG_MODEM_SETUP]}; Console console{ {0, 4 * 16, 240, screen_width}}; diff --git a/firmware/application/external/blespam/ui_blespam.cpp b/firmware/application/external/blespam/ui_blespam.cpp index 15679a95..818b45ad 100644 --- a/firmware/application/external/blespam/ui_blespam.cpp +++ b/firmware/application/external/blespam/ui_blespam.cpp @@ -85,11 +85,11 @@ BLESpamView::BLESpamView(NavigationView& nav) if (is_running) { is_running = false; stop(); - button_startstop.set_text("Start"); + button_startstop.set_text(LanguageHelper::currentMessages[LANG_START]); } else { is_running = true; start(); - button_startstop.set_text("Stop"); + button_startstop.set_text(LanguageHelper::currentMessages[LANG_STOP]); } }; chk_randdev.set_value(true); diff --git a/firmware/application/external/blespam/ui_blespam.hpp b/firmware/application/external/blespam/ui_blespam.hpp index 39ec2059..ab33bffc 100644 --- a/firmware/application/external/blespam/ui_blespam.hpp +++ b/firmware/application/external/blespam/ui_blespam.hpp @@ -28,6 +28,7 @@ #define __UI_BLESPAM_H__ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_navigation.hpp" #include "ui_transmitter.hpp" #include "ui_freq_field.hpp" @@ -107,7 +108,7 @@ class BLESpamView : public View { Button button_startstop{ {0, 3 * 16, 96, 24}, - "Start"}; + LanguageHelper::currentMessages[LANG_START]}; Checkbox chk_randdev{{100, 16}, 10, "Rnd device", true}; Console console{ diff --git a/firmware/application/external/coasterp/main.cpp b/firmware/application/external/coasterp/main.cpp new file mode 100644 index 00000000..a81d5888 --- /dev/null +++ b/firmware/application/external/coasterp/main.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2023 Bernd Herzog + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui.hpp" +#include "ui_coasterp.hpp" +#include "ui_navigation.hpp" +#include "external_app.hpp" + +namespace ui::external_app::coasterp { +void initialize_app(ui::NavigationView& nav) { + nav.push(); +} +} // namespace ui::external_app::coasterp + +extern "C" { + +__attribute__((section(".external_app.app_coasterp.application_information"), used)) application_information_t _application_information_coasterp = { + /*.memory_location = */ (uint8_t*)0x00000000, + /*.externalAppEntry = */ ui::external_app::coasterp::initialize_app, + /*.header_version = */ CURRENT_HEADER_VERSION, + /*.app_version = */ VERSION_MD5, + + /*.app_name = */ "BurgerPgr", + /*.bitmap_data = */ { + + 0x00, + 0x00, + 0xE0, + 0x07, + 0xF8, + 0x1F, + 0xFC, + 0x3F, + 0xFE, + 0x7F, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0x00, + 0x00, + 0x55, + 0x55, + 0xAA, + 0xAA, + 0x55, + 0x55, + 0x00, + 0x00, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFE, + 0x7F, + 0x00, + 0x00, + }, + /*.icon_color = */ ui::Color::yellow().v, + /*.menu_location = */ app_location_t::TX, + + /*.m4_app_tag = portapack::spi_flash::image_tag_fsktx */ {'P', 'F', 'S', 'K'}, + /*.m4_app_offset = */ 0x00000000, // will be filled at compile time +}; +} diff --git a/firmware/application/apps/ui_coasterp.cpp b/firmware/application/external/coasterp/ui_coasterp.cpp similarity index 97% rename from firmware/application/apps/ui_coasterp.cpp rename to firmware/application/external/coasterp/ui_coasterp.cpp index 9849b3d9..e8ec6d2b 100644 --- a/firmware/application/apps/ui_coasterp.cpp +++ b/firmware/application/external/coasterp/ui_coasterp.cpp @@ -30,7 +30,7 @@ using namespace portapack; -namespace ui { +namespace ui::external_app::coasterp { void CoasterPagerView::focus() { sym_data.focus(); @@ -131,4 +131,4 @@ CoasterPagerView::CoasterPagerView(NavigationView& nav) { }; } -} /* namespace ui */ +} /* namespace ui::external_app::coasterp */ diff --git a/firmware/application/apps/ui_coasterp.hpp b/firmware/application/external/coasterp/ui_coasterp.hpp similarity index 90% rename from firmware/application/apps/ui_coasterp.hpp rename to firmware/application/external/coasterp/ui_coasterp.hpp index 4314ff68..e989f987 100644 --- a/firmware/application/apps/ui_coasterp.hpp +++ b/firmware/application/external/coasterp/ui_coasterp.hpp @@ -21,6 +21,7 @@ */ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_widget.hpp" #include "ui_navigation.hpp" #include "ui_transmitter.hpp" @@ -31,7 +32,7 @@ #include "radio_state.hpp" #include "portapack.hpp" -namespace ui { +namespace ui::external_app::coasterp { class CoasterPagerView : public View { public: @@ -65,7 +66,7 @@ class CoasterPagerView : public View { Labels labels{ {{1 * 8, 3 * 8}, "Syscall pager TX beta", Color::light_grey()}, - {{1 * 8, 8 * 8}, "Data:", Color::light_grey()}}; + {{1 * 8, 8 * 8}, LanguageHelper::currentMessages[LANG_DATADP], Color::light_grey()}}; SymField sym_data{ {7 * 8, 8 * 8}, @@ -75,7 +76,7 @@ class CoasterPagerView : public View { Checkbox checkbox_scan{ {10 * 8, 14 * 8}, 4, - "Scan"}; + LanguageHelper::currentMessages[LANG_SCAN]}; /* ProgressBar progressbar { @@ -99,4 +100,4 @@ class CoasterPagerView : public View { }}; }; -} /* namespace ui */ +} /* namespace ui::external_app::coasterp */ diff --git a/firmware/application/external/external.cmake b/firmware/application/external/external.cmake index 4d6a3e00..bc7be0d2 100644 --- a/firmware/application/external/external.cmake +++ b/firmware/application/external/external.cmake @@ -28,6 +28,18 @@ set(EXTCPPSRC external/nrf_rx/main.cpp external/nrf_rx/ui_nrf_rx.cpp + #coasterp + external/coasterp/main.cpp + external/coasterp/ui_coasterp.cpp + + #lge + external/lge/main.cpp + external/lge/lge_app.cpp + + #lcr + external/lcr/main.cpp + external/lcr/ui_lcr.cpp + ) set(EXTAPPLIST @@ -38,4 +50,7 @@ set(EXTAPPLIST blespam nrf_rx analogtv + coasterp + lge + lcr ) diff --git a/firmware/application/external/external.ld b/firmware/application/external/external.ld index f3c11f7e..b7881291 100644 --- a/firmware/application/external/external.ld +++ b/firmware/application/external/external.ld @@ -24,6 +24,9 @@ MEMORY ram_external_app_blespam(rwx) : org = 0xEEED0000, len = 32k ram_external_app_analogtv(rwx) : org = 0xEEEE0000, len = 32k ram_external_app_nrf_rx(rwx) : org = 0xEEEF0000, len = 32k + ram_external_app_coasterp(rwx) : org = 0xEEF00000, len = 32k + ram_external_app_lge(rwx) : org = 0xEEF10000, len = 32k + ram_external_app_lcr(rwx) : org = 0xEEF20000, len = 32k } SECTIONS @@ -71,4 +74,23 @@ SECTIONS *(*ui*external_app*nrf_rx*); } > ram_external_app_nrf_rx + .external_app_coasterp : ALIGN(4) SUBALIGN(4) + { + KEEP(*(.external_app.app_coasterp.application_information)); + *(*ui*external_app*coasterp*); + } > ram_external_app_coasterp + + .external_app_lge : ALIGN(4) SUBALIGN(4) + { + KEEP(*(.external_app.app_lge.application_information)); + *(*ui*external_app*lge*); + } > ram_external_app_lge + + + .external_app_lcr : ALIGN(4) SUBALIGN(4) + { + KEEP(*(.external_app.app_lcr.application_information)); + *(*ui*external_app*lcr*); + } > ram_external_app_lcr + } diff --git a/firmware/application/external/lcr/main.cpp b/firmware/application/external/lcr/main.cpp new file mode 100644 index 00000000..aa748af7 --- /dev/null +++ b/firmware/application/external/lcr/main.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2023 Bernd Herzog + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui.hpp" +#include "ui_lcr.hpp" +#include "ui_navigation.hpp" +#include "external_app.hpp" + +namespace ui::external_app::lcr { +void initialize_app(ui::NavigationView& nav) { + nav.push(); +} +} // namespace ui::external_app::lcr + +extern "C" { + +__attribute__((section(".external_app.app_lcr.application_information"), used)) application_information_t _application_information_lcr = { + /*.memory_location = */ (uint8_t*)0x00000000, + /*.externalAppEntry = */ ui::external_app::lcr::initialize_app, + /*.header_version = */ CURRENT_HEADER_VERSION, + /*.app_version = */ VERSION_MD5, + + /*.app_name = */ "TEDI/LCR", + /*.bitmap_data = */ { + 0x0C, + 0x00, + 0xFF, + 0x7F, + 0x01, + 0x80, + 0xC1, + 0x9B, + 0xFF, + 0x7F, + 0x0C, + 0x00, + 0xFF, + 0x7F, + 0x01, + 0x80, + 0xC1, + 0x9D, + 0xFF, + 0x7F, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + 0x0C, + 0x00, + }, + /*.icon_color = */ ui::Color::yellow().v, + /*.menu_location = */ app_location_t::TX, + + /*.m4_app_tag = portapack::spi_flash::image_tag_afsk */ {'P', 'A', 'F', 'T'}, + /*.m4_app_offset = */ 0x00000000, // will be filled at compile time +}; +} diff --git a/firmware/application/apps/ui_lcr.cpp b/firmware/application/external/lcr/ui_lcr.cpp similarity index 84% rename from firmware/application/apps/ui_lcr.cpp rename to firmware/application/external/lcr/ui_lcr.cpp index fbf955a6..c451c9ea 100644 --- a/firmware/application/apps/ui_lcr.cpp +++ b/firmware/application/external/lcr/ui_lcr.cpp @@ -23,7 +23,6 @@ #include "ui_lcr.hpp" #include "ui_modemsetup.hpp" -#include "lcr.hpp" #include "baseband_api.hpp" #include "string_format.hpp" @@ -31,7 +30,7 @@ using namespace portapack; -namespace ui { +namespace ui::external_app::lcr { void LCRView::focus() { button_set_rgsb.focus(); @@ -42,6 +41,49 @@ LCRView::~LCRView() { baseband::shutdown(); } +std::string LCRView::generate_message(std::string rgsb, std::vector litterals, size_t option_ec) { + const std::string ec_lut[4] = {"A", "J", "N", "S"}; // Eclairage (Auto, Jour, Nuit) + char eom[3] = {3, 0, 0}; // EOM and space for checksum + uint8_t i; + std::string lcr_message{127, 127, 127, 127, 127, 127, 127, 5}; // 5/15 ? Modem sync and SOM + char checksum = 0; + + // Pad litterals to 7 chars (not required ?) + for (auto& litteral : litterals) + while (litteral.length() < 7) + litteral += ' '; + + // Compose LCR message + lcr_message += rgsb; + lcr_message += "PA "; + + i = 1; + for (auto& litteral : litterals) { + lcr_message += "AM="; + lcr_message += to_string_dec_uint(i, 1); + lcr_message += " AF=\""; + lcr_message += litteral; + lcr_message += "\" CL=0 "; + i++; + } + + lcr_message += "EC="; + lcr_message += ec_lut[option_ec]; + lcr_message += " SAB=0"; + + // Checksum + i = 7; // Skip modem sync + while (lcr_message[i]) + checksum ^= lcr_message[i++]; + checksum ^= eom[0]; // EOM char + checksum &= 0x7F; // Trim + eom[1] = checksum; + + lcr_message += eom; + + return lcr_message; +} + /* // Recap: frequency @ baudrate final_str = to_string_short_freq(persistent_memory::tuned_frequency()); @@ -53,7 +95,7 @@ text_recap.set(final_str);*/ void LCRView::update_progress() { if (tx_mode == IDLE) { - text_status.set("Ready"); + text_status.set(LanguageHelper::currentMessages[LANG_READY]); progress.set_value(0); } else { std::string progress_str = to_string_dec_uint(repeat_index) + "/" + to_string_dec_uint(persistent_memory::modem_repeat()) + @@ -125,7 +167,7 @@ void LCRView::start_tx(const bool scan) { litterals_list.push_back(litteral[i]); } - modems::generate_data(lcr::generate_message(rgsb, litterals_list, options_ec.selected_index()), lcr_message_data); + modems::generate_data(generate_message(rgsb, litterals_list, options_ec.selected_index()), lcr_message_data); /* It is AFSK modulation , measuring original fw 1.7.4 spectrum BW is just around 30khz , NBFM */ transmitter_model.set_baseband_bandwidth(1'750'000); // Min TX LPF 1M75, same spectrum as previous fw 1.7.4 @@ -269,4 +311,4 @@ LCRView::LCRView(NavigationView& nav) { }; } -} /* namespace ui */ +} /* namespace ui::external_app::lcr */ diff --git a/firmware/application/apps/ui_lcr.hpp b/firmware/application/external/lcr/ui_lcr.hpp similarity index 90% rename from firmware/application/apps/ui_lcr.hpp rename to firmware/application/external/lcr/ui_lcr.hpp index 06c92387..390123b2 100644 --- a/firmware/application/apps/ui_lcr.hpp +++ b/firmware/application/external/lcr/ui_lcr.hpp @@ -21,6 +21,7 @@ */ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_widget.hpp" #include "ui_textentry.hpp" #include "ui_transmitter.hpp" @@ -31,7 +32,7 @@ #include "app_settings.hpp" #include "radio_state.hpp" -namespace ui { +namespace ui::external_app::lcr { #define LCR_MAX_AM 5 @@ -101,6 +102,7 @@ class LCRView : public View { void start_tx(const bool scan); void on_tx_progress(const uint32_t progress, const bool done); void on_button_set_am(NavigationView& nav, int16_t button_id); + std::string generate_message(std::string rgsb, std::vector litterals, size_t option_ec); Labels labels{ {{0, 8}, "EC: RGSB:", Color::light_grey()}, @@ -125,11 +127,11 @@ class LCRView : public View { Checkbox check_scan{ {22 * 8, 4}, 4, - "Scan"}; + LanguageHelper::currentMessages[LANG_SCAN]}; Button button_modem_setup{ {1 * 8, 4 * 8 + 2, 14 * 8, 24}, - "Modem setup"}; + LanguageHelper::currentMessages[LANG_MODEM_SETUP]}; OptionsField options_scanlist{ {22 * 8, 4 * 8}, 6, @@ -137,11 +139,11 @@ class LCRView : public View { Button button_clear{ {22 * 8, 8 * 8, 7 * 8, 19 * 8}, - "CLEAR"}; + LanguageHelper::currentMessages[LANG_CLEAR]}; Text text_status{ {2 * 8, 27 * 8 + 4, 26 * 8, 16}, - "Ready"}; + LanguageHelper::currentMessages[LANG_READY]}; ProgressBar progress{ {2 * 8, 29 * 8 + 4, 26 * 8, 16}}; @@ -158,4 +160,4 @@ class LCRView : public View { }}; }; -} /* namespace ui */ +} /* namespace ui::external_app::lcr */ diff --git a/firmware/application/apps/lge_app.cpp b/firmware/application/external/lge/lge_app.cpp similarity index 99% rename from firmware/application/apps/lge_app.cpp rename to firmware/application/external/lge/lge_app.cpp index 95aa1379..97e56163 100644 --- a/firmware/application/apps/lge_app.cpp +++ b/firmware/application/external/lge/lge_app.cpp @@ -36,7 +36,7 @@ using namespace portapack; -namespace ui { +namespace ui::external_app::lge { void LGEView::focus() { options_frame.focus(); @@ -354,4 +354,4 @@ LGEView::LGEView(NavigationView& nav) { }; } -} /* namespace ui */ +} /* namespace ui::external_app::lge */ diff --git a/firmware/application/apps/lge_app.hpp b/firmware/application/external/lge/lge_app.hpp similarity index 96% rename from firmware/application/apps/lge_app.hpp rename to firmware/application/external/lge/lge_app.hpp index 4eac2b1a..3db41ba2 100644 --- a/firmware/application/apps/lge_app.hpp +++ b/firmware/application/external/lge/lge_app.hpp @@ -21,6 +21,7 @@ */ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_widget.hpp" #include "ui_navigation.hpp" #include "ui_transmitter.hpp" @@ -32,7 +33,7 @@ #include "app_settings.hpp" #include "radio_state.hpp" -namespace ui { +namespace ui::external_app::lge { class LGEView : public View { public: @@ -105,7 +106,7 @@ class LGEView : public View { {"Set nickname", 1}, {"Set team", 2}, {"Brdcst nick", 3}, - {"Start", 4}, + {LanguageHelper::currentMessages[LANG_START], 4}, {"Game over", 5}, {"Set vest", 6}}}; @@ -185,4 +186,4 @@ class LGEView : public View { }}; }; -} /* namespace ui */ +} /* namespace ui::external_app::lge */ diff --git a/firmware/application/external/lge/main.cpp b/firmware/application/external/lge/main.cpp new file mode 100644 index 00000000..e09564e8 --- /dev/null +++ b/firmware/application/external/lge/main.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2023 Bernd Herzog + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "ui.hpp" +#include "lge_app.hpp" +#include "ui_navigation.hpp" +#include "external_app.hpp" + +namespace ui::external_app::lge { +void initialize_app(ui::NavigationView& nav) { + nav.push(); +} +} // namespace ui::external_app::lge + +extern "C" { + +__attribute__((section(".external_app.app_lge.application_information"), used)) application_information_t _application_information_lge = { + /*.memory_location = */ (uint8_t*)0x00000000, + /*.externalAppEntry = */ ui::external_app::lge::initialize_app, + /*.header_version = */ CURRENT_HEADER_VERSION, + /*.app_version = */ VERSION_MD5, + + /*.app_name = */ "LGE", + /*.bitmap_data = */ { + 0x00, + 0x00, + 0x80, + 0x00, + 0xA4, + 0x12, + 0xA8, + 0x0A, + 0xD0, + 0x05, + 0xEC, + 0x1B, + 0xF0, + 0x07, + 0xFE, + 0xFF, + 0xF0, + 0x07, + 0xEC, + 0x1B, + 0xD0, + 0x05, + 0xA8, + 0x0A, + 0xA4, + 0x12, + 0x80, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }, + /*.icon_color = */ ui::Color::yellow().v, + /*.menu_location = */ app_location_t::TX, + + /*.m4_app_tag = portapack::spi_flash::image_tag_fsktx */ {'P', 'F', 'S', 'K'}, + /*.m4_app_offset = */ 0x00000000, // will be filled at compile time +}; +} diff --git a/firmware/application/external/nrf_rx/ui_nrf_rx.hpp b/firmware/application/external/nrf_rx/ui_nrf_rx.hpp index 3f33b571..61af7094 100644 --- a/firmware/application/external/nrf_rx/ui_nrf_rx.hpp +++ b/firmware/application/external/nrf_rx/ui_nrf_rx.hpp @@ -25,6 +25,7 @@ #define __UI_NRF_RX_H__ #include "ui.hpp" +#include "ui_language.hpp" #include "ui_navigation.hpp" #include "ui_receiver.hpp" #include "ui_freq_field.hpp" @@ -77,7 +78,7 @@ class NRFRxView : public View { Button button_modem_setup{ {240 - 12 * 8, 1 * 16, 96, 24}, - "Modem setup"}; + LanguageHelper::currentMessages[LANG_MODEM_SETUP]}; Console console{ {0, 4 * 16, 240, 240}}; diff --git a/firmware/application/protocols/lcr.cpp b/firmware/application/protocols/lcr.cpp deleted file mode 100644 index f40291e5..00000000 --- a/firmware/application/protocols/lcr.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. - * Copyright (C) 2016 Furrtek - * - * This file is part of PortaPack. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "lcr.hpp" -#include "string_format.hpp" - -namespace lcr { - -std::string generate_message(std::string rgsb, std::vector litterals, size_t option_ec) { - const std::string ec_lut[4] = {"A", "J", "N", "S"}; // Eclairage (Auto, Jour, Nuit) - char eom[3] = {3, 0, 0}; // EOM and space for checksum - uint8_t i; - std::string lcr_message{127, 127, 127, 127, 127, 127, 127, 5}; // 5/15 ? Modem sync and SOM - char checksum = 0; - - // Pad litterals to 7 chars (not required ?) - for (auto& litteral : litterals) - while (litteral.length() < 7) - litteral += ' '; - - // Compose LCR message - lcr_message += rgsb; - lcr_message += "PA "; - - i = 1; - for (auto& litteral : litterals) { - lcr_message += "AM="; - lcr_message += to_string_dec_uint(i, 1); - lcr_message += " AF=\""; - lcr_message += litteral; - lcr_message += "\" CL=0 "; - i++; - } - - lcr_message += "EC="; - lcr_message += ec_lut[option_ec]; - lcr_message += " SAB=0"; - - // Checksum - i = 7; // Skip modem sync - while (lcr_message[i]) - checksum ^= lcr_message[i++]; - checksum ^= eom[0]; // EOM char - checksum &= 0x7F; // Trim - eom[1] = checksum; - - lcr_message += eom; - - return lcr_message; -} - -} /* namespace lcr */ diff --git a/firmware/application/protocols/lcr.hpp b/firmware/application/protocols/lcr.hpp deleted file mode 100644 index 82beee2b..00000000 --- a/firmware/application/protocols/lcr.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. - * Copyright (C) 2016 Furrtek - * - * This file is part of PortaPack. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "ui.hpp" -#include -#include -#include - -#ifndef __LCR_H__ -#define __LCR_H__ - -namespace lcr { - -std::string generate_message(std::string rgsb, std::vector litterals, size_t option_ec); - -} /* namespace lcr */ - -#endif /*__LCR_H__*/ diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 14e1d4a5..4efa7f5d 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -38,7 +38,7 @@ #include "ui_aprs_tx.hpp" #include "ui_bht_tx.hpp" #include "ui_btle_rx.hpp" -#include "ui_coasterp.hpp" +// #include "ui_coasterp.hpp" //moved to ext #include "ui_debug.hpp" #include "ui_encoders.hpp" #include "ui_fileman.hpp" @@ -49,12 +49,12 @@ #include "ui_iq_trim.hpp" #include "ui_jammer.hpp" // #include "ui_keyfob.hpp" -#include "ui_lcr.hpp" +// #include "ui_lcr.hpp" #include "ui_level.hpp" #include "ui_looking_glass_app.hpp" #include "ui_mictx.hpp" #include "ui_morse.hpp" -// #include "ui_nrf_rx.hpp" +// #include "ui_nrf_rx.hpp" //moved to ext // #include "ui_numbers.hpp" // #include "ui_nuoptix.hpp" // #include "ui_playdead.hpp" @@ -86,14 +86,14 @@ // #include "acars_app.hpp" #include "ais_app.hpp" #include "analog_audio_app.hpp" -// #include "analog_tv_app.hpp" +// #include "analog_tv_app.hpp" //moved to ext #include "ble_comm_app.hpp" #include "ble_rx_app.hpp" #include "ble_tx_app.hpp" #include "capture_app.hpp" #include "ert_app.hpp" #include "gps_sim_app.hpp" -#include "lge_app.hpp" +// #include "lge_app.hpp" //moved to ext #include "pocsag_app.hpp" #include "replay_app.hpp" #include "soundboard_app.hpp" @@ -552,7 +552,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) { // {"ACARS", Color::yellow(), &bitmap_icon_adsb, [&nav](){ nav.push(); }}, {"ADS-B", Color::green(), &bitmap_icon_adsb, [&nav]() { nav.push(); }}, {"AIS Boats", Color::green(), &bitmap_icon_ais, [&nav]() { nav.push(); }}, - //{"Analog TV", Color::yellow(), &bitmap_icon_sstv, [&nav]() { nav.push(); }}, + //{"Analog TV", Color::yellow(), &bitmap_icon_sstv, [&nav]() { nav.push(); }}, //moved to ext {"APRS", Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push(); }}, {"Audio", Color::green(), &bitmap_icon_speaker, [&nav]() { nav.push(); }}, //{"BTLE", Color::yellow(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, @@ -560,7 +560,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) { {"BLE Rx", Color::green(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, {"ERT Meter", Color::green(), &bitmap_icon_ert, [&nav]() { nav.push(); }}, {"Level", Color::green(), &bitmap_icon_options_radio, [&nav]() { nav.push(); }}, - //{"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push(); }}, + //{"NRF", Color::yellow(), &bitmap_icon_nrf, [&nav]() { nav.push(); }}, //moved to ext {"POCSAG", Color::green(), &bitmap_icon_pocsag, [&nav]() { nav.push(); }}, {"Radiosnde", Color::green(), &bitmap_icon_sonde, [&nav]() { nav.push(); }}, {"Recon", Color::green(), &bitmap_icon_scanner, [&nav]() { nav.push(); }}, @@ -591,11 +591,11 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) { {"APRS TX", ui::Color::green(), &bitmap_icon_aprs, [&nav]() { nav.push(); }}, {"BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav]() { nav.push(); }}, {"BLE Tx", ui::Color::green(), &bitmap_icon_btle, [&nav]() { nav.push(); }}, - {"BurgerPgr", ui::Color::yellow(), &bitmap_icon_burger, [&nav]() { nav.push(); }}, + // {"BurgerPgr", ui::Color::yellow(), &bitmap_icon_burger, [&nav]() { nav.push(); }}, //moved to ext {"GPS Sim", ui::Color::green(), &bitmap_icon_gps_sim, [&nav]() { nav.push(); }}, {"Jammer", ui::Color::green(), &bitmap_icon_jammer, [&nav]() { nav.push(); }}, // { "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push(); }}, - {"LGE", ui::Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push(); }}, + // {"LGE", ui::Color::yellow(), &bitmap_icon_lge, [&nav]() { nav.push(); }}, //moved to ext {"Morse", ui::Color::green(), &bitmap_icon_morse, [&nav]() { nav.push(); }}, // { "Nuoptix DTMF", ui::Color::green(), &bitmap_icon_nuoptix, [&nav](){ nav.push(); }}, {"OOK", ui::Color::yellow(), &bitmap_icon_remote, [&nav]() { nav.push(); }}, @@ -604,7 +604,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) { {"Soundbrd", ui::Color::green(), &bitmap_icon_soundboard, [&nav]() { nav.push(); }}, {"S.Painter", ui::Color::orange(), &bitmap_icon_paint, [&nav]() { nav.push(); }}, {"SSTV", ui::Color::green(), &bitmap_icon_sstv, [&nav]() { nav.push(); }}, - {"TEDI/LCR", ui::Color::yellow(), &bitmap_icon_lcr, [&nav]() { nav.push(); }}, + // {"TEDI/LCR", ui::Color::yellow(), &bitmap_icon_lcr, [&nav]() { nav.push(); }}, //moved to ext {"TouchTune", ui::Color::green(), &bitmap_icon_touchtunes, [&nav]() { nav.push(); }}, }); diff --git a/firmware/common/ui_language.cpp b/firmware/common/ui_language.cpp new file mode 100644 index 00000000..c3199010 --- /dev/null +++ b/firmware/common/ui_language.cpp @@ -0,0 +1,18 @@ +#include "ui_language.hpp" + +const char* LanguageHelper::englishMessages[] = {"OK", "Cancel", "Error", "Modem setup", "Debug", "Log", "Done", "Start", "Stop", "Scan", "Clear", "Ready", "Data:"}; + +const char** LanguageHelper::currentMessages = englishMessages; + +void LanguageHelper::setLanguage(LanguageList lang) { + switch (lang) { + default: + case ENGLISH: + currentMessages = englishMessages; + break; + } +} + +const char* LanguageHelper::getMessage(LangConsts msg) { + return currentMessages[msg]; +} diff --git a/firmware/common/ui_language.hpp b/firmware/common/ui_language.hpp new file mode 100644 index 00000000..cec801cf --- /dev/null +++ b/firmware/common/ui_language.hpp @@ -0,0 +1,34 @@ +#ifndef __UI_LANGUAGE_H__ +#define __UI_LANGUAGE_H__ + +enum LanguageList { + ENGLISH, +}; + +enum LangConsts { + LANG_OK, + LANG_CANCEL, + LANG_ERROR, + LANG_MODEM_SETUP, + LANG_DEBUG, + LANG_LOG, + LANG_DONE, + LANG_START, + LANG_STOP, + LANG_SCAN, + LANG_CLEAR, + LANG_READY, + LANG_DATADP +}; + +class LanguageHelper { + public: + static void setLanguage(LanguageList lang); + static const char* getMessage(LangConsts msg); + static const char** currentMessages; // expose, so can link directly too + + private: + static const char* englishMessages[]; +}; + +#endif \ No newline at end of file