From b19ed5fec5f4b513ccae3affa35d14516fd8cfaf Mon Sep 17 00:00:00 2001 From: gullradriel <3157857+gullradriel@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:33:09 +0200 Subject: [PATCH] Looking glass narrow view marker wrap around (#2271) * allow 1 MHz wide view (because why not?) * allow marker to wrap around each corner * added another define for clarity --- .../application/apps/ui_looking_glass_app.cpp | 20 +++++++++++-------- .../application/apps/ui_looking_glass_app.hpp | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index 7160337a..5e412c42 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -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; } @@ -257,7 +256,7 @@ 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 @@ -265,7 +264,7 @@ void GlassView::on_range_changed() { // 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; @@ -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; } @@ -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; } @@ -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(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(); }; diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index 2acfde71..d02803b9 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -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 )