From 1b2c68b3c0099f09dcd9fc374101bc2f98f2749a Mon Sep 17 00:00:00 2001 From: euquiq <31453004+euquiq@users.noreply.github.com> Date: Sat, 1 Aug 2020 00:58:34 -0300 Subject: [PATCH] New squelch behavior and fixes Squelch value now goes from -90 to +20 and it's directly compared against the max_db parameter returned from each freq scanned by the radio subsystem, with no adjusts or manipulation (you adjust the number as will be used). Less squelch means weaker signals will trigger it. (as expected). There was a tiny cosmetic bug when you deleted a frequency from the scanning memory: The description was not erased from screen and you could see it while the scan did not resume. There was another bug on the pause button: If you asked for another manual scan range when paused, the button kept the text "RESUME" (its text was not reset to "PAUSE" again). --- firmware/application/apps/ui_scanner.cpp | 28 ++++++++++-------------- firmware/application/apps/ui_scanner.hpp | 6 ++--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/firmware/application/apps/ui_scanner.cpp b/firmware/application/apps/ui_scanner.cpp index 63b5f9bb..65c4788d 100644 --- a/firmware/application/apps/ui_scanner.cpp +++ b/firmware/application/apps/ui_scanner.cpp @@ -105,7 +105,6 @@ void ScannerThread::run() { EventDispatcher::send_message(message); } else { //NOT scanning - restart_scan=true; //Flag the need for skipping a cycle when restarting scan if (_freq_del != 0) { //There is a frequency to delete for (uint16_t i = 0; i < frequency_list_.size(); i++) { //Search for the freq to delete if (frequency_list_[i] == _freq_del) @@ -120,6 +119,9 @@ void ScannerThread::run() { } _freq_del = 0; //deleted. } + else { + restart_scan=true; //Flag the need for skipping a cycle when restarting scan + } } chThdSleepMilliseconds(50); //Needed to (eventually) stabilize the receiver into new freq } @@ -161,8 +163,10 @@ void ScannerView::show_max() { //show total number of freqs to scan text_max.set_style(&style_red); text_max.set( "/ " + to_string_dec_uint(MAX_DB_ENTRY) + " (DB MAX!)"); } - else + else { + text_max.set_style(&style_grey); text_max.set( "/ " + to_string_dec_uint(frequency_list.size())); + } } ScannerView::ScannerView( @@ -200,8 +204,6 @@ ScannerView::ScannerView( def_step = change_mode(AM); //Start on AM field_mode.set_by_value(AM); //Reflect the mode into the manual selector - //big_display.set_style(&style_grey); //Start with gray color - //HELPER: Pre-setting a manual range, based on stored frequency rf::Frequency stored_freq = persistent_memory::tuned_frequency(); frequency_range.min = stored_freq - 1000000; @@ -255,8 +257,7 @@ ScannerView::ScannerView( description_list.erase(description_list.begin() + current_index); frequency_list.erase(frequency_list.begin() + current_index); show_max(); //UPDATE new list size on screen - chThdSleepMilliseconds(300); //"debouncing" pause so user take finger off - timer = wait * 10; //Unlock timer pause on_statistics_update + desc_cycle.set(" "); //Clean up description (cosmetic detail) scan_thread->set_freq_lock(0); //Reset the scanner lock if ( userpause ) //If user-paused, resume user_resume(); @@ -296,16 +297,12 @@ ScannerView::ScannerView( }; field_mode.on_change = [this](size_t, OptionsField::value_t v) { - if (scan_thread->is_scanning()) - scan_thread->set_scanning(false); //STOP SCANNING - audio::output::stop(); - scan_thread->stop(); receiver_model.disable(); baseband::shutdown(); change_mode(v); - if ( userpause ) //If user-paused, resume - user_resume(); - start_scan_thread(); + if ( !scan_thread->is_scanning() ) //for some motive, audio output gets stopped. + audio::output::start(); //So if scan was stopped we resume audio + receiver_model.enable(); }; button_dir.on_select = [this](Button&) { @@ -357,7 +354,7 @@ ScannerView::ScannerView( //PRE-CONFIGURATION: field_wait.on_change = [this](int32_t v) { wait = v; }; field_wait.set_value(5); - field_squelch.on_change = [this](int32_t v) { squelch = v; }; field_squelch.set_value(30); + field_squelch.on_change = [this](int32_t v) { squelch = v; }; field_squelch.set_value(-10); 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); }; // LEARN FREQUENCIES @@ -417,7 +414,7 @@ void ScannerView::on_statistics_update(const ChannelStatistics& statistics) { } else if (!timer) { - if (statistics.max_db > -squelch) { //There is something on the air... + if (statistics.max_db > squelch ) { //There is something on the air...(statistics.max_db > -squelch) if (scan_thread->is_freq_lock() >= MAX_FREQ_LOCK) { //checking time reached scan_pause(); timer++; @@ -511,7 +508,6 @@ size_t ScannerView::change_mode(uint8_t new_mod) { //Before this, do a scan_thre } return mod_step[new_mod]; - } void ScannerView::start_scan_thread() { diff --git a/firmware/application/apps/ui_scanner.hpp b/firmware/application/apps/ui_scanner.hpp index 35598e12..d2befbfe 100644 --- a/firmware/application/apps/ui_scanner.hpp +++ b/firmware/application/apps/ui_scanner.hpp @@ -142,7 +142,7 @@ private: Labels labels { { { 0 * 8, 0 * 16 }, "LNA: VGA: AMP: VOL:", Color::light_grey() }, - { { 0 * 8, 1* 16 }, "BW: SQUELCH: /99 WAIT:", Color::light_grey() }, + { { 0 * 8, 1* 16 }, "BW: SQUELCH: db WAIT:", Color::light_grey() }, { { 3 * 8, 10 * 16 }, "START END MANUAL", Color::light_grey() }, { { 0 * 8, (26 * 8) + 4 }, "MODE:", Color::light_grey() }, { { 11 * 8, (26 * 8) + 4 }, "STEP:", Color::light_grey() }, @@ -176,8 +176,8 @@ private: NumberField field_squelch { { 15 * 8, 1 * 16 }, - 2, - { 0, 99 }, + 3, + { -90, 20 }, 1, ' ', };