Skip to content

Commit

Permalink
Looking glass narrow view marker wrap around (#2271)
Browse files Browse the repository at this point in the history
* allow 1 MHz wide view (because why not?)
* allow marker to wrap around each corner
* added another define for clarity
  • Loading branch information
gullradriel committed Sep 28, 2024
1 parent 419bc75 commit b19ed5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions firmware/application/apps/ui_looking_glass_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ rf::Frequency GlassView::get_freq_from_bin_pos(uint8_t pos) {
freq_at_pos = f_center_ini + ((pos - 120) * ((looking_glass_range - ((16 * looking_glass_range) / SPEC_NB_BINS)) / 2)) / (SCREEN_W / 2);
} else
freq_at_pos = f_min + (2 * offset * each_bin_size) + (pos * looking_glass_range) / SCREEN_W;

return freq_at_pos;
}

Expand Down Expand Up @@ -257,15 +256,15 @@ void GlassView::on_range_changed() {
bin_length = SCREEN_W;
ignore_dc = 0;
looking_glass_bandwidth = looking_glass_range;
looking_glass_sampling_rate = looking_glass_bandwidth;
looking_glass_sampling_rate = looking_glass_range;
each_bin_size = looking_glass_bandwidth / SCREEN_W;
looking_glass_step = looking_glass_bandwidth;
f_center_ini = f_min + (looking_glass_bandwidth / 2); // Initial center frequency for sweep
} else {
// view is made in multiple pass, use original bin picking
mode = scan_type.selected_index_value();
looking_glass_bandwidth = LOOKING_GLASS_SLICE_WIDTH_MAX;
looking_glass_sampling_rate = LOOKING_GLASS_SLICE_WIDTH_MAX;
looking_glass_sampling_rate = LOOKING_GLASS_MAX_SAMPLERATE;
each_bin_size = LOOKING_GLASS_SLICE_WIDTH_MAX / SPEC_NB_BINS;
if (mode == LOOKING_GLASS_FASTSCAN) {
offset = 2;
Expand Down Expand Up @@ -315,8 +314,8 @@ void GlassView::update_min(int32_t v) {
int32_t min_size = steps;
if (locked_range)
min_size = search_span;
if (min_size < 2)
min_size = 2;
if (min_size < 1)
min_size = 1;
if (v > 7200 - min_size) {
v = 7200 - min_size;
}
Expand All @@ -332,8 +331,8 @@ void GlassView::update_max(int32_t v) {
int32_t min_size = steps;
if (locked_range)
min_size = search_span;
if (min_size < 2)
min_size = 2;
if (min_size < 1)
min_size = 1;
if (v < min_size) {
v = min_size;
}
Expand Down Expand Up @@ -487,7 +486,12 @@ GlassView::GlassView(
range_presets.set_selected_index(preset_index);

field_marker.on_encoder_change = [this](TextField&, EncoderEvent delta) {
marker_pixel_index = clip<uint8_t>(marker_pixel_index + delta, 0, SCREEN_W);
if ((marker_pixel_index + delta) < 0)
marker_pixel_index = marker_pixel_index + delta + SCREEN_W;
else if ((marker_pixel_index + delta) > SCREEN_W)
marker_pixel_index = marker_pixel_index + delta - SCREEN_W;
else
marker_pixel_index = marker_pixel_index + delta;
on_marker_change();
};

Expand Down
1 change: 1 addition & 0 deletions firmware/application/apps/ui_looking_glass_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
namespace ui {

#define LOOKING_GLASS_SLICE_WIDTH_MAX 20000000
#define LOOKING_GLASS_MAX_SAMPLERATE 20000000
#define MHZ_DIV 1000000

// blanked DC (16 centered bins ignored ) and top left and right (2 bins ignored on each side )
Expand Down

0 comments on commit b19ed5f

Please sign in to comment.