mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-09-20 08:05:44 +00:00
parent
22430fb8d4
commit
1a829707f4
@ -29,6 +29,191 @@ using portapack::memory::map::backup_ram;
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool ReconView::ReconSaveFreq( const std::string &freq_file_path , size_t freq_index , bool warn_if_exists )
|
||||
{
|
||||
File recon_file;
|
||||
|
||||
if( frequency_list.size() == 0 || ( frequency_list.size() && current_index > (int32_t)frequency_list.size() ) )
|
||||
return false ;
|
||||
|
||||
freqman_entry entry = frequency_list[ freq_index ] ;
|
||||
entry . frequency_a = freq ;
|
||||
entry . frequency_b = 0 ;
|
||||
entry . modulation = last_entry.modulation ;
|
||||
entry . bandwidth = last_entry.bandwidth ;
|
||||
entry . type = SINGLE ;
|
||||
|
||||
std::string frequency_to_add ;
|
||||
get_freq_string( entry , frequency_to_add );
|
||||
|
||||
auto result = recon_file.open(freq_file_path); //First recon if freq is already in txt
|
||||
if (!result.is_valid()) {
|
||||
char one_char[1]; //Read it char by char
|
||||
std::string line; //and put read line in here
|
||||
bool found=false;
|
||||
for (size_t pointer=0; pointer < recon_file.size();pointer++) {
|
||||
recon_file.seek(pointer);
|
||||
recon_file.read(one_char, 1);
|
||||
if ((int)one_char[0] > 31) { //ascii space upwards
|
||||
line += one_char[0]; //add it to the textline
|
||||
}
|
||||
else if (one_char[0] == '\n') { //New Line
|
||||
if (line.compare(0, frequency_to_add.size(),frequency_to_add) == 0) {
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
line.clear(); //Ready for next textline
|
||||
}
|
||||
}
|
||||
if( !found) {
|
||||
result = recon_file.append(freq_file_path); //Second: append if it is not there
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
if(found && warn_if_exists)
|
||||
{
|
||||
nav_.display_modal("Error", "Frequency already exists");
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = recon_file.create( freq_file_path ); //First freq if no output file
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ReconView::ReconSetupLoadStrings( const std::string &source, std::string &input_file , std::string &output_file , uint32_t &recon_lock_duration , uint32_t &recon_lock_nb_match , int32_t &recon_squelch_level , uint32_t &recon_match_mode , int32_t &wait , int32_t &volume )
|
||||
{
|
||||
File settings_file;
|
||||
size_t length, file_position = 0;
|
||||
char * pos;
|
||||
char * line_start;
|
||||
char * line_end;
|
||||
char file_data[257];
|
||||
|
||||
uint32_t it = 0 ;
|
||||
uint32_t nb_params = RECON_SETTINGS_NB_PARAMS ;
|
||||
std::string params[ RECON_SETTINGS_NB_PARAMS ];
|
||||
|
||||
bool check_sd_card = (sd_card::status() == sd_card::Status::Mounted) ? true : false ;
|
||||
|
||||
if( check_sd_card )
|
||||
{
|
||||
auto result = settings_file.open( source );
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
while( it < nb_params )
|
||||
{
|
||||
// Read a 256 bytes block from file
|
||||
settings_file.seek(file_position);
|
||||
memset(file_data, 0, 257);
|
||||
auto read_size = settings_file.read(file_data, 256);
|
||||
if (read_size.is_error())
|
||||
break ;
|
||||
file_position += 256;
|
||||
// Reset line_start to beginning of buffer
|
||||
line_start = file_data;
|
||||
pos=line_start;
|
||||
while ((line_end = strstr(line_start, "\x0A"))) {
|
||||
length = line_end - line_start - 1 ;
|
||||
params[ it ] = string( pos , length );
|
||||
it ++ ;
|
||||
line_start = line_end + 1;
|
||||
pos=line_start ;
|
||||
if (line_start - file_data >= 256)
|
||||
break;
|
||||
if( it >= nb_params )
|
||||
break ;
|
||||
}
|
||||
if (read_size.value() != 256)
|
||||
break; // End of file
|
||||
|
||||
// Restart at beginning of last incomplete line
|
||||
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 = RECON_MIN_LOCK_DURATION ;
|
||||
recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
recon_squelch_level = -14 ;
|
||||
recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
wait = RECON_DEF_WAIT_DURATION ;
|
||||
volume = 40 ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if( it > 0 )
|
||||
input_file = params[ 0 ];
|
||||
else
|
||||
input_file = "RECON" ;
|
||||
|
||||
if( it > 1 )
|
||||
output_file= params[ 1 ];
|
||||
else
|
||||
output_file = "RECON_RESULTS" ;
|
||||
|
||||
if( it > 2 )
|
||||
recon_lock_duration = strtoll( params[ 2 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_lock_duration = RECON_MIN_LOCK_DURATION ;
|
||||
|
||||
if( it > 3 )
|
||||
recon_lock_nb_match = strtoll( params[ 3 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
|
||||
if( it > 4 )
|
||||
recon_squelch_level = strtoll( params[ 4 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_squelch_level = -14 ;
|
||||
|
||||
if( it > 5 )
|
||||
recon_match_mode = strtoll( params[ 5 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
|
||||
if( it > 6 )
|
||||
wait = strtoll( params[ 6 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
wait = RECON_DEF_WAIT_DURATION ;
|
||||
|
||||
if( it > 7 )
|
||||
volume = strtoll( params[ 7 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
volume = 40 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ReconView::ReconSetupSaveStrings( const std::string &dest, const std::string &input_file , const std::string &output_file , uint32_t recon_lock_duration , uint32_t recon_lock_nb_match , int32_t recon_squelch_level , uint32_t recon_match_mode , int32_t wait , int32_t volume )
|
||||
{
|
||||
File settings_file;
|
||||
|
||||
auto result = settings_file.create( dest );
|
||||
if( result.is_valid() )
|
||||
return false ;
|
||||
settings_file.write_line( input_file );
|
||||
settings_file.write_line( output_file );
|
||||
settings_file.write_line( to_string_dec_uint( recon_lock_duration ) );
|
||||
settings_file.write_line( to_string_dec_uint( recon_lock_nb_match ) );
|
||||
settings_file.write_line( to_string_dec_int( recon_squelch_level ) );
|
||||
settings_file.write_line( to_string_dec_uint( recon_match_mode ) );
|
||||
settings_file.write_line( to_string_dec_int( wait ) );
|
||||
settings_file.write_line( to_string_dec_int( volume ) );
|
||||
return true ;
|
||||
}
|
||||
|
||||
void ReconView::audio_output_start()
|
||||
{
|
||||
audio::output::start();
|
||||
@ -41,15 +226,6 @@ namespace ui {
|
||||
}
|
||||
|
||||
void ReconView::recon_redraw() {
|
||||
|
||||
static int32_t last_db = 999999 ;
|
||||
static uint32_t last_nb_match = 999999 ;
|
||||
static uint32_t last_freq_lock = 999999 ;
|
||||
static size_t last_list_size = 0 ;
|
||||
static int8_t last_rssi_min = -127 ;
|
||||
static int8_t last_rssi_med = -127 ;
|
||||
static int8_t last_rssi_max = -127 ;
|
||||
|
||||
if( last_rssi_min != rssi.get_min() || last_rssi_med != rssi.get_avg() || last_rssi_max != rssi.get_max() )
|
||||
{
|
||||
last_rssi_min = rssi.get_min();
|
||||
@ -57,13 +233,11 @@ namespace ui {
|
||||
last_rssi_max = rssi.get_max();
|
||||
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" );
|
||||
}
|
||||
|
||||
if( last_entry . frequency_a != freq )
|
||||
{
|
||||
last_entry . frequency_a = freq ;
|
||||
big_display.set( "FREQ: "+to_string_short_freq( freq )+" MHz" );
|
||||
}
|
||||
|
||||
if( last_db != db || last_list_size != frequency_list.size() || last_freq_lock != freq_lock || last_nb_match != recon_lock_nb_match )
|
||||
{
|
||||
last_freq_lock = freq ;
|
||||
@ -92,61 +266,13 @@ namespace ui {
|
||||
|
||||
//FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
|
||||
if( (!scanner_mode) && autosave && frequency_list.size() > 0 ) {
|
||||
File recon_file;
|
||||
std::string freq_file_path = "/FREQMAN/"+output_file+".TXT" ;
|
||||
std::string frequency_to_add ;
|
||||
|
||||
freqman_entry entry = frequency_list[ current_index ] ;
|
||||
entry . frequency_a = freq ;
|
||||
entry . frequency_b = 0 ;
|
||||
entry . modulation = last_entry.modulation ;
|
||||
entry . bandwidth = last_entry.bandwidth ;
|
||||
entry . type = SINGLE ;
|
||||
|
||||
get_freq_string( entry , frequency_to_add );
|
||||
|
||||
auto result = recon_file.open(freq_file_path); //First recon if freq is already in txt
|
||||
if (!result.is_valid()) {
|
||||
char one_char[1]; //Read it char by char
|
||||
std::string line; //and put read line in here
|
||||
bool found=false;
|
||||
for (size_t pointer=0; pointer < recon_file.size();pointer++) {
|
||||
recon_file.seek(pointer);
|
||||
recon_file.read(one_char, 1);
|
||||
if ((int)one_char[0] > 31) { //ascii space upwards
|
||||
line += one_char[0]; //Add it to the textline
|
||||
}
|
||||
else if (one_char[0] == '\n') { //New Line
|
||||
if (line.compare(0, frequency_to_add.size(),frequency_to_add) == 0) {
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
line.clear(); //Ready for next textline
|
||||
}
|
||||
}
|
||||
if( !found) {
|
||||
result = recon_file.append(freq_file_path); //Second: append if it is not there
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = recon_file.create( freq_file_path ); //First freq if no output file
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
ReconSaveFreq( freq_file_path , current_index , false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReconView::handle_retune() {
|
||||
static int32_t last_index = -1 ;
|
||||
static int64_t last_freq = 0 ;
|
||||
if( last_freq != freq )
|
||||
{
|
||||
last_freq = freq ;
|
||||
@ -509,8 +635,6 @@ namespace ui {
|
||||
|
||||
File freqman_file;
|
||||
|
||||
std::string freq_file_path = "FREQMAN/" + output_file + ".TXT";
|
||||
|
||||
delete_file( freq_file_path );
|
||||
|
||||
auto result = freqman_file.create( freq_file_path );
|
||||
@ -529,8 +653,7 @@ namespace ui {
|
||||
{
|
||||
File recon_file;
|
||||
File tmp_recon_file;
|
||||
std::string freq_file_path = "/FREQMAN/"+output_file+".TXT" ;
|
||||
std::string tmp_freq_file_path = "/FREQMAN/"+output_file+"TMP.TXT" ;
|
||||
std::string tmp_freq_file_path = freq_file_path+".TMP" ;
|
||||
std::string frequency_to_add ;
|
||||
|
||||
freqman_entry entry = frequency_list[ current_index ] ;
|
||||
@ -544,7 +667,6 @@ namespace ui {
|
||||
|
||||
delete_file( tmp_freq_file_path );
|
||||
auto result = tmp_recon_file.create(tmp_freq_file_path); //First recon if freq is already in txt
|
||||
//
|
||||
if (!result.is_valid()) {
|
||||
bool found=false;
|
||||
result = recon_file.open(freq_file_path); //First recon if freq is already in txt
|
||||
@ -555,9 +677,9 @@ namespace ui {
|
||||
recon_file.seek(pointer);
|
||||
recon_file.read(one_char, 1);
|
||||
if ((int)one_char[0] > 31) { //ascii space upwards
|
||||
line += one_char[0]; //Add it to the textline
|
||||
line += one_char[0]; //add it to the textline
|
||||
}
|
||||
else if (one_char[0] == '\n') { //New Line
|
||||
else if (one_char[0] == '\n') { //new Line
|
||||
if (line.compare(0, frequency_to_add.size(),frequency_to_add) == 0) {
|
||||
found=true;
|
||||
}
|
||||
@ -565,7 +687,7 @@ namespace ui {
|
||||
{
|
||||
tmp_recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
line.clear(); //Ready for next textline
|
||||
line.clear(); // ready for next textline
|
||||
}
|
||||
}
|
||||
if( found)
|
||||
@ -580,15 +702,16 @@ namespace ui {
|
||||
}
|
||||
}
|
||||
}
|
||||
receiver_model.set_tuning_frequency( frequency_list[ current_index ] . frequency_a ); // Retune
|
||||
receiver_model.set_tuning_frequency( frequency_list[ current_index ] . frequency_a ); // retune
|
||||
}
|
||||
if( frequency_list.size() == 0 )
|
||||
{
|
||||
text_cycle.set_text( " " );
|
||||
desc_cycle.set( "no entries in list" ); //Show new description
|
||||
delete_file( "FREQMAN/"+output_file+".TXT" );
|
||||
delete_file( freq_file_path );
|
||||
}
|
||||
timer = 0 ;
|
||||
freq_lock = 0 ;
|
||||
};
|
||||
|
||||
button_remove.on_change = [this]() {
|
||||
@ -660,7 +783,7 @@ namespace ui {
|
||||
button_dir.set_text( "FW>" );
|
||||
}
|
||||
timer = 0 ;
|
||||
if ( userpause ) //If user-paused, resume
|
||||
if ( userpause )
|
||||
recon_resume();
|
||||
};
|
||||
|
||||
@ -696,60 +819,7 @@ namespace ui {
|
||||
button_add.on_select = [this](ButtonWithEncoder&) { //frequency_list[current_index]
|
||||
if( !scanner_mode)
|
||||
{
|
||||
if( frequency_list.size() && frequency_list.size() && current_index < (int32_t)frequency_list.size() )
|
||||
{
|
||||
bool found=false;
|
||||
File recon_file;
|
||||
std::string freq_file_path = "/FREQMAN/"+output_file+".TXT" ;
|
||||
std::string frequency_to_add ;
|
||||
|
||||
freqman_entry entry = frequency_list[ current_index ] ;
|
||||
entry . frequency_a = freq ;
|
||||
entry . frequency_b = 0 ;
|
||||
entry . modulation = last_entry.modulation ;
|
||||
entry . bandwidth = last_entry.bandwidth;
|
||||
entry . type = SINGLE ;
|
||||
|
||||
get_freq_string( entry , frequency_to_add );
|
||||
|
||||
auto result = recon_file.open(freq_file_path); //First recon if freq is already in txt
|
||||
if (!result.is_valid()) {
|
||||
char one_char[1]; //Read it char by char
|
||||
std::string line; //and put read line in here
|
||||
for (size_t pointer=0; pointer < recon_file.size();pointer++) {
|
||||
recon_file.seek(pointer);
|
||||
recon_file.read(one_char, 1);
|
||||
if ((int)one_char[0] > 31) { //ascii space upwards
|
||||
line += one_char[0]; //Add it to the textline
|
||||
}
|
||||
else if (one_char[0] == '\n') { //New Line
|
||||
if (line.compare(0, frequency_to_add.size(),frequency_to_add) == 0) {
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
line.clear(); //Ready for next textline
|
||||
}
|
||||
}
|
||||
if( !found) {
|
||||
result = recon_file.append(freq_file_path); //Second: append if it is not there
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
nav_.display_modal("Error", "Frequency already exists");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto result = recon_file.create(freq_file_path); //third: create if it is not there
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
recon_file.write_line( frequency_to_add );
|
||||
}
|
||||
}
|
||||
}
|
||||
ReconSaveFreq( freq_file_path , current_index , true );
|
||||
}
|
||||
};
|
||||
|
||||
@ -793,6 +863,7 @@ namespace ui {
|
||||
open_view -> on_changed = [this](std::vector<std::string> result) {
|
||||
input_file = result[0];
|
||||
output_file = result[1];
|
||||
freq_file_path = "/FREQMAN/"+output_file+".TXT" ;
|
||||
recon_lock_duration = strtol( result[2].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 );
|
||||
@ -883,6 +954,7 @@ namespace ui {
|
||||
|
||||
//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 , volume );
|
||||
freq_file_path = "/FREQMAN/"+output_file+".TXT" ;
|
||||
|
||||
field_squelch.set_value( squelch );
|
||||
field_wait.set_value(wait);
|
||||
@ -900,7 +972,7 @@ namespace ui {
|
||||
|
||||
if( filedelete )
|
||||
{
|
||||
delete_file( "FREQMAN/"+output_file+".TXT" );
|
||||
delete_file( freq_file_path );
|
||||
}
|
||||
|
||||
frequency_file_load( false ); /* do not stop all at start */
|
||||
@ -1054,12 +1126,7 @@ namespace ui {
|
||||
}
|
||||
|
||||
void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
// 0 recon , 1 locking , 2 locked
|
||||
static int32_t status = -1 ;
|
||||
static int32_t last_timer = -1 ;
|
||||
|
||||
db = statistics.max_db ;
|
||||
|
||||
if( !userpause )
|
||||
{
|
||||
if( !timer )
|
||||
@ -1326,7 +1393,7 @@ namespace ui {
|
||||
}
|
||||
|
||||
void ReconView::recon_pause() {
|
||||
timer = 0 ; // Will trigger a recon_resume() on_statistics_update, also advancing to next freq.
|
||||
timer = 0 ;
|
||||
freq_lock = 0 ;
|
||||
userpause = true;
|
||||
continuous_lock=false;
|
||||
@ -1398,8 +1465,8 @@ namespace ui {
|
||||
|
||||
size_t ReconView::change_mode( freqman_index_t new_mod ) {
|
||||
|
||||
field_mode.on_change = [this](size_t , OptionsField::value_t v) { (void)v; };
|
||||
field_bw.on_change = [this](size_t n, OptionsField::value_t) { (void)n; };
|
||||
field_mode.on_change = [this](size_t , OptionsField::value_t) { };
|
||||
field_bw.on_change = [this](size_t , OptionsField::value_t) { };
|
||||
|
||||
receiver_model.disable();
|
||||
baseband::shutdown();
|
||||
@ -1449,15 +1516,13 @@ namespace ui {
|
||||
};
|
||||
|
||||
if ( !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();
|
||||
|
||||
return freqman_entry_get_step_value( def_step );
|
||||
}
|
||||
|
||||
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;
|
||||
@ -1478,9 +1543,9 @@ namespace ui {
|
||||
}
|
||||
|
||||
// Arbitrary confidence threshold
|
||||
if( last_idx < 0 || (unsigned)last_idx != min_idx )
|
||||
if( last_squelch_index < 0 || (unsigned)last_squelch_index != min_idx )
|
||||
{
|
||||
last_idx = min_idx ;
|
||||
last_squelch_index = min_idx ;
|
||||
if (min_diff < 40)
|
||||
text_ctcss.set("T: "+tone_keys[min_idx].first);
|
||||
else
|
||||
|
@ -61,7 +61,7 @@ namespace ui {
|
||||
.foreground = Color::white(),
|
||||
};
|
||||
|
||||
const Style style_yellow { //Found signal
|
||||
const Style style_yellow { //found signal
|
||||
.font = font::fixed_8x16,
|
||||
.background = Color::black(),
|
||||
.foreground = Color::yellow(),
|
||||
@ -106,6 +106,9 @@ namespace ui {
|
||||
void recon_redraw();
|
||||
void handle_retune();
|
||||
void handle_coded_squelch(const uint32_t value);
|
||||
bool ReconSetupLoadStrings( const std::string &source, std::string &input_file , std::string &output_file , uint32_t &recon_lock_duration , uint32_t &recon_lock_nb_match , int32_t &recon_squelch_level , uint32_t &recon_match_mode , int32_t &wait , int32_t &volume );
|
||||
bool ReconSetupSaveStrings( const std::string &dest, const std::string &input_file , const std::string &output_file , uint32_t recon_lock_duration , uint32_t recon_lock_nb_match , int32_t recon_squelch_level , uint32_t recon_match_mode , int32_t wait , int32_t volume );
|
||||
bool ReconSaveFreq( const std::string &freq_file_path , size_t index , bool warn_if_exists );
|
||||
|
||||
jammer::jammer_range_t frequency_range { false, 0, MAX_UFREQ }; //perfect for manual recon task too...
|
||||
int32_t squelch { 0 };
|
||||
@ -129,7 +132,7 @@ namespace ui {
|
||||
bool fwd = { true };
|
||||
bool recon = true ;
|
||||
uint32_t recon_lock_nb_match = { 3 };
|
||||
uint32_t recon_lock_duration = { RECON_DEF_LOCK_DURATION };
|
||||
uint32_t recon_lock_duration = { RECON_MIN_LOCK_DURATION };
|
||||
uint32_t recon_match_mode = { RECON_MATCH_CONTINUOUS };
|
||||
bool scanner_mode { false };
|
||||
bool manual_mode { false };
|
||||
@ -149,6 +152,19 @@ namespace ui {
|
||||
int64_t minfreq = 0 ;
|
||||
int64_t maxfreq = 0 ;
|
||||
bool has_looped = false ;
|
||||
int8_t status = -1 ; // 0 recon , 1 locking , 2 locked
|
||||
int32_t last_timer = -1 ;
|
||||
int8_t last_db = -127 ;
|
||||
uint16_t last_nb_match = 999 ;
|
||||
uint16_t last_freq_lock = 999 ;
|
||||
size_t last_list_size = 0 ;
|
||||
int8_t last_rssi_min = -127 ;
|
||||
int8_t last_rssi_med = -127 ;
|
||||
int8_t last_rssi_max = -127 ;
|
||||
int32_t last_index = -1 ;
|
||||
int32_t last_squelch_index = -1 ;
|
||||
int64_t last_freq = 0 ;
|
||||
std::string freq_file_path = { } ;
|
||||
|
||||
Labels labels
|
||||
{
|
||||
@ -196,7 +212,7 @@ namespace ui {
|
||||
NumberField field_wait {
|
||||
{ 20 * 8, 1 * 16 },
|
||||
5,
|
||||
{ -(10000-STATS_UPDATE_INTERVAL) , (10000-STATS_UPDATE_INTERVAL) },
|
||||
{ -RECON_MAX_LOCK_DURATION , RECON_MAX_LOCK_DURATION },
|
||||
STATS_UPDATE_INTERVAL,
|
||||
' ',
|
||||
};
|
||||
@ -204,8 +220,8 @@ namespace ui {
|
||||
NumberField field_lock_wait {
|
||||
{ 26 * 8, 1 * 16 },
|
||||
4,
|
||||
{ RECON_DEF_LOCK_DURATION , (10000-RECON_DEF_LOCK_DURATION) },
|
||||
RECON_DEF_LOCK_DURATION,
|
||||
{ RECON_MIN_LOCK_DURATION , RECON_MAX_LOCK_DURATION },
|
||||
STATS_UPDATE_INTERVAL,
|
||||
' ',
|
||||
};
|
||||
|
||||
@ -226,11 +242,6 @@ namespace ui {
|
||||
{0, 4 * 16, SCREEN_W , 16 },
|
||||
};
|
||||
|
||||
/* BigFrequency big_display { //Show frequency in glamour
|
||||
{ 4, 7 * 16 - 8 , 28 * 8, 52 },
|
||||
0
|
||||
}; */
|
||||
|
||||
Text big_display { //Show frequency in text mode
|
||||
{ 0, 5 * 16 , 23 * 8, 16 },
|
||||
};
|
||||
@ -266,7 +277,7 @@ namespace ui {
|
||||
"RECON"
|
||||
};
|
||||
|
||||
Text file_name { //Show file used
|
||||
Text file_name { //show file used
|
||||
{ 0 , 8 * 16 + 6 , SCREEN_W - 7 * 8, 16 },
|
||||
};
|
||||
|
||||
|
@ -34,133 +34,6 @@ using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool ReconSetupLoadStrings( std::string source, std::string &input_file , std::string &output_file , uint32_t &recon_lock_duration , uint32_t &recon_lock_nb_match , int32_t &recon_squelch_level , uint32_t &recon_match_mode , int32_t &wait , int32_t &volume )
|
||||
{
|
||||
File settings_file;
|
||||
size_t length, file_position = 0;
|
||||
char * pos;
|
||||
char * line_start;
|
||||
char * line_end;
|
||||
char file_data[257];
|
||||
|
||||
uint32_t it = 0 ;
|
||||
uint32_t nb_params = RECON_SETTINGS_NB_PARAMS ;
|
||||
std::string params[ RECON_SETTINGS_NB_PARAMS ];
|
||||
|
||||
bool check_sd_card = (sd_card::status() == sd_card::Status::Mounted) ? true : false ;
|
||||
|
||||
if( check_sd_card )
|
||||
{
|
||||
auto result = settings_file.open( source );
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
while( it < nb_params )
|
||||
{
|
||||
// Read a 256 bytes block from file
|
||||
settings_file.seek(file_position);
|
||||
memset(file_data, 0, 257);
|
||||
auto read_size = settings_file.read(file_data, 256);
|
||||
if (read_size.is_error())
|
||||
break ;
|
||||
file_position += 256;
|
||||
// Reset line_start to beginning of buffer
|
||||
line_start = file_data;
|
||||
pos=line_start;
|
||||
while ((line_end = strstr(line_start, "\x0A"))) {
|
||||
length = line_end - line_start - 1 ;
|
||||
params[ it ] = string( pos , length );
|
||||
it ++ ;
|
||||
line_start = line_end + 1;
|
||||
pos=line_start ;
|
||||
if (line_start - file_data >= 256)
|
||||
break;
|
||||
if( it >= nb_params )
|
||||
break ;
|
||||
}
|
||||
if (read_size.value() != 256)
|
||||
break; // End of file
|
||||
|
||||
// Restart at beginning of last incomplete line
|
||||
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 = RECON_DEF_LOCK_DURATION ;
|
||||
recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
recon_squelch_level = -14 ;
|
||||
recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
wait = RECON_DEF_WAIT_DURATION ;
|
||||
volume = 40 ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if( it > 0 )
|
||||
input_file = params[ 0 ];
|
||||
else
|
||||
input_file = "RECON" ;
|
||||
|
||||
if( it > 1 )
|
||||
output_file= params[ 1 ];
|
||||
else
|
||||
output_file = "RECON_RESULTS" ;
|
||||
|
||||
if( it > 2 )
|
||||
recon_lock_duration = strtoll( params[ 2 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_lock_duration = RECON_DEF_LOCK_DURATION ;
|
||||
|
||||
if( it > 3 )
|
||||
recon_lock_nb_match = strtoll( params[ 3 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
|
||||
if( it > 4 )
|
||||
recon_squelch_level = strtoll( params[ 4 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_squelch_level = -14 ;
|
||||
|
||||
if( it > 5 )
|
||||
recon_match_mode = strtoll( params[ 5 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
|
||||
if( it > 6 )
|
||||
wait = strtoll( params[ 6 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
wait = RECON_DEF_WAIT_DURATION ;
|
||||
|
||||
if( it > 8 )
|
||||
volume = strtoll( params[ 8 ].c_str() , nullptr , 10 );
|
||||
else
|
||||
volume = 40 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ReconSetupSaveStrings( std::string dest, std::string input_file , std::string output_file , uint32_t recon_lock_duration , uint32_t recon_lock_nb_match , int32_t recon_squelch_level , uint32_t recon_match_mode , int32_t wait , int32_t volume )
|
||||
{
|
||||
File settings_file;
|
||||
|
||||
auto result = settings_file.create( dest );
|
||||
if( result.is_valid() )
|
||||
return false ;
|
||||
settings_file.write_line( input_file );
|
||||
settings_file.write_line( output_file );
|
||||
settings_file.write_line( to_string_dec_uint( recon_lock_duration ) );
|
||||
settings_file.write_line( to_string_dec_uint( recon_lock_nb_match ) );
|
||||
settings_file.write_line( to_string_dec_int( recon_squelch_level ) );
|
||||
settings_file.write_line( to_string_dec_uint( recon_match_mode ) );
|
||||
settings_file.write_line( to_string_dec_int( wait ) );
|
||||
settings_file.write_line( to_string_dec_int( volume ) );
|
||||
return true ;
|
||||
}
|
||||
|
||||
ReconSetupViewMain::ReconSetupViewMain( NavigationView &nav , Rect parent_rect , std::string input_file , std::string output_file ) : View( parent_rect ) , _input_file { input_file } , _output_file { output_file }
|
||||
{
|
||||
hidden(true);
|
||||
|
@ -43,12 +43,15 @@
|
||||
#define RECON_MATCH_CONTINUOUS 0
|
||||
#define RECON_MATCH_SPARSE 1
|
||||
|
||||
// statistics update interval (change here if it's evolving) in ms
|
||||
// statistics update interval in ms (change here if the statistics API is changing it's pace)
|
||||
#define STATS_UPDATE_INTERVAL 100
|
||||
|
||||
// maximum lock duration
|
||||
#define RECON_MAX_LOCK_DURATION 9900
|
||||
|
||||
// default number of match to have a lock
|
||||
#define RECON_DEF_NB_MATCH 3
|
||||
#define RECON_DEF_LOCK_DURATION 100 // have to be >= and a multiple of STATS_UPDATE_INTERVAL
|
||||
#define RECON_MIN_LOCK_DURATION 100 // have to be >= and a multiple of STATS_UPDATE_INTERVAL
|
||||
#define RECON_DEF_WAIT_DURATION 1000 // will be incremented/decremented by STATS_UPDATE_INTERVAL steps
|
||||
|
||||
// screen size helper
|
||||
@ -60,9 +63,6 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool ReconSetupLoadStrings( std::string source, std::string &input_file , std::string &output_file , uint32_t &recon_lock_duration , uint32_t &recon_lock_nb_match , int32_t &recon_squelch_level , uint32_t &recon_match_mode , int32_t &wait , int32_t &volume );
|
||||
bool ReconSetupSaveStrings( std::string dest, const std::string input_file , const std::string output_file , const uint32_t recon_lock_duration , const uint32_t recon_lock_nb_match , int32_t recon_squelch_level , uint32_t recon_match_mode , int32_t wait , int32_t volume );
|
||||
|
||||
class ReconSetupViewMain : public View {
|
||||
public:
|
||||
ReconSetupViewMain( NavigationView& nav, Rect parent_rect , std::string input_file , std::string output_file );
|
||||
@ -117,7 +117,7 @@ namespace ui {
|
||||
|
||||
class ReconSetupViewMore : public View {
|
||||
public:
|
||||
ReconSetupViewMore( NavigationView& nav, Rect parent_rect , const uint32_t _recon_lock_duration , const uint32_t _recon_lock_nb_match , const uint32_t _recon_match_mode );
|
||||
ReconSetupViewMore( NavigationView& nav, Rect parent_rect , uint32_t _recon_lock_duration , uint32_t _recon_lock_nb_match , uint32_t _recon_match_mode );
|
||||
|
||||
void Save( uint32_t &recon_lock_duration , uint32_t &recon_lock_nb_match , uint32_t &recon_match_mode );
|
||||
|
||||
@ -125,9 +125,9 @@ namespace ui {
|
||||
|
||||
private:
|
||||
|
||||
const uint32_t _recon_lock_duration = STATS_UPDATE_INTERVAL ;
|
||||
const uint32_t _recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
const uint32_t _recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
uint32_t _recon_lock_duration = STATS_UPDATE_INTERVAL ;
|
||||
uint32_t _recon_lock_nb_match = RECON_DEF_NB_MATCH ;
|
||||
uint32_t _recon_match_mode = RECON_MATCH_CONTINUOUS ;
|
||||
|
||||
Checkbox checkbox_load_freqs {
|
||||
{ 1 * 8, 12 },
|
||||
@ -159,7 +159,7 @@ namespace ui {
|
||||
NumberField field_recon_lock_duration {
|
||||
{ 1 * 8, 132 }, // position X , Y
|
||||
4, // number of displayed digits (even empty)
|
||||
{ STATS_UPDATE_INTERVAL , 10000-STATS_UPDATE_INTERVAL }, // range of number
|
||||
{ -RECON_MAX_LOCK_DURATION , RECON_MAX_LOCK_DURATION }, // range of number
|
||||
STATS_UPDATE_INTERVAL, // rotary encoder increment
|
||||
' ', // filling character
|
||||
false // can loop
|
||||
@ -189,7 +189,7 @@ namespace ui {
|
||||
|
||||
class ReconSetupView : public View {
|
||||
public:
|
||||
ReconSetupView( NavigationView& nav , std::string _input_file , std::string _output_file , const uint32_t _recon_lock_duration , const uint32_t _recon_lock_nb_match , const uint32_t _recon_match_mode );
|
||||
ReconSetupView( NavigationView& nav , std::string _input_file , std::string _output_file , uint32_t _recon_lock_duration , uint32_t _recon_lock_nb_match , uint32_t _recon_match_mode );
|
||||
|
||||
std::function<void( std::vector<std::string> messages )> on_changed { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user