From 866e12fbc5761830cbb6ee4bc14ccc825c08eae9 Mon Sep 17 00:00:00 2001 From: gullradriel <3157857+gullradriel@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:25:18 +0100 Subject: [PATCH] added RXIQCALC (#1974) Co-authored-by: GullCode --- .../application/apps/ui_looking_glass_app.cpp | 17 +++++++++++++++++ .../application/apps/ui_looking_glass_app.hpp | 19 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/ui_looking_glass_app.cpp b/firmware/application/apps/ui_looking_glass_app.cpp index 8371b895..62a2b03a 100644 --- a/firmware/application/apps/ui_looking_glass_app.cpp +++ b/firmware/application/apps/ui_looking_glass_app.cpp @@ -338,6 +338,7 @@ GlassView::GlassView( &field_trigger, &button_jump, &button_rst, + &field_rx_iq_phase_cal, &freq_stats}); load_presets(); // Load available presets from TXT files (or default). @@ -474,6 +475,13 @@ GlassView::GlassView( reset_live_view(); }; + field_rx_iq_phase_cal.set_range(0, hackrf_r9 ? 63 : 31); // max2839 has 6 bits [0..63], max2837 has 5 bits [0..31] + field_rx_iq_phase_cal.set_value(get_spec_iq_phase_calibration_value()); // using accessor function of AnalogAudioView to read iq_phase_calibration_value from rx_audio.ini + field_rx_iq_phase_cal.on_change = [this](int32_t v) { + set_spec_iq_phase_calibration_value(v); // using accessor function of AnalogAudioView to write inside SPEC submenu, register value to max283x and save it to rx_audio.ini + }; + set_spec_iq_phase_calibration_value(get_spec_iq_phase_calibration_value()); // initialize iq_phase_calibration in radio + display.scroll_set_area(109, 319); // trigger: @@ -491,6 +499,15 @@ GlassView::GlassView( receiver_model.enable(); } +uint8_t GlassView::get_spec_iq_phase_calibration_value() { // define accessor functions inside AnalogAudioView to read & write real iq_phase_calibration_value + return iq_phase_calibration_value; +} + +void GlassView::set_spec_iq_phase_calibration_value(uint8_t cal_value) { // define accessor functions + iq_phase_calibration_value = cal_value; + radio::set_rx_max283x_iq_phase_calibration(iq_phase_calibration_value); +} + void GlassView::load_presets() { File presets_file; auto error = presets_file.open("LOOKINGGLASS/PRESETS.TXT"); diff --git a/firmware/application/apps/ui_looking_glass_app.hpp b/firmware/application/apps/ui_looking_glass_app.hpp index 21d4f520..d3052c6f 100644 --- a/firmware/application/apps/ui_looking_glass_app.hpp +++ b/firmware/application/apps/ui_looking_glass_app.hpp @@ -69,6 +69,9 @@ class GlassView : public View { void on_hide() override; void focus() override; + uint8_t get_spec_iq_phase_calibration_value(); + void set_spec_iq_phase_calibration_value(uint8_t cal_value); + private: NavigationView& nav_; RxRadioState radio_state_{ReceiverModel::Mode::SpectrumAnalysis}; @@ -79,8 +82,9 @@ class GlassView : public View { uint8_t filter_index = 0; // OFF uint8_t trigger = 32; uint8_t mode = LOOKING_GLASS_FASTSCAN; - uint8_t live_frequency_view = 0; // Spectrum - uint8_t live_frequency_integrate = 3; // Default (3 * old value + new_value) / 4 + uint8_t live_frequency_view = 0; // Spectrum + uint8_t live_frequency_integrate = 3; // Default (3 * old value + new_value) / 4 + uint8_t iq_phase_calibration_value{15}; // initial default RX IQ phase calibration value , used for both max2837 & max2839 app_settings::SettingsManager settings_{ "rx_glass"sv, app_settings::Mode::RX, @@ -93,6 +97,7 @@ class GlassView : public View { {"scan_mode"sv, &mode}, {"freq_view"sv, &live_frequency_view}, {"freq_integrate"sv, &live_frequency_integrate}, + {"iq_phase_calibration"sv, &iq_phase_calibration_value}, // we are saving and restoring that CAL from Settings. }}; struct preset_entry { @@ -160,7 +165,7 @@ class GlassView : public View { {{0, 0 * 16}, "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", Color::light_grey()}, + {{0, 3 * 16}, "MARKER: MHz RXIQCAL", Color::light_grey()}, {{0, 4 * 16}, "RES: STEP:", Color::light_grey()}}; NumberField field_frequency_min{ @@ -208,6 +213,14 @@ class GlassView : public View { {7 * 8, 3 * 16, 9 * 8, 16}, ""}; + NumberField field_rx_iq_phase_cal{ + {28 * 8, 3 * 16}, + 2, + {0, 63}, // 5 or 6 bits IQ CAL phase adjustment (range updated later) + 1, + ' ', + }; + NumberField field_trigger{ {4 * 8, 4 * 16}, 3,