mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-28 08:49:45 -05:00
Changed to per pixel marker, short freq display, adjusted <24Mhz view to look like SPEC one
This commit is contained in:
parent
cb93f2636e
commit
98e7116230
@ -28,7 +28,7 @@ namespace ui
|
||||
{
|
||||
void GlassView::focus()
|
||||
{
|
||||
field_marker.focus();
|
||||
button_marker.focus();
|
||||
}
|
||||
|
||||
GlassView::~GlassView()
|
||||
@ -130,7 +130,7 @@ namespace ui
|
||||
last_max_freq = max_freq_hold ;
|
||||
freq_stats.set( "MAX HOLD: "+to_string_short_freq( max_freq_hold ) );
|
||||
}
|
||||
PlotMarker(field_marker.value());
|
||||
PlotMarker( marker );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -148,19 +148,38 @@ namespace ui
|
||||
if( fast_scan || ( LOOKING_GLASS_SLICE_WIDTH < LOOKING_GLASS_SLICE_WIDTH_MAX ) )
|
||||
{
|
||||
// Convert bins of this spectrum slice into a representative max_power and when enough, into pixels
|
||||
// Spectrum.db has 256 bins. Center 12 bins are ignored (DC spike is blanked) Leftmost and rightmost 2 bins are ignored
|
||||
// All things said and done, we actually need 240 of those bins:
|
||||
// Spectrum.db has 256 bins.
|
||||
// All things said and done, we actually need 240 of those bins
|
||||
for (uint8_t bin = 0; bin < 240; bin++)
|
||||
{
|
||||
if (bin < 120)
|
||||
// if the view is done in one pass, show it like in analog_audio_app
|
||||
if( ( LOOKING_GLASS_SLICE_WIDTH < LOOKING_GLASS_SLICE_WIDTH_MAX ) )
|
||||
{
|
||||
if (spectrum.db[134 + bin] > max_power) // 134
|
||||
max_power = spectrum.db[134 + bin];
|
||||
// Center 16 bins are ignored (DC spike is blanked)
|
||||
if (bin < 120)
|
||||
{
|
||||
if (spectrum.db[256 - 120 + bin] > max_power) // 134
|
||||
max_power = spectrum.db[256 - 120 + bin];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spectrum.db[ bin - 120] > max_power) // 118
|
||||
max_power = spectrum.db[bin - 120];
|
||||
}
|
||||
}
|
||||
else
|
||||
else // view is made in multiple pass, use original bin picking
|
||||
{
|
||||
if (spectrum.db[bin - 118] > max_power) // 118
|
||||
max_power = spectrum.db[bin - 118];
|
||||
// Center 12 bins are ignored (DC spike is blanked) Leftmost and rightmost 2 bins are ignored
|
||||
if (bin < 120)
|
||||
{
|
||||
if (spectrum.db[134 + bin] > max_power) // 134
|
||||
max_power = spectrum.db[134 + bin];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spectrum.db[bin - 118] > max_power) // 118
|
||||
max_power = spectrum.db[bin - 118];
|
||||
}
|
||||
}
|
||||
|
||||
bins_Hz_size += each_bin_size; // add this bin Hz count into the "pixel fulfilled bag of Hz"
|
||||
@ -176,8 +195,8 @@ namespace ui
|
||||
|
||||
if (!pixel_index) // Received indication that a waterfall line has been completed
|
||||
{
|
||||
bins_Hz_size = 0; // Since this is an entire pixel line, we don't carry "Pixels into next bin"
|
||||
f_center = f_center_ini - 2 * each_bin_size ; // Start a new sweep
|
||||
bins_Hz_size = 0; // Since this is an entire pixel line, we don't carry "Pixels into next bin"
|
||||
f_center = f_center_ini - 2 * each_bin_size ; // Start a new sweep
|
||||
radio::set_tuning_frequency(f_center); // tune rx for this new slice directly, faster than using persistent memory saving
|
||||
chThdSleepMilliseconds(10);
|
||||
baseband::spectrum_streaming_start(); // Do the RX
|
||||
@ -186,14 +205,14 @@ namespace ui
|
||||
bins_Hz_size -= marker_pixel_step; // reset bins size, but carrying the eventual excess Hz into next pixel
|
||||
}
|
||||
}
|
||||
f_center += 240 * each_bin_size ; // Move into the next bandwidth slice NOTE: spectrum.sampling_rate = LOOKING_GLASS_SLICE_WIDTH
|
||||
f_center += 238 * each_bin_size ; // Move into the next bandwidth slice NOTE: spectrum.sampling_rate = LOOKING_GLASS_SLICE_WIDTH
|
||||
}
|
||||
else //slow scan
|
||||
{
|
||||
for (uint8_t bin = 0; bin < 120 ; bin++)
|
||||
for (uint8_t bin = 0 ; bin < 80 ; bin++)
|
||||
{
|
||||
if (spectrum.db[134 + bin] > max_power) // 134
|
||||
max_power = spectrum.db[134 + bin];
|
||||
max_power = spectrum.db[134 + bin];
|
||||
|
||||
bins_Hz_size += each_bin_size; // add this bin Hz count into the "pixel fulfilled bag of Hz"
|
||||
|
||||
@ -218,7 +237,7 @@ namespace ui
|
||||
bins_Hz_size -= marker_pixel_step; // reset bins size, but carrying the eventual excess Hz into next pixel
|
||||
}
|
||||
}
|
||||
f_center += 120 * each_bin_size ;
|
||||
f_center += 80 * each_bin_size ;
|
||||
}
|
||||
radio::set_tuning_frequency(f_center); // tune rx for this new slice directly, faster than using persistent memory saving
|
||||
chThdSleepMilliseconds(5);
|
||||
@ -243,9 +262,7 @@ namespace ui
|
||||
f_min = field_frequency_min.value();
|
||||
f_max = field_frequency_max.value();
|
||||
search_span = f_max - f_min;
|
||||
|
||||
field_marker.set_range(f_min, f_max); // Move the marker between range
|
||||
field_marker.set_value(f_min + (search_span / 2)); // Put MARKER AT MIDDLE RANGE
|
||||
|
||||
if( locked_range )
|
||||
{
|
||||
button_range.set_text(">"+to_string_dec_uint(search_span)+"<");
|
||||
@ -260,19 +277,13 @@ namespace ui
|
||||
adjust_range( &f_min , &f_max , 240 );
|
||||
|
||||
marker_pixel_step = (f_max - f_min) / 240; // Each pixel value in Hz
|
||||
text_marker_pm.set(to_string_dec_uint((marker_pixel_step / X2_MHZ_DIV) + 1)); // Give idea of +/- marker precision
|
||||
|
||||
int32_t marker_step = marker_pixel_step / MHZ_DIV;
|
||||
if (!marker_step)
|
||||
field_marker.set_step(1); // in case selected range is less than 240 (pixels)
|
||||
else
|
||||
field_marker.set_step(marker_step); // step needs to be a pixel wide.
|
||||
|
||||
f_center_ini = f_min + (LOOKING_GLASS_SLICE_WIDTH / 2); // Initial center frequency for sweep
|
||||
marker = f_min + (f_max - f_min) / 2 ;
|
||||
button_marker.set_text( to_string_short_freq( marker ) );
|
||||
PlotMarker( marker ); // Refresh marker on screen
|
||||
|
||||
|
||||
PlotMarker(field_marker.value()); // Refresh marker on screen
|
||||
|
||||
f_center = f_center_ini; // Reset sweep into first slice
|
||||
pixel_index = 0; // reset pixel counter
|
||||
max_power = 0;
|
||||
bins_Hz_size = 0; // reset amount of Hz filled up by pixels
|
||||
@ -290,18 +301,18 @@ namespace ui
|
||||
}
|
||||
receiver_model.set_squelch_level(0);
|
||||
each_bin_size = LOOKING_GLASS_SLICE_WIDTH / 240 ;
|
||||
f_center = f_center_ini - 2 * each_bin_size ; // Reset sweep into first slice
|
||||
baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, field_trigger.value());
|
||||
receiver_model.set_tuning_frequency(f_center_ini); // tune rx for this slice
|
||||
}
|
||||
|
||||
void GlassView::PlotMarker(rf::Frequency pos)
|
||||
{
|
||||
pos = pos * MHZ_DIV;
|
||||
pos -= f_min;
|
||||
pos = pos / marker_pixel_step; // Real pixel
|
||||
|
||||
uint8_t shift_y = 0 ;
|
||||
if( live_frequency_view > 0 )
|
||||
if( live_frequency_view > 0 ) // plot one line down when in live view
|
||||
{
|
||||
shift_y = 16 ;
|
||||
}
|
||||
@ -329,8 +340,7 @@ namespace ui
|
||||
&filter_config,
|
||||
&field_rf_amp,
|
||||
&range_presets,
|
||||
&field_marker,
|
||||
&text_marker_pm,
|
||||
&button_marker,
|
||||
&field_trigger,
|
||||
&button_jump,
|
||||
&button_rst,
|
||||
@ -509,16 +519,21 @@ namespace ui
|
||||
this->on_range_changed();
|
||||
};
|
||||
|
||||
field_marker.on_change = [this](int32_t v)
|
||||
button_marker.on_change = [this]()
|
||||
{
|
||||
PlotMarker(v); // Refresh marker on screen
|
||||
marker = marker + button_marker.get_encoder_delta() * marker_pixel_step ;
|
||||
if( marker < f_min )
|
||||
marker = f_min ;
|
||||
if( marker > f_max )
|
||||
marker = f_max ;
|
||||
button_marker.set_text( to_string_short_freq( marker ) );
|
||||
button_marker.set_encoder_delta( 0 );
|
||||
PlotMarker( marker ); // Refresh marker on screen
|
||||
};
|
||||
|
||||
field_marker.on_select = [this](NumberField &)
|
||||
button_marker.on_select = [this](ButtonWithEncoder &)
|
||||
{
|
||||
f_center = field_marker.value();
|
||||
f_center = f_center * MHZ_DIV;
|
||||
receiver_model.set_tuning_frequency(f_center); // Center tune rx in marker freq.
|
||||
receiver_model.set_tuning_frequency(marker); // Center tune rx in marker freq.
|
||||
receiver_model.set_frequency_step(MHZ_DIV); // Preset a 1 MHz frequency step into RX -> AUDIO
|
||||
nav_.pop();
|
||||
nav_.push<AnalogAudioView>(); // Jump into audio view
|
||||
|
@ -108,6 +108,7 @@ namespace ui
|
||||
rf::Frequency search_span { 0 };
|
||||
rf::Frequency f_center { 0 };
|
||||
rf::Frequency f_center_ini { 0 };
|
||||
rf::Frequency marker { 0 };
|
||||
rf::Frequency marker_pixel_step { 0 };
|
||||
rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 };
|
||||
rf::Frequency bins_Hz_size { 0 };
|
||||
@ -129,7 +130,7 @@ namespace ui
|
||||
{{0, 0}, "MIN: MAX: LNA VGA ", Color::light_grey()},
|
||||
{{0, 1 * 16}, "RANGE: FILTER: AMP:", Color::light_grey()},
|
||||
{{0, 2 * 16}, "PRESET:", Color::light_grey()},
|
||||
{{0, 3 * 16}, "MARKER: MHz +/- MHz", Color::light_grey()},
|
||||
{{0, 3 * 16}, "MARKER: MHz", Color::light_grey()},
|
||||
{{0, 4 * 16}, "RES: STEP:", Color::light_grey()}
|
||||
};
|
||||
|
||||
@ -180,16 +181,10 @@ namespace ui
|
||||
{" NONE (WIFI 2.4GHz)", 0},
|
||||
}};
|
||||
|
||||
NumberField field_marker{
|
||||
{7 * 8, 3 * 16},
|
||||
4,
|
||||
{0, 7200},
|
||||
25,
|
||||
' '};
|
||||
|
||||
Text text_marker_pm{
|
||||
{20 * 8, 3 * 16, 2 * 8, 16},
|
||||
""};
|
||||
ButtonWithEncoder button_marker{
|
||||
{7 * 8, 3 * 16 , 10 * 8 , 16},
|
||||
" "
|
||||
};
|
||||
|
||||
NumberField field_trigger{
|
||||
{4 * 8, 4 * 16},
|
||||
|
Loading…
Reference in New Issue
Block a user