From 88ca1234d9894ddcba4eefd8925c375ad13be487 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Sun, 2 May 2021 18:54:33 +0200 Subject: [PATCH 01/33] Added GSM-NL.txt contaning Dutch GSM frequencies --- sdcard/FREQMAN/GSM-NL.TXT | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sdcard/FREQMAN/GSM-NL.TXT diff --git a/sdcard/FREQMAN/GSM-NL.TXT b/sdcard/FREQMAN/GSM-NL.TXT new file mode 100644 index 00000000..d2fadb1c --- /dev/null +++ b/sdcard/FREQMAN/GSM-NL.TXT @@ -0,0 +1,46 @@ +a=703000000,b=713000000,d=5G 700u Vodafone +a=713000000,b=723000000,d=5G 700u KPN +a=723000000,b=733000000,d=5G 700u T-Mobile +a=758000000,b=768000000,d=5G 700d Vodafone +a=768000000,b=778000000,d=5G 700d KPN +a=778000000,b=788000000,d=5G 700d T-Mobile +a=791000000,b=801000000,d=4G 800d T-Mobile +a=801000000,b=811000000,d=4G 800d Vodafone +a=811000000,b=821000000,d=4G 800d KPN +a=832000000,b=842000000,d=4G 800u T-Mobile +a=842000000,b=852000000,d=4G 800u Vodafone +a=852000000,b=862000000,d=4G 800u KPN +a=880000000,b=890000000,d=2G_3G 900u Vodafone +a=890000000,b=900000000,d=2G_3G 900u KPN +a=900000000,b=915000000,d=4G 900u T-Mobile +a=925000000,b=935000000,d=2G_3G 900d Vodafone +a=935000000,b=945000000,d=2G_3G 900d KPN +a=945000000,b=960000000,d=4G 900d T-Mobile +a=1452000000,b=1467000000,d=2G_3G 1400d Vodafone +a=1467000000,b=1482000000,d=2G_3G 1400d KPN +a=1482000000,b=1492000000,d=4G 1400d T-Mobile +a=1710000000,b=1730000000,d=4G 1800u KPN +a=1730000000,b=1750000000,d=4G 1800u Vodafone +a=1750000000,b=1780000000,d=4G 1800u T-Mobile +a=1805000000,b=1825000000,d=4G 1800d KPN +a=1825000000,b=1845000000,d=4G 1800d Vodafone +a=1845000000,b=1875000000,d=4G 1800d T-Mobile +a=1920000000,b=1940000000,d=3G_4G 2100u Vodafone +a=1940000000,b=1960000000,d=3G_4G 2100u T-Mobile +a=1960000000,b=1980000000,d=3G_4G 2100u KPN +a=2110000000,b=2130000000,d=3G_4G 2100d Vodafone +a=2130000000,b=2150000000,d=3G_4G 2100d T-Mobile +a=2150000000,b=2170000000,d=3G_4G 2100d KPN +a=2500000000,b=2510000000,d=LTE 2600u Vodafone +a=2510000000,b=2530000000,d=LTE 2600u Vodafone +a=2530000000,b=2535000000,d=LTE 2600u T-Mobile +a=2535000000,b=2545000000,d=LTE 2600u KPN +a=2545000000,b=2565000000,d=LTE 2600u T-Mobile +a=2565000000,b=2590000000,d=4G 2600d_u T-Mobile +a=2590000000,b=2620000000,d=4G 2600d_u KPN +a=2620000000,b=2630000000,d=LTE 2600d Vodafone +a=2630000000,b=2650000000,d=LTE 2600d Vodafone +a=2650000000,b=2655000000,d=LTE 2600d T-Mobile +a=2655000000,b=2665000000,d=LTE 2600d KPN +a=2665000000,b=2685000000,d=LTE 2600d T-Mobile +a=2685000000,b=2690000000,d=UNKNOWNd_u 2600 T-Mobile \ No newline at end of file From 2ab4ed591def3c9f4551ad3d7a5e1f001a21d91a Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Mon, 3 May 2021 04:00:39 +0200 Subject: [PATCH 02/33] Update ui_about_simple.cpp --- firmware/application/apps/ui_about_simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_about_simple.cpp b/firmware/application/apps/ui_about_simple.cpp index 241bbb4a..f527b485 100644 --- a/firmware/application/apps/ui_about_simple.cpp +++ b/firmware/application/apps/ui_about_simple.cpp @@ -32,7 +32,7 @@ namespace ui console.writeln("jamesshao8,ITAxReal,rascafr"); console.writeln("mcules,dqs105,strijar"); console.writeln("zhang00963,RedFox-Fr"); - console.writeln("East2West,fossum"); + console.writeln("East2West,fossum,ArjanOnwezen"); console.writeln(""); break; From 1a8319b86e5d40f1e391dce78f8328f986a32187 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 10 May 2021 16:28:46 +0200 Subject: [PATCH 03/33] /havoc/firmware/application/apps/ui_aprs_rx.cpp:51:7: warning: unused variable 'entry_age' [-Wunused-variable] /havoc/firmware/application/apps/ui_aprs_rx.cpp:345:12: warning: unused variable 'age' [-Wunused-variable] --- firmware/application/apps/ui_aprs_rx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/application/apps/ui_aprs_rx.cpp b/firmware/application/apps/ui_aprs_rx.cpp index db898a69..3c8f2eca 100644 --- a/firmware/application/apps/ui_aprs_rx.cpp +++ b/firmware/application/apps/ui_aprs_rx.cpp @@ -48,7 +48,7 @@ void RecentEntriesTable::draw( ) { char aged_color; Color target_color; - auto entry_age = entry.age; + // auto entry_age = entry.age; target_color = Color::green(); @@ -342,7 +342,7 @@ void APRSDetailsView::set_entry(const APRSRecentEntry& entry){ void APRSDetailsView::update() { if(!hidden()){ - uint32_t age = entry_copy.age; + //uint32_t age = entry_copy.age; console.clear(true); console.write(entry_copy.info_string); From a2e4a1522940513618e7f335ca0eb974476072a2 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 10 May 2021 19:17:28 +0200 Subject: [PATCH 04/33] dsp.modulelate.cpp compiler warning fix --- firmware/baseband/dsp_modulate.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/baseband/dsp_modulate.cpp b/firmware/baseband/dsp_modulate.cpp index d59c7e3e..cc9644bf 100644 --- a/firmware/baseband/dsp_modulate.cpp +++ b/firmware/baseband/dsp_modulate.cpp @@ -114,7 +114,7 @@ AM::AM() { void AM::execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) { int32_t sample = 0; - int8_t re, im; + int8_t re = 0, im = 0; float q = 0.0; for (size_t counter = 0; counter < buffer.count; counter++) { @@ -125,8 +125,8 @@ void AM::execute(const buffer_s16_t& audio, const buffer_c8_t& buffer) { q = sample / 32768.0f; q *= 64.0f; switch (mode) { - case Mode::AM: re = q + 20; im = q + 20; - case Mode::DSB: re = q; im = q; + case Mode::AM: re = q + 20; im = q + 20; break; + case Mode::DSB: re = q; im = q; break; default: break; } buffer.p[counter] = { re, im }; From f5c3219035f50c7cbfa26d124f25fa2b547e8287 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 10 May 2021 21:30:45 +0200 Subject: [PATCH 05/33] aprs_packet.hpp compiler warning fix --- firmware/common/aprs_packet.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/common/aprs_packet.hpp b/firmware/common/aprs_packet.hpp index e3d76ece..e521a955 100644 --- a/firmware/common/aprs_packet.hpp +++ b/firmware/common/aprs_packet.hpp @@ -339,9 +339,9 @@ private: std::string lat_str = ""; std::string lng_str = ""; - bool is_north; - bool is_west; - uint8_t lng_offset; + bool is_north = false; + bool is_west = false; + uint8_t lng_offset = 0; for(uint8_t i = DESTINATION_START; i < DESTINATION_START + ADDRESS_SIZE - 1; i++){ uint8_t ascii = payload[i] >> 1; From a3ef7d069e6507947e31758b6fc16755606616ca Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Tue, 11 May 2021 21:47:55 +0200 Subject: [PATCH 06/33] ui_adsb_rx.hpp compiler warning fix --- firmware/application/apps/ui_adsb_rx.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index dd7adb5a..bb474e83 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -49,7 +49,7 @@ struct AircraftRecentEntry { uint16_t hits { 0 }; uint32_t age { 0 }; adsb_pos pos { false, 0, 0, 0 }; - adsb_vel velo { false, 0, 999 }; + adsb_vel velo { false, 0, 999, 0 }; ADSBFrame frame_pos_even { }; ADSBFrame frame_pos_odd { }; From c307e9d5ae367afb155191d8f48ed7cf6a5dfae8 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Wed, 12 May 2021 08:09:04 +0200 Subject: [PATCH 07/33] proc_aprsrx.cpp compile warning fix --- firmware/baseband/proc_aprsrx.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/firmware/baseband/proc_aprsrx.cpp b/firmware/baseband/proc_aprsrx.cpp index 56249ce1..6a579ac0 100644 --- a/firmware/baseband/proc_aprsrx.cpp +++ b/firmware/baseband/proc_aprsrx.cpp @@ -141,12 +141,11 @@ bool APRSRxProcessor::parse_bit(const uint8_t current_bit){ uint8_t decoded_bit = ~(current_bit ^ last_bit) & 0x1; last_bit = current_bit; - int16_t log = decoded_bit == 0 ? -32768 : 32767; - - //if( stream ) { - // const size_t bytes_to_write = sizeof(log) * 1; -// const auto result = stream->write(&log, bytes_to_write); -// } + //int16_t log = decoded_bit == 0 ? -32768 : 32767; + //if(stream){ + // const size_t bytes_to_write = sizeof(log) * 1; + // const auto result = stream->write(&log, bytes_to_write); + //} if(decoded_bit & 0x1){ if(ones_count < 8){ From bf0b9b9881e156c861dafe1e644c9d04b6421c97 Mon Sep 17 00:00:00 2001 From: Frey Hertz Date: Fri, 14 May 2021 22:49:26 +0300 Subject: [PATCH 08/33] FrequencyStepView field in TransmitterView class --- firmware/application/ui/ui_transmitter.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/firmware/application/ui/ui_transmitter.hpp b/firmware/application/ui/ui_transmitter.hpp index da5ce799..d8d4db89 100644 --- a/firmware/application/ui/ui_transmitter.hpp +++ b/firmware/application/ui/ui_transmitter.hpp @@ -124,8 +124,8 @@ private: }; Text text_bw { - { 11 * 8, 1 * 8, 9 * 8, 1 * 16 }, - "BW: kHz" + { 18 * 8, 1 * 8, 3 * 8, 1 * 16 }, + "kHz" }; NumberField field_bw { { 14 * 8, 1 * 8 }, @@ -152,6 +152,10 @@ private: { 21 * 8, 1 * 8, 9 * 8, 32 }, "START" }; + + FrequencyStepView field_frequency_step { + { 10 * 8 - 4, 1 * 8 }, + }; void on_tuning_frequency_changed(rf::Frequency f); void on_channel_bandwidth_changed(uint32_t channel_bandwidth); From 97f3f773fb25e1198ed0f107b3af045678d59e1f Mon Sep 17 00:00:00 2001 From: Frey Hertz Date: Fri, 14 May 2021 22:57:25 +0300 Subject: [PATCH 09/33] FrequencyStepView field in TransmitterView class --- firmware/application/ui/ui_transmitter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firmware/application/ui/ui_transmitter.cpp b/firmware/application/ui/ui_transmitter.cpp index acc30574..6cfb19bf 100644 --- a/firmware/application/ui/ui_transmitter.cpp +++ b/firmware/application/ui/ui_transmitter.cpp @@ -103,6 +103,7 @@ void TransmitterView::set_transmitting(const bool transmitting) { void TransmitterView::on_show() { field_frequency.set_value(transmitter_model.tuning_frequency()); + field_frequency_step.set_by_value(receiver_model.frequency_step()); field_gain.set_value(transmitter_model.tx_gain()); field_amp.set_value(transmitter_model.rf_amp() ? 14 : 0); @@ -122,6 +123,7 @@ TransmitterView::TransmitterView( add_children({ &field_frequency, + &field_frequency_step, &text_gain, &field_gain, &button_start, @@ -157,6 +159,10 @@ TransmitterView::TransmitterView( if (on_edit_frequency) on_edit_frequency(); }; + + field_frequency_step.on_change = [this](size_t, OptionsField::value_t v) { + this->field_frequency.set_step(v); + }; field_gain.on_change = [this](uint32_t tx_gain) { on_tx_gain_changed(tx_gain); From e76609a74a87233e95c5bc09689e6ad64db21d6f Mon Sep 17 00:00:00 2001 From: Frey Hertz Date: Fri, 14 May 2021 23:00:09 +0300 Subject: [PATCH 10/33] Update ui_transmitter.hpp --- firmware/application/ui/ui_transmitter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/ui/ui_transmitter.hpp b/firmware/application/ui/ui_transmitter.hpp index d8d4db89..e38aea83 100644 --- a/firmware/application/ui/ui_transmitter.hpp +++ b/firmware/application/ui/ui_transmitter.hpp @@ -128,7 +128,7 @@ private: "kHz" }; NumberField field_bw { - { 14 * 8, 1 * 8 }, + { 15 * 8, 1 * 8 }, 3, { 1, 150 }, 1, From 6bc2cbeda9498dd004eb2f27d167e791597c97c4 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Sun, 16 May 2021 11:41:09 +0200 Subject: [PATCH 11/33] ISO datetime for Clock, FileManager, Frequency manager Added option to show/hide clock (with/without date) --- firmware/application/apps/ui_freqman.hpp | 8 ++-- firmware/application/apps/ui_settings.cpp | 17 +++++++- firmware/application/apps/ui_settings.hpp | 31 +++++++++++---- firmware/application/string_format.cpp | 14 +++---- firmware/application/ui_navigation.cpp | 16 ++++++-- firmware/application/ui_navigation.hpp | 6 ++- .../common/portapack_persistent_memory.cpp | 18 ++++++++- .../common/portapack_persistent_memory.hpp | 4 ++ firmware/common/ui_widget.cpp | 39 ++++++++++++------- firmware/common/ui_widget.hpp | 2 + 10 files changed, 114 insertions(+), 41 deletions(-) diff --git a/firmware/application/apps/ui_freqman.hpp b/firmware/application/apps/ui_freqman.hpp index 4611080b..51e93e79 100644 --- a/firmware/application/apps/ui_freqman.hpp +++ b/firmware/application/apps/ui_freqman.hpp @@ -103,19 +103,19 @@ private: }; Labels labels { - { { 2 * 8, 14 * 8 }, "Save as:", Color::white() } + { { 1 * 8, 12 * 8 }, "Save as:", Color::white() } }; Button button_save_name { - { 2 * 8, 17 * 8, 14 * 8, 48 }, + { 1 * 8, 17 * 8, 12 * 8, 48 }, "Name (set)" }; Button button_save_timestamp { - { 2 * 8, 25 * 8, 14 * 8, 48 }, + { 1 * 8, 25 * 8, 12 * 8, 48 }, "Timestamp:" }; LiveDateTime live_timestamp { - { 17 * 8, 27 * 8, 11 * 8, 16 } + { 14 * 8, 27 * 8, 16 * 8, 16 } }; }; diff --git a/firmware/application/apps/ui_settings.cpp b/firmware/application/apps/ui_settings.cpp index 7525b8dd..fbda02b7 100644 --- a/firmware/application/apps/ui_settings.cpp +++ b/firmware/application/apps/ui_settings.cpp @@ -285,15 +285,17 @@ SetUIView::SetUIView(NavigationView& nav) { &checkbox_bloff, &options_bloff, &checkbox_showsplash, + &checkbox_showclock, + &options_clockformat, &button_ok }); checkbox_speaker.set_value(persistent_memory::config_speaker()); checkbox_showsplash.set_value(persistent_memory::config_splash()); + checkbox_showclock.set_value(!persistent_memory::hide_clock()); //checkbox_login.set_value(persistent_memory::config_login()); uint32_t backlight_timer = persistent_memory::config_backlight_timer(); - if (backlight_timer) { checkbox_bloff.set_value(true); options_bloff.set_by_value(backlight_timer); @@ -301,6 +303,12 @@ SetUIView::SetUIView(NavigationView& nav) { options_bloff.set_selected_index(0); } + if (persistent_memory::clock_with_date()) { + options_clockformat.set_selected_index(1); + } else { + options_clockformat.set_selected_index(0); + } + checkbox_speaker.on_select = [this](Checkbox&, bool v) { if (v) audio::output::speaker_mute(); //Just mute audio if speaker is disabled @@ -316,7 +324,14 @@ SetUIView::SetUIView(NavigationView& nav) { else persistent_memory::set_config_backlight_timer(0); + if (checkbox_showclock.value()){ + if (options_clockformat.selected_index() == 1) + persistent_memory::set_clock_with_date(true); + else + persistent_memory::set_clock_with_date(false); + } persistent_memory::set_config_splash(checkbox_showsplash.value()); + persistent_memory::set_clock_hidden(!checkbox_showclock.value()); //persistent_memory::set_config_login(checkbox_login.value()); nav.pop(); }; diff --git a/firmware/application/apps/ui_settings.hpp b/firmware/application/apps/ui_settings.hpp index c66ccd2b..30acd820 100644 --- a/firmware/application/apps/ui_settings.hpp +++ b/firmware/application/apps/ui_settings.hpp @@ -51,8 +51,8 @@ public: private: Labels labels { - { { 6 * 8, 7 * 16 }, "YYYY/MM/DD HH:MM:SS", Color::grey() }, - { { 10 * 8, 9 * 16 }, "/ / : :", Color::light_grey() } + { { 6 * 8, 7 * 16 }, "YYYY-MM-DD HH:MM:SS", Color::grey() }, + { { 10 * 8, 9 * 16 }, "- - : :", Color::light_grey() } }; NumberField field_year { @@ -226,19 +226,19 @@ private: };*/ Checkbox checkbox_speaker { - { 3 * 8, 2 * 16 }, + { 3 * 8, 4 * 16 }, 20, "Hide H1 Speaker option" }; + Checkbox checkbox_bloff { - { 3 * 8, 5 * 16 }, + { 3 * 8, 6 * 16 }, 20, "Backlight off after:" }; - OptionsField options_bloff { - { 52, 6 * 16 + 8 }, - 10, + { 52, 7 * 16 + 8 }, + 20, { { "5 seconds", 5 }, { "15 seconds", 15 }, @@ -252,10 +252,25 @@ private: Checkbox checkbox_showsplash { { 3 * 8, 9 * 16 }, - 11, + 20, "Show splash" }; + Checkbox checkbox_showclock { + { 3 * 8, 11 * 16 }, + 20, + "Show clock with:" + }; + + OptionsField options_clockformat { + { 52, 12 * 16 + 8 }, + 20, + { + { "time only", 0 }, + { "time and date", 1 } + } + }; + Button button_ok { { 2 * 8, 16 * 16, 12 * 8, 32 }, "Save" diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 442034e4..1aa365e6 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -165,8 +165,8 @@ std::string to_string_datetime(const rtc::RTC& value, const TimeFormat format) { std::string string { "" }; if (format == YMDHMS) { - string += to_string_dec_uint(value.year(), 4) + "/" + - to_string_dec_uint(value.month(), 2, '0') + "/" + + string += to_string_dec_uint(value.year(), 4) + "-" + + to_string_dec_uint(value.month(), 2, '0') + "-" + to_string_dec_uint(value.day(), 2, '0') + " "; } @@ -189,11 +189,11 @@ std::string to_string_timestamp(const rtc::RTC& value) { } std::string to_string_FAT_timestamp(const FATTimestamp& timestamp) { - return to_string_dec_uint((timestamp.FAT_date >> 9) + 1980) + "/" + - to_string_dec_uint((timestamp.FAT_date >> 5) & 0xF, 2) + "/" + - to_string_dec_uint((timestamp.FAT_date & 0x1F), 2) + " " + - to_string_dec_uint((timestamp.FAT_time >> 11), 2) + ":" + - to_string_dec_uint((timestamp.FAT_time >> 5) & 0x3F, 2); + return to_string_dec_uint((timestamp.FAT_date >> 9) + 1980) + "-" + + to_string_dec_uint((timestamp.FAT_date >> 5) & 0xF, 2, '0') + "-" + + to_string_dec_uint((timestamp.FAT_date & 0x1F), 2, '0') + " " + + to_string_dec_uint((timestamp.FAT_time >> 11), 2, '0') + ":" + + to_string_dec_uint((timestamp.FAT_time >> 5) & 0x3F, 2, '0'); } std::string unit_auto_scale(double n, const uint32_t base_nano, uint32_t precision) { diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index c44e7b6e..e5f7f573 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -68,7 +68,7 @@ #include "ui_view_wav.hpp" #include "ui_whipcalc.hpp" -#include "acars_app.hpp" +//#include "acars_app.hpp" #include "ais_app.hpp" #include "analog_audio_app.hpp" #include "analog_tv_app.hpp" @@ -350,13 +350,21 @@ InformationView::InformationView( }); version.set_style(&style_infobar); + + ltime.set_hide_clock(portapack::persistent_memory::hide_clock()); ltime.set_style(&style_infobar); ltime.set_seconds_enabled(true); - ltime.set_date_enabled(false); - + ltime.set_date_enabled(portapack::persistent_memory::clock_with_date()); set_dirty(); } +void InformationView::refresh() { + ltime.set_hide_clock(portapack::persistent_memory::hide_clock()); + ltime.set_seconds_enabled(true); + ltime.set_date_enabled(portapack::persistent_memory::clock_with_date()); + +} + /* Navigation ************************************************************/ bool NavigationView::is_top() const { @@ -387,6 +395,7 @@ void NavigationView::pop() { update_view(); } + } void NavigationView::pop_modal() { @@ -606,6 +615,7 @@ SystemView::SystemView( } else{ add_child(&info_view); + info_view.refresh(); } this->status_view.set_back_enabled(!this->navigation_view.is_top()); diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index f7b7f45e..86ea96fb 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -212,7 +212,7 @@ private: class InformationView : public View { public: InformationView(NavigationView& nav); - + void refresh(); private: static constexpr auto version_string = "v1.4.0"; NavigationView& nav_; @@ -228,8 +228,10 @@ private: }; LiveDateTime ltime { - {174, 0, 8 * 8, 16} + {86, 0, 19 * 8, 16} }; + + }; class BMPView : public View { diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index 21f40c31..2bee6470 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -224,9 +224,17 @@ void set_playdead_sequence(const uint32_t new_value) { // ui_config is an uint32_t var storing information bitwise // bits 0,1,2 store the backlight timer -// bits 31, 30,29,28,27 stores the different single bit configs depicted below +// bits 31, 30,29,28,27, 26, 25 stores the different single bit configs depicted below // bits on position 4 to 19 (16 bits) store the clkout frequency +bool hide_clock() { // clock hidden from main menu + return data->ui_config & (1 << 25); +} + +bool clock_with_date() { // show clock with date, if not hidden + return data->ui_config & (1 << 26); +} + bool clkout_enabled() { return data->ui_config & (1 << 27); } @@ -251,6 +259,14 @@ uint32_t config_backlight_timer() { return timer_seconds[data->ui_config & 7]; //first three bits, 8 possible values } +void set_clock_hidden(bool v) { + data->ui_config = (data->ui_config & ~(1 << 25)) | (v << 25); +} + +void set_clock_with_date(bool v) { + data->ui_config = (data->ui_config & ~(1 << 26)) | (v << 26); +} + void set_clkout_enabled(bool v) { data->ui_config = (data->ui_config & ~(1 << 27)) | (v << 27); } diff --git a/firmware/common/portapack_persistent_memory.hpp b/firmware/common/portapack_persistent_memory.hpp index df0d7d0d..11643bab 100644 --- a/firmware/common/portapack_persistent_memory.hpp +++ b/firmware/common/portapack_persistent_memory.hpp @@ -75,11 +75,15 @@ bool stealth_mode(); void set_stealth_mode(const bool v); bool config_splash(); +bool hide_clock(); +bool clock_with_date(); bool config_login(); bool config_speaker(); uint32_t config_backlight_timer(); void set_config_splash(bool v); +void set_clock_hidden(bool v); +void set_clock_with_date(bool v); void set_config_login(bool v); void set_config_speaker(bool v); void set_config_backlight_timer(uint32_t i); diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 85ad91f1..79cd7cd4 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -410,23 +410,29 @@ void Labels::paint(Painter& painter) { void LiveDateTime::on_tick_second() { rtcGetTime(&RTCD1, &datetime); text = ""; - - if(date_enabled){ - text = to_string_dec_uint(datetime.month(), 2, '0') + "/" + to_string_dec_uint(datetime.day(), 2, '0') + " "; - } - - text = text + to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0'); + if(!hide_clock) { + if(date_enabled){ + text = to_string_dec_uint(datetime.year(), 4, '0') + "-" + + to_string_dec_uint(datetime.month(), 2, '0') + "-" + + to_string_dec_uint(datetime.day(), 2, '0') + " "; + } + else{ + text = " "; + } + + text = text + to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0'); - if(seconds_enabled){ - text += ":"; + if(seconds_enabled){ + text += ":"; - if(init_delay==0) - text += to_string_dec_uint(datetime.second(), 2, '0'); - else - { - // Placeholder while the seconds are not updated - text += "XX"; - init_delay--; + if(init_delay==0) + text += to_string_dec_uint(datetime.second(), 2, '0'); + else + { + // Placeholder while the seconds are not updated + text += "XX"; + init_delay--; + } } } set_dirty(); @@ -459,6 +465,9 @@ void LiveDateTime::paint(Painter& painter) { text ); } +void LiveDateTime::set_hide_clock(bool new_value){ + this->hide_clock = new_value; +} void LiveDateTime::set_date_enabled(bool new_value){ this->date_enabled = new_value; diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 71cd8f91..18ff7309 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -244,6 +244,7 @@ public: void paint(Painter& painter) override; + void set_hide_clock(bool new_value); void set_seconds_enabled(bool new_value); void set_date_enabled(bool new_value); @@ -255,6 +256,7 @@ private: void on_tick_second(); uint16_t init_delay = 4; + bool hide_clock = false; bool date_enabled = true; bool seconds_enabled = false; From d74e1830f83ca03e5e8a3608f0605bc93712a986 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Sat, 22 May 2021 20:57:48 +0100 Subject: [PATCH 12/33] Added fix in the scope of issue #365 --- firmware/application/radio.cpp | 14 ++++++-------- firmware/application/receiver_model.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/firmware/application/radio.cpp b/firmware/application/radio.cpp index 60981c70..617f22ac 100644 --- a/firmware/application/radio.cpp +++ b/firmware/application/radio.cpp @@ -111,14 +111,12 @@ void set_direction(const rf::Direction new_direction) { // Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction // Use CPLD's EEPROM config when transmitting // Use the SRAM overlay when receiving - if (direction != new_direction) { - if (new_direction == rf::Direction::Transmit) { - hackrf::cpld::init_from_eeprom(); - } else { - if( !hackrf::cpld::load_sram() ) { - chSysHalt(); - } - } + + // teixeluis: undone "Hack to fix the CPLD (clocking ?) bug". + // Apparently with current CPLD code from the hackrf repo, + // toggling CPLD overlay should no longer be necessary: + if (direction != new_direction && new_direction == rf::Direction::Transmit) { + hackrf::cpld::init_from_eeprom(); } direction = new_direction; diff --git a/firmware/application/receiver_model.cpp b/firmware/application/receiver_model.cpp index c3216654..bef08025 100644 --- a/firmware/application/receiver_model.cpp +++ b/firmware/application/receiver_model.cpp @@ -171,7 +171,11 @@ void ReceiverModel::enable() { update_baseband_bandwidth(); update_sampling_rate(); update_modulation(); + + // TODO: would challenge if this should belong to the + // receiver_model namespace: update_headphone_volume(); + led_rx.on(); } @@ -182,6 +186,10 @@ void ReceiverModel::disable() { // TODO: Responsibility for enabling/disabling the radio is muddy. // Some happens in ReceiverModel, some inside radio namespace. radio::disable(); + + // TODO: we are doing this repeatedly in different levels of the + // call stack. Keeping it for now, but there seem to be too many + // redundant calls: led_rx.off(); } From 226c0c2d8097ed04770c52dc09665232c3ea74c1 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Sun, 6 Jun 2021 00:22:55 +0200 Subject: [PATCH 13/33] fix for freq manager save file --- firmware/application/apps/ui_freqman.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/application/apps/ui_freqman.cpp b/firmware/application/apps/ui_freqman.cpp index eb728bcf..2fe3fdc2 100644 --- a/firmware/application/apps/ui_freqman.cpp +++ b/firmware/application/apps/ui_freqman.cpp @@ -48,6 +48,9 @@ FreqManBaseView::FreqManBaseView( } else error_ = ERROR_NOFILES; + // initialize + change_category(last_category_id); + // Default function on_change_category = [this](int32_t category_id) { change_category(category_id); From 9040e780bc7186bba2775a72f369a1d20879dc2f Mon Sep 17 00:00:00 2001 From: teixeluis Date: Tue, 8 Jun 2021 23:07:37 +0100 Subject: [PATCH 14/33] Added beep on radiosonde packet decoding, and volume widget to control its level. --- firmware/application/apps/ui_sonde.cpp | 36 ++++++++++++- firmware/application/apps/ui_sonde.hpp | 34 +++++++++++- firmware/baseband/proc_sonde.cpp | 71 ++++++++++++++++++++++++++ firmware/baseband/proc_sonde.hpp | 36 ++++++++++++- 4 files changed, 171 insertions(+), 6 deletions(-) diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index 66e3c576..278037dd 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -22,6 +22,7 @@ #include "ui_sonde.hpp" #include "baseband_api.hpp" +#include "audio.hpp" #include "portapack.hpp" #include @@ -50,6 +51,8 @@ SondeView::SondeView(NavigationView& nav) { &field_lna, &field_vga, &rssi, + &field_volume, + &check_beep, &check_log, &check_crc, &text_signature, @@ -80,6 +83,10 @@ SondeView::SondeView(NavigationView& nav) { geopos.set_read_only(true); + check_beep.on_select = [this](Checkbox&, bool v) { + beep = v; + }; + check_log.on_select = [this](Checkbox&, bool v) { logging = v; }; @@ -107,16 +114,30 @@ SondeView::SondeView(NavigationView& nav) { gps_info.lon, 999); //set a dummy heading out of range to draw a cross...probably not ideal? }; - + logger = std::make_unique(); if (logger) logger->append(u"sonde.txt"); + + // initialize audio: + field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99); + + field_volume.on_change = [this](int32_t v) { + this->on_headphone_volume_changed(v); + }; + + audio::output::start(); + audio::output::speaker_unmute(); + + baseband::set_pitch_rssi(0, true); } SondeView::~SondeView() { + baseband::set_pitch_rssi(0, false); radio::disable(); baseband::shutdown(); + audio::output::stop(); } void SondeView::focus() { @@ -156,15 +177,26 @@ void SondeView::on_packet(const sonde::Packet &packet) } gps_info = packet.get_GPS_data(); + geopos.set_altitude(gps_info.alt); geopos.set_lat(gps_info.lat); geopos.set_lon(gps_info.lon); - if (logger && logging) + if (logger && logging) { logger->on_packet(packet); + } + + if(beep) { + baseband::request_beep(); + } } } +void SondeView::on_headphone_volume_changed(int32_t v) { + const auto new_volume = volume_t::decibel(v - 99) + audio::headphone::volume_range().max; + receiver_model.set_headphone_volume(new_volume); +} + void SondeView::set_target_frequency(const uint32_t new_value) { target_frequency_ = new_value; radio::set_tuning_frequency(tuning_frequency()); diff --git a/firmware/application/apps/ui_sonde.hpp b/firmware/application/apps/ui_sonde.hpp index 65a397f1..73591eb3 100644 --- a/firmware/application/apps/ui_sonde.hpp +++ b/firmware/application/apps/ui_sonde.hpp @@ -55,7 +55,15 @@ class SondeView : public View { public: static constexpr uint32_t sampling_rate = 2457600; static constexpr uint32_t baseband_bandwidth = 1750000; + static constexpr int rssi_sample_range = 256; + static constexpr float rssi_voltage_min = 0.4; + static constexpr float rssi_voltage_max = 2.2; + static constexpr float adc_voltage_max = 3.3; + static constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max; + static constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max; + static constexpr int raw_delta = raw_max - raw_min; + SondeView(NavigationView& nav); ~SondeView(); @@ -68,10 +76,14 @@ private: uint32_t target_frequency_ { 402700000 }; bool logging { false }; bool use_crc { false }; + bool beep { false }; + sonde::GPS_data gps_info { }; sonde::temp_humid temp_humid_info { }; std::string sonde_id { }; + // AudioOutput audio_output { }; + Labels labels { { { 4 * 8, 2 * 16 }, "Type:", Color::light_grey() }, { { 6 * 8, 3 * 16 }, "ID:", Color::light_grey() }, @@ -103,14 +115,29 @@ private: { 21 * 8, 0, 6 * 8, 4 }, }; + NumberField field_volume { + { 28 * 8, 0 * 16 }, + 2, + { 0, 99 }, + 1, + ' ', + }; + + + Checkbox check_beep { + { 22 * 8, 6 * 16 }, + 3, + "Beep" + }; + Checkbox check_log { - { 23 * 8, 6 * 16 }, + { 22 * 8, 8 * 16 }, 3, "Log" }; Checkbox check_crc { - { 23 * 8, 8 * 16 }, + { 22 * 8, 10 * 16 }, 3, "CRC" }; @@ -170,7 +197,10 @@ private: }; void on_packet(const sonde::Packet& packet); + void on_headphone_volume_changed(int32_t v); + void set_target_frequency(const uint32_t new_value); + uint32_t tuning_frequency() const; }; diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index f670dd36..a593bec9 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -26,9 +26,14 @@ #include "event_m4.hpp" +#include "audio_output.hpp" + SondeProcessor::SondeProcessor() { + decim_0.configure(taps_11k0_decim_0.taps, 33554432); decim_1.configure(taps_11k0_decim_1.taps, 131072); + + audio_output.configure(false); } void SondeProcessor::execute(const buffer_c8_t& buffer) { @@ -47,10 +52,76 @@ void SondeProcessor::execute(const buffer_c8_t& buffer) { clock_recovery_fsk_4800(mf.get_output()); } } + + if(pitch_rssi_enabled) { + if(beep_playing) { + beep_loop(); + } + else { + silence_loop(); + } + } +} + +void SondeProcessor::on_message(const Message* const msg) { + switch(msg->id) { + case Message::ID::RequestSignal: + if ((*reinterpret_cast(msg)).signal == RequestSignalMessage::Signal::BeepRequest) { + play_beep(); + chThdSleepMilliseconds(100); + stop_beep(); + } + break; + + case Message::ID::PitchRSSIConfigure: + pitch_rssi_config(*reinterpret_cast(msg)); + break; + + default: + break; + } +} + +void SondeProcessor::play_beep() { + beep_playing = true; +} + +void SondeProcessor::stop_beep() { + beep_playing = false; +} + +void SondeProcessor::beep_loop() { + for (size_t i = 0; i < sizeof(audio_buffer.p); i++) { + audio_buffer.p[i] = (sine_table_i8[(tone_phase & 0xFF000000U) >> 24]) * 128; + tone_phase += tone_delta; + } + + audio_output.write(audio_buffer); +} + +void SondeProcessor::silence_loop() { + for (size_t i = 0; i < sizeof(audio_buffer.p); i++) { + audio_buffer.p[i] = 0; + } + + audio_output.write(audio_buffer); +} + +void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) { + // rtc::RTC datetime; + // rtcGetTime(&RTCD1, &datetime); + + // log_file.write_entry(datetime, "pitch_rssi_config: message.rssi: " + message.rssi); + + pitch_rssi_enabled = message.enabled; + tone_delta = (message.rssi * 10 + 1000) * ((1ULL << 32) / 24000); + + // log_file.write_entry(datetime, "pitch_rssi_config: tone_delta: " + tone_delta); } int main() { EventDispatcher event_dispatcher { std::make_unique() }; event_dispatcher.run(); + return 0; } diff --git a/firmware/baseband/proc_sonde.hpp b/firmware/baseband/proc_sonde.hpp index 92e53580..a7b4574f 100644 --- a/firmware/baseband/proc_sonde.hpp +++ b/firmware/baseband/proc_sonde.hpp @@ -88,6 +88,13 @@ #include "message.hpp" #include "portapack_shared_memory.hpp" +#include "audio_output.hpp" +#include "tone_gen.hpp" +#include "tonesets.hpp" +#include "sine_table_int8.hpp" + +#include "buffer.hpp" + #include #include #include @@ -97,10 +104,27 @@ public: SondeProcessor(); void execute(const buffer_c8_t& buffer) override; - + void on_message(const Message* const msg); private: + static constexpr size_t baseband_fs = 2457600; - + static constexpr size_t beep_iterations = 60; + + std::array audio { }; + + const buffer_s16_t audio_buffer { + (int16_t*) audio.data(), + sizeof(audio) / sizeof(int16_t) + }; + + AudioOutput audio_output { }; + + bool beep_playing { false }; + bool pitch_rssi_enabled { false }; + + uint32_t tone_delta { 0 }; + uint32_t tone_phase { 0 }; + BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive }; RSSIThread rssi_thread { NORMALPRIO + 10 }; @@ -149,6 +173,14 @@ private: shared_memory.application_queue.push(message); } }; + + void play_beep(); + void stop_beep(); + + void beep_loop(); + void silence_loop(); + + void pitch_rssi_config(const PitchRSSIConfigureMessage& message); }; #endif/*__PROC_ERT_H__*/ From c85e6a4d523585bd0838b06759c01bf8679e69c2 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Wed, 9 Jun 2021 09:10:01 +0100 Subject: [PATCH 15/33] Now getting rssi events.Pitch changes still to be improved. --- firmware/application/apps/ui_sonde.cpp | 7 +++++++ firmware/baseband/proc_sonde.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index 278037dd..28796cd7 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -130,6 +130,13 @@ SondeView::SondeView(NavigationView& nav) { audio::output::start(); audio::output::speaker_unmute(); + // inject a PitchRSSIConfigureMessage in order to arm + // the pitch rssi events that will be used by the + // processor: + const PitchRSSIConfigureMessage message { true, 0 }; + + shared_memory.application_queue.push(message); + baseband::set_pitch_rssi(0, true); } diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index a593bec9..4beb6eb4 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -114,7 +114,7 @@ void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) // log_file.write_entry(datetime, "pitch_rssi_config: message.rssi: " + message.rssi); pitch_rssi_enabled = message.enabled; - tone_delta = (message.rssi * 10 + 1000) * ((1ULL << 32) / 24000); + tone_delta = (message.rssi + 1000) * ((1ULL << 32) / 24000); // log_file.write_entry(datetime, "pitch_rssi_config: tone_delta: " + tone_delta); } From edcd780402273ef59d1043ccf97c98a88faba38f Mon Sep 17 00:00:00 2001 From: teixeluis Date: Thu, 10 Jun 2021 12:10:24 +0100 Subject: [PATCH 16/33] Improved the pitch RSSI. Still looking for better approach. --- firmware/application/ui/ui_rssi.cpp | 6 +- firmware/baseband/proc_sonde.cpp | 46 +++++---- firmware/baseband/proc_sonde.hpp | 9 +- firmware/common/sine_table_int16.hpp | 138 +++++++++++++++++++++++++++ firmware/common/sine_table_int8.hpp | 1 + 5 files changed, 174 insertions(+), 26 deletions(-) create mode 100644 firmware/common/sine_table_int16.hpp diff --git a/firmware/application/ui/ui_rssi.cpp b/firmware/application/ui/ui_rssi.cpp index 98cfed63..ce6acd9a 100644 --- a/firmware/application/ui/ui_rssi.cpp +++ b/firmware/application/ui/ui_rssi.cpp @@ -75,8 +75,10 @@ void RSSI::paint(Painter& painter) { Color::black() ); - if (pitch_rssi_enabled) - baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true); + if (pitch_rssi_enabled) { + //baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true); + baseband::set_pitch_rssi((min_ - raw_min) * 2000 / raw_delta, true); + } } void RSSI::set_pitch_rssi(bool enabled) { diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index 4beb6eb4..d967dbb3 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -53,13 +53,11 @@ void SondeProcessor::execute(const buffer_c8_t& buffer) { } } - if(pitch_rssi_enabled) { - if(beep_playing) { - beep_loop(); - } - else { - silence_loop(); - } + if(pitch_rssi_enabled && beep_playing) { + generate_beep(); + } + else { + generate_silence(); } } @@ -90,33 +88,41 @@ void SondeProcessor::stop_beep() { beep_playing = false; } -void SondeProcessor::beep_loop() { - for (size_t i = 0; i < sizeof(audio_buffer.p); i++) { - audio_buffer.p[i] = (sine_table_i8[(tone_phase & 0xFF000000U) >> 24]) * 128; +void SondeProcessor::generate_beep() { + // if(curr_sample == sizeof(audio_buffer.p)) { + // audio_output.write(audio_buffer); + // curr_sample = 0; + // //tone_phase = 0; + // } + // else if(beep_playing) { + // audio_buffer.p[curr_sample++] = (sine_table_i16[(tone_phase & 0xFF000000U) >> 24]); + // tone_phase += tone_delta; + // } + // else { + // audio_buffer.p[curr_sample++] = 0; + // tone_phase = 0; + // } + + for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) { + audio_buffer.p[i] = (sine_table_i16_1024[(tone_phase & 0xFFC00000U) >> 22]); tone_phase += tone_delta; } - + audio_output.write(audio_buffer); } -void SondeProcessor::silence_loop() { - for (size_t i = 0; i < sizeof(audio_buffer.p); i++) { +void SondeProcessor::generate_silence() { + for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) { audio_buffer.p[i] = 0; + tone_phase = 0; } audio_output.write(audio_buffer); } void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) { - // rtc::RTC datetime; - // rtcGetTime(&RTCD1, &datetime); - - // log_file.write_entry(datetime, "pitch_rssi_config: message.rssi: " + message.rssi); - pitch_rssi_enabled = message.enabled; tone_delta = (message.rssi + 1000) * ((1ULL << 32) / 24000); - - // log_file.write_entry(datetime, "pitch_rssi_config: tone_delta: " + tone_delta); } int main() { diff --git a/firmware/baseband/proc_sonde.hpp b/firmware/baseband/proc_sonde.hpp index a7b4574f..1662440c 100644 --- a/firmware/baseband/proc_sonde.hpp +++ b/firmware/baseband/proc_sonde.hpp @@ -91,7 +91,7 @@ #include "audio_output.hpp" #include "tone_gen.hpp" #include "tonesets.hpp" -#include "sine_table_int8.hpp" +#include "sine_table_int16.hpp" #include "buffer.hpp" @@ -110,7 +110,7 @@ private: static constexpr size_t baseband_fs = 2457600; static constexpr size_t beep_iterations = 60; - std::array audio { }; + std::array audio { }; const buffer_s16_t audio_buffer { (int16_t*) audio.data(), @@ -124,6 +124,7 @@ private: uint32_t tone_delta { 0 }; uint32_t tone_phase { 0 }; + uint8_t curr_sample { 0 }; BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive }; RSSIThread rssi_thread { NORMALPRIO + 10 }; @@ -177,8 +178,8 @@ private: void play_beep(); void stop_beep(); - void beep_loop(); - void silence_loop(); + void generate_beep(); + void generate_silence(); void pitch_rssi_config(const PitchRSSIConfigureMessage& message); }; diff --git a/firmware/common/sine_table_int16.hpp b/firmware/common/sine_table_int16.hpp new file mode 100644 index 00000000..b0dda364 --- /dev/null +++ b/firmware/common/sine_table_int16.hpp @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2015 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. + */ + +#ifndef __SINE_TABLE_I16_H__ +#define __SINE_TABLE_I16_H__ + +#include + +static const int16_t sine_table_i16[256] = { 0, 804, 1607, 2410, 3211, 4011, 4807, + 5601, 6392, 7179, 7961, 8739, 9511, 10278, 11039, 11792, 12539, 13278, 14009, 14732, + 15446, 16151, 16845, 17530, 18204, 18867, 19519, 20159, 20787, 21402, 22005, 22594, + 23170, 23731, 24279, 24811, 25329, 25832, 26319, 26790, 27245, 27683, 28105, 28510, + 28898, 29268, 29621, 29956, 30273, 30571, 30852, 31113, 31356, 31580, 31785, 31971, + 32137, 32285, 32412, 32521, 32609, 32678, 32728, 32757, 32767, 32757, 32728, 32678, + 32609, 32521, 32412, 32285, 32137, 31971, 31785, 31580, 31356, 31113, 30852, 30571, + 30273, 29956, 29621, 29268, 28898, 28510, 28105, 27683, 27245, 26790, 26319, 25832, + 25329, 24811, 24279, 23731, 23170, 22594, 22005, 21402, 20787, 20159, 19519, 18867, + 18204, 17530, 16845, 16151, 15446, 14732, 14009, 13278, 12539, 11792, 11039, 10278, + 9511, 8739, 7961, 7179, 6392, 5601, 4807, 4011, 3211, 2410, 1607, 804, 0, -805, -1608, + -2411, -3212, -4012, -4808, -5602, -6393, -7180, -7962, -8740, -9512, -10279, -11040, + -11793, -12540, -13279, -14010, -14733, -15447, -16152, -16846, -17531, -18205, -18868, + -19520, -20160, -20788, -21403, -22006, -22595, -23171, -23732, -24280, -24812, -25330, + -25833, -26320, -26791, -27246, -27684, -28106, -28511, -28899, -29269, -29622, -29957, + -30274, -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138, -32286, -32413, + -32522, -32610, -32679, -32729, -32758, -32768, -32758, -32729, -32679, -32610, -32522, + -32413, -32286, -32138, -31972, -31786, -31581, -31357, -31114, -30853, -30572, -30274, + -29957, -29622, -29269, -28899, -28511, -28106, -27684, -27246, -26791, -26320, -25833, + -25330, -24812, -24280, -23732, -23171, -22595, -22006, -21403, -20788, -20160, -19520, + -18868, -18205, -17531, -16846, -16152, -15447, -14733, -14010, -13279, -12540, -11793, + -11040, -10279, -9512, -8740, -7962, -7180, -6393, -5602, -4808, -4012, -3212, -2411, + -1608, -805 }; + +static const int16_t sine_table_i16_1024[1024] = {0, 201, 402, 603, 804, 1005, 1206, 1406, + 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, 3211, 3411, 3611, 3811, 4011, 4210, 4409, + 4609, 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, 6392, 6589, 6786, 6983, 7179, 7375, + 7571, 7766, 7961, 8156, 8351, 8545, 8739, 8933, 9126, 9319, 9511, 9704, 9895, 10087, 10278, + 10469, 10659, 10849, 11039, 11228, 11416, 11605, 11792, 11980, 12167, 12353, 12539, 12725, + 12910, 13094, 13278, 13462, 13645, 13827, 14009, 14191, 14372, 14552, 14732, 14911, 15090, + 15268, 15446, 15623, 15799, 15975, 16151, 16325, 16499, 16673, 16845, 17017, 17189, 17360, + 17530, 17700, 17868, 18037, 18204, 18371, 18537, 18703, 18867, 19031, 19195, 19357, 19519, + 19680, 19841, 20000, 20159, 20317, 20475, 20631, 20787, 20942, 21096, 21250, 21402, 21554, + 21705, 21855, 22005, 22153, 22301, 22448, 22594, 22739, 22884, 23027, 23170, 23311, 23452, + 23592, 23731, 23869, 24007, 24143, 24279, 24413, 24547, 24680, 24811, 24942, 25072, 25201, + 25329, 25456, 25582, 25707, 25832, 25955, 26077, 26198, 26319, 26438, 26556, 26673, 26790, + 26905, 27019, 27132, 27245, 27356, 27466, 27575, 27683, 27790, 27896, 28001, 28105, 28208, + 28310, 28410, 28510, 28609, 28706, 28803, 28898, 28992, 29085, 29177, 29268, 29358, 29447, + 29534, 29621, 29706, 29791, 29874, 29956, 30037, 30117, 30195, 30273, 30349, 30424, 30498, + 30571, 30643, 30714, 30783, 30852, 30919, 30985, 31050, 31113, 31176, 31237, 31297, 31356, + 31414, 31470, 31526, 31580, 31633, 31685, 31736, 31785, 31833, 31880, 31926, 31971, 32014, + 32057, 32098, 32137, 32176, 32213, 32250, 32285, 32318, 32351, 32382, 32412, 32441, 32469, + 32495, 32521, 32545, 32567, 32589, 32609, 32628, 32646, 32663, 32678, 32692, 32705, 32717, + 32728, 32737, 32745, 32752, 32757, 32761, 32765, 32766, 32767, 32766, 32765, 32761, 32757, + 32752, 32745, 32737, 32728, 32717, 32705, 32692, 32678, 32663, 32646, 32628, 32609, 32589, + 32567, 32545, 32521, 32495, 32469, 32441, 32412, 32382, 32351, 32318, 32285, 32250, 32213, + 32176, 32137, 32098, 32057, 32014, 31971, 31926, 31880, 31833, 31785, 31736, 31685, 31633, + 31580, 31526, 31470, 31414, 31356, 31297, 31237, 31176, 31113, 31050, 30985, 30919, 30852, + 30783, 30714, 30643, 30571, 30498, 30424, 30349, 30273, 30195, 30117, 30037, 29956, 29874, + 29791, 29706, 29621, 29534, 29447, 29358, 29268, 29177, 29085, 28992, 28898, 28803, 28706, + 28609, 28510, 28410, 28310, 28208, 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27356, + 27245, 27132, 27019, 26905, 26790, 26673, 26556, 26438, 26319, 26198, 26077, 25955, 25832, + 25707, 25582, 25456, 25329, 25201, 25072, 24942, 24811, 24680, 24547, 24413, 24279, 24143, + 24007, 23869, 23731, 23592, 23452, 23311, 23170, 23027, 22884, 22739, 22594, 22448, 22301, + 22153, 22005, 21855, 21705, 21554, 21402, 21250, 21096, 20942, 20787, 20631, 20475, 20317, + 20159, 20000, 19841, 19680, 19519, 19357, 19195, 19031, 18867, 18703, 18537, 18371, 18204, + 18037, 17868, 17700, 17530, 17360, 17189, 17017, 16845, 16673, 16499, 16325, 16151, 15975, + 15799, 15623, 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 14009, 13827, 13645, + 13462, 13278, 13094, 12910, 12725, 12539, 12353, 12167, 11980, 11792, 11605, 11416, 11228, + 11039, 10849, 10659, 10469, 10278, 10087, 9895, 9704, 9511, 9319, 9126, 8933, 8739, 8545, + 8351, 8156, 7961, 7766, 7571, 7375, 7179, 6983, 6786, 6589, 6392, 6195, 5997, 5799, 5601, + 5403, 5205, 5006, 4807, 4609, 4409, 4210, 4011, 3811, 3611, 3411, 3211, 3011, 2811, 2610, + 2410, 2209, 2009, 1808, 1607, 1406, 1206, 1005, 804, 603, 402, 201, 0, -202, -403, -604, + -805, -1006, -1207, -1407, -1608, -1809, -2010, -2210, -2411, -2611, -2812, -3012, -3212, + -3412, -3612, -3812, -4012, -4211, -4410, -4610, -4808, -5007, -5206, -5404, -5602, -5800, + -5998, -6196, -6393, -6590, -6787, -6984, -7180, -7376, -7572, -7767, -7962, -8157, -8352, + -8546, -8740, -8934, -9127, -9320, -9512, -9705, -9896, -10088, -10279, -10470, -10660, + -10850, -11040, -11229, -11417, -11606, -11793, -11981, -12168, -12354, -12540, -12726, + -12911, -13095, -13279, -13463, -13646, -13828, -14010, -14192, -14373, -14553, -14733, + -14912, -15091, -15269, -15447, -15624, -15800, -15976, -16152, -16326, -16500, -16674, + -16846, -17018, -17190, -17361, -17531, -17701, -17869, -18038, -18205, -18372, -18538, + -18704, -18868, -19032, -19196, -19358, -19520, -19681, -19842, -20001, -20160, -20318, + -20476, -20632, -20788, -20943, -21097, -21251, -21403, -21555, -21706, -21856, -22006, + -22154, -22302, -22449, -22595, -22740, -22885, -23028, -23171, -23312, -23453, -23593, + -23732, -23870, -24008, -24144, -24280, -24414, -24548, -24681, -24812, -24943, -25073, + -25202, -25330, -25457, -25583, -25708, -25833, -25956, -26078, -26199, -26320, -26439, + -26557, -26674, -26791, -26906, -27020, -27133, -27246, -27357, -27467, -27576, -27684, + -27791, -27897, -28002, -28106, -28209, -28311, -28411, -28511, -28610, -28707, -28804, + -28899, -28993, -29086, -29178, -29269, -29359, -29448, -29535, -29622, -29707, -29792, + -29875, -29957, -30038, -30118, -30196, -30274, -30350, -30425, -30499, -30572, -30644, + -30715, -30784, -30853, -30920, -30986, -31051, -31114, -31177, -31238, -31298, -31357, + -31415, -31471, -31527, -31581, -31634, -31686, -31737, -31786, -31834, -31881, -31927, + -31972, -32015, -32058, -32099, -32138, -32177, -32214, -32251, -32286, -32319, -32352, + -32383, -32413, -32442, -32470, -32496, -32522, -32546, -32568, -32590, -32610, -32629, + -32647, -32664, -32679, -32693, -32706, -32718, -32729, -32738, -32746, -32753, -32758, + -32762, -32766, -32767, -32768, -32767, -32766, -32762, -32758, -32753, -32746, -32738, + -32729, -32718, -32706, -32693, -32679, -32664, -32647, -32629, -32610, -32590, -32568, + -32546, -32522, -32496, -32470, -32442, -32413, -32383, -32352, -32319, -32286, -32251, + -32214, -32177, -32138, -32099, -32058, -32015, -31972, -31927, -31881, -31834, -31786, + -31737, -31686, -31634, -31581, -31527, -31471, -31415, -31357, -31298, -31238, -31177, + -31114, -31051, -30986, -30920, -30853, -30784, -30715, -30644, -30572, -30499, -30425, + -30350, -30274, -30196, -30118, -30038, -29957, -29875, -29792, -29707, -29622, -29535, + -29448, -29359, -29269, -29178, -29086, -28993, -28899, -28804, -28707, -28610, -28511, + -28411, -28311, -28209, -28106, -28002, -27897, -27791, -27684, -27576, -27467, -27357, + -27246, -27133, -27020, -26906, -26791, -26674, -26557, -26439, -26320, -26199, -26078, + -25956, -25833, -25708, -25583, -25457, -25330, -25202, -25073, -24943, -24812, -24681, + -24548, -24414, -24280, -24144, -24008, -23870, -23732, -23593, -23453, -23312, -23171, + -23028, -22885, -22740, -22595, -22449, -22302, -22154, -22006, -21856, -21706, -21555, + -21403, -21251, -21097, -20943, -20788, -20632, -20476, -20318, -20160, -20001, -19842, + -19681, -19520, -19358, -19196, -19032, -18868, -18704, -18538, -18372, -18205, -18038, + -17869, -17701, -17531, -17361, -17190, -17018, -16846, -16674, -16500, -16326, -16152, + -15976, -15800, -15624, -15447, -15269, -15091, -14912, -14733, -14553, -14373, -14192, + -14010, -13828, -13646, -13463, -13279, -13095, -12911, -12726, -12540, -12354, -12168, + -11981, -11793, -11606, -11417, -11229, -11040, -10850, -10660, -10470, -10279, -10088, + -9896, -9705, -9512, -9320, -9127, -8934, -8740, -8546, -8352, -8157, -7962, -7767, + -7572, -7376, -7180, -6984, -6787, -6590, -6393, -6196, -5998, -5800, -5602, -5404, + -5206, -5007, -4808, -4610, -4410, -4211, -4012, -3812, -3612, -3412, -3212, -3012, + -2812, -2611, -2411, -2210, -2010, -1809, -1608, -1407, -1207, -1006, -805, -604, + -403, -202 }; + +#endif/*__SINE_TABLE_I16_H__*/ diff --git a/firmware/common/sine_table_int8.hpp b/firmware/common/sine_table_int8.hpp index 828b6db5..0583fa67 100644 --- a/firmware/common/sine_table_int8.hpp +++ b/firmware/common/sine_table_int8.hpp @@ -44,4 +44,5 @@ static const int8_t sine_table_i8[256] = { -49, -46, -43, -40, -37, -34, -31, -28, -25, -22, -19, -16, -13, -9, -6, -3 }; + #endif/*__SINE_TABLE_I8_H__*/ From c2dc7d1cf58d424d3ea4f03d7d0d9683e27f3fff Mon Sep 17 00:00:00 2001 From: teixeluis Date: Fri, 11 Jun 2021 00:13:56 +0100 Subject: [PATCH 17/33] Slight improvement of the tone generator. --- firmware/application/ui/ui_rssi.cpp | 3 +- firmware/baseband/proc_sonde.cpp | 51 ++++++++++++++-------------- firmware/baseband/proc_sonde.hpp | 19 +++++++---- firmware/baseband/tone_gen.cpp | 41 ++++++++++++++++++++-- firmware/baseband/tone_gen.hpp | 21 +++++++++++- firmware/common/sine_table_int16.hpp | 2 +- 6 files changed, 99 insertions(+), 38 deletions(-) diff --git a/firmware/application/ui/ui_rssi.cpp b/firmware/application/ui/ui_rssi.cpp index ce6acd9a..84487b16 100644 --- a/firmware/application/ui/ui_rssi.cpp +++ b/firmware/application/ui/ui_rssi.cpp @@ -76,8 +76,7 @@ void RSSI::paint(Painter& painter) { ); if (pitch_rssi_enabled) { - //baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true); - baseband::set_pitch_rssi((min_ - raw_min) * 2000 / raw_delta, true); + baseband::set_pitch_rssi((avg_ - raw_min) * 2000 / raw_delta, true); } } diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index d967dbb3..b7397a31 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -34,6 +34,8 @@ SondeProcessor::SondeProcessor() { decim_1.configure(taps_11k0_decim_1.taps, 131072); audio_output.configure(false); + + tone_gen.configure(0, 1, ToneGen::tone_type::square); } void SondeProcessor::execute(const buffer_c8_t& buffer) { @@ -53,11 +55,21 @@ void SondeProcessor::execute(const buffer_c8_t& buffer) { } } - if(pitch_rssi_enabled && beep_playing) { - generate_beep(); - } - else { - generate_silence(); + if(pitch_rssi_enabled) { + if(beep_play) { + // if we let the buffer underrun, for some reason + // once it starts looping it ignores zero (silence) + // samples, so we need to keep feeding the buffer + // and not be able to take advantage of the circular + // buffer loop: + //beep_play = false; + generate_beep(); + } + + if(silence_play) { + //silence_play = false; + generate_silence(); + } } } @@ -66,7 +78,7 @@ void SondeProcessor::on_message(const Message* const msg) { case Message::ID::RequestSignal: if ((*reinterpret_cast(msg)).signal == RequestSignalMessage::Signal::BeepRequest) { play_beep(); - chThdSleepMilliseconds(100); + chThdSleepMilliseconds(150); stop_beep(); } break; @@ -81,31 +93,20 @@ void SondeProcessor::on_message(const Message* const msg) { } void SondeProcessor::play_beep() { - beep_playing = true; + beep_play = true; + silence_play = false; } void SondeProcessor::stop_beep() { - beep_playing = false; + beep_play = false; + silence_play = true; } void SondeProcessor::generate_beep() { - // if(curr_sample == sizeof(audio_buffer.p)) { - // audio_output.write(audio_buffer); - // curr_sample = 0; - // //tone_phase = 0; - // } - // else if(beep_playing) { - // audio_buffer.p[curr_sample++] = (sine_table_i16[(tone_phase & 0xFF000000U) >> 24]); - // tone_phase += tone_delta; - // } - // else { - // audio_buffer.p[curr_sample++] = 0; - // tone_phase = 0; - // } + // here we let the samples be created using the ToneGen class: for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) { - audio_buffer.p[i] = (sine_table_i16_1024[(tone_phase & 0xFFC00000U) >> 22]); - tone_phase += tone_delta; + audio_buffer.p[i] = (int16_t) ((tone_gen.process(0) >> 16) & 0x0000FFFF); } audio_output.write(audio_buffer); @@ -114,7 +115,6 @@ void SondeProcessor::generate_beep() { void SondeProcessor::generate_silence() { for(uint8_t i = 0; i < sizeof(audio_buffer.p); i++) { audio_buffer.p[i] = 0; - tone_phase = 0; } audio_output.write(audio_buffer); @@ -122,7 +122,8 @@ void SondeProcessor::generate_silence() { void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) { pitch_rssi_enabled = message.enabled; - tone_delta = (message.rssi + 1000) * ((1ULL << 32) / 24000); + uint32_t tone_delta = (message.rssi + 1000) * ((1ULL << 32) / 24000); + tone_gen.configure(tone_delta, 1.0, ToneGen::tone_type::square); } int main() { diff --git a/firmware/baseband/proc_sonde.hpp b/firmware/baseband/proc_sonde.hpp index 1662440c..108c4066 100644 --- a/firmware/baseband/proc_sonde.hpp +++ b/firmware/baseband/proc_sonde.hpp @@ -90,8 +90,6 @@ #include "audio_output.hpp" #include "tone_gen.hpp" -#include "tonesets.hpp" -#include "sine_table_int16.hpp" #include "buffer.hpp" @@ -108,7 +106,6 @@ public: private: static constexpr size_t baseband_fs = 2457600; - static constexpr size_t beep_iterations = 60; std::array audio { }; @@ -119,12 +116,11 @@ private: AudioOutput audio_output { }; - bool beep_playing { false }; + bool beep_play { false }; + bool silence_play { false }; bool pitch_rssi_enabled { false }; - uint32_t tone_delta { 0 }; - uint32_t tone_phase { 0 }; - uint8_t curr_sample { 0 }; + ToneGen tone_gen { }; BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive }; RSSIThread rssi_thread { NORMALPRIO + 10 }; @@ -178,7 +174,16 @@ private: void play_beep(); void stop_beep(); + /** + * Used for filling the audio buffer with the waveform + * generated by the ToneGen class: + * + */ void generate_beep(); + + /** + * Used for filling the audio buffer with silence: + */ void generate_silence(); void pitch_rssi_config(const PitchRSSIConfigureMessage& message); diff --git a/firmware/baseband/tone_gen.cpp b/firmware/baseband/tone_gen.cpp index bbe5587e..d2185f53 100644 --- a/firmware/baseband/tone_gen.cpp +++ b/firmware/baseband/tone_gen.cpp @@ -23,18 +23,55 @@ #include "tone_gen.hpp" #include "sine_table_int8.hpp" + +int32_t ToneGen::tone_from_sine_table() { + int32_t tone_sample = sine_table_i8[(tone_phase_ & 0xFF000000U) >> 24] << 24; + tone_phase_ += delta_; + + return tone_sample; +} + +int32_t ToneGen::tone_square() { + int32_t tone_sample = 0; + + if(tone_phase_ < (UINT32_MAX / 2)) { + tone_sample = INT32_MAX; + } + else { + tone_sample = INT32_MIN; + } + + tone_phase_ += delta_; + + return tone_sample; +} + void ToneGen::configure(const uint32_t delta, const float tone_mix_weight) { delta_ = delta; tone_mix_weight_ = tone_mix_weight; input_mix_weight_ = 1.0 - tone_mix_weight; + current_tone_type_ = sine; +} + +void ToneGen::configure(const uint32_t delta, const float tone_mix_weight, const tone_type tone_type) { + delta_ = delta; + tone_mix_weight_ = tone_mix_weight; + input_mix_weight_ = 1.0 - tone_mix_weight; + current_tone_type_ = tone_type; } int32_t ToneGen::process(const int32_t sample_in) { if (!delta_) return sample_in; - int32_t tone_sample = sine_table_i8[(tone_phase_ & 0xFF000000U) >> 24]; - tone_phase_ += delta_; + int32_t tone_sample = 0; + + if(current_tone_type_ == sine) { + tone_sample = tone_from_sine_table(); + } + else if(current_tone_type_ == square) { + tone_sample = tone_square(); + } return (sample_in * input_mix_weight_) + (tone_sample * tone_mix_weight_); } diff --git a/firmware/baseband/tone_gen.hpp b/firmware/baseband/tone_gen.hpp index ef547f26..d12782c1 100644 --- a/firmware/baseband/tone_gen.hpp +++ b/firmware/baseband/tone_gen.hpp @@ -25,22 +25,41 @@ #include #include +#include + +static const std::bitset<2048> wave_bits (0xFFFFFF); class ToneGen { public: + enum tone_type { sine, square }; + /*ToneGen(const size_t sample_rate ) : sample_rate_ { sample_rate } {};*/ void configure(const uint32_t delta, const float tone_mix_weight); + void configure(const uint32_t delta, const float tone_mix_weight, const tone_type tone_type); + int32_t process(const int32_t sample_in); private: + tone_type current_tone_type_ { sine }; + //size_t sample_rate_; float input_mix_weight_ { 1 }; float tone_mix_weight_ { 0 }; uint32_t delta_ { 0 }; uint32_t tone_phase_ { 0 }; + + /** + * Generator function for sine waves: + */ + int32_t tone_from_sine_table(); + + /** + * Generator function for square waves: + */ + int32_t tone_square(); }; -#endif +#endif /* __TONE_GEN_H__ */ diff --git a/firmware/common/sine_table_int16.hpp b/firmware/common/sine_table_int16.hpp index b0dda364..0909a75c 100644 --- a/firmware/common/sine_table_int16.hpp +++ b/firmware/common/sine_table_int16.hpp @@ -25,7 +25,7 @@ #include -static const int16_t sine_table_i16[256] = { 0, 804, 1607, 2410, 3211, 4011, 4807, +static const int16_t sine_table_i16_256[256] = { 0, 804, 1607, 2410, 3211, 4011, 4807, 5601, 6392, 7179, 7961, 8739, 9511, 10278, 11039, 11792, 12539, 13278, 14009, 14732, 15446, 16151, 16845, 17530, 18204, 18867, 19519, 20159, 20787, 21402, 22005, 22594, 23170, 23731, 24279, 24811, 25329, 25832, 26319, 26790, 27245, 27683, 28105, 28510, From 43e123bafe99a0e60b9e43e6a646ae57e2a0399a Mon Sep 17 00:00:00 2001 From: teixeluis Date: Fri, 11 Jun 2021 00:25:24 +0100 Subject: [PATCH 18/33] Used temporarily for experimental purposes, no longer needed. --- firmware/common/sine_table_int16.hpp | 138 --------------------------- 1 file changed, 138 deletions(-) delete mode 100644 firmware/common/sine_table_int16.hpp diff --git a/firmware/common/sine_table_int16.hpp b/firmware/common/sine_table_int16.hpp deleted file mode 100644 index 0909a75c..00000000 --- a/firmware/common/sine_table_int16.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef __SINE_TABLE_I16_H__ -#define __SINE_TABLE_I16_H__ - -#include - -static const int16_t sine_table_i16_256[256] = { 0, 804, 1607, 2410, 3211, 4011, 4807, - 5601, 6392, 7179, 7961, 8739, 9511, 10278, 11039, 11792, 12539, 13278, 14009, 14732, - 15446, 16151, 16845, 17530, 18204, 18867, 19519, 20159, 20787, 21402, 22005, 22594, - 23170, 23731, 24279, 24811, 25329, 25832, 26319, 26790, 27245, 27683, 28105, 28510, - 28898, 29268, 29621, 29956, 30273, 30571, 30852, 31113, 31356, 31580, 31785, 31971, - 32137, 32285, 32412, 32521, 32609, 32678, 32728, 32757, 32767, 32757, 32728, 32678, - 32609, 32521, 32412, 32285, 32137, 31971, 31785, 31580, 31356, 31113, 30852, 30571, - 30273, 29956, 29621, 29268, 28898, 28510, 28105, 27683, 27245, 26790, 26319, 25832, - 25329, 24811, 24279, 23731, 23170, 22594, 22005, 21402, 20787, 20159, 19519, 18867, - 18204, 17530, 16845, 16151, 15446, 14732, 14009, 13278, 12539, 11792, 11039, 10278, - 9511, 8739, 7961, 7179, 6392, 5601, 4807, 4011, 3211, 2410, 1607, 804, 0, -805, -1608, - -2411, -3212, -4012, -4808, -5602, -6393, -7180, -7962, -8740, -9512, -10279, -11040, - -11793, -12540, -13279, -14010, -14733, -15447, -16152, -16846, -17531, -18205, -18868, - -19520, -20160, -20788, -21403, -22006, -22595, -23171, -23732, -24280, -24812, -25330, - -25833, -26320, -26791, -27246, -27684, -28106, -28511, -28899, -29269, -29622, -29957, - -30274, -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138, -32286, -32413, - -32522, -32610, -32679, -32729, -32758, -32768, -32758, -32729, -32679, -32610, -32522, - -32413, -32286, -32138, -31972, -31786, -31581, -31357, -31114, -30853, -30572, -30274, - -29957, -29622, -29269, -28899, -28511, -28106, -27684, -27246, -26791, -26320, -25833, - -25330, -24812, -24280, -23732, -23171, -22595, -22006, -21403, -20788, -20160, -19520, - -18868, -18205, -17531, -16846, -16152, -15447, -14733, -14010, -13279, -12540, -11793, - -11040, -10279, -9512, -8740, -7962, -7180, -6393, -5602, -4808, -4012, -3212, -2411, - -1608, -805 }; - -static const int16_t sine_table_i16_1024[1024] = {0, 201, 402, 603, 804, 1005, 1206, 1406, - 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, 3211, 3411, 3611, 3811, 4011, 4210, 4409, - 4609, 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, 6392, 6589, 6786, 6983, 7179, 7375, - 7571, 7766, 7961, 8156, 8351, 8545, 8739, 8933, 9126, 9319, 9511, 9704, 9895, 10087, 10278, - 10469, 10659, 10849, 11039, 11228, 11416, 11605, 11792, 11980, 12167, 12353, 12539, 12725, - 12910, 13094, 13278, 13462, 13645, 13827, 14009, 14191, 14372, 14552, 14732, 14911, 15090, - 15268, 15446, 15623, 15799, 15975, 16151, 16325, 16499, 16673, 16845, 17017, 17189, 17360, - 17530, 17700, 17868, 18037, 18204, 18371, 18537, 18703, 18867, 19031, 19195, 19357, 19519, - 19680, 19841, 20000, 20159, 20317, 20475, 20631, 20787, 20942, 21096, 21250, 21402, 21554, - 21705, 21855, 22005, 22153, 22301, 22448, 22594, 22739, 22884, 23027, 23170, 23311, 23452, - 23592, 23731, 23869, 24007, 24143, 24279, 24413, 24547, 24680, 24811, 24942, 25072, 25201, - 25329, 25456, 25582, 25707, 25832, 25955, 26077, 26198, 26319, 26438, 26556, 26673, 26790, - 26905, 27019, 27132, 27245, 27356, 27466, 27575, 27683, 27790, 27896, 28001, 28105, 28208, - 28310, 28410, 28510, 28609, 28706, 28803, 28898, 28992, 29085, 29177, 29268, 29358, 29447, - 29534, 29621, 29706, 29791, 29874, 29956, 30037, 30117, 30195, 30273, 30349, 30424, 30498, - 30571, 30643, 30714, 30783, 30852, 30919, 30985, 31050, 31113, 31176, 31237, 31297, 31356, - 31414, 31470, 31526, 31580, 31633, 31685, 31736, 31785, 31833, 31880, 31926, 31971, 32014, - 32057, 32098, 32137, 32176, 32213, 32250, 32285, 32318, 32351, 32382, 32412, 32441, 32469, - 32495, 32521, 32545, 32567, 32589, 32609, 32628, 32646, 32663, 32678, 32692, 32705, 32717, - 32728, 32737, 32745, 32752, 32757, 32761, 32765, 32766, 32767, 32766, 32765, 32761, 32757, - 32752, 32745, 32737, 32728, 32717, 32705, 32692, 32678, 32663, 32646, 32628, 32609, 32589, - 32567, 32545, 32521, 32495, 32469, 32441, 32412, 32382, 32351, 32318, 32285, 32250, 32213, - 32176, 32137, 32098, 32057, 32014, 31971, 31926, 31880, 31833, 31785, 31736, 31685, 31633, - 31580, 31526, 31470, 31414, 31356, 31297, 31237, 31176, 31113, 31050, 30985, 30919, 30852, - 30783, 30714, 30643, 30571, 30498, 30424, 30349, 30273, 30195, 30117, 30037, 29956, 29874, - 29791, 29706, 29621, 29534, 29447, 29358, 29268, 29177, 29085, 28992, 28898, 28803, 28706, - 28609, 28510, 28410, 28310, 28208, 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27356, - 27245, 27132, 27019, 26905, 26790, 26673, 26556, 26438, 26319, 26198, 26077, 25955, 25832, - 25707, 25582, 25456, 25329, 25201, 25072, 24942, 24811, 24680, 24547, 24413, 24279, 24143, - 24007, 23869, 23731, 23592, 23452, 23311, 23170, 23027, 22884, 22739, 22594, 22448, 22301, - 22153, 22005, 21855, 21705, 21554, 21402, 21250, 21096, 20942, 20787, 20631, 20475, 20317, - 20159, 20000, 19841, 19680, 19519, 19357, 19195, 19031, 18867, 18703, 18537, 18371, 18204, - 18037, 17868, 17700, 17530, 17360, 17189, 17017, 16845, 16673, 16499, 16325, 16151, 15975, - 15799, 15623, 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, 14009, 13827, 13645, - 13462, 13278, 13094, 12910, 12725, 12539, 12353, 12167, 11980, 11792, 11605, 11416, 11228, - 11039, 10849, 10659, 10469, 10278, 10087, 9895, 9704, 9511, 9319, 9126, 8933, 8739, 8545, - 8351, 8156, 7961, 7766, 7571, 7375, 7179, 6983, 6786, 6589, 6392, 6195, 5997, 5799, 5601, - 5403, 5205, 5006, 4807, 4609, 4409, 4210, 4011, 3811, 3611, 3411, 3211, 3011, 2811, 2610, - 2410, 2209, 2009, 1808, 1607, 1406, 1206, 1005, 804, 603, 402, 201, 0, -202, -403, -604, - -805, -1006, -1207, -1407, -1608, -1809, -2010, -2210, -2411, -2611, -2812, -3012, -3212, - -3412, -3612, -3812, -4012, -4211, -4410, -4610, -4808, -5007, -5206, -5404, -5602, -5800, - -5998, -6196, -6393, -6590, -6787, -6984, -7180, -7376, -7572, -7767, -7962, -8157, -8352, - -8546, -8740, -8934, -9127, -9320, -9512, -9705, -9896, -10088, -10279, -10470, -10660, - -10850, -11040, -11229, -11417, -11606, -11793, -11981, -12168, -12354, -12540, -12726, - -12911, -13095, -13279, -13463, -13646, -13828, -14010, -14192, -14373, -14553, -14733, - -14912, -15091, -15269, -15447, -15624, -15800, -15976, -16152, -16326, -16500, -16674, - -16846, -17018, -17190, -17361, -17531, -17701, -17869, -18038, -18205, -18372, -18538, - -18704, -18868, -19032, -19196, -19358, -19520, -19681, -19842, -20001, -20160, -20318, - -20476, -20632, -20788, -20943, -21097, -21251, -21403, -21555, -21706, -21856, -22006, - -22154, -22302, -22449, -22595, -22740, -22885, -23028, -23171, -23312, -23453, -23593, - -23732, -23870, -24008, -24144, -24280, -24414, -24548, -24681, -24812, -24943, -25073, - -25202, -25330, -25457, -25583, -25708, -25833, -25956, -26078, -26199, -26320, -26439, - -26557, -26674, -26791, -26906, -27020, -27133, -27246, -27357, -27467, -27576, -27684, - -27791, -27897, -28002, -28106, -28209, -28311, -28411, -28511, -28610, -28707, -28804, - -28899, -28993, -29086, -29178, -29269, -29359, -29448, -29535, -29622, -29707, -29792, - -29875, -29957, -30038, -30118, -30196, -30274, -30350, -30425, -30499, -30572, -30644, - -30715, -30784, -30853, -30920, -30986, -31051, -31114, -31177, -31238, -31298, -31357, - -31415, -31471, -31527, -31581, -31634, -31686, -31737, -31786, -31834, -31881, -31927, - -31972, -32015, -32058, -32099, -32138, -32177, -32214, -32251, -32286, -32319, -32352, - -32383, -32413, -32442, -32470, -32496, -32522, -32546, -32568, -32590, -32610, -32629, - -32647, -32664, -32679, -32693, -32706, -32718, -32729, -32738, -32746, -32753, -32758, - -32762, -32766, -32767, -32768, -32767, -32766, -32762, -32758, -32753, -32746, -32738, - -32729, -32718, -32706, -32693, -32679, -32664, -32647, -32629, -32610, -32590, -32568, - -32546, -32522, -32496, -32470, -32442, -32413, -32383, -32352, -32319, -32286, -32251, - -32214, -32177, -32138, -32099, -32058, -32015, -31972, -31927, -31881, -31834, -31786, - -31737, -31686, -31634, -31581, -31527, -31471, -31415, -31357, -31298, -31238, -31177, - -31114, -31051, -30986, -30920, -30853, -30784, -30715, -30644, -30572, -30499, -30425, - -30350, -30274, -30196, -30118, -30038, -29957, -29875, -29792, -29707, -29622, -29535, - -29448, -29359, -29269, -29178, -29086, -28993, -28899, -28804, -28707, -28610, -28511, - -28411, -28311, -28209, -28106, -28002, -27897, -27791, -27684, -27576, -27467, -27357, - -27246, -27133, -27020, -26906, -26791, -26674, -26557, -26439, -26320, -26199, -26078, - -25956, -25833, -25708, -25583, -25457, -25330, -25202, -25073, -24943, -24812, -24681, - -24548, -24414, -24280, -24144, -24008, -23870, -23732, -23593, -23453, -23312, -23171, - -23028, -22885, -22740, -22595, -22449, -22302, -22154, -22006, -21856, -21706, -21555, - -21403, -21251, -21097, -20943, -20788, -20632, -20476, -20318, -20160, -20001, -19842, - -19681, -19520, -19358, -19196, -19032, -18868, -18704, -18538, -18372, -18205, -18038, - -17869, -17701, -17531, -17361, -17190, -17018, -16846, -16674, -16500, -16326, -16152, - -15976, -15800, -15624, -15447, -15269, -15091, -14912, -14733, -14553, -14373, -14192, - -14010, -13828, -13646, -13463, -13279, -13095, -12911, -12726, -12540, -12354, -12168, - -11981, -11793, -11606, -11417, -11229, -11040, -10850, -10660, -10470, -10279, -10088, - -9896, -9705, -9512, -9320, -9127, -8934, -8740, -8546, -8352, -8157, -7962, -7767, - -7572, -7376, -7180, -6984, -6787, -6590, -6393, -6196, -5998, -5800, -5602, -5404, - -5206, -5007, -4808, -4610, -4410, -4211, -4012, -3812, -3612, -3412, -3212, -3012, - -2812, -2611, -2411, -2210, -2010, -1809, -1608, -1407, -1207, -1006, -805, -604, - -403, -202 }; - -#endif/*__SINE_TABLE_I16_H__*/ From a80d91fb1eb72d829eb781a0077a82f0bf52b632 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Sun, 13 Jun 2021 23:35:33 +0100 Subject: [PATCH 19/33] More improvements to the rssi tone. Added saving of the tuned frequency to the radio model persistent store. --- firmware/application/apps/ui_sonde.cpp | 7 ++++++- firmware/application/apps/ui_sonde.hpp | 8 -------- firmware/baseband/proc_sonde.cpp | 18 ++++++++++++++++-- firmware/baseband/proc_sonde.hpp | 9 +++++++++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index 28796cd7..419ad579 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -66,6 +66,9 @@ SondeView::SondeView(NavigationView& nav) { &button_see_map }); + // start from the frequency currently stored in the receiver_model: + target_frequency_ = receiver_model.tuning_frequency(); + field_frequency.set_value(target_frequency_); field_frequency.set_step(500); //euquiq: was 10000, but we are using this for fine-tunning field_frequency.on_change = [this](rf::Frequency f) { @@ -206,7 +209,9 @@ void SondeView::on_headphone_volume_changed(int32_t v) { void SondeView::set_target_frequency(const uint32_t new_value) { target_frequency_ = new_value; - radio::set_tuning_frequency(tuning_frequency()); + //radio::set_tuning_frequency(tuning_frequency()); + // we better remember the tuned frequency, by using this function instead: + receiver_model.set_tuning_frequency(tuning_frequency()); } uint32_t SondeView::tuning_frequency() const { diff --git a/firmware/application/apps/ui_sonde.hpp b/firmware/application/apps/ui_sonde.hpp index 73591eb3..afc2bbec 100644 --- a/firmware/application/apps/ui_sonde.hpp +++ b/firmware/application/apps/ui_sonde.hpp @@ -55,14 +55,6 @@ class SondeView : public View { public: static constexpr uint32_t sampling_rate = 2457600; static constexpr uint32_t baseband_bandwidth = 1750000; - static constexpr int rssi_sample_range = 256; - static constexpr float rssi_voltage_min = 0.4; - static constexpr float rssi_voltage_max = 2.2; - static constexpr float adc_voltage_max = 3.3; - - static constexpr int raw_min = rssi_sample_range * rssi_voltage_min / adc_voltage_max; - static constexpr int raw_max = rssi_sample_range * rssi_voltage_max / adc_voltage_max; - static constexpr int raw_delta = raw_max - raw_min; SondeView(NavigationView& nav); ~SondeView(); diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index b7397a31..d956372f 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -77,8 +77,21 @@ void SondeProcessor::on_message(const Message* const msg) { switch(msg->id) { case Message::ID::RequestSignal: if ((*reinterpret_cast(msg)).signal == RequestSignalMessage::Signal::BeepRequest) { + float rssi_ratio = (float) last_rssi / (float) RSSI_CEILING; + int beep_duration = 0; + + if(rssi_ratio <= PROPORTIONAL_BEEP_THRES) { + beep_duration = BEEP_MIN_DURATION; + } + else if(rssi_ratio < 1) { + beep_duration = (int) rssi_ratio * BEEP_DURATION_RANGE + BEEP_MIN_DURATION; + } + else { + beep_duration = BEEP_DURATION_RANGE + BEEP_MIN_DURATION; + } + play_beep(); - chThdSleepMilliseconds(150); + chThdSleepMilliseconds(beep_duration); stop_beep(); } break; @@ -122,7 +135,8 @@ void SondeProcessor::generate_silence() { void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) { pitch_rssi_enabled = message.enabled; - uint32_t tone_delta = (message.rssi + 1000) * ((1ULL << 32) / 24000); + uint32_t tone_delta = (int) ((float) message.rssi * (float) RSSI_PITCH_WEIGHT + (float) 1000) * ((float) (1ULL << 32) / (float) 24000); + last_rssi = message.rssi; tone_gen.configure(tone_delta, 1.0, ToneGen::tone_type::square); } diff --git a/firmware/baseband/proc_sonde.hpp b/firmware/baseband/proc_sonde.hpp index 108c4066..fcf4d20b 100644 --- a/firmware/baseband/proc_sonde.hpp +++ b/firmware/baseband/proc_sonde.hpp @@ -97,6 +97,13 @@ #include #include + +#define BEEP_MIN_DURATION 80 +#define BEEP_DURATION_RANGE 150 +#define RSSI_CEILING 1000 +#define PROPORTIONAL_BEEP_THRES 0.8 +#define RSSI_PITCH_WEIGHT 0.7 + class SondeProcessor : public BasebandProcessor { public: SondeProcessor(); @@ -120,6 +127,8 @@ private: bool silence_play { false }; bool pitch_rssi_enabled { false }; + uint32_t last_rssi { 0 }; + ToneGen tone_gen { }; BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive }; From 81f7875764999d09c1fe70143cc4a143436ab350 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 14 Jun 2021 18:10:45 +0200 Subject: [PATCH 20/33] Added radiosonde.txt --- firmware/baseband/proc_aprsrx.hpp | 4 +-- sdcard/FREQMAN/RADIOSONDE.TXT | 46 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 sdcard/FREQMAN/RADIOSONDE.TXT diff --git a/firmware/baseband/proc_aprsrx.hpp b/firmware/baseband/proc_aprsrx.hpp index 2d3c4568..b6634419 100644 --- a/firmware/baseband/proc_aprsrx.hpp +++ b/firmware/baseband/proc_aprsrx.hpp @@ -125,7 +125,7 @@ private: uint32_t sample_bits { 0 }; uint32_t phase { }, phase_inc { }; int32_t sample_mixed { }, prev_mixed { }, sample_filtered { }, prev_filtered { }; - uint8_t last_bit; + uint8_t last_bit = 0; uint8_t ones_count = 0; uint8_t current_byte = 0; uint8_t byte_index = 0; @@ -136,7 +136,7 @@ private: bool wait_start { }; bool bit_value { }; - aprs::APRSPacket aprs_packet; + aprs::APRSPacket aprs_packet { }; void configure(const APRSRxConfigureMessage& message); void capture_config(const CaptureConfigMessage& message); diff --git a/sdcard/FREQMAN/RADIOSONDE.TXT b/sdcard/FREQMAN/RADIOSONDE.TXT new file mode 100644 index 00000000..de308df5 --- /dev/null +++ b/sdcard/FREQMAN/RADIOSONDE.TXT @@ -0,0 +1,46 @@ +f=400500000,d=AU SE +f=401000000,d=FR +f=401100000,d=CZ +f=401400000,d=FR +f=401500000,d=AU +f=401590000,d=FR +f=401600000,d=FR +f=402000000,d=BR FR GR IT RS +f=402010000,d=TR +f=402200000,d=GR +f=402500000,d=AU DE +f=402740000,d=GR +f=402790000,d=RS +f=402800000,d=GB IT RS +f=402870000,d=BE +f=403000000,d=BE BR CZ HU IE IT NL +f=403010000,d=DE NL TR +f=403150000,d=DE +f=403200000,d=HU +f=403500000,d=BE HU +f=403530000,d=BY +f=403600000,d=RO +f=403700000,d=BR GB +f=403820000,d=RO +f=403900000,d=NL +f=403920000,d=RO +f=403810000,d=DE +f=404000000,d=BR CZ ES IT US +f=404010000,d=US +f=404020000,d=US +f=404100000,d=GB +f=404300000,d=DE +f=404310000,d=DE +f=404380000,d=GB +f=404400000,d=GB +f=404710000,d=DE +f=404800000,d=IT +f=405000000,d=ES +f=405010000,d=FR +f=405030000,d=BY +f=405100000,d=GB +f=405300000,d=BY ES IE SE +f=405600000,d=GB +f=405680000,d=GB +f=405700000,d=DE GB +f=405900000,d=DE \ No newline at end of file From 935db5b58b8ebd8f2cc4dbdbc1b98a65a6e4241c Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 14 Jun 2021 18:15:42 +0200 Subject: [PATCH 21/33] Added radiosonde.txt --- firmware/baseband/proc_aprsrx.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/baseband/proc_aprsrx.hpp b/firmware/baseband/proc_aprsrx.hpp index b6634419..2d3c4568 100644 --- a/firmware/baseband/proc_aprsrx.hpp +++ b/firmware/baseband/proc_aprsrx.hpp @@ -125,7 +125,7 @@ private: uint32_t sample_bits { 0 }; uint32_t phase { }, phase_inc { }; int32_t sample_mixed { }, prev_mixed { }, sample_filtered { }, prev_filtered { }; - uint8_t last_bit = 0; + uint8_t last_bit; uint8_t ones_count = 0; uint8_t current_byte = 0; uint8_t byte_index = 0; @@ -136,7 +136,7 @@ private: bool wait_start { }; bool bit_value { }; - aprs::APRSPacket aprs_packet { }; + aprs::APRSPacket aprs_packet; void configure(const APRSRxConfigureMessage& message); void capture_config(const CaptureConfigMessage& message); From c8a8a6983282283e131093e9053a45e3c8e45007 Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Mon, 14 Jun 2021 21:58:15 +0200 Subject: [PATCH 22/33] fix save frequency gui glitch --- firmware/application/apps/ui_freqman.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_freqman.hpp b/firmware/application/apps/ui_freqman.hpp index 51e93e79..b65c8433 100644 --- a/firmware/application/apps/ui_freqman.hpp +++ b/firmware/application/apps/ui_freqman.hpp @@ -64,7 +64,7 @@ protected: OptionsField options_category { { 9 * 8, 4 }, - 12, + 14, { } }; From 8aff0bb4d8fc0a9e84547ac0e1a26e66955fadb0 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Wed, 16 Jun 2021 23:23:47 +0100 Subject: [PATCH 23/33] Improved tone generator for proper frequency control. Also features a square wave mode. Added proportional beep duration based on the RSSI as well. Now reading the current radiosonde frequency from the battery backed RAM instead starting with the same frequency all the time. --- firmware/application/apps/ui_sonde.cpp | 2 +- firmware/baseband/proc_sonde.cpp | 8 +++++--- firmware/baseband/proc_sonde.hpp | 8 +++++--- firmware/baseband/tone_gen.cpp | 13 +++++++------ firmware/baseband/tone_gen.hpp | 16 +++++++--------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index 419ad579..c8916113 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -211,7 +211,7 @@ void SondeView::set_target_frequency(const uint32_t new_value) { target_frequency_ = new_value; //radio::set_tuning_frequency(tuning_frequency()); // we better remember the tuned frequency, by using this function instead: - receiver_model.set_tuning_frequency(tuning_frequency()); + receiver_model.set_tuning_frequency(target_frequency_); } uint32_t SondeView::tuning_frequency() const { diff --git a/firmware/baseband/proc_sonde.cpp b/firmware/baseband/proc_sonde.cpp index d956372f..d33b6ea4 100644 --- a/firmware/baseband/proc_sonde.cpp +++ b/firmware/baseband/proc_sonde.cpp @@ -35,7 +35,7 @@ SondeProcessor::SondeProcessor() { audio_output.configure(false); - tone_gen.configure(0, 1, ToneGen::tone_type::square); + tone_gen.configure(BEEP_BASE_FREQ, 1.0, ToneGen::tone_type::sine, AUDIO_SAMPLE_RATE); } void SondeProcessor::execute(const buffer_c8_t& buffer) { @@ -135,9 +135,11 @@ void SondeProcessor::generate_silence() { void SondeProcessor::pitch_rssi_config(const PitchRSSIConfigureMessage& message) { pitch_rssi_enabled = message.enabled; - uint32_t tone_delta = (int) ((float) message.rssi * (float) RSSI_PITCH_WEIGHT + (float) 1000) * ((float) (1ULL << 32) / (float) 24000); + + uint32_t freq = (int) ((float) message.rssi * (float) RSSI_PITCH_WEIGHT + (float) BEEP_BASE_FREQ); + last_rssi = message.rssi; - tone_gen.configure(tone_delta, 1.0, ToneGen::tone_type::square); + tone_gen.configure(freq, 1.0, ToneGen::tone_type::sine, AUDIO_SAMPLE_RATE); } int main() { diff --git a/firmware/baseband/proc_sonde.hpp b/firmware/baseband/proc_sonde.hpp index fcf4d20b..e0c1cb95 100644 --- a/firmware/baseband/proc_sonde.hpp +++ b/firmware/baseband/proc_sonde.hpp @@ -98,11 +98,13 @@ #include -#define BEEP_MIN_DURATION 80 -#define BEEP_DURATION_RANGE 150 +#define BEEP_MIN_DURATION 60 +#define BEEP_DURATION_RANGE 100 +#define BEEP_BASE_FREQ 200 #define RSSI_CEILING 1000 #define PROPORTIONAL_BEEP_THRES 0.8 -#define RSSI_PITCH_WEIGHT 0.7 +#define RSSI_PITCH_WEIGHT 0.5 +#define AUDIO_SAMPLE_RATE 24000 class SondeProcessor : public BasebandProcessor { public: diff --git a/firmware/baseband/tone_gen.cpp b/firmware/baseband/tone_gen.cpp index d2185f53..dd74579d 100644 --- a/firmware/baseband/tone_gen.cpp +++ b/firmware/baseband/tone_gen.cpp @@ -24,8 +24,8 @@ #include "sine_table_int8.hpp" -int32_t ToneGen::tone_from_sine_table() { - int32_t tone_sample = sine_table_i8[(tone_phase_ & 0xFF000000U) >> 24] << 24; +int32_t ToneGen::tone_sine() { + int32_t tone_sample = sine_table_i8[tone_phase_] * 0x1000000; tone_phase_ += delta_; return tone_sample; @@ -47,14 +47,15 @@ int32_t ToneGen::tone_square() { } void ToneGen::configure(const uint32_t delta, const float tone_mix_weight) { - delta_ = delta; + delta_ = (uint8_t) ((delta & 0xFF000000U) >> 24); tone_mix_weight_ = tone_mix_weight; input_mix_weight_ = 1.0 - tone_mix_weight; + current_tone_type_ = sine; } -void ToneGen::configure(const uint32_t delta, const float tone_mix_weight, const tone_type tone_type) { - delta_ = delta; +void ToneGen::configure(const uint32_t freq, const float tone_mix_weight, const tone_type tone_type, const uint32_t sample_rate) { + delta_ = (uint8_t) ((freq * sizeof(sine_table_i8)) / sample_rate); tone_mix_weight_ = tone_mix_weight; input_mix_weight_ = 1.0 - tone_mix_weight; current_tone_type_ = tone_type; @@ -67,7 +68,7 @@ int32_t ToneGen::process(const int32_t sample_in) { int32_t tone_sample = 0; if(current_tone_type_ == sine) { - tone_sample = tone_from_sine_table(); + tone_sample = tone_sine(); } else if(current_tone_type_ == square) { tone_sample = tone_square(); diff --git a/firmware/baseband/tone_gen.hpp b/firmware/baseband/tone_gen.hpp index d12782c1..c1eee222 100644 --- a/firmware/baseband/tone_gen.hpp +++ b/firmware/baseband/tone_gen.hpp @@ -25,9 +25,6 @@ #include #include -#include - -static const std::bitset<2048> wave_bits (0xFFFFFF); class ToneGen { public: @@ -38,23 +35,24 @@ public: {};*/ void configure(const uint32_t delta, const float tone_mix_weight); - void configure(const uint32_t delta, const float tone_mix_weight, const tone_type tone_type); + void configure(const uint32_t freq, const float tone_mix_weight, const tone_type tone_type, const uint32_t sample_rate); int32_t process(const int32_t sample_in); private: tone_type current_tone_type_ { sine }; - //size_t sample_rate_; float input_mix_weight_ { 1 }; float tone_mix_weight_ { 0 }; - uint32_t delta_ { 0 }; - uint32_t tone_phase_ { 0 }; + + uint8_t delta_ { 0 }; + uint8_t tone_phase_ { 0 }; /** - * Generator function for sine waves: + * Generator function which selects every other sample from the reference sine waveform to the output sample: */ - int32_t tone_from_sine_table(); + int32_t tone_sine(); + /** * Generator function for square waves: From 2ceb49e4f2790f76c791c4791bc2c2725036619b Mon Sep 17 00:00:00 2001 From: teixeluis Date: Sat, 19 Jun 2021 23:41:06 +0100 Subject: [PATCH 24/33] Added more precise function to calculate NL (based on cmath lib). Created constants for some of the values scattered in the code. --- firmware/application/apps/ui_adsb_rx.cpp | 11 +++++--- firmware/application/apps/ui_adsb_rx.hpp | 32 +++++++++++++++++++++--- firmware/common/adsb.cpp | 16 +++++++++--- firmware/common/adsb.hpp | 4 +++ 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index ba080481..66b7900b 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -205,7 +205,7 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { auto frame = message->frame; uint32_t ICAO_address = frame.get_ICAO_address(); - if (frame.check_CRC() && frame.get_ICAO_address()) { + if (frame.check_CRC() && ICAO_address) { rtcGetTime(&RTCD1, &datetime); auto& entry = ::on_packet(recent, ICAO_address); frame.set_rx_timestamp(datetime.minute() * 60 + datetime.second()); @@ -222,11 +222,14 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { uint8_t msg_sub = frame.get_msg_sub(); uint8_t * raw_data = frame.get_raw_data(); - if ((msg_type >= 1) && (msg_type <= 4)) { + if ((msg_type >= AIRCRAFT_ID_L) && (msg_type <= AIRCRAFT_ID_H)) { callsign = decode_frame_id(frame); entry.set_callsign(callsign); logentry+=callsign+" "; - } else if (((msg_type >= 9) && (msg_type <= 18)) || ((msg_type >= 20) && (msg_type <= 22))) { + } + // + else if (((msg_type >= AIRBORNE_POS_BARO_L) && (msg_type <= AIRBORNE_POS_BARO_H)) || + ((msg_type >= AIRBORNE_POS_GPS_L) && (msg_type <= AIRBORNE_POS_GPS_H))) { entry.set_frame_pos(frame, raw_data[6] & 4); if (entry.pos.valid) { @@ -242,7 +245,7 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { if (send_updates) details_view->update(entry); } - } else if(msg_type == 19 && msg_sub >= 1 && msg_sub <= 4){ + } else if(msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC){ entry.set_frame_velo(frame); logentry += "Type:" + to_string_dec_uint(msg_sub) + " Hdg:" + to_string_dec_uint(entry.velo.heading) + diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index bb474e83..a63b7eb2 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -36,9 +36,33 @@ using namespace adsb; namespace ui { -#define ADSB_DECAY_A 10 // In seconds -#define ADSB_DECAY_B 30 -#define ADSB_DECAY_C 60 // Can be used for removing old entries, RecentEntries already caps to 64 +#define ADSB_DECAY_A 10 // In seconds +#define ADSB_DECAY_B 30 +#define ADSB_DECAY_C 60 // Can be used for removing old entries, RecentEntries already caps to 64 + +#define AIRCRAFT_ID_L 1 // aircraft ID message type (lowest type id) +#define AIRCRAFT_ID_H 4 // aircraft ID message type (highest type id) + +#define SURFACE_POS_L 5 // surface position (lowest type id) +#define SURFACE_POS_H 8 // surface position (highest type id) + +#define AIRBORNE_POS_BARO_L 9 // airborne position (lowest type id) +#define AIRBORNE_POS_BARO_H 18 // airborne position (highest type id) + +#define AIRBORNE_VEL 19 // airborne velocities + +#define AIRBORNE_POS_GPS_L 20 // airborne position (lowest type id) +#define AIRBORNE_POS_GPS_H 22 // airborne position (highest type id) + +#define RESERVED_L 23 // reserved for other uses +#define RESERVED_H 31 // reserved for other uses + +#define VEL_GND_SUBSONIC 1 +#define VEL_GND_SUPERSONIC 2 +#define VEL_AIR_SUBSONIC 3 +#define VEL_AIR_SUPERSONIC 4 + +#define O_E_FRAME_TIMEOUT 20 // timeout between odd and even frames struct AircraftRecentEntry { using Key = uint32_t; @@ -82,7 +106,7 @@ struct AircraftRecentEntry { frame_pos_odd = frame; if (!frame_pos_even.empty() && !frame_pos_odd.empty()) { - if (abs(frame_pos_even.get_rx_timestamp() - frame_pos_odd.get_rx_timestamp()) < 20) + if (abs(frame_pos_even.get_rx_timestamp() - frame_pos_odd.get_rx_timestamp()) < O_E_FRAME_TIMEOUT) pos = decode_frame_pos(frame_pos_even, frame_pos_odd); } } diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index 862e375d..335c6d21 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -141,7 +141,11 @@ float cpr_mod(float a, float b) { return a - (b * floor(a / b)); } -int cpr_NL(float lat) { +int cpr_NL_precise(float lat) { + return (int) floor(2 * PI / acos(1 - ((1 - cos(PI / (2 * NZ))) / pow(cos(PI * lat / 180), 2)))); +} + +int cpr_NL_approx(float lat) { if (lat < 0) lat = -lat; // Symmetry @@ -150,7 +154,11 @@ int cpr_NL(float lat) { return 59 - c; } - return 1; + return 1; +} + +int cpr_NL(float lat) { + return cpr_NL_precise(lat); } int cpr_N(float lat, int is_odd) { @@ -258,7 +266,7 @@ adsb_pos decode_frame_pos(ADSBFrame& frame_even, ADSBFrame& frame_odd) { // Compute longitude if (time_even > time_odd) { - // Use even frame + // Use even frame2 ni = cpr_N(latE, 0); Dlon = 360.0 / ni; @@ -279,7 +287,7 @@ adsb_pos decode_frame_pos(ADSBFrame& frame_even, ADSBFrame& frame_odd) { position.latitude = latO; } - if (position.longitude > 180) position.longitude -= 360; + if (position.longitude >= 180) position.longitude -= 360; position.valid = true; diff --git a/firmware/common/adsb.hpp b/firmware/common/adsb.hpp index 82d177e4..f3a2f3ac 100644 --- a/firmware/common/adsb.hpp +++ b/firmware/common/adsb.hpp @@ -83,6 +83,10 @@ const float adsb_lat_lut[58] = { 86.53536998, 87.00000000 }; +const float PI = 3.14159265358979323846; + +const float NZ = 15; + void make_frame_adsb(ADSBFrame& frame, const uint32_t ICAO_address); void encode_frame_id(ADSBFrame& frame, const uint32_t ICAO_address, const std::string& callsign); From 8329b669261b2efe18f2634cbff4b6503cf5f81f Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Tue, 22 Jun 2021 12:44:19 +0200 Subject: [PATCH 25/33] Update credits --- firmware/application/apps/ui_about_simple.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/application/apps/ui_about_simple.cpp b/firmware/application/apps/ui_about_simple.cpp index f527b485..6af138ba 100644 --- a/firmware/application/apps/ui_about_simple.cpp +++ b/firmware/application/apps/ui_about_simple.cpp @@ -31,8 +31,9 @@ namespace ui console.writeln("N0vaPixel,klockee,GullCode"); console.writeln("jamesshao8,ITAxReal,rascafr"); console.writeln("mcules,dqs105,strijar"); - console.writeln("zhang00963,RedFox-Fr"); + console.writeln("zhang00963,RedFox-Fr,aldude999"); console.writeln("East2West,fossum,ArjanOnwezen"); + console.writeln("vXxOinvizioNxX,teixeluis"); console.writeln(""); break; From 97349b06ef32f26df046f135cb87bdc645cb7fad Mon Sep 17 00:00:00 2001 From: teixeluis Date: Wed, 23 Jun 2021 19:54:34 +0100 Subject: [PATCH 26/33] Fixes to the log and screen rendering of the geo coordinates. --- firmware/application/apps/ui_adsb_rx.cpp | 37 ++++++++++++++++++++---- firmware/common/adsb.cpp | 6 ++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index 66b7900b..b91771b4 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -20,6 +20,7 @@ * Boston, MA 02110-1301, USA. */ + #include "ui_adsb_rx.hpp" #include "ui_alphanum.hpp" @@ -233,14 +234,38 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { entry.set_frame_pos(frame, raw_data[6] & 4); if (entry.pos.valid) { + std::string latitude_str(8, '\0'); + std::string longitude_str(8, '\0'); + + int written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.2f", entry.pos.latitude); + latitude_str.resize(written); + + written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.2f", entry.pos.longitude); + longitude_str.resize(written); + str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + - " Lat:" + to_string_dec_int(entry.pos.latitude) + - "." + to_string_dec_int((int)abs(entry.pos.latitude * 1000) % 100, 2, '0') + - " Lon:" + to_string_dec_int(entry.pos.longitude) + - "." + to_string_dec_int((int)abs(entry.pos.longitude * 1000) % 100, 2, '0'); - + " Lat:" + latitude_str + + " Lon:" + longitude_str; + + // printing the coordinates in the log file with more + // resolution, as we are not constrained by screen + // real estate there: + + latitude_str.resize(13, '\0'); + longitude_str.resize(13, '\0'); + + written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.7f", entry.pos.latitude); + latitude_str.resize(written); + + written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.7f", entry.pos.longitude); + longitude_str.resize(written); + + std::string log_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + + " Lat:" + latitude_str + + " Lon:" + longitude_str; + entry.set_info_string(str_info); - logentry+=str_info+ " "; + logentry+=log_info + " "; if (send_updates) details_view->update(entry); diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index 335c6d21..f43ff478 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -158,6 +158,12 @@ int cpr_NL_approx(float lat) { } int cpr_NL(float lat) { + // TODO prove that the approximate function is good + // enough for the precision we need. Uncomment if + // that is true: + + //return cpr_NL_approx(lat); + return cpr_NL_precise(lat); } From b09439afb118c3b23d2509ce42d221b027c5625a Mon Sep 17 00:00:00 2001 From: teixeluis Date: Wed, 23 Jun 2021 23:52:15 +0100 Subject: [PATCH 27/33] Fixed the mixing of aircraft coordinates in the details view, by checking if the ICAO address of the frame and the current item in the details view match. Slight refactor by placing the decimal to string conversion function into the string_format module. --- firmware/application/apps/ui_adsb_rx.cpp | 38 +++++++++--------------- firmware/application/apps/ui_adsb_rx.hpp | 2 ++ firmware/application/string_format.cpp | 17 +++++++++++ firmware/application/string_format.hpp | 2 ++ firmware/application/ui/ui_geomap.cpp | 14 ++------- firmware/common/adsb.cpp | 12 ++++---- firmware/common/adsb.hpp | 2 +- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index b91771b4..88474923 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -20,6 +20,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include "ui_adsb_rx.hpp" #include "ui_alphanum.hpp" @@ -234,49 +235,38 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { entry.set_frame_pos(frame, raw_data[6] & 4); if (entry.pos.valid) { - std::string latitude_str(8, '\0'); - std::string longitude_str(8, '\0'); - - int written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.2f", entry.pos.latitude); - latitude_str.resize(written); - - written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.2f", entry.pos.longitude); - longitude_str.resize(written); - str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + - " Lat:" + latitude_str + - " Lon:" + longitude_str; + " Lat:" + to_string_decimal(entry.pos.latitude, 2) + + " Lon:" + to_string_decimal(entry.pos.longitude, 2); // printing the coordinates in the log file with more // resolution, as we are not constrained by screen // real estate there: - latitude_str.resize(13, '\0'); - longitude_str.resize(13, '\0'); - - written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.7f", entry.pos.latitude); - latitude_str.resize(written); - - written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.7f", entry.pos.longitude); - longitude_str.resize(written); - std::string log_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + - " Lat:" + latitude_str + - " Lon:" + longitude_str; + " Lat:" + to_string_decimal(entry.pos.latitude, 7) + + " Lon:" + to_string_decimal(entry.pos.longitude, 7); entry.set_info_string(str_info); logentry+=log_info + " "; - if (send_updates) + if(send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { + // we only want to update the details view if the frame + // we received has the same ICAO address, i.e. belongs to + // the same aircraft: details_view->update(entry); + } } } else if(msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC){ entry.set_frame_velo(frame); logentry += "Type:" + to_string_dec_uint(msg_sub) + " Hdg:" + to_string_dec_uint(entry.velo.heading) + " Spd: "+ to_string_dec_int(entry.velo.speed); - if (send_updates) + + if (send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { + // same here: details_view->update(entry); + } } } recent_entries_view.set_dirty(); diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index a63b7eb2..c55ec680 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -161,6 +161,8 @@ public: void update(const AircraftRecentEntry& entry); std::string title() const override { return "Details"; }; + + AircraftRecentEntry get_current_entry() { return entry_copy; } private: AircraftRecentEntry entry_copy { 0 }; diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 1aa365e6..c639923e 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -112,6 +112,23 @@ std::string to_string_dec_int( return q; } +std::string to_string_decimal(float decimal, int8_t precision) { + double integer_part; + double fractional_part; + + std::string result; + + fractional_part = modf(decimal, &integer_part) * pow(10, precision); + + if (fractional_part < 0) { + fractional_part = -fractional_part; + } + + result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision); + + return result; +} + std::string to_string_short_freq(const uint64_t f) { auto final_str = to_string_dec_int(f / 1000000,4) + "." + to_string_dec_int((f / 100) % 10000, 4, '0'); return final_str; diff --git a/firmware/application/string_format.hpp b/firmware/application/string_format.hpp index 0555db8e..a588ef95 100644 --- a/firmware/application/string_format.hpp +++ b/firmware/application/string_format.hpp @@ -43,6 +43,8 @@ const char unit_prefix[7] { 'n', 'u', 'm', 0, 'k', 'M', 'G' }; std::string to_string_bin(const uint32_t n, const uint8_t l = 0); std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char fill = ' '); std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0); +std::string to_string_decimal(float decimal, int8_t precision); + std::string to_string_hex(const uint64_t n, const int32_t l = 0); std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0); diff --git a/firmware/application/ui/ui_geomap.cpp b/firmware/application/ui/ui_geomap.cpp index 0f4809dc..1d09880d 100644 --- a/firmware/application/ui/ui_geomap.cpp +++ b/firmware/application/ui/ui_geomap.cpp @@ -63,17 +63,9 @@ GeoPos::GeoPos( const auto changed_fn = [this](int32_t) { float lat_value = lat(); float lon_value = lon(); - double integer_part; - double fractional_part; - - fractional_part = modf(lat_value, &integer_part) * 100000; - if (fractional_part < 0) - fractional_part = -fractional_part; - text_lat_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5)); - fractional_part = modf(lon_value, &integer_part) * 100000; - if (fractional_part < 0) - fractional_part = -fractional_part; - text_lon_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5)); + + text_lat_decimal.set(to_string_decimal(lat_value, 5)); + text_lon_decimal.set(to_string_decimal(lon_value, 5)); if (on_change && report_change) on_change(altitude(), lat_value, lon_value); diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index f43ff478..3d0e43ef 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -199,18 +199,18 @@ void encode_frame_pos(ADSBFrame& frame, const uint32_t ICAO_address, const int32 // CPR encoding // Info from: http://antena.fe.uni-lj.si/literatura/Razno/Avionika/modes/CPRencoding.pdf - delta_lat = 360.0 / ((4.0 * 15.0) - time_parity); // NZ = 15 - yz = floor(131072.0 * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5); - rlat = delta_lat * ((yz / 131072.0) + floor(latitude / delta_lat)); + delta_lat = 360.0 / ((4.0 * NZ) - time_parity); // NZ = 15 + yz = floor(CPR_MAX_VALUE * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5); + rlat = delta_lat * ((yz / CPR_MAX_VALUE) + floor(latitude / delta_lat)); if ((cpr_NL(rlat) - time_parity) > 0) delta_lon = 360.0 / cpr_N(rlat, time_parity); else delta_lon = 360.0; - xz = floor(131072.0 * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5); + xz = floor(CPR_MAX_VALUE * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5); - lat = cpr_mod(yz, 131072.0); - lon = cpr_mod(xz, 131072.0); + lat = cpr_mod(yz, CPR_MAX_VALUE); + lon = cpr_mod(xz, CPR_MAX_VALUE); frame.push_byte((altitude_coded << 4) | ((uint32_t)time_parity << 2) | (lat >> 15)); // T = 0 frame.push_byte(lat >> 7); diff --git a/firmware/common/adsb.hpp b/firmware/common/adsb.hpp index f3a2f3ac..7e4d3bce 100644 --- a/firmware/common/adsb.hpp +++ b/firmware/common/adsb.hpp @@ -85,7 +85,7 @@ const float adsb_lat_lut[58] = { const float PI = 3.14159265358979323846; -const float NZ = 15; +const float NZ = 15.0; void make_frame_adsb(ADSBFrame& frame, const uint32_t ICAO_address); From 22e8add4dd8a1577a23e3c2a89182eff0fbdc9e4 Mon Sep 17 00:00:00 2001 From: teixeluis Date: Thu, 24 Jun 2021 15:10:06 +0100 Subject: [PATCH 28/33] Fixed left padding of the decimal part of the numbers. --- firmware/application/apps/ui_adsb_rx.cpp | 8 ++++---- firmware/application/string_format.cpp | 2 +- firmware/common/adsb.cpp | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index 88474923..25667fe6 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -250,10 +250,10 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { entry.set_info_string(str_info); logentry+=log_info + " "; + // we only want to update the details view if the frame + // we received has the same ICAO address, i.e. belongs to + // the same aircraft: if(send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { - // we only want to update the details view if the frame - // we received has the same ICAO address, i.e. belongs to - // the same aircraft: details_view->update(entry); } } @@ -263,8 +263,8 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { " Hdg:" + to_string_dec_uint(entry.velo.heading) + " Spd: "+ to_string_dec_int(entry.velo.speed); + // same here: if (send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { - // same here: details_view->update(entry); } } diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index c639923e..22b02d0b 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -124,7 +124,7 @@ std::string to_string_decimal(float decimal, int8_t precision) { fractional_part = -fractional_part; } - result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision); + result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision, '0'); return result; } diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index 3d0e43ef..d1d11707 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -160,7 +160,9 @@ int cpr_NL_approx(float lat) { int cpr_NL(float lat) { // TODO prove that the approximate function is good // enough for the precision we need. Uncomment if - // that is true: + // that is true. No performance penalty was noticed + // from testing, but if you find it might be an issue, + // switch to cpr_NL_approx() instead: //return cpr_NL_approx(lat); From fe806b7bdc3cf611d3a47a053e8d3a8f2ad762fd Mon Sep 17 00:00:00 2001 From: teixeluis Date: Wed, 23 Jun 2021 23:52:15 +0100 Subject: [PATCH 29/33] Fixed the mixing of aircraft coordinates in the details view, by checking if the ICAO address of the frame and the current item in the details view match. Slight refactor by placing the decimal to string conversion function into the string_format module. Added fix in the scope of issue #365 FrequencyStepView field in TransmitterView class FrequencyStepView field in TransmitterView class Update ui_transmitter.hpp Update credits Fixed left padding of the decimal part of the numbers. --- firmware/application/apps/ui_about_simple.cpp | 3 +- firmware/application/apps/ui_adsb_rx.cpp | 38 +++++++------------ firmware/application/apps/ui_adsb_rx.hpp | 2 + firmware/application/radio.cpp | 14 +++---- firmware/application/receiver_model.cpp | 8 ++++ firmware/application/string_format.cpp | 17 +++++++++ firmware/application/string_format.hpp | 2 + firmware/application/ui/ui_geomap.cpp | 14 ++----- firmware/application/ui/ui_transmitter.cpp | 6 +++ firmware/application/ui/ui_transmitter.hpp | 10 +++-- firmware/common/adsb.cpp | 16 ++++---- firmware/common/adsb.hpp | 2 +- 12 files changed, 77 insertions(+), 55 deletions(-) diff --git a/firmware/application/apps/ui_about_simple.cpp b/firmware/application/apps/ui_about_simple.cpp index f527b485..6af138ba 100644 --- a/firmware/application/apps/ui_about_simple.cpp +++ b/firmware/application/apps/ui_about_simple.cpp @@ -31,8 +31,9 @@ namespace ui console.writeln("N0vaPixel,klockee,GullCode"); console.writeln("jamesshao8,ITAxReal,rascafr"); console.writeln("mcules,dqs105,strijar"); - console.writeln("zhang00963,RedFox-Fr"); + console.writeln("zhang00963,RedFox-Fr,aldude999"); console.writeln("East2West,fossum,ArjanOnwezen"); + console.writeln("vXxOinvizioNxX,teixeluis"); console.writeln(""); break; diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index b91771b4..25667fe6 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -20,6 +20,7 @@ * Boston, MA 02110-1301, USA. */ +#include #include "ui_adsb_rx.hpp" #include "ui_alphanum.hpp" @@ -234,49 +235,38 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) { entry.set_frame_pos(frame, raw_data[6] & 4); if (entry.pos.valid) { - std::string latitude_str(8, '\0'); - std::string longitude_str(8, '\0'); - - int written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.2f", entry.pos.latitude); - latitude_str.resize(written); - - written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.2f", entry.pos.longitude); - longitude_str.resize(written); - str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + - " Lat:" + latitude_str + - " Lon:" + longitude_str; + " Lat:" + to_string_decimal(entry.pos.latitude, 2) + + " Lon:" + to_string_decimal(entry.pos.longitude, 2); // printing the coordinates in the log file with more // resolution, as we are not constrained by screen // real estate there: - latitude_str.resize(13, '\0'); - longitude_str.resize(13, '\0'); - - written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.7f", entry.pos.latitude); - latitude_str.resize(written); - - written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.7f", entry.pos.longitude); - longitude_str.resize(written); - std::string log_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + - " Lat:" + latitude_str + - " Lon:" + longitude_str; + " Lat:" + to_string_decimal(entry.pos.latitude, 7) + + " Lon:" + to_string_decimal(entry.pos.longitude, 7); entry.set_info_string(str_info); logentry+=log_info + " "; - if (send_updates) + // we only want to update the details view if the frame + // we received has the same ICAO address, i.e. belongs to + // the same aircraft: + if(send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { details_view->update(entry); + } } } else if(msg_type == AIRBORNE_VEL && msg_sub >= VEL_GND_SUBSONIC && msg_sub <= VEL_AIR_SUPERSONIC){ entry.set_frame_velo(frame); logentry += "Type:" + to_string_dec_uint(msg_sub) + " Hdg:" + to_string_dec_uint(entry.velo.heading) + " Spd: "+ to_string_dec_int(entry.velo.speed); - if (send_updates) + + // same here: + if (send_updates && details_view->get_current_entry().ICAO_address == ICAO_address) { details_view->update(entry); + } } } recent_entries_view.set_dirty(); diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index a63b7eb2..c55ec680 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -161,6 +161,8 @@ public: void update(const AircraftRecentEntry& entry); std::string title() const override { return "Details"; }; + + AircraftRecentEntry get_current_entry() { return entry_copy; } private: AircraftRecentEntry entry_copy { 0 }; diff --git a/firmware/application/radio.cpp b/firmware/application/radio.cpp index 60981c70..617f22ac 100644 --- a/firmware/application/radio.cpp +++ b/firmware/application/radio.cpp @@ -111,14 +111,12 @@ void set_direction(const rf::Direction new_direction) { // Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction // Use CPLD's EEPROM config when transmitting // Use the SRAM overlay when receiving - if (direction != new_direction) { - if (new_direction == rf::Direction::Transmit) { - hackrf::cpld::init_from_eeprom(); - } else { - if( !hackrf::cpld::load_sram() ) { - chSysHalt(); - } - } + + // teixeluis: undone "Hack to fix the CPLD (clocking ?) bug". + // Apparently with current CPLD code from the hackrf repo, + // toggling CPLD overlay should no longer be necessary: + if (direction != new_direction && new_direction == rf::Direction::Transmit) { + hackrf::cpld::init_from_eeprom(); } direction = new_direction; diff --git a/firmware/application/receiver_model.cpp b/firmware/application/receiver_model.cpp index c3216654..bef08025 100644 --- a/firmware/application/receiver_model.cpp +++ b/firmware/application/receiver_model.cpp @@ -171,7 +171,11 @@ void ReceiverModel::enable() { update_baseband_bandwidth(); update_sampling_rate(); update_modulation(); + + // TODO: would challenge if this should belong to the + // receiver_model namespace: update_headphone_volume(); + led_rx.on(); } @@ -182,6 +186,10 @@ void ReceiverModel::disable() { // TODO: Responsibility for enabling/disabling the radio is muddy. // Some happens in ReceiverModel, some inside radio namespace. radio::disable(); + + // TODO: we are doing this repeatedly in different levels of the + // call stack. Keeping it for now, but there seem to be too many + // redundant calls: led_rx.off(); } diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 1aa365e6..22b02d0b 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -112,6 +112,23 @@ std::string to_string_dec_int( return q; } +std::string to_string_decimal(float decimal, int8_t precision) { + double integer_part; + double fractional_part; + + std::string result; + + fractional_part = modf(decimal, &integer_part) * pow(10, precision); + + if (fractional_part < 0) { + fractional_part = -fractional_part; + } + + result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision, '0'); + + return result; +} + std::string to_string_short_freq(const uint64_t f) { auto final_str = to_string_dec_int(f / 1000000,4) + "." + to_string_dec_int((f / 100) % 10000, 4, '0'); return final_str; diff --git a/firmware/application/string_format.hpp b/firmware/application/string_format.hpp index 0555db8e..a588ef95 100644 --- a/firmware/application/string_format.hpp +++ b/firmware/application/string_format.hpp @@ -43,6 +43,8 @@ const char unit_prefix[7] { 'n', 'u', 'm', 0, 'k', 'M', 'G' }; std::string to_string_bin(const uint32_t n, const uint8_t l = 0); std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char fill = ' '); std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0); +std::string to_string_decimal(float decimal, int8_t precision); + std::string to_string_hex(const uint64_t n, const int32_t l = 0); std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0); diff --git a/firmware/application/ui/ui_geomap.cpp b/firmware/application/ui/ui_geomap.cpp index 0f4809dc..1d09880d 100644 --- a/firmware/application/ui/ui_geomap.cpp +++ b/firmware/application/ui/ui_geomap.cpp @@ -63,17 +63,9 @@ GeoPos::GeoPos( const auto changed_fn = [this](int32_t) { float lat_value = lat(); float lon_value = lon(); - double integer_part; - double fractional_part; - - fractional_part = modf(lat_value, &integer_part) * 100000; - if (fractional_part < 0) - fractional_part = -fractional_part; - text_lat_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5)); - fractional_part = modf(lon_value, &integer_part) * 100000; - if (fractional_part < 0) - fractional_part = -fractional_part; - text_lon_decimal.set(to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, 5)); + + text_lat_decimal.set(to_string_decimal(lat_value, 5)); + text_lon_decimal.set(to_string_decimal(lon_value, 5)); if (on_change && report_change) on_change(altitude(), lat_value, lon_value); diff --git a/firmware/application/ui/ui_transmitter.cpp b/firmware/application/ui/ui_transmitter.cpp index acc30574..6cfb19bf 100644 --- a/firmware/application/ui/ui_transmitter.cpp +++ b/firmware/application/ui/ui_transmitter.cpp @@ -103,6 +103,7 @@ void TransmitterView::set_transmitting(const bool transmitting) { void TransmitterView::on_show() { field_frequency.set_value(transmitter_model.tuning_frequency()); + field_frequency_step.set_by_value(receiver_model.frequency_step()); field_gain.set_value(transmitter_model.tx_gain()); field_amp.set_value(transmitter_model.rf_amp() ? 14 : 0); @@ -122,6 +123,7 @@ TransmitterView::TransmitterView( add_children({ &field_frequency, + &field_frequency_step, &text_gain, &field_gain, &button_start, @@ -157,6 +159,10 @@ TransmitterView::TransmitterView( if (on_edit_frequency) on_edit_frequency(); }; + + field_frequency_step.on_change = [this](size_t, OptionsField::value_t v) { + this->field_frequency.set_step(v); + }; field_gain.on_change = [this](uint32_t tx_gain) { on_tx_gain_changed(tx_gain); diff --git a/firmware/application/ui/ui_transmitter.hpp b/firmware/application/ui/ui_transmitter.hpp index da5ce799..e38aea83 100644 --- a/firmware/application/ui/ui_transmitter.hpp +++ b/firmware/application/ui/ui_transmitter.hpp @@ -124,11 +124,11 @@ private: }; Text text_bw { - { 11 * 8, 1 * 8, 9 * 8, 1 * 16 }, - "BW: kHz" + { 18 * 8, 1 * 8, 3 * 8, 1 * 16 }, + "kHz" }; NumberField field_bw { - { 14 * 8, 1 * 8 }, + { 15 * 8, 1 * 8 }, 3, { 1, 150 }, 1, @@ -152,6 +152,10 @@ private: { 21 * 8, 1 * 8, 9 * 8, 32 }, "START" }; + + FrequencyStepView field_frequency_step { + { 10 * 8 - 4, 1 * 8 }, + }; void on_tuning_frequency_changed(rf::Frequency f); void on_channel_bandwidth_changed(uint32_t channel_bandwidth); diff --git a/firmware/common/adsb.cpp b/firmware/common/adsb.cpp index f43ff478..d1d11707 100644 --- a/firmware/common/adsb.cpp +++ b/firmware/common/adsb.cpp @@ -160,7 +160,9 @@ int cpr_NL_approx(float lat) { int cpr_NL(float lat) { // TODO prove that the approximate function is good // enough for the precision we need. Uncomment if - // that is true: + // that is true. No performance penalty was noticed + // from testing, but if you find it might be an issue, + // switch to cpr_NL_approx() instead: //return cpr_NL_approx(lat); @@ -199,18 +201,18 @@ void encode_frame_pos(ADSBFrame& frame, const uint32_t ICAO_address, const int32 // CPR encoding // Info from: http://antena.fe.uni-lj.si/literatura/Razno/Avionika/modes/CPRencoding.pdf - delta_lat = 360.0 / ((4.0 * 15.0) - time_parity); // NZ = 15 - yz = floor(131072.0 * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5); - rlat = delta_lat * ((yz / 131072.0) + floor(latitude / delta_lat)); + delta_lat = 360.0 / ((4.0 * NZ) - time_parity); // NZ = 15 + yz = floor(CPR_MAX_VALUE * (cpr_mod(latitude, delta_lat) / delta_lat) + 0.5); + rlat = delta_lat * ((yz / CPR_MAX_VALUE) + floor(latitude / delta_lat)); if ((cpr_NL(rlat) - time_parity) > 0) delta_lon = 360.0 / cpr_N(rlat, time_parity); else delta_lon = 360.0; - xz = floor(131072.0 * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5); + xz = floor(CPR_MAX_VALUE * (cpr_mod(longitude, delta_lon) / delta_lon) + 0.5); - lat = cpr_mod(yz, 131072.0); - lon = cpr_mod(xz, 131072.0); + lat = cpr_mod(yz, CPR_MAX_VALUE); + lon = cpr_mod(xz, CPR_MAX_VALUE); frame.push_byte((altitude_coded << 4) | ((uint32_t)time_parity << 2) | (lat >> 15)); // T = 0 frame.push_byte(lat >> 7); diff --git a/firmware/common/adsb.hpp b/firmware/common/adsb.hpp index f3a2f3ac..7e4d3bce 100644 --- a/firmware/common/adsb.hpp +++ b/firmware/common/adsb.hpp @@ -85,7 +85,7 @@ const float adsb_lat_lut[58] = { const float PI = 3.14159265358979323846; -const float NZ = 15; +const float NZ = 15.0; void make_frame_adsb(ADSBFrame& frame, const uint32_t ICAO_address); From 03eae70555d8ddb0759b5036288a95453414068f Mon Sep 17 00:00:00 2001 From: Brumi-2021 <86470699+Brumi-2021@users.noreply.github.com> Date: Thu, 15 Jul 2021 18:15:44 +0200 Subject: [PATCH 30/33] Add Gain_TX control to the Replay App Current Replay App , shows in the user menu a UI to select two kind of controls for the RF output level : 1-) LNA GAIN (0..40 ) dB => but it has no TX effect because it is the RX-LNA . GAIN 2-) RF AMP (0 / +14dBm , (that was correct , we have two IC's , RX / TX ) (sw is controlling weill . Note, although SW Version 1.40 do not leave to control drictly the GAIN TX , that Replay App , in fact, it was using the inheritated selected GAIN TX from any previous usage of MIC App. That Pull request alllows now to have the following controls 1-) GAIN TX (0..47 ) dB (now it is OK 2-) RF AMP (0 / +14dBm , (that was correct , we have two IC's , RX / TX ) (sw is controlling weill . Remakrs : After the change , now we can control the GAIN TX , but not "in the fly" . When we are in the Replay loop , any change of the FREQUENCY or GAIN TX will be ignored , till we play STOP / START the loop again. (but the AMP RF (0 /+14 dBs) it works in the loop withouth any problems (same as before ) . --- firmware/application/apps/replay_app.cpp | 11 +++++++++-- firmware/application/apps/replay_app.hpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/firmware/application/apps/replay_app.cpp b/firmware/application/apps/replay_app.cpp index d6d445d3..900a8ed9 100644 --- a/firmware/application/apps/replay_app.cpp +++ b/firmware/application/apps/replay_app.cpp @@ -139,7 +139,12 @@ void ReplayAppView::start() { } ); } - + field_rfgain.on_change = [this](int32_t v) { + tx_gain = v; + }; + field_rfgain.set_value(tx_gain); + receiver_model.set_tx_gain(tx_gain); + radio::enable({ receiver_model.tuning_frequency(), sample_rate * 8 , @@ -180,6 +185,8 @@ ReplayAppView::ReplayAppView( NavigationView& nav ) : nav_ (nav) { + + tx_gain = 35;field_rfgain.set_value(tx_gain); baseband::run_image(portapack::spi_flash::image_tag_replay); add_children({ @@ -190,7 +197,7 @@ ReplayAppView::ReplayAppView( &text_duration, &progressbar, &field_frequency, - &field_lna, + &field_rfgain, &field_rf_amp, &check_loop, &button_play, diff --git a/firmware/application/apps/replay_app.hpp b/firmware/application/apps/replay_app.hpp index 9a25ffcf..ac3df3b0 100644 --- a/firmware/application/apps/replay_app.hpp +++ b/firmware/application/apps/replay_app.hpp @@ -51,6 +51,7 @@ private: static constexpr ui::Dim header_height = 3 * 16; uint32_t sample_rate = 0; + int32_t tx_gain { 47 }; static constexpr uint32_t baseband_bandwidth = 2500000; const size_t read_size { 16384 }; const size_t buffer_count { 3 }; @@ -75,7 +76,7 @@ private: bool ready_signal { false }; Labels labels { - { { 10 * 8, 2 * 16 }, "LNA: A:", Color::light_grey() } + { { 10 * 8, 2 * 16 }, "GAIN A:", Color::light_grey() } }; Button button_open { @@ -103,8 +104,13 @@ private: FrequencyField field_frequency { { 0 * 8, 2 * 16 }, }; - LNAGainField field_lna { - { 14 * 8, 2 * 16 } + + NumberField field_rfgain { + { 14 * 8, 2 * 16 }, + 2, + { 0, 47 }, + 1, + ' ' }; RFAmpField field_rf_amp { { 19 * 8, 2 * 16 } From af7242f7d14897136bac905fd686eeb327ba5853 Mon Sep 17 00:00:00 2001 From: AD5NL Date: Mon, 26 Jul 2021 15:39:31 -0500 Subject: [PATCH 31/33] Create ISM.TXT Center frequencies for ISM bands. These are probably where we should be transmitting if unlicensed. --- sdcard/FREQMAN/ISM.TXT | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 sdcard/FREQMAN/ISM.TXT diff --git a/sdcard/FREQMAN/ISM.TXT b/sdcard/FREQMAN/ISM.TXT new file mode 100644 index 00000000..41dcad22 --- /dev/null +++ b/sdcard/FREQMAN/ISM.TXT @@ -0,0 +1,7 @@ +f=13560000,d=Worldwide 13.56 MHz +f=27120000,d=Worldwide 27MHz +f=40660000,d=Worldwide 40MHz +f=433920000,d=ITU Reg 1 433 MHz +f=915000000,d=ITU Reg 2 915 MHz +f=2450000000,d=Worldwide 2.4 GHz +f=5800000000,d=Worldwide 5.8 GHz From 68711261001731edd0cbad8b42c78bb58e98f05c Mon Sep 17 00:00:00 2001 From: Arjan Onwezen Date: Fri, 3 Sep 2021 16:14:16 +0200 Subject: [PATCH 32/33] changed datatype to be able to store > 255 second for backlight timer --- firmware/application/portapack.cpp | 2 +- firmware/application/portapack.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index 44fc1db7..c4f03855 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -83,7 +83,7 @@ TransmitterModel transmitter_model; TemperatureLogger temperature_logger; bool antenna_bias { false }; -uint8_t bl_tick_counter { 0 }; +uint32_t bl_tick_counter { 0 }; void set_antenna_bias(const bool v) { antenna_bias = v; diff --git a/firmware/application/portapack.hpp b/firmware/application/portapack.hpp index c46a8d42..a34d93a6 100644 --- a/firmware/application/portapack.hpp +++ b/firmware/application/portapack.hpp @@ -54,7 +54,7 @@ extern TransmitterModel transmitter_model; extern bool speaker_mode; void set_speaker_mode(const bool v); -extern uint8_t bl_tick_counter; +extern uint32_t bl_tick_counter; extern bool antenna_bias; extern TemperatureLogger temperature_logger; From b335886f42d6a0433469b294b9c78cc6622023cb Mon Sep 17 00:00:00 2001 From: Brumi-2021 <86470699+Brumi-2021@users.noreply.github.com> Date: Sat, 25 Sep 2021 16:37:30 +0200 Subject: [PATCH 33/33] Update main.cpp Remove initial short wrong Ant-DC_BIAS pulse. (250 msegs aprox) --- firmware/application/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 1e5703e1..59ef942c 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -140,6 +140,9 @@ Continuous (Fox-oring) #include "sd_card.hpp" #include + +#include "rffc507x.hpp" /* c/m, avoiding initial short ON Ant_DC_Bias pulse, from cold reset */ +rffc507x::RFFC507x first_if; static void event_loop() { ui::Context context; @@ -160,6 +163,7 @@ static void event_loop() { } int main(void) { + first_if.init(); /* To avoid initial short Ant_DC_Bias pulse ,we need quick set up GP01_RFF507X =1 */ if( portapack::init() ) { portapack::display.init();