mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 03:34:35 +00:00
Recon skip fix (#974)
* definitely fixed, tested, documented bad consecutive match skip problem * stability fix for config when no list * fixed boundaries * replaced 1000000 by #define OneMHz 1000000
This commit is contained in:
parent
69927e3c2d
commit
3c2fc74f82
@ -91,10 +91,10 @@ namespace ui {
|
||||
return _recon;
|
||||
}
|
||||
|
||||
void ReconThread::set_freq_lock(const uint32_t v) {
|
||||
void ReconThread::set_freq_lock(const int32_t v) {
|
||||
_freq_lock = v;
|
||||
}
|
||||
uint32_t ReconThread::is_freq_lock() {
|
||||
int32_t ReconThread::is_freq_lock() {
|
||||
return _freq_lock;
|
||||
}
|
||||
int64_t ReconThread::get_current_freq() {
|
||||
@ -204,6 +204,7 @@ namespace ui {
|
||||
|
||||
while( !chThdShouldTerminate() && frequency_list_.size() > 0 )
|
||||
{
|
||||
uint32_t remaining_sleep = _lock_duration ;
|
||||
if( !_freq_delete )
|
||||
{
|
||||
has_looped = false ;
|
||||
@ -408,7 +409,6 @@ namespace ui {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
restart_recon = true ;
|
||||
}
|
||||
// send a pause message with the right freq
|
||||
if( has_looped && !_continuous )
|
||||
@ -429,9 +429,23 @@ namespace ui {
|
||||
restart_recon = false ;
|
||||
}
|
||||
} // if( _freq_lock == 0 || _stepper != 0 || _index_stepper != 0 )
|
||||
// needed to stabilize consecutive match without skipping
|
||||
// the little the rest, the more reactive and more CPU hog
|
||||
// the bigger the rest, less CPU and more delay when switching
|
||||
while( _freq_lock != -1 && _freq_lock < (int32_t)_lock_nb_match && !chThdShouldTerminate() )
|
||||
{
|
||||
chThdSleepMilliseconds( 10 );
|
||||
if( remaining_sleep >= 10 )
|
||||
remaining_sleep -= 10 ;
|
||||
else
|
||||
remaining_sleep = 0 ;
|
||||
}
|
||||
if( _freq_lock == -1 )
|
||||
_freq_lock = 0 ;
|
||||
} // if( _recon || _stepper != 0 || _index_stepper != 0 )
|
||||
} // if( !freq_delete )
|
||||
chThdSleepMilliseconds( _lock_duration ); //Needed to (eventually) stabilize the receiver into new freq
|
||||
if( remaining_sleep > 0 )
|
||||
chThdSleepMilliseconds( remaining_sleep ); //Needed to (eventually) stabilize the receiver into new freq
|
||||
} //while( !chThdShouldTerminate() && frequency_list_.size() > 0 )
|
||||
}//if (frequency_list_.size() > 0 )
|
||||
} //ReconThread::run
|
||||
@ -648,6 +662,8 @@ namespace ui {
|
||||
if( recon_thread )
|
||||
{
|
||||
int32_t nb_match = recon_thread->is_freq_lock();
|
||||
if( nb_match == -1 )
|
||||
nb_match = 0 ;
|
||||
if( last_db != db )
|
||||
{
|
||||
last_db = db ;
|
||||
@ -719,9 +735,15 @@ namespace ui {
|
||||
//HELPER: Pre-setting a manual range, based on stored frequency
|
||||
rf::Frequency stored_freq = persistent_memory::tuned_frequency();
|
||||
receiver_model.set_tuning_frequency( stored_freq );
|
||||
frequency_range.min = stored_freq - 1000000;
|
||||
if( stored_freq - OneMHz > 0 )
|
||||
frequency_range.min = stored_freq - OneMHz ;
|
||||
else
|
||||
frequency_range.min = 0 ;
|
||||
button_manual_start.set_text(to_string_short_freq(frequency_range.min));
|
||||
frequency_range.max = stored_freq + 1000000;
|
||||
if( stored_freq + OneMHz < MAX_UFREQ )
|
||||
frequency_range.max = stored_freq + OneMHz ;
|
||||
else
|
||||
frequency_range.max = MAX_UFREQ ;
|
||||
button_manual_end.set_text(to_string_short_freq(frequency_range.max));
|
||||
// Loading settings
|
||||
autostart = persistent_memory::recon_autostart_recon();
|
||||
@ -769,11 +791,11 @@ namespace ui {
|
||||
{
|
||||
auto new_view = nav_.push<FrequencyKeypadView>(current_index);
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
f = f / 1000000 ;
|
||||
f = f / OneMHz ;
|
||||
if( f >= 1 && f <= frequency_list.size() )
|
||||
{
|
||||
recon_thread-> set_index_stepper( f - 1 - current_index );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -781,9 +803,9 @@ namespace ui {
|
||||
|
||||
button_manual_start.on_change = [this]() {
|
||||
frequency_range.min = frequency_range.min + button_manual_start.get_encoder_delta() * freqman_entry_get_step_value( def_step );
|
||||
if( frequency_range.min < 1 )
|
||||
if( frequency_range.min < 0 )
|
||||
{
|
||||
frequency_range.min = 1 ;
|
||||
frequency_range.min = 0 ;
|
||||
}
|
||||
if( frequency_range.min > ( MAX_UFREQ - freqman_entry_get_step_value( def_step ) ) )
|
||||
{
|
||||
@ -836,7 +858,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "FW>" );
|
||||
recon_thread-> set_index_stepper( 1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
else if( text_cycle.get_encoder_delta() < 0 )
|
||||
{
|
||||
@ -844,7 +866,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "<RW" );
|
||||
recon_thread-> set_index_stepper( -1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
}
|
||||
text_cycle.set_encoder_delta( 0 );
|
||||
@ -907,7 +929,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "FW>" );
|
||||
recon_thread-> set_stepper( 1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
else if( button_pause.get_encoder_delta() < 0 )
|
||||
{
|
||||
@ -915,7 +937,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "<RW" );
|
||||
recon_thread-> set_stepper( -1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
}
|
||||
button_pause.set_encoder_delta( 0 );
|
||||
@ -1117,7 +1139,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "FW>" );
|
||||
recon_thread-> set_stepper( 1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
else if( button_remove.get_encoder_delta() < 0 )
|
||||
{
|
||||
@ -1125,7 +1147,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "<RW" );
|
||||
recon_thread-> set_stepper( -1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
}
|
||||
button_remove.set_encoder_delta( 0 );
|
||||
@ -1317,7 +1339,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "FW>" );
|
||||
recon_thread-> set_stepper( 1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
else if( button_add.get_encoder_delta() < 0 )
|
||||
{
|
||||
@ -1325,7 +1347,7 @@ namespace ui {
|
||||
recon_thread -> set_recon_direction( fwd );
|
||||
button_dir.set_text( "<RW" );
|
||||
recon_thread-> set_stepper( -1 );
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
}
|
||||
button_add.set_encoder_delta( 0 );
|
||||
@ -1366,10 +1388,11 @@ namespace ui {
|
||||
|
||||
button_recon_setup.on_select = [this,&nav](Button&) {
|
||||
|
||||
ReconSetupSaveStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , recon_lock_duration , field_volume.value() );
|
||||
audio::output::stop();
|
||||
recon_thread->stop(); //STOP SCANNER THREAD
|
||||
frequency_list.clear();
|
||||
|
||||
if( frequency_list.size() != 0 )
|
||||
user_pause();
|
||||
ReconSetupSaveStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , recon_lock_duration , field_volume.value() );
|
||||
|
||||
auto open_view = nav.push<ReconSetupView>(input_file,output_file,recon_lock_duration,recon_lock_nb_match,recon_match_mode);
|
||||
open_view -> on_changed = [this](std::vector<std::string> result) {
|
||||
@ -1390,61 +1413,60 @@ namespace ui {
|
||||
load_hamradios = persistent_memory::recon_load_hamradios();
|
||||
|
||||
update_ranges = persistent_memory::recon_update_ranges_when_recon();
|
||||
|
||||
frequency_file_load( true );
|
||||
frequency_file_load( false );
|
||||
if( recon_thread )
|
||||
{
|
||||
recon_thread->set_lock_duration( recon_lock_duration );
|
||||
recon_thread->set_lock_nb_match( recon_lock_nb_match );
|
||||
recon_thread->set_continuous( continuous );
|
||||
recon_thread->set_recon_direction( fwd );
|
||||
}
|
||||
if( autostart )
|
||||
{
|
||||
user_resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
user_pause();
|
||||
}
|
||||
|
||||
if( update_ranges )
|
||||
{
|
||||
button_manual_start.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) );
|
||||
frequency_range.min = frequency_list[ current_index ] . frequency_a ;
|
||||
if( frequency_list[ current_index ] . frequency_b != 0 )
|
||||
if( autostart )
|
||||
{
|
||||
button_manual_end.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_b ) );
|
||||
frequency_range.max = frequency_list[ current_index ] . frequency_b ;
|
||||
user_resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
button_manual_end.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) );
|
||||
frequency_range.max = frequency_list[ current_index ] . frequency_a ;
|
||||
user_pause();
|
||||
}
|
||||
if( update_ranges && frequency_list.size() != 0 )
|
||||
{
|
||||
current_index = 0 ;
|
||||
button_manual_start.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) );
|
||||
frequency_range.min = frequency_list[ current_index ] . frequency_a ;
|
||||
if( frequency_list[ current_index ] . frequency_b != 0 )
|
||||
{
|
||||
button_manual_end.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_b ) );
|
||||
frequency_range.max = frequency_list[ current_index ] . frequency_b ;
|
||||
}
|
||||
else
|
||||
{
|
||||
button_manual_end.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) );
|
||||
frequency_range.max = frequency_list[ current_index ] . frequency_a ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock_wait = ( 4 * ( recon_lock_duration * recon_lock_nb_match ) ) / 100 ;
|
||||
lock_wait = lock_wait * 100 ; // poor man's rounding
|
||||
if( lock_wait < 400 )
|
||||
lock_wait = 400 ;
|
||||
field_lock_wait.set_value( lock_wait );
|
||||
show_max();
|
||||
return ;
|
||||
if( userpause != true )
|
||||
{
|
||||
timer = 0 ;
|
||||
user_resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( recon_thread && frequency_list.size() != 0 )
|
||||
{
|
||||
RetuneMessage message { };
|
||||
message.freq = recon_thread->get_current_freq();
|
||||
message.range = current_index ;
|
||||
EventDispatcher::send_message(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if( userpause != true )
|
||||
{
|
||||
timer = 0 ;
|
||||
user_resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
RetuneMessage message { };
|
||||
message.freq = recon_thread->get_current_freq();
|
||||
message.range = current_index ;
|
||||
EventDispatcher::send_message(message);
|
||||
}
|
||||
};
|
||||
|
||||
field_wait.on_change = [this](int32_t v)
|
||||
@ -1668,7 +1690,7 @@ namespace ui {
|
||||
status = 0 ;
|
||||
update_stats = true ;
|
||||
continuous_lock = false ;
|
||||
recon_thread->set_freq_lock( 0 ); //in lock period, still analyzing the signal
|
||||
recon_thread->set_freq_lock( -1 ); //in lock period, still analyzing the signal
|
||||
recon_resume(); // RESUME!
|
||||
big_display.set_style(&style_white);
|
||||
}
|
||||
@ -1703,7 +1725,7 @@ namespace ui {
|
||||
}
|
||||
}
|
||||
}
|
||||
else // freq_lock < max_lock , LOCKING
|
||||
else if( freq_lock >= 0 ) // freq_lock < max_lock , LOCKING
|
||||
{
|
||||
if( actual_db > squelch ) //MATCHING LEVEL
|
||||
{
|
||||
@ -1734,6 +1756,7 @@ namespace ui {
|
||||
{
|
||||
timer = 0 ;
|
||||
update_stats = true ;
|
||||
recon_thread->set_freq_lock( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,12 @@
|
||||
// maximum usable freq
|
||||
#define MAX_UFREQ 7200000000
|
||||
|
||||
// 1Mhz helper
|
||||
#ifdef OneMHz
|
||||
#undef OneMHz
|
||||
#endif
|
||||
#define OneMHz 1000000
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ReconThread {
|
||||
@ -59,8 +65,8 @@ namespace ui {
|
||||
void set_match_mode( const uint32_t v );
|
||||
uint32_t get_lock_nb_match();
|
||||
|
||||
void set_freq_lock(const uint32_t v);
|
||||
uint32_t is_freq_lock();
|
||||
void set_freq_lock(const int32_t v);
|
||||
int32_t is_freq_lock();
|
||||
int64_t get_current_freq();
|
||||
|
||||
void set_stepper(const int64_t v);
|
||||
|
Loading…
Reference in New Issue
Block a user