Skip to content

Commit

Permalink
added RXIQCALC (#1974)
Browse files Browse the repository at this point in the history
Co-authored-by: GullCode <gullradriel@hotmail.com>
  • Loading branch information
gullradriel and GullCode authored Mar 10, 2024
1 parent ccd71d9 commit 866e12f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
17 changes: 17 additions & 0 deletions firmware/application/apps/ui_looking_glass_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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:
Expand All @@ -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");
Expand Down
19 changes: 16 additions & 3 deletions firmware/application/apps/ui_looking_glass_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 866e12f

Please sign in to comment.