mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-27 06:47:13 -05:00
changed text index to button, adding set to index and on_encoder, global indentation
This commit is contained in:
parent
9398b12093
commit
3d13ee828e
@ -196,17 +196,19 @@ namespace ui {
|
||||
last_entry . modulation = -1 ;
|
||||
last_entry . bandwidth = -1 ;
|
||||
last_entry . step = -1 ;
|
||||
int16_t last_index = -1 ;
|
||||
bool restart_recon = false; //Flag whenever scanning is restarting after a pause
|
||||
|
||||
while( !chThdShouldTerminate() && frequency_list_.size() > 0 ) {
|
||||
if( !_freq_delete )
|
||||
{
|
||||
if( _recon || _stepper != 0 )
|
||||
if( _recon || _stepper != 0 || last_index != frequency_index )
|
||||
{
|
||||
if( _freq_lock == 0 || _stepper != 0 ) //normal recon (not performing freq_lock)
|
||||
if( _freq_lock == 0 || _stepper != 0 || last_index != frequency_index ) //normal recon (not performing freq_lock)
|
||||
{
|
||||
if( !restart_recon || _stepper != 0 )
|
||||
if( !restart_recon || _stepper != 0 || last_index != frequency_index )
|
||||
{
|
||||
last_index = frequency_index ;
|
||||
has_looped = false ;
|
||||
entry_has_changed = false ;
|
||||
|
||||
@ -520,7 +522,7 @@ 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 ) );
|
||||
text_cycle.set_text( to_string_dec_uint( index + 1 , 3 ) );
|
||||
if(frequency_list[index].description.size() > 0) desc_cycle.set( frequency_list[index].description ); //Show new description
|
||||
}
|
||||
big_display.set_style(&style_white);
|
||||
@ -675,6 +677,7 @@ namespace ui {
|
||||
&big_display,
|
||||
&freq_stats,
|
||||
&text_timer,
|
||||
&text_ctcss,
|
||||
&button_manual_start,
|
||||
&button_manual_end,
|
||||
&button_manual_recon,
|
||||
@ -754,6 +757,36 @@ 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() )
|
||||
{
|
||||
current_index=f;
|
||||
text_cycle.set_text( to_string_dec_uint( current_index + 1 , 3 ) );
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
desc_cycle.set( "no description" ); //Show new description
|
||||
show_max( true ); //UPDATE new list size on screen
|
||||
}
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
RetuneMessage message { };
|
||||
message.freq = 0 ;
|
||||
message.range = current_index ;
|
||||
EventDispatcher::send_message(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
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 +835,27 @@ namespace ui {
|
||||
button_manual_end.set_encoder_delta( 0 );
|
||||
};
|
||||
|
||||
|
||||
text_cycle.on_change = [this]() {
|
||||
int32_t new_index = current_index + text_cycle.get_encoder_delta();
|
||||
if( frequency_list.size() > 0 )
|
||||
{
|
||||
if( new_index < 0 )
|
||||
new_index = frequency_list.size() - 1 ;
|
||||
if( (unsigned)new_index > frequency_list.size() - 1 )
|
||||
new_index = 0 ;
|
||||
current_index=new_index ;
|
||||
timer = 0 ;
|
||||
recon_thread->set_freq_index( current_index );
|
||||
RetuneMessage message { };
|
||||
receiver_model.set_tuning_frequency( frequency_list[ current_index ] . frequency_a ); // Retune
|
||||
recon_thread->set_freq_lock( 0 );
|
||||
message.freq = frequency_list[ current_index ] . frequency_a ;
|
||||
message.range = current_index ;
|
||||
EventDispatcher::send_message(message);
|
||||
chThdSleepMilliseconds( recon_lock_duration );
|
||||
}
|
||||
text_cycle.set_encoder_delta( 0 );
|
||||
};
|
||||
|
||||
button_pause.on_select = [this](ButtonWithEncoder&) {
|
||||
if( recon_thread && frequency_list.size() > 0 )
|
||||
@ -861,16 +914,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 );
|
||||
@ -938,7 +991,7 @@ namespace ui {
|
||||
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 +1069,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 +1112,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 +1164,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 +1307,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 );
|
||||
@ -1642,16 +1695,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 +1764,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 +1785,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 +1803,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 */
|
||||
|
@ -173,6 +173,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 };
|
||||
@ -269,8 +270,9 @@ namespace ui {
|
||||
{ 0 * 16, 2 * 16, 240 - 4 * 8 , 16 },
|
||||
};
|
||||
|
||||
Text text_cycle {
|
||||
ButtonWithEncoder text_cycle {
|
||||
{ 0, 3 * 16, 3 * 8, 16 },
|
||||
""
|
||||
};
|
||||
|
||||
Text text_max {
|
||||
@ -294,8 +296,14 @@ 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 },
|
||||
};
|
||||
|
||||
Text text_ctcss {
|
||||
{ 12 * 8 + 4, 7 * 16 , 14 * 8, 1 * 8 },
|
||||
""
|
||||
};
|
||||
|
||||
Button button_recon_setup {
|
||||
@ -385,6 +393,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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user