mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
save load settings / thread timer fix (#979)
* fixing bad parameter in save and load settings, as well as default settings. Tuned thread timers a bit * uniformisation of default values * indentation * fix resume recon after lock
This commit is contained in:
parent
a86993af91
commit
1e4ea753ba
@ -103,7 +103,6 @@ namespace ui {
|
|||||||
|
|
||||||
void ReconThread::change_recon_direction() {
|
void ReconThread::change_recon_direction() {
|
||||||
_fwd = !_fwd;
|
_fwd = !_fwd;
|
||||||
//chThdSleepMilliseconds(300); //Give some pause after reversing recon direction
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReconThread::get_recon_direction() {
|
bool ReconThread::get_recon_direction() {
|
||||||
@ -429,22 +428,23 @@ namespace ui {
|
|||||||
restart_recon = false ;
|
restart_recon = false ;
|
||||||
}
|
}
|
||||||
} // if( _freq_lock == 0 || _stepper != 0 || _index_stepper != 0 )
|
} // if( _freq_lock == 0 || _stepper != 0 || _index_stepper != 0 )
|
||||||
// needed to stabilize consecutive match without skipping
|
|
||||||
|
// this while loop is needed to stabilize consecutive match without skipping
|
||||||
// the little the rest, the more reactive and more CPU hog
|
// the little the rest, the more reactive and more CPU hog
|
||||||
// the bigger the rest, less CPU and more delay when switching
|
// the bigger the rest, less CPU and more delay when switching. I choose 5 msecs.
|
||||||
while( _freq_lock != -1 && _freq_lock < (int32_t)_lock_nb_match && !chThdShouldTerminate() )
|
while( _freq_lock != -1 && _freq_lock < (int32_t)_lock_nb_match && !chThdShouldTerminate() )
|
||||||
{
|
{
|
||||||
chThdSleepMilliseconds( 10 );
|
chThdSleepMilliseconds( 5 );
|
||||||
if( remaining_sleep >= 10 )
|
if( remaining_sleep >= 5 )
|
||||||
remaining_sleep -= 10 ;
|
remaining_sleep -= 5 ;
|
||||||
else
|
else
|
||||||
remaining_sleep = 0 ;
|
remaining_sleep = 0 ; // leave some process time
|
||||||
}
|
}
|
||||||
if( _freq_lock == -1 )
|
if( _freq_lock == -1 )
|
||||||
_freq_lock = 0 ;
|
_freq_lock = 0 ;
|
||||||
} // if( _recon || _stepper != 0 || _index_stepper != 0 )
|
} // if( _recon || _stepper != 0 || _index_stepper != 0 )
|
||||||
} // if( !freq_delete )
|
} // if( !freq_delete )
|
||||||
if( remaining_sleep > 0 )
|
if( remaining_sleep )
|
||||||
chThdSleepMilliseconds( remaining_sleep ); //Needed to (eventually) stabilize the receiver into new freq
|
chThdSleepMilliseconds( remaining_sleep ); //Needed to (eventually) stabilize the receiver into new freq
|
||||||
} //while( !chThdShouldTerminate() && frequency_list_.size() > 0 )
|
} //while( !chThdShouldTerminate() && frequency_list_.size() > 0 )
|
||||||
}//if (frequency_list_.size() > 0 )
|
}//if (frequency_list_.size() > 0 )
|
||||||
@ -645,7 +645,7 @@ namespace ui {
|
|||||||
|
|
||||||
ReconView::~ReconView() {
|
ReconView::~ReconView() {
|
||||||
|
|
||||||
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() );
|
ReconSetupSaveStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , lock_wait , field_volume.value() );
|
||||||
|
|
||||||
// save app settings
|
// save app settings
|
||||||
settings.save("recon", &app_settings);
|
settings.save("recon", &app_settings);
|
||||||
@ -758,8 +758,6 @@ namespace ui {
|
|||||||
field_volume.set_value( volume );
|
field_volume.set_value( volume );
|
||||||
if( sd_card_mounted )
|
if( sd_card_mounted )
|
||||||
{
|
{
|
||||||
//Loading input and output file from settings
|
|
||||||
ReconSetupLoadStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , recon_lock_duration , volume );
|
|
||||||
// load auto common app settings
|
// load auto common app settings
|
||||||
auto rc = settings.load("recon", &app_settings);
|
auto rc = settings.load("recon", &app_settings);
|
||||||
if(rc == SETTINGS_OK) {
|
if(rc == SETTINGS_OK) {
|
||||||
@ -1392,8 +1390,6 @@ namespace ui {
|
|||||||
recon_thread->stop(); //STOP SCANNER THREAD
|
recon_thread->stop(); //STOP SCANNER THREAD
|
||||||
frequency_list.clear();
|
frequency_list.clear();
|
||||||
|
|
||||||
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);
|
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) {
|
open_view -> on_changed = [this](std::vector<std::string> result) {
|
||||||
input_file = result[0];
|
input_file = result[0];
|
||||||
@ -1402,7 +1398,7 @@ namespace ui {
|
|||||||
recon_lock_nb_match = strtol( result[3].c_str() , nullptr , 10 );
|
recon_lock_nb_match = strtol( result[3].c_str() , nullptr , 10 );
|
||||||
recon_match_mode = strtol( result[4].c_str() , nullptr , 10 );
|
recon_match_mode = strtol( result[4].c_str() , nullptr , 10 );
|
||||||
|
|
||||||
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() );
|
ReconSetupSaveStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , lock_wait , field_volume.value() );
|
||||||
|
|
||||||
autosave = persistent_memory::recon_autosave_freqs();
|
autosave = persistent_memory::recon_autosave_freqs();
|
||||||
autostart = persistent_memory::recon_autostart_recon();
|
autostart = persistent_memory::recon_autostart_recon();
|
||||||
@ -1445,10 +1441,6 @@ namespace ui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 );
|
field_lock_wait.set_value( lock_wait );
|
||||||
show_max();
|
show_max();
|
||||||
if( userpause != true )
|
if( userpause != true )
|
||||||
@ -1529,13 +1521,12 @@ namespace ui {
|
|||||||
button_scanner_mode.set_style( &style_blue );
|
button_scanner_mode.set_style( &style_blue );
|
||||||
button_scanner_mode.set_text( "RECON" );
|
button_scanner_mode.set_text( "RECON" );
|
||||||
file_name.set( "=>" );
|
file_name.set( "=>" );
|
||||||
field_squelch.set_value( squelch );
|
|
||||||
|
|
||||||
|
//Loading input and output file from settings
|
||||||
|
ReconSetupLoadStrings( "RECON/RECON.CFG" , input_file , output_file , recon_lock_duration , recon_lock_nb_match , squelch , recon_match_mode , wait , lock_wait , volume );
|
||||||
|
|
||||||
|
field_squelch.set_value( squelch );
|
||||||
field_wait.set_value(wait);
|
field_wait.set_value(wait);
|
||||||
lock_wait = ( 4 * ( recon_lock_duration * recon_lock_nb_match ) );
|
|
||||||
lock_wait = lock_wait / 100 ; lock_wait = lock_wait * 100 ; // poor man's rounding
|
|
||||||
if( lock_wait < 400 )
|
|
||||||
lock_wait = 400 ;
|
|
||||||
field_lock_wait.set_value(lock_wait);
|
field_lock_wait.set_value(lock_wait);
|
||||||
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
|
field_volume.set_value((receiver_model.headphone_volume() - audio::headphone::volume_range().max).decibel() + 99);
|
||||||
|
|
||||||
@ -1819,7 +1810,7 @@ namespace ui {
|
|||||||
|
|
||||||
void ReconView::user_pause() {
|
void ReconView::user_pause() {
|
||||||
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
|
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
|
||||||
//button_pause.set_text("<RESUME>"); //PAUSED, show resume
|
button_pause.set_text("<RESUME>"); //PAUSED, show resume
|
||||||
userpause=true;
|
userpause=true;
|
||||||
continuous_lock=false;
|
continuous_lock=false;
|
||||||
recon_pause();
|
recon_pause();
|
||||||
@ -1827,7 +1818,7 @@ namespace ui {
|
|||||||
|
|
||||||
void ReconView::user_resume() {
|
void ReconView::user_resume() {
|
||||||
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
|
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
|
||||||
//button_pause.set_text("<PAUSE>"); //Show button for pause
|
button_pause.set_text("<PAUSE>"); //Show button for pause
|
||||||
userpause=false; // Resume recon
|
userpause=false; // Resume recon
|
||||||
continuous_lock=false;
|
continuous_lock=false;
|
||||||
recon_resume();
|
recon_resume();
|
||||||
|
@ -188,8 +188,8 @@ namespace ui {
|
|||||||
int32_t squelch { 0 };
|
int32_t squelch { 0 };
|
||||||
int32_t db { 0 };
|
int32_t db { 0 };
|
||||||
int32_t timer { 0 };
|
int32_t timer { 0 };
|
||||||
int32_t wait { 5000 }; // in msec. if > 0 wait duration after a lock, if < 0 duration is set to 'wait' unless there is no more activity
|
int32_t wait { 1000 }; // in msec. if > 0 wait duration after a lock, if < 0 duration is set to 'wait' unless there is no more activity
|
||||||
uint32_t lock_wait { 500 }; // in msec. Represent the maximum amount of time we will wait for a lock to complete before switching to next
|
uint32_t lock_wait { 1000 }; // in msec. Represent the maximum amount of time we will wait for a lock to complete before switching to next
|
||||||
int32_t def_step { 0 };
|
int32_t def_step { 0 };
|
||||||
freqman_db frequency_list = { };
|
freqman_db frequency_list = { };
|
||||||
uint32_t current_index { 0 };
|
uint32_t current_index { 0 };
|
||||||
@ -206,7 +206,7 @@ namespace ui {
|
|||||||
bool load_hamradios = { true };
|
bool load_hamradios = { true };
|
||||||
bool update_ranges = { true };
|
bool update_ranges = { true };
|
||||||
bool fwd = { true };
|
bool fwd = { true };
|
||||||
uint32_t recon_lock_nb_match = { 10 };
|
uint32_t recon_lock_nb_match = { 3 };
|
||||||
uint32_t recon_lock_duration = { 50 };
|
uint32_t recon_lock_duration = { 50 };
|
||||||
uint32_t recon_match_mode = { 0 };
|
uint32_t recon_match_mode = { 0 };
|
||||||
bool scanner_mode { false };
|
bool scanner_mode { false };
|
||||||
|
@ -84,7 +84,21 @@ namespace ui {
|
|||||||
file_position -= (file_data + 256 - line_start);
|
file_position -= (file_data + 256 - line_start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( it < nb_params )
|
||||||
|
{
|
||||||
|
/* bad number of params, signal defaults */
|
||||||
|
input_file = "RECON" ;
|
||||||
|
output_file = "RECON_RESULTS" ;
|
||||||
|
recon_lock_duration = 50 ;
|
||||||
|
recon_lock_nb_match = 3 ;
|
||||||
|
recon_squelch_level = -14 ;
|
||||||
|
recon_match_mode = 0 ;
|
||||||
|
wait = 1000 ;
|
||||||
|
lock_wait = 1000 ;
|
||||||
|
volume = 40 ;
|
||||||
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( it > 0 )
|
if( it > 0 )
|
||||||
@ -105,7 +119,7 @@ namespace ui {
|
|||||||
if( it > 3 )
|
if( it > 3 )
|
||||||
recon_lock_nb_match = strtoll( params[ 3 ].c_str() , nullptr , 10 );
|
recon_lock_nb_match = strtoll( params[ 3 ].c_str() , nullptr , 10 );
|
||||||
else
|
else
|
||||||
recon_lock_nb_match = 10 ;
|
recon_lock_nb_match = 3 ;
|
||||||
|
|
||||||
if( it > 4 )
|
if( it > 4 )
|
||||||
recon_squelch_level = strtoll( params[ 4 ].c_str() , nullptr , 10 );
|
recon_squelch_level = strtoll( params[ 4 ].c_str() , nullptr , 10 );
|
||||||
@ -120,7 +134,7 @@ namespace ui {
|
|||||||
if( it > 6 )
|
if( it > 6 )
|
||||||
wait = strtoll( params[ 6 ].c_str() , nullptr , 10 );
|
wait = strtoll( params[ 6 ].c_str() , nullptr , 10 );
|
||||||
else
|
else
|
||||||
wait = 5000 ;
|
wait = 1000 ;
|
||||||
|
|
||||||
if( it > 7 )
|
if( it > 7 )
|
||||||
lock_wait = strtoll( params[ 7 ].c_str() , nullptr , 10 );
|
lock_wait = strtoll( params[ 7 ].c_str() , nullptr , 10 );
|
||||||
@ -132,11 +146,6 @@ namespace ui {
|
|||||||
else
|
else
|
||||||
volume = 40 ;
|
volume = 40 ;
|
||||||
|
|
||||||
if( it < nb_params )
|
|
||||||
{
|
|
||||||
/* bad number of params, signal defaults */
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user