From b739dd883cad0f8acf9ed8d888e4433af568a243 Mon Sep 17 00:00:00 2001 From: Totoo Date: Tue, 28 Oct 2025 01:10:09 +0100 Subject: [PATCH] Free up some fw space (#2844) --- firmware/application/CMakeLists.txt | 2 - firmware/application/apps/ui_iq_trim.cpp | 2 +- firmware/application/apps/ui_subghzd.cpp | 2 +- firmware/application/apps/ui_text_editor.cpp | 2 +- .../{ui => external/analogtv}/ui_tv.cpp | 4 +- .../{ui => external/analogtv}/ui_tv.hpp | 4 +- firmware/application/external/bht_tx/bht.cpp | 1 - .../application/external/bht_tx/ui_bht_tx.hpp | 2 +- firmware/application/external/external.cmake | 148 +++++++++--------- .../external/flippertx/ui_flippertx.hpp | 2 +- .../application/{ => external/lge}/rfm69.cpp | 4 + .../application/{ => external/lge}/rfm69.hpp | 4 + .../random_password/ui_random_password.cpp | 54 ++++--- .../random_password/ui_random_password.hpp | 4 + firmware/application/metadata_file.cpp | 2 +- firmware/application/ui_record_view.cpp | 4 +- 16 files changed, 132 insertions(+), 109 deletions(-) rename firmware/application/{ui => external/analogtv}/ui_tv.cpp (99%) rename firmware/application/{ui => external/analogtv}/ui_tv.hpp (98%) rename firmware/application/{ => external/lge}/rfm69.cpp (96%) rename firmware/application/{ => external/lge}/rfm69.hpp (95%) diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 8a92d51f8..9026e3509 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -192,7 +192,6 @@ set(CPPSRC core_control.cpp database.cpp gradient.cpp - rfm69.cpp event_m0.cpp file_reader.cpp file.cpp @@ -261,7 +260,6 @@ set(CPPSRC ui/ui_receiver.cpp ui/ui_rssi.cpp ui/ui_freqlist.cpp - ui/ui_tv.cpp ui/ui_spectrum.cpp ui/ui_tabview.cpp ui/ui_textentry.cpp diff --git a/firmware/application/apps/ui_iq_trim.cpp b/firmware/application/apps/ui_iq_trim.cpp index d5cbffd4d..d8de4e6b0 100644 --- a/firmware/application/apps/ui_iq_trim.cpp +++ b/firmware/application/apps/ui_iq_trim.cpp @@ -171,7 +171,7 @@ void IQTrimView::update_range_controls(iq::TrimRange trim_range) { } void IQTrimView::profile_capture() { - power_buckets_ = {}; + power_buckets_.clear(); iq::PowerBuckets buckets{ .p = power_buckets_.data(), .size = power_buckets_.size()}; diff --git a/firmware/application/apps/ui_subghzd.cpp b/firmware/application/apps/ui_subghzd.cpp index 06ddf997c..6cd6318c5 100644 --- a/firmware/application/apps/ui_subghzd.cpp +++ b/firmware/application/apps/ui_subghzd.cpp @@ -339,7 +339,7 @@ void SubGhzDRecentEntryDetailView::parseProtocol() { if (entry_.sensorType == FPS_CAMEATOMO) { entry_.data ^= 0xFFFFFFFFFFFFFFFF; entry_.data <<= 4; - uint8_t pack[8] = {}; + uint8_t pack[8]; pack[0] = (entry_.data >> 56); pack[1] = ((entry_.data >> 48) & 0xFF); pack[2] = ((entry_.data >> 40) & 0xFF); diff --git a/firmware/application/apps/ui_text_editor.cpp b/firmware/application/apps/ui_text_editor.cpp index c96274354..ad386e5ad 100644 --- a/firmware/application/apps/ui_text_editor.cpp +++ b/firmware/application/apps/ui_text_editor.cpp @@ -612,7 +612,7 @@ void TextEditorView::open_file(const fs::path& path) { viewer.clear_file(); delete_temp_file(path_); - path_ = {}; + path_ = ""; file_dirty_ = false; has_temp_file_ = false; auto result = FileWrapper::open( diff --git a/firmware/application/ui/ui_tv.cpp b/firmware/application/external/analogtv/ui_tv.cpp similarity index 99% rename from firmware/application/ui/ui_tv.cpp rename to firmware/application/external/analogtv/ui_tv.cpp index cec989bfa..7938b03b9 100644 --- a/firmware/application/ui/ui_tv.cpp +++ b/firmware/application/external/analogtv/ui_tv.cpp @@ -34,7 +34,7 @@ using namespace portapack; #include #include -namespace ui { +namespace ui::external_app::analogtv { namespace tv { /* TimeScopeView******************************************************/ @@ -235,4 +235,4 @@ void TVWidget::on_audio_spectrum() { } } /* namespace tv */ -} /* namespace ui */ +} // namespace ui::external_app::analogtv diff --git a/firmware/application/ui/ui_tv.hpp b/firmware/application/external/analogtv/ui_tv.hpp similarity index 98% rename from firmware/application/ui/ui_tv.hpp rename to firmware/application/external/analogtv/ui_tv.hpp index 425c3c574..f1584bb67 100644 --- a/firmware/application/ui/ui_tv.hpp +++ b/firmware/application/external/analogtv/ui_tv.hpp @@ -33,7 +33,7 @@ #include #include -namespace ui { +namespace ui::external_app::analogtv { namespace tv { class TimeScopeView : public View { @@ -167,6 +167,6 @@ class TVWidget : public View { }; } /* namespace tv */ -} /* namespace ui */ +} // namespace ui::external_app::analogtv #endif /*__UI_TV_H__*/ diff --git a/firmware/application/external/bht_tx/bht.cpp b/firmware/application/external/bht_tx/bht.cpp index 6ac6f0f53..9ac8578b1 100644 --- a/firmware/application/external/bht_tx/bht.cpp +++ b/firmware/application/external/bht_tx/bht.cpp @@ -21,7 +21,6 @@ */ #include "bht.hpp" -#include "portapack_persistent_memory.hpp" namespace ui::external_app::bht_tx { diff --git a/firmware/application/external/bht_tx/ui_bht_tx.hpp b/firmware/application/external/bht_tx/ui_bht_tx.hpp index 564ae5ee2..13bbd7308 100644 --- a/firmware/application/external/bht_tx/ui_bht_tx.hpp +++ b/firmware/application/external/bht_tx/ui_bht_tx.hpp @@ -207,7 +207,7 @@ class BHTView : public View { "Scan"}; Checkbox checkbox_flashing{ - {16 * 8, 25 * 8}, + {UI_POS_X(16), 25 * 8}, 8, "Flashing"}; NumberField field_speed{ diff --git a/firmware/application/external/external.cmake b/firmware/application/external/external.cmake index 52642f24d..a32bdffbc 100644 --- a/firmware/application/external/external.cmake +++ b/firmware/application/external/external.cmake @@ -1,265 +1,267 @@ set(EXTCPPSRC - - #afsk_rx + #afsk_rx 16 byte external/afsk_rx/main.cpp external/afsk_rx/ui_afsk_rx.cpp - #calculator + #calculator 632 bytes external/calculator/main.cpp external/calculator/ui_calculator.cpp - #font_viewer + #font_viewer 8 byte?! external/font_viewer/main.cpp external/font_viewer/ui_font_viewer.cpp - #blespam + #blespam 336 bytes - array initializers? external/blespam/main.cpp external/blespam/ui_blespam.cpp - #analogtv + #analogtv 552 bytes external/analogtv/main.cpp external/analogtv/analog_tv_app.cpp + external/analogtv/ui_tv.cpp - #nrf_rx + #nrf_rx 40 byte external/nrf_rx/main.cpp external/nrf_rx/ui_nrf_rx.cpp - #coasterp + #coasterp 0 byte external/coasterp/main.cpp external/coasterp/ui_coasterp.cpp - #lge + #lge 120 byte external/lge/main.cpp external/lge/lge_app.cpp + external/lge/rfm69.cpp - #lcr + #lcr - 460 byte flash external/lcr/main.cpp external/lcr/ui_lcr.cpp - #jammer + #jammer 144 byte external/jammer/main.cpp external/jammer/ui_jammer.cpp - #gpssim + #gpssim 160 byte external/gpssim/main.cpp external/gpssim/gps_sim_app.cpp - #spainter + #spainter 464 byte external/spainter/main.cpp external/spainter/ui_spectrum_painter.cpp external/spainter/ui_spectrum_painter_text.cpp external/spainter/ui_spectrum_painter_image.cpp - #keyfob + #keyfob 216 byte external/keyfob/main.cpp external/keyfob/ui_keyfob.cpp external/keyfob/ui_keyfob.hpp - #tetris + #tetris 88 byte external/tetris/main.cpp external/tetris/ui_tetris.cpp - #extsensors + + #extsensors 192 byte external/extsensors/main.cpp external/extsensors/ui_extsensors.cpp external/extsensors/ui_extsensors.hpp - #foxhunt + #foxhunt 0 external/foxhunt/main.cpp external/foxhunt/ui_foxhunt_rx.cpp external/foxhunt/ui_foxhunt_rx.hpp - #audio_test + #audio_test 192 byte external/audio_test/main.cpp external/audio_test/ui_audio_test.cpp - #wardrivemap + #wardrivemap 64 byte external/wardrivemap/main.cpp external/wardrivemap/ui_wardrivemap.cpp - #tpmsrx + #tpmsrx 920 byte- possible shared part with baseband external/tpmsrx/main.cpp external/tpmsrx/tpms_app.cpp - #protoview + #protoview 8 byte external/protoview/main.cpp external/protoview/ui_protoview.cpp - #adsbtx + #adsbtx 3544 byte - adsb shared part external/adsbtx/main.cpp external/adsbtx/ui_adsb_tx.cpp - #morse_tx + #morse_tx 768 bytes external/morse_tx/main.cpp external/morse_tx/ui_morse.cpp - #sstvtx + #sstvtx 456 bytes external/sstvtx/main.cpp external/sstvtx/ui_sstvtx.cpp - #random + #random 464 bytes. external/random_password/main.cpp external/random_password/ui_random_password.cpp external/random_password/sha512.cpp - external/random_password/sha512.h #acars - external/acars_rx/main.cpp - external/acars_rx/acars_app.cpp + #external/acars_rx/main.cpp + #external/acars_rx/acars_app.cpp - #wefax_rx + #wefax_rx 192 bytes external/wefax_rx/main.cpp external/wefax_rx/ui_wefax_rx.cpp - #noaaapt_rx + #noaaapt_rx 72 bytes external/noaaapt_rx/main.cpp external/noaaapt_rx/ui_noaaapt_rx.cpp - - - #shoppingcart_lock + #shoppingcart_lock 272 bytes external/shoppingcart_lock/main.cpp external/shoppingcart_lock/shoppingcart_lock.cpp - #ookbrute + + #ookbrute 80 byte external/ookbrute/main.cpp external/ookbrute/ui_ookbrute.cpp - #ook_editor + #ook_editor 1808 bytes external/ook_editor/main.cpp external/ook_editor/ui_ook_editor.cpp - #cvs_spam + #cvs_spam 24 byte external/cvs_spam/main.cpp external/cvs_spam/cvs_spam.cpp - #flippertx + #flippertx 712 bytes external/flippertx/main.cpp external/flippertx/ui_flippertx.cpp - #remote + #remote 1664 bytes external/remote/main.cpp external/remote/ui_remote.cpp - #mcu_temperature + #mcu_temperature 112 external/mcu_temperature/main.cpp external/mcu_temperature/mcu_temperature.cpp - #fmradio + #fmradio 640 external/fmradio/main.cpp external/fmradio/ui_fmradio.cpp - #tuner + #tuner 384 external/tuner/main.cpp external/tuner/ui_tuner.cpp - #metronome + #metronome 696 bytes external/metronome/main.cpp external/metronome/ui_metronome.cpp - #app_manager + #app_manager 40 bytes external/app_manager/main.cpp external/app_manager/ui_app_manager.cpp - #hopper + #hopper 472 bytes external/hopper/main.cpp external/hopper/ui_hopper.cpp - # whip calculator + # whip calculator 48 bytes external/antenna_length/main.cpp external/antenna_length/ui_whipcalc.cpp - # wav viewer + # wav viewer 1232 bytes external/wav_view/main.cpp external/wav_view/ui_view_wav.cpp - # wipe sdcard + + # wipe sdcard 16 byte external/sd_wipe/main.cpp external/sd_wipe/ui_sd_wipe.cpp - # playlist editor + # playlist editor 232 bytes external/playlist_editor/main.cpp external/playlist_editor/ui_playlist_editor.cpp - #snake + #snake 240 bytes external/snake/main.cpp external/snake/ui_snake.cpp - #stopwatch + + #stopwatch 0 external/stopwatch/main.cpp external/stopwatch/ui_stopwatch.cpp - #breakout + #breakout 1144 bytes external/breakout/main.cpp external/breakout/ui_breakout.cpp - #dinogame + #dinogame 0 external/dinogame/main.cpp external/dinogame/ui_dinogame.cpp - #doom + #doom 224 external/doom/main.cpp external/doom/ui_doom.cpp - #debug_pmem + #debug_pmem 944 byte external/debug_pmem/main.cpp external/debug_pmem/ui_debug_pmem.cpp - #scanner + #scanner 520 byte external/scanner/main.cpp external/scanner/ui_scanner.cpp - #level + #level 24 byte external/level/main.cpp external/level/ui_level.cpp - #gfxEQ + #gfxEQ 80 byte external/gfxeq/main.cpp external/gfxeq/ui_gfxeq.cpp - #detector_rx + #detector_rx 168 byte external/detector_rx/main.cpp external/detector_rx/ui_detector_rx.cpp - #space_invaders + #space_invaders 0 byte external/spaceinv/main.cpp external/spaceinv/ui_spaceinv.cpp - #blackjack + #blackjack 24 byte external/blackjack/main.cpp external/blackjack/ui_blackjack.cpp - #battleship + #battleship 256 byte external/battleship/main.cpp external/battleship/ui_battleship.cpp - #ert + #ert 3040 bytes - has common with baseband, could be renamed the namespace, so both could have it, but not kept in fw. external/ert/main.cpp external/ert/ert_app.cpp - #epirb_rx + #epirb_rx 168 byte flash external/epirb_rx/main.cpp external/epirb_rx/ui_epirb_rx.cpp - #soundboard + #soundboard 272byte - 1236 bytes external/soundboard/main.cpp external/soundboard/soundboard_app.cpp - #game2048 + #game2048 - 168 byte flash external/game2048/main.cpp external/game2048/ui_game2048.cpp - #bht_tx + #bht_tx - 3920 byte flash, unknown external/bht_tx/main.cpp external/bht_tx/ui_bht_tx.cpp external/bht_tx/bht.cpp - #morse_practice + #morse_practice - 80 byte flash - bc of array initializers external/morse_practice/main.cpp external/morse_practice/ui_morse_practice.cpp - #adult_toys_controller + #adult_toys_controller 144 bytes external/adult_toys_controller/main.cpp external/adult_toys_controller/ui_adult_toys_controller.cpp ) @@ -269,8 +271,8 @@ set(EXTAPPLIST calculator font_viewer blespam - nrf_rx analogtv + nrf_rx coasterp lge lcr @@ -283,19 +285,19 @@ set(EXTAPPLIST foxhunt_rx audio_test wardrivemap - cvs_spam tpmsrx protoview adsbtx morse_tx sstvtx random_password - # acars_rx - ookbrute - ook_editor + # acars_rx --not working wefax_rx noaaapt_rx shoppingcart_lock + ookbrute + ook_editor + cvs_spam flippertx remote mcu_temperature diff --git a/firmware/application/external/flippertx/ui_flippertx.hpp b/firmware/application/external/flippertx/ui_flippertx.hpp index 27d974e30..0f30ab342 100644 --- a/firmware/application/external/flippertx/ui_flippertx.hpp +++ b/firmware/application/external/flippertx/ui_flippertx.hpp @@ -79,7 +79,7 @@ class FlipperTxView : public View { void on_tx_progress(const bool done); bool on_file_changed(std::filesystem::path new_file_path); - std::filesystem::path filename = {}; + std::filesystem::path filename = ""; FlipperProto proto = FLIPPER_PROTO_UNSUPPORTED; FlipperPreset preset = FLIPPER_PRESET_UNK; uint16_t te = 0; // for binraw diff --git a/firmware/application/rfm69.cpp b/firmware/application/external/lge/rfm69.cpp similarity index 96% rename from firmware/application/rfm69.cpp rename to firmware/application/external/lge/rfm69.cpp index 5c8971cd7..2bcf7115b 100644 --- a/firmware/application/rfm69.cpp +++ b/firmware/application/external/lge/rfm69.cpp @@ -24,6 +24,8 @@ #include "crc.hpp" #include "portapack_shared_memory.hpp" +namespace ui::external_app::lge { + uint32_t RFM69::gen_frame(std::vector& payload) { CRC<16> crc{0x1021, 0x1D0F, 0xFFFF}; std::vector frame{}; @@ -74,3 +76,5 @@ uint32_t RFM69::gen_frame(std::vector& payload) { // Copy for baseband return frame.size(); } + +} /* namespace ui::external_app::lge */ diff --git a/firmware/application/rfm69.hpp b/firmware/application/external/lge/rfm69.hpp similarity index 95% rename from firmware/application/rfm69.hpp rename to firmware/application/external/lge/rfm69.hpp index 21e42dc7d..5f298d7ed 100644 --- a/firmware/application/rfm69.hpp +++ b/firmware/application/external/lge/rfm69.hpp @@ -28,6 +28,8 @@ #include "utility.hpp" +namespace ui::external_app::lge { + class RFM69 { public: RFM69(const uint8_t num_preamble, const uint16_t sync_word, const bool CRC, const bool manchester) @@ -54,4 +56,6 @@ class RFM69 { bool manchester_{false}; }; +} /* namespace ui::external_app::lge */ + #endif /*__RFM69_H__*/ diff --git a/firmware/application/external/random_password/ui_random_password.cpp b/firmware/application/external/random_password/ui_random_password.cpp index c36236f63..5c6372eac 100644 --- a/firmware/application/external/random_password/ui_random_password.cpp +++ b/firmware/application/external/random_password/ui_random_password.cpp @@ -231,7 +231,7 @@ void RandomPasswordView::on_data(uint32_t value, bool is_data) { } void RandomPasswordView::clean_buffer() { - seeds_deque = {}; + seeds_deque.clear(); } void RandomPasswordView::on_freqchg(int64_t freq) { @@ -247,6 +247,18 @@ void RandomPasswordView::set_random_freq() { field_frequency.set_value(random_freq); } +bool RandomPasswordView::islower(char c) { + return (c >= 'a' && c <= 'z'); +} + +bool RandomPasswordView::isupper(char c) { + return (c >= 'A' && c <= 'Z'); +} + +bool RandomPasswordView::isdigit(char c) { + return (c >= '0' && c <= '9'); +} + void RandomPasswordView::new_password() { if (seeds_deque.size() < MAX_DIGITS * 2) { seeds_buffer_not_full = true; @@ -261,21 +273,21 @@ void RandomPasswordView::new_password() { int password_length = field_digits.value(); /// charset worker - if (check_digits.value()) - charset += "0123456789"; - if (check_latin_lower.value()) - charset += "abcdefghijklmnopqrstuvwxyz"; - if (check_latin_upper.value()) - charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + if (check_digits.value()) { + charset += "23456789"; + if (check_allow_confusable_chars.value()) charset += "01"; + } + if (check_latin_lower.value()) { + charset += "abcdefghijkmnpqrstuvwxyz"; + if (check_allow_confusable_chars.value()) charset += "ol"; + } + if (check_latin_upper.value()) { + charset += "ABCDEFGHIJKLMNPQRSTUVWXYZ"; + if (check_allow_confusable_chars.value()) charset += "O"; + } if (check_punctuation.value()) charset += ".,-!?"; - if (!check_allow_confusable_chars.value()) { - charset.erase(std::remove_if(charset.begin(), charset.end(), - [](char c) { return c == '0' || c == 'O' || c == 'o' || c == '1' || c == 'l'; }), - charset.end()); - } - if (charset.empty()) { text_generated_passwd.set("generate failed,"); text_char_type_hints.set("select at least 1 type"); @@ -306,11 +318,11 @@ void RandomPasswordView::new_password() { /// hint text worker for (char c : password_chars) { password += c; - if (std::isdigit(c)) { + if (isdigit(c)) { char_type_hints += "1"; - } else if (std::islower(c)) { + } else if (islower(c)) { char_type_hints += "a"; - } else if (std::isupper(c)) { + } else if (isupper(c)) { char_type_hints += "A"; } else { char_type_hints += ","; @@ -360,11 +372,11 @@ void RandomPasswordView::paint_password_hints() { for (size_t i = 0; i < password.length(); i++) { char c = password[i]; Color color; - if (std::isdigit(c)) { + if (isdigit(c)) { color = Color::red(); - } else if (std::islower(c)) { + } else if (islower(c)) { color = Color::green(); - } else if (std::isupper(c)) { + } else if (isupper(c)) { color = Color::blue(); } else { color = Color::white(); @@ -379,8 +391,8 @@ void RandomPasswordView::paint_password_hints() { std::string RandomPasswordView::generate_log_line() { std::string seeds_set = ""; - for (auto seed : seeds_deque) { - seeds_set += std::to_string(seed); + for (unsigned int seed : seeds_deque) { + seeds_set += to_string_dec_uint(seed); seeds_set += " "; } std::string line = "\npassword=" + password + diff --git a/firmware/application/external/random_password/ui_random_password.hpp b/firmware/application/external/random_password/ui_random_password.hpp index d565309cf..c87cbd859 100644 --- a/firmware/application/external/random_password/ui_random_password.hpp +++ b/firmware/application/external/random_password/ui_random_password.hpp @@ -92,6 +92,10 @@ class RandomPasswordView : public View { std::string generate_log_line(); void paint_password_hints(); + bool islower(char c); + bool isupper(char c); + bool isdigit(char c); + NavigationView& nav_; RxRadioState radio_state_{}; app_settings::SettingsManager settings_{ diff --git a/firmware/application/metadata_file.cpp b/firmware/application/metadata_file.cpp index bc5d696ec..bcddb2a99 100644 --- a/firmware/application/metadata_file.cpp +++ b/firmware/application/metadata_file.cpp @@ -114,7 +114,7 @@ Optional read_metadata_file(const fs::path& path) { } bool parse_float_meta(std::string_view str, float& out_val) { - out_val = {}; + out_val = 0.0f; if (str.size() > max_parse_int_length) return false; diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 64f7a6bf0..4fdb845b8 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -175,7 +175,7 @@ void RecordView::start() { text_record_filename.set(""); text_record_dropped.set(""); - trim_path = {}; + trim_path = ""; if (sampling_rate == 0) { return; @@ -348,7 +348,7 @@ void RecordView::trim_capture() { trim_ui.clear(); } - trim_path = {}; + trim_path = ""; } void RecordView::on_gps(const GPSPosDataMessage* msg) {