Fixed so ui glitches, start when empty file and direct click on config. Added yellow coloration when loaded file was truncated (too big). Added/changed some error messages

This commit is contained in:
GullCode 2023-05-04 15:20:12 +02:00
parent 1b18b3ac45
commit 7b6f8b271c
2 changed files with 133 additions and 89 deletions

View File

@ -33,7 +33,6 @@
#define MSG_RECON_SET_RECEIVER_BANDWIDTH 40000 // for handle_retune to know that recon thread triggered a receiver bandwidth change. f is the new bandwidth in hz #define MSG_RECON_SET_RECEIVER_BANDWIDTH 40000 // for handle_retune to know that recon thread triggered a receiver bandwidth change. f is the new bandwidth in hz
#define MSG_RECON_SET_RECEIVER_SAMPLERATE 50000 // for handle_retune to know that recon thread triggered a receiver samplerate change. f is the new samplerate in hz/s #define MSG_RECON_SET_RECEIVER_SAMPLERATE 50000 // for handle_retune to know that recon thread triggered a receiver samplerate change. f is the new samplerate in hz/s
using namespace portapack; using namespace portapack;
using portapack::memory::map::backup_ram; using portapack::memory::map::backup_ram;
@ -476,7 +475,7 @@ namespace ui {
baseband::shutdown(); baseband::shutdown();
change_mode( freq ); change_mode( freq );
if ( !recon_thread->is_recon() ) // for some motive, audio output gets stopped. if ( !recon_thread->is_recon() ) // for some motive, audio output gets stopped.
audio::output::start(); //So if recon was stopped we resume audio audio::output::start(); // so if recon was stopped we resume audio
receiver_model.enable(); receiver_model.enable();
field_mode.set_selected_index( freq ); field_mode.set_selected_index( freq );
return ; return ;
@ -543,6 +542,10 @@ namespace ui {
break ; break ;
} }
} }
else
{
desc_cycle.set( "...no description..." ); //Show new description
}
} }
uint32_t freq_lock = recon_thread->is_freq_lock(); uint32_t freq_lock = recon_thread->is_freq_lock();
@ -641,7 +644,7 @@ namespace ui {
static int32_t last_db = 999999 ; static int32_t last_db = 999999 ;
static int32_t last_nb_match = 999999 ; static int32_t last_nb_match = 999999 ;
static int32_t last_timer = -1 ; static int32_t last_timer = -1 ;
if( recon_thread && frequency_list.size() > 0 ) if( recon_thread )
{ {
int32_t nb_match = recon_thread->is_freq_lock(); int32_t nb_match = recon_thread->is_freq_lock();
if( last_db != db ) if( last_db != db )
@ -666,15 +669,6 @@ namespace ui {
text_timer.set( "TIMER: " + to_string_dec_int( timer ) ); text_timer.set( "TIMER: " + to_string_dec_int( timer ) );
} }
} }
else
{
if( refresh_display )
{
text_max.set( to_string_dec_int( db ) + " db" );
freq_stats.set( "RSSI: " +to_string_dec_int( rssi.get_min() )+"/"+to_string_dec_int( rssi.get_avg() )+"/"+to_string_dec_int( rssi.get_max() )+" db" );
text_timer.set( "TIMER: " + to_string_dec_int( timer ) );
}
}
} }
ReconView::ReconView( NavigationView& nav) : nav_ { nav } { ReconView::ReconView( NavigationView& nav) : nav_ { nav } {
@ -720,11 +714,7 @@ namespace ui {
make_new_directory( u"/RECON" ); make_new_directory( u"/RECON" );
sd_card_mounted = true ; sd_card_mounted = true ;
} }
def_step = 0 ; def_step = 0 ;
change_mode(AM_MODULATION); //Start on AM
field_mode.set_by_value(AM_MODULATION); //Reflect the mode into the manual selector
//HELPER: Pre-setting a manual range, based on stored frequency //HELPER: Pre-setting a manual range, based on stored frequency
rf::Frequency stored_freq = persistent_memory::tuned_frequency(); rf::Frequency stored_freq = persistent_memory::tuned_frequency();
receiver_model.set_tuning_frequency( stored_freq ); receiver_model.set_tuning_frequency( stored_freq );
@ -742,14 +732,12 @@ namespace ui {
load_hamradios = persistent_memory::recon_load_hamradios(); load_hamradios = persistent_memory::recon_load_hamradios();
update_ranges = persistent_memory::recon_update_ranges_when_recon(); update_ranges = persistent_memory::recon_update_ranges_when_recon();
//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 );
field_volume.set_value( volume ); field_volume.set_value( volume );
// load auto common app settings
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
auto rc = settings.load("recon", &app_settings); auto rc = settings.load("recon", &app_settings);
if(rc == SETTINGS_OK) { if(rc == SETTINGS_OK) {
field_lna.set_value(app_settings.lna); field_lna.set_value(app_settings.lna);
@ -758,11 +746,6 @@ namespace ui {
receiver_model.set_rf_amp(app_settings.rx_amp); receiver_model.set_rf_amp(app_settings.rx_amp);
} }
} }
button_scanner_mode.set_style( &style_blue );
button_scanner_mode.set_text( "RECON" );
file_name.set( "=>" );
field_squelch.set_value( squelch );
button_manual_start.on_select = [this, &nav](ButtonWithEncoder& button) { button_manual_start.on_select = [this, &nav](ButtonWithEncoder& button) {
auto new_view = nav_.push<FrequencyKeypadView>(frequency_range.min); auto new_view = nav_.push<FrequencyKeypadView>(frequency_range.min);
@ -995,21 +978,21 @@ namespace ui {
switch( frequency_list[current_index].type ) switch( frequency_list[current_index].type )
{ {
case RANGE: case RANGE:
desc_cycle.set( "R: " + frequency_list[current_index].description ); //Show new description desc_cycle.set( "R: " + frequency_list[current_index].description );
break ; break ;
case HAMRADIO: case HAMRADIO:
desc_cycle.set( "H: " + frequency_list[current_index].description ); //Show new description desc_cycle.set( "H: " + frequency_list[current_index].description );
break ; break ;
default: default:
case SINGLE: case SINGLE:
desc_cycle.set( "S: " + frequency_list[current_index].description ); //Show new description desc_cycle.set( "S: " + frequency_list[current_index].description );
break ; break ;
} }
} }
else else
{ {
desc_cycle.set( "no description" ); //Show new description desc_cycle.set( "...no description..." );
show_max( true ); //UPDATE new list size on screen show_max( true );
} }
text_cycle.set_text( to_string_dec_uint( current_index + 1 , 3 ) ); text_cycle.set_text( to_string_dec_uint( current_index + 1 , 3 ) );
@ -1163,7 +1146,6 @@ namespace ui {
def_step = step_mode.selected_index(); // max range val def_step = step_mode.selected_index(); // max range val
manual_freq_entry . type = RANGE ; manual_freq_entry . type = RANGE ;
manual_freq_entry . description = manual_freq_entry . description =
"R " + to_string_short_freq(frequency_range.min) + ">" "R " + to_string_short_freq(frequency_range.min) + ">"
@ -1184,11 +1166,14 @@ namespace ui {
freq_stats.set( "0/0/0" ); freq_stats.set( "0/0/0" );
show_max(); /* display step information */ show_max(); /* display step information */
text_cycle.set_text( "MANUAL SEARCH" ); text_cycle.set_text( "1" );
text_max.set( "/1" );
button_scanner_mode.set_style( &style_white ); button_scanner_mode.set_style( &style_white );
button_scanner_mode.set_text( "MSEARCH" ); button_scanner_mode.set_text( "MSEARCH" );
file_name.set_style( &style_white ); file_name.set_style( &style_white );
file_name.set( "=> MANUAL RANGE" ); file_name.set( "MANUAL RANGE RECON" );
desc_cycle.set_style( &style_white );
desc_cycle.set( "MANUAL RANGE RECON" );
start_recon_thread(); start_recon_thread();
user_resume(); user_resume();
@ -1245,9 +1230,20 @@ namespace ui {
show_max(); show_max();
user_resume(); user_resume();
} }
if( scanner_mode )
{
file_name.set_style( &style_red );
button_scanner_mode.set_style( &style_red );
button_scanner_mode.set_text( "SCANNER" );
}
else
{
file_name.set_style( &style_blue );
button_scanner_mode.set_style( &style_blue );
button_scanner_mode.set_text( "RECON" );
}
}; };
button_add.on_select = [this](ButtonWithEncoder&) { //frequency_list[current_index] button_add.on_select = [this](ButtonWithEncoder&) { //frequency_list[current_index]
if( !scanner_mode) if( !scanner_mode)
{ {
@ -1371,6 +1367,7 @@ namespace ui {
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 , recon_lock_duration , field_volume.value() );
if( frequency_list.size() != 0 )
user_pause(); user_pause();
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);
@ -1449,7 +1446,6 @@ namespace ui {
} }
}; };
//PRE-CONFIGURATION:
field_wait.on_change = [this](int32_t v) field_wait.on_change = [this](int32_t v)
{ {
wait = v ; wait = v ;
@ -1470,6 +1466,7 @@ namespace ui {
field_wait.set_style( &style_green ); field_wait.set_style( &style_green );
} }
}; };
field_lock_wait.on_change = [this](int32_t v) field_lock_wait.on_change = [this](int32_t v)
{ {
lock_wait = v ; lock_wait = v ;
@ -1495,34 +1492,47 @@ namespace ui {
} }
}; };
field_squelch.on_change = [this](int32_t v) {
squelch = v ;
};
field_volume.on_change = [this](int32_t v) {
this->on_headphone_volume_changed(v);
};
//PRE-CONFIGURATION:
change_mode(AM_MODULATION); //Start on AM
field_mode.set_by_value(AM_MODULATION); //Reflect the mode into the manual selector
button_scanner_mode.set_style( &style_blue );
button_scanner_mode.set_text( "RECON" );
file_name.set( "=>" );
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 = ( 4 * ( recon_lock_duration * recon_lock_nb_match ) );
lock_wait = lock_wait / 100 ; lock_wait = lock_wait * 100 ; // poor man's rounding lock_wait = lock_wait / 100 ; lock_wait = lock_wait * 100 ; // poor man's rounding
if( lock_wait < 400 ) if( lock_wait < 400 )
lock_wait = 400 ; lock_wait = 400 ;
field_lock_wait.set_value(lock_wait); field_lock_wait.set_value(lock_wait);
field_squelch.on_change = [this](int32_t v) {
squelch = v ;
};
field_volume.on_change = [this](int32_t v) { this->on_headphone_volume_changed(v); };
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);
//FILL STEP OPTIONS //FILL STEP OPTIONS
freqman_set_modulation_option( field_mode ); freqman_set_modulation_option( field_mode );
freqman_set_step_option( step_mode ); freqman_set_step_option( step_mode );
receiver_model.set_tuning_frequency( portapack::persistent_memory::tuned_frequency() ); // Retune
if( filedelete ) if( filedelete )
{ {
delete_file( "FREQMAN/"+output_file+".TXT" ); delete_file( "FREQMAN/"+output_file+".TXT" );
} }
frequency_file_load( false ); /* do not stop all at start */ frequency_file_load( false ); /* do not stop all at start */
if( recon_thread && frequency_list.size() > 0 ) if( recon_thread )
{ {
recon_thread->set_lock_duration( recon_lock_duration ); recon_thread->set_lock_duration( recon_lock_duration );
recon_thread->set_lock_nb_match( recon_lock_nb_match ); recon_thread->set_lock_nb_match( recon_lock_nb_match );
if( update_ranges ) if( update_ranges && frequency_list.size() > 0 )
{ {
button_manual_start.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) ); button_manual_start.set_text( to_string_short_freq( frequency_list[ current_index ] . frequency_a ) );
frequency_range.min = frequency_list[ current_index ] . frequency_a ; frequency_range.min = frequency_list[ current_index ] . frequency_a ;
@ -1537,7 +1547,6 @@ namespace ui {
frequency_range.max = frequency_list[ current_index ] . frequency_a ; frequency_range.max = frequency_list[ current_index ] . frequency_a ;
} }
} }
if( autostart ) if( autostart )
{ {
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.
@ -1560,42 +1569,77 @@ namespace ui {
} }
audio::output::stop(); audio::output::stop();
if( !scanner_mode) def_step = step_mode.selected_index(); // use def_step from manual selector
{
def_step = step_mode.selected_index(); //Use def_step from manual selector
frequency_list.clear(); // clear the existing frequency list (expected behavior) frequency_list.clear(); // clear the existing frequency list (expected behavior)
if( !load_freqman_file_ex( input_file , frequency_list, load_freqs, load_ranges, load_hamradios ) ) std::string file_input = input_file ; // default recon mode
if( scanner_mode )
{ {
desc_cycle.set(" NO " + input_file + ".TXT FILE ..." ); file_input = output_file ;
file_name.set_style( &style_white ); file_name.set_style( &style_red );
file_name.set( "=> NO DATA" ); button_scanner_mode.set_style( &style_red );
button_scanner_mode.set_text( "SCANNER" );
} }
else else
{ {
file_name.set_style( &style_blue ); file_name.set_style( &style_blue );
file_name.set( "=> "+input_file ); button_scanner_mode.set_style( &style_blue );
button_scanner_mode.set_text( "RECON" );
} }
step_mode.set_selected_index(def_step); //Impose the default step into the manual step selector
}
else
{
def_step = step_mode.selected_index(); //Use def_step from manual selector
frequency_list.clear(); // clear the existing frequency list (expected behavior)
if( !load_freqman_file_ex( output_file , frequency_list, load_freqs, load_ranges, load_hamradios ) )
{
desc_cycle.set(" NO " + output_file + ".TXT FILE ..." );
file_name.set_style( &style_white ); file_name.set_style( &style_white );
file_name.set( "=> EMPTY" ); desc_cycle.set_style( &style_white );
if( !load_freqman_file_ex( file_input , frequency_list, load_freqs, load_ranges, load_hamradios ) )
{
file_name.set_style( &style_red );
desc_cycle.set_style( &style_red );
desc_cycle.set(" NO " + file_input + ".TXT FILE ..." );
file_name.set( "=> NO DATA" );
} }
else else
{ {
file_name.set( "=> "+output_file ); file_name.set( "=> "+file_input );
if( frequency_list.size() == 0 )
{
file_name.set_style( &style_red ); file_name.set_style( &style_red );
desc_cycle.set_style( &style_red );
desc_cycle.set("/0 no entries in list" );
file_name.set( "BadOrEmpty "+file_input );
}
else
{
if( frequency_list.size() > FREQMAN_MAX_PER_FILE )
{
file_name.set_style( &style_yellow );
desc_cycle.set_style( &style_yellow );
}
}
} }
step_mode.set_selected_index(def_step); //Impose the default step into the manual step selector step_mode.set_selected_index(def_step); //Impose the default step into the manual step selector
}
start_recon_thread(); start_recon_thread();
std::string description = "...no description..." ;
if( frequency_list.size() != 0 )
{
current_index = 0 ;
recon_thread-> set_freq_index( 0 );
switch( frequency_list[current_index].type )
{
case RANGE:
description = "R: " + frequency_list[current_index].description ;
break ;
case HAMRADIO:
description = "H: " + frequency_list[current_index].description ;
break ;
default:
case SINGLE:
description = "S: " + frequency_list[current_index].description ;
break ;
}
text_cycle.set_text( to_string_dec_uint( current_index + 1 , 3 ) );
}
else
{
text_cycle.set_text( " " );
}
desc_cycle.set( description );
} }
void ReconView::on_statistics_update(const ChannelStatistics& statistics) { void ReconView::on_statistics_update(const ChannelStatistics& statistics) {

View File

@ -39,6 +39,8 @@
#include "file.hpp" #include "file.hpp"
#include "app_settings.hpp" #include "app_settings.hpp"
// maximum usable freq
#define MAX_UFREQ 7200000000
namespace ui { namespace ui {
@ -176,7 +178,7 @@ namespace ui {
bool check_sd_card(); bool check_sd_card();
void handle_coded_squelch(const uint32_t value); void handle_coded_squelch(const uint32_t value);
jammer::jammer_range_t frequency_range { false, 0, 0 }; //perfect for manual recon task too... jammer::jammer_range_t frequency_range { false, 0, MAX_UFREQ }; //perfect for manual recon task too...
int32_t squelch { 0 }; int32_t squelch { 0 };
int32_t db { 0 }; int32_t db { 0 };
int32_t timer { 0 }; int32_t timer { 0 };
@ -198,8 +200,6 @@ namespace ui {
bool load_hamradios = { true }; bool load_hamradios = { true };
bool update_ranges = { true }; bool update_ranges = { true };
bool fwd = { true }; bool fwd = { true };
// maximum usable freq
long long int MAX_UFREQ = { 7200000000 };
uint32_t recon_lock_nb_match = { 10 }; uint32_t recon_lock_nb_match = { 10 };
uint32_t recon_lock_duration = { 50 }; uint32_t recon_lock_duration = { 50 };
uint32_t recon_match_mode = { 0 }; uint32_t recon_match_mode = { 0 };