Merge pull request #852 from gullradriel/recon-minor-update

Recon minor update
This commit is contained in:
gullradriel 2023-03-26 21:06:16 +02:00 committed by GitHub
commit d6555a7af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2501 additions and 2364 deletions

View File

@ -68,6 +68,10 @@ namespace ui {
_stepper = v;
}
void ReconThread::set_index_stepper( const int64_t v){
_index_stepper = v;
}
void ReconThread::set_lock_duration( const uint32_t v ){
_lock_duration = v;
}
@ -152,7 +156,6 @@ namespace ui {
int64_t minfreq = 0 ;
int64_t maxfreq = 0 ;
bool has_looped = false ;
bool entry_has_changed = false ;
RetuneMessage message { };
if( frequency_list_[ 0 ] . step >= 0 )
@ -197,19 +200,16 @@ namespace ui {
last_entry . bandwidth = -1 ;
last_entry . step = -1 ;
bool restart_recon = false; //Flag whenever scanning is restarting after a pause
int16_t last_index = -1 ;
while( !chThdShouldTerminate() && frequency_list_.size() > 0 ) {
if( !_freq_delete )
{
if( _recon || _stepper != 0 )
{
if( _freq_lock == 0 || _stepper != 0 ) //normal recon (not performing freq_lock)
{
if( !restart_recon || _stepper != 0 )
{
has_looped = false ;
entry_has_changed = false ;
if( !_freq_delete )
{
if( _recon || _stepper != 0 || _index_stepper != 0 || last_index !=frequency_index )
{
last_index = frequency_index ;
if( last_entry . frequency_a != freq )
{
last_entry . frequency_a = freq ;
@ -218,7 +218,6 @@ namespace ui {
message.range = frequency_index ;
EventDispatcher::send_message(message);
}
// Set modulation if any
if( last_entry . modulation != frequency_list_[ frequency_index ] . modulation && frequency_list_[ frequency_index ] . modulation >= 0 )
{
@ -243,6 +242,10 @@ namespace ui {
EventDispatcher::send_message(message);
step = freqman_entry_get_step_value( last_entry . step );
}
if( _freq_lock == 0 || _stepper != 0 ) //normal recon (not performing freq_lock)
{
if( !restart_recon || _stepper != 0 )
{
/* we are doing a range */
if( frequency_list_[ frequency_index ] . type == RANGE ) {
@ -355,13 +358,29 @@ namespace ui {
frequency_index = frequency_list_.size() - 1 ;
}
}
}
else
{
restart_recon = false ;
}
}
}
else
{
restart_recon = true ;
}
if( _index_stepper != 0 )
{
if( _index_stepper > 0 )
frequency_index ++ ;
if( _index_stepper < 0 )
frequency_index -- ;
if( frequency_index < 0 )
frequency_index = frequency_list_.size() - 1 ;
if( (unsigned)frequency_index >= frequency_list_.size() )
frequency_index = 0 ;
entry_has_changed = true ;
}
// reload entry if changed
if( entry_has_changed ){
switch( frequency_list_[ frequency_index ] . type ){
@ -371,11 +390,11 @@ namespace ui {
case RANGE:
minfreq = frequency_list_[ frequency_index ] . frequency_a ;
maxfreq = frequency_list_[ frequency_index ] . frequency_b ;
if( ( _fwd && _stepper == 0 ) || _stepper > 0 )
if( ( _fwd && _stepper == 0 ) || _stepper > 0 || _index_stepper > 0 )
{
freq = minfreq ;
}
else if( ( !_fwd && _stepper == 0 ) || _stepper < 0 )
else if( ( !_fwd && _stepper == 0 ) || _stepper < 0 || _index_stepper < 0 )
{
freq = maxfreq ;
}
@ -383,11 +402,11 @@ namespace ui {
case HAMRADIO:
minfreq = frequency_list_[ frequency_index ] . frequency_a ;
maxfreq = frequency_list_[ frequency_index ] . frequency_b ;
if( ( _fwd && _stepper == 0 ) || _stepper > 0 )
if( ( _fwd && _stepper == 0 ) || _stepper > 0 || _index_stepper > 0 )
{
freq = minfreq ;
}
else if( ( !_fwd && _stepper == 0 ) || _stepper < 0 )
else if( ( !_fwd && _stepper == 0 ) || _stepper < 0 || _index_stepper < 0 )
{
freq = maxfreq ;
}
@ -397,7 +416,6 @@ namespace ui {
}
}
// send a pause message with the right freq
if( has_looped && !_continuous )
{
@ -409,11 +427,9 @@ namespace ui {
}
if( _stepper < 0 ) _stepper ++ ;
if( _stepper > 0 ) _stepper -- ;
}
else
{
restart_recon = true ;
}
if( _index_stepper < 0 ) _index_stepper ++ ;
if( _index_stepper > 0 ) _index_stepper -- ;
}
chThdSleepMilliseconds( _lock_duration ); //Needed to (eventually) stabilize the receiver into new freq
}
@ -520,8 +536,23 @@ namespace ui {
//NO FREQ LOCK, ONGOING STANDARD SCANNING
if( index < 1000 && index < frequency_list.size() )
{
text_cycle.set( to_string_dec_uint( index + 1 , 3 ) );
if(frequency_list[index].description.size() > 0) desc_cycle.set( frequency_list[index].description ); //Show new description
text_cycle.set_text( to_string_dec_uint( index + 1 , 3 ) );
if(frequency_list[index].description.size() > 0)
{
switch( frequency_list[current_index].type )
{
case RANGE:
desc_cycle.set( "R: " + frequency_list[current_index].description ); //Show new description
break ;
case HAMRADIO:
desc_cycle.set( "H: " + frequency_list[current_index].description ); //Show new description
break ;
default:
case SINGLE:
desc_cycle.set( "S: " + frequency_list[current_index].description ); //Show new description
break ;
}
}
}
big_display.set_style(&style_white);
if( !userpause )
@ -645,7 +676,7 @@ namespace ui {
{
if( refresh_display )
{
text_max.set( " " );
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 ) );
}
@ -675,6 +706,7 @@ namespace ui {
&big_display,
&freq_stats,
&text_timer,
&text_ctcss,
&button_manual_start,
&button_manual_end,
&button_manual_recon,
@ -754,6 +786,21 @@ namespace ui {
};
};
text_cycle.on_select = [this, &nav](ButtonWithEncoder& button) {
if( frequency_list.size() > 0 )
{
auto new_view = nav_.push<FrequencyKeypadView>(current_index);
new_view->on_changed = [this, &button](rf::Frequency f) {
f = f / 1000000 ;
if( f >= 1 && f <= frequency_list.size() )
{
recon_thread-> set_index_stepper( f - 1 - current_index );
recon_thread->set_freq_lock( 0 );
}
};
}
};
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 )
@ -802,7 +849,28 @@ namespace ui {
button_manual_end.set_encoder_delta( 0 );
};
text_cycle.on_change = [this]() {
if( frequency_list.size() > 0 )
{
if( text_cycle.get_encoder_delta() > 0 )
{
fwd = true ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "FW>" );
recon_thread-> set_index_stepper( 1 );
recon_thread->set_freq_lock( 0 );
}
else if( text_cycle.get_encoder_delta() < 0 )
{
fwd = false ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "<RW" );
recon_thread-> set_index_stepper( -1 );
recon_thread->set_freq_lock( 0 );
}
}
text_cycle.set_encoder_delta( 0 );
};
button_pause.on_select = [this](ButtonWithEncoder&) {
if( recon_thread && frequency_list.size() > 0 )
@ -850,7 +918,6 @@ namespace ui {
}
}
}
button_manual_start.set_encoder_delta( 0 );
};
button_pause.on_change = [this]() {
@ -861,16 +928,16 @@ namespace ui {
fwd = true ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "FW>" );
recon_thread->set_freq_lock( 0 );
recon_thread-> set_stepper( 1 );
recon_thread->set_freq_lock( 0 );
}
else if( button_pause.get_encoder_delta() < 0 )
{
fwd = false ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "<RW" );
recon_thread->set_freq_lock( 0 );
recon_thread-> set_stepper( -1 );
recon_thread->set_freq_lock( 0 );
}
}
button_pause.set_encoder_delta( 0 );
@ -931,14 +998,26 @@ namespace ui {
recon_thread->set_freq_index( current_index );
if(frequency_list[current_index].description.size() > 0)
{
desc_cycle.set( frequency_list[current_index].description ); //Show new description
switch( frequency_list[current_index].type )
{
case RANGE:
desc_cycle.set( "R: " + frequency_list[current_index].description ); //Show new description
break ;
case HAMRADIO:
desc_cycle.set( "H: " + frequency_list[current_index].description ); //Show new description
break ;
default:
case SINGLE:
desc_cycle.set( "S: " + frequency_list[current_index].description ); //Show new description
break ;
}
}
else
{
desc_cycle.set( "no description" ); //Show new description
show_max( true ); //UPDATE new list size on screen
}
text_cycle.set( to_string_dec_uint( current_index + 1 , 3 ) );
text_cycle.set_text( to_string_dec_uint( current_index + 1 , 3 ) );
File freqman_file;
@ -1016,7 +1095,7 @@ namespace ui {
}
if( frequency_list.size() == 0 )
{
text_cycle.set( " " );
text_cycle.set_text( " " );
desc_cycle.set( "no entries in list" ); //Show new description
show_max( true ); //UPDATE new list size on screen
delete_file( "FREQMAN/"+output_file+".TXT" );
@ -1059,16 +1138,16 @@ namespace ui {
fwd = true ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "FW>" );
recon_thread->set_freq_lock( 0 );
recon_thread-> set_stepper( 1 );
recon_thread->set_freq_lock( 0 );
}
else if( button_remove.get_encoder_delta() < 0 )
{
fwd = false ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "<RW" );
recon_thread->set_freq_lock( 0 );
recon_thread-> set_stepper( -1 );
recon_thread->set_freq_lock( 0 );
}
}
button_remove.set_encoder_delta( 0 );
@ -1111,7 +1190,7 @@ namespace ui {
freq_stats.set( "0/0/0" );
show_max(); /* display step information */
text_cycle.set( "MANUAL SEARCH" );
text_cycle.set_text( "MANUAL SEARCH" );
button_scanner_mode.set_style( &style_white );
button_scanner_mode.set_text( "MSEARCH" );
file_name.set_style( &style_white );
@ -1254,8 +1333,8 @@ namespace ui {
fwd = false ;
recon_thread -> set_recon_direction( fwd );
button_dir.set_text( "<RW" );
recon_thread->set_freq_lock( 0 );
recon_thread-> set_stepper( -1 );
recon_thread->set_freq_lock( 0 );
}
}
button_add.set_encoder_delta( 0 );
@ -1500,7 +1579,7 @@ namespace ui {
else
{
file_name.set_style( &style_blue );
file_name.set( "USE: "+input_file );
file_name.set( "USE: "+input_file + ".TXT" );
}
step_mode.set_selected_index(def_step); //Impose the default step into the manual step selector
}
@ -1516,7 +1595,7 @@ namespace ui {
}
else
{
file_name.set( "USE: "+output_file );
file_name.set( "USE: "+output_file + ".TXT" );
file_name.set_style( &style_red );
}
step_mode.set_selected_index(def_step); //Impose the default step into the manual step selector
@ -1642,16 +1721,19 @@ namespace ui {
}
}
if( update_stats )
{
show_max();
}
if( timer > 0 )
show_max();
timer -= 50 ;
if( timer < 0 )
{
timer = 0 ;
show_max();
}
} /* on_statistic_updates */
@ -1708,6 +1790,7 @@ namespace ui {
receiver_model.set_am_configuration(field_bw.selected_index());
field_bw.on_change = [this](size_t n, OptionsField::value_t) { receiver_model.set_am_configuration(n); };
receiver_model.set_sampling_rate(3072000); receiver_model.set_baseband_bandwidth(1750000);
text_ctcss.set(" ");
break;
case NFM_MODULATION:
freqman_set_bandwidth_option( new_mod , field_bw );
@ -1728,6 +1811,7 @@ namespace ui {
receiver_model.set_wfm_configuration(field_bw.selected_index());
field_bw.on_change = [this](size_t n, OptionsField::value_t) { receiver_model.set_wfm_configuration(n); };
receiver_model.set_sampling_rate(3072000); receiver_model.set_baseband_bandwidth(1750000);
text_ctcss.set(" ");
break;
default:
break;
@ -1745,4 +1829,36 @@ namespace ui {
recon_thread->set_recon_direction( fwd );
}
void ReconView::handle_coded_squelch(const uint32_t value) {
static int32_t last_idx = -1 ;
float diff, min_diff = value;
size_t min_idx { 0 };
size_t c;
if( field_mode.selected_index() != NFM_MODULATION )
{
text_ctcss.set(" ");
return ;
}
// Find nearest match
for (c = 0; c < tone_keys.size(); c++) {
diff = abs(((float)value / 100.0) - tone_keys[c].second);
if (diff < min_diff) {
min_idx = c;
min_diff = diff;
}
}
// Arbitrary confidence threshold
if( last_idx < 0 || (unsigned)last_idx != min_idx )
{
last_idx = min_idx ;
if (min_diff < 40)
text_ctcss.set("T: "+tone_keys[min_idx].first);
else
text_ctcss.set(" ");
}
}
} /* namespace ui */

View File

@ -62,6 +62,7 @@ namespace ui {
int64_t get_current_freq();
void set_stepper(const int64_t v);
void set_index_stepper(const int64_t v);
void change_recon_direction();
bool get_recon_direction();
@ -101,7 +102,9 @@ namespace ui {
bool _freq_delete { false };
bool _fwd { true };
bool _continuous { true };
bool entry_has_changed = false ;
int64_t _stepper { 0 };
int64_t _index_stepper { 0 };
int32_t _freq_lock { 0 };
uint32_t _lock_duration { 50 };
uint32_t _lock_nb_match { 10 };
@ -173,6 +176,7 @@ namespace ui {
void set_display_freq( int64_t freq );
void handle_retune( int64_t freq , uint32_t index );
bool check_sd_card();
void handle_coded_squelch(const uint32_t value);
jammer::jammer_range_t frequency_range { false, 0, 0 }; //perfect for manual recon task too...
int32_t squelch { 0 };
@ -266,11 +270,12 @@ namespace ui {
};
RSSI rssi {
{ 0 * 16, 2 * 16, 240 - 4 * 8 , 16 },
{ 0 * 16, 2 * 16, 240 - 5 * 8 - 1 , 16 },
};
Text text_cycle {
ButtonWithEncoder text_cycle {
{ 0, 3 * 16, 3 * 8, 16 },
""
};
Text text_max {
@ -294,27 +299,35 @@ namespace ui {
{ 0, 6 * 16 , 21 * 8, 16 },
};
// TIMER: 9999
Text text_timer { //Show frequency stats in text mode
{ 0, 7 * 16 , 21 * 8, 16 },
{ 0, 7 * 16 , 11 * 8, 16 },
};
// T: Senn. 32.000k
Text text_ctcss {
{ 12 * 8 + 4, 7 * 16 , 14 * 8, 1 * 8 },
""
};
Button button_recon_setup {
{ 240 - 4 * 8 , 2 * 16 , 4 * 8, 28 },
{ 240 - 5 * 8 , 2 * 16 , 5 * 8, 28 },
"OPT"
};
Button button_looking_glass {
{ 240 - 5 * 8 , 6 * 16 - 4 , 5 * 8, 28 },
{ 240 - 5 * 8 , 5 * 16 , 5 * 8, 28 },
"GLASS"
};
// Button can be RECON or SCANNER
Button button_scanner_mode {
{ 240 - 8 * 8 , 8 * 16 , 8 * 8, 28 },
{ 240 - 7 * 8 , 8 * 16 , 7 * 8, 28 },
"RECON"
};
Text file_name { //Show file used
{ 0 , 8 * 16 + 6 , 21 * 8, 16 },
{ 0 , 8 * 16 + 6 , 240 - 7 * 8, 16 },
};
ButtonWithEncoder button_manual_start {
@ -385,6 +398,14 @@ namespace ui {
std::unique_ptr<ReconThread> recon_thread { };
MessageHandlerRegistration message_handler_coded_squelch {
Message::ID::CodedSquelch,
[this](const Message* const p) {
const auto message = *reinterpret_cast<const CodedSquelchMessage*>(p);
this->handle_coded_squelch(message.value);
}
};
MessageHandlerRegistration message_handler_retune {
Message::ID::Retune,
[this](const Message* const p) {