From 42113434f0a18a684127d5e97616239df67372d7 Mon Sep 17 00:00:00 2001 From: GullCode Date: Wed, 27 Jan 2021 16:30:09 +0100 Subject: [PATCH 1/3] Fixed redefined define, possibly overflowing variable, missing constructors --- .../application/apps/ui_looking_glass_app.cpp | 20 +++++++++---------- .../application/apps/ui_looking_glass_app.hpp | 10 +++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index e18bba62..54d347e1 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -100,7 +100,7 @@ void GlassView::on_channel_spectrum(const ChannelSpectrum &spectrum) } if (pixel_index) - f_center += SEARCH_SLICE_WIDTH; //Move into the next bandwidth slice NOTE: spectrum.sampling_rate = SEARCH_SLICE_WIDTH + f_center += LOOKING_GLASS_SLICE_WIDTH; //Move into the next bandwidth slice NOTE: spectrum.sampling_rate = LOOKING_GLASS_SLICE_WIDTH else f_center = f_center_ini; //Start a new sweep @@ -143,8 +143,8 @@ void GlassView::on_range_changed() else field_marker.set_step(marker_step); //step needs to be a pixel wide. - f_center_ini = f_min + (SEARCH_SLICE_WIDTH / 2); //Initial center frequency for sweep - f_center_ini += SEARCH_SLICE_WIDTH; //euquiq: Why do I need to move the center ???!!! (shift needed for marker accuracy) + f_center_ini = f_min + (LOOKING_GLASS_SLICE_WIDTH / 2); //Initial center frequency for sweep + f_center_ini += LOOKING_GLASS_SLICE_WIDTH; //euquiq: Why do I need to move the center ???!!! (shift needed for marker accuracy) PlotMarker(field_marker.value()); //Refresh marker on screen @@ -153,13 +153,13 @@ void GlassView::on_range_changed() max_power = 0; bins_Hz_size = 0; //reset amount of Hz filled up by pixels - baseband::set_spectrum(SEARCH_SLICE_WIDTH, field_trigger.value()); + 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) +void GlassView::PlotMarker(rf::Frequency fpos) { - pos = pos * MHZ_DIV; + int64_t pos = fpos * MHZ_DIV; pos -= f_min; pos = pos / marker_pixel_step; //Real pixel @@ -240,11 +240,11 @@ GlassView::GlassView( field_trigger.set_value(32); //Defaults to 32, as normal triggering resolution field_trigger.on_change = [this](int32_t v) { - baseband::set_spectrum(SEARCH_SLICE_WIDTH, v); + baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, v); }; display.scroll_set_area( 109, 319); - baseband::set_spectrum(SEARCH_SLICE_WIDTH, field_trigger.value()); //trigger: + baseband::set_spectrum(LOOKING_GLASS_SLICE_WIDTH, field_trigger.value()); //trigger: // Discord User jteich: WidebandSpectrum::on_message to set the trigger value. In WidebandSpectrum::execute , // it keeps adding the output of the fft to the buffer until "trigger" number of calls are made, //at which time it pushes the buffer up with channel_spectrum.feed @@ -252,8 +252,8 @@ GlassView::GlassView( on_range_changed(); receiver_model.set_modulation(ReceiverModel::Mode::SpectrumAnalysis); - receiver_model.set_sampling_rate(SEARCH_SLICE_WIDTH); //20mhz - receiver_model.set_baseband_bandwidth(SEARCH_SLICE_WIDTH); // possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz + receiver_model.set_sampling_rate(LOOKING_GLASS_SLICE_WIDTH); //20mhz + receiver_model.set_baseband_bandwidth(LOOKING_GLASS_SLICE_WIDTH); // possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz receiver_model.set_squelch_level(0); receiver_model.enable(); } diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index 3313a55f..df93a819 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -33,7 +33,7 @@ namespace ui { - #define SEARCH_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz + #define LOOKING_GLASS_SLICE_WIDTH 20000000 // Each slice bandwidth 20 MHz #define MHZ_DIV 1000000 #define X2_MHZ_DIV 2000000 @@ -41,6 +41,10 @@ { public: GlassView(NavigationView &nav); + + GlassView( const GlassView &); + GlassView& operator=(const GlassView &nav); + ~GlassView(); std::string title() const override { return "Looking Glass"; }; @@ -77,7 +81,7 @@ rf::Frequency f_center { 0 }; rf::Frequency f_center_ini { 0 }; rf::Frequency marker_pixel_step { 0 }; - rf::Frequency each_bin_size { SEARCH_SLICE_WIDTH / 240 }; + rf::Frequency each_bin_size { LOOKING_GLASS_SLICE_WIDTH / 240 }; rf::Frequency bins_Hz_size { 0 }; uint8_t min_color_power { 0 }; uint32_t pixel_index { 0 }; @@ -180,4 +184,4 @@ }; } - \ No newline at end of file + From 8c84719598ffcf1fdc6ef30354f1aaa6296c08f5 Mon Sep 17 00:00:00 2001 From: GullCode Date: Wed, 27 Jan 2021 16:54:17 +0100 Subject: [PATCH 2/3] Added two voided vars --- firmware/application/apps/ui_looking_glass_app.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index 54d347e1..73ff1428 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -216,10 +216,12 @@ GlassView::GlassView( filter_config.set_selected_index(0); filter_config.on_change = [this](size_t n, OptionsField::value_t v) { + (void)n; min_color_power = v; }; range_presets.on_change = [this](size_t n, OptionsField::value_t v) { + (void)n; field_frequency_min.set_value(presets_db[v].min,false); field_frequency_max.set_value(presets_db[v].max,false); this->on_range_changed(); From cd8732c24f6c73166fcc330178e07d817810706c Mon Sep 17 00:00:00 2001 From: GullCode Date: Fri, 5 Feb 2021 23:08:54 +0100 Subject: [PATCH 3/3] Direct casting to int instead of new var --- firmware/application/apps/ui_looking_glass_app.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index 73ff1428..1f478fb3 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -164,9 +164,9 @@ void GlassView::PlotMarker(rf::Frequency fpos) pos = pos / marker_pixel_step; //Real pixel portapack::display.fill_rectangle({0, 100, 240, 8}, Color::black()); //Clear old marker and whole marker rectangle btw - portapack::display.fill_rectangle({pos - 2, 100, 5, 3}, Color::red()); //Red marker middle - portapack::display.fill_rectangle({pos - 1, 103, 3, 3}, Color::red()); //Red marker middle - portapack::display.fill_rectangle({pos, 106, 1, 2}, Color::red()); //Red marker middle + portapack::display.fill_rectangle({(int16_t)pos - 2, 100, 5, 3}, Color::red()); //Red marker middle + portapack::display.fill_rectangle({(int16_t)pos - 1, 103, 3, 3}, Color::red()); //Red marker middle + portapack::display.fill_rectangle({(int16_t)pos, 106, 1, 2}, Color::red()); //Red marker middle } GlassView::GlassView(