Adding Rx IQ error phase CAL to SPEC Audio_App (#1963)

This commit is contained in:
Brumi-2021
2024-03-09 23:46:38 +01:00
committed by GitHub
parent 73c29f666f
commit 9d8132978f
9 changed files with 125 additions and 17 deletions

View File

@@ -30,6 +30,7 @@
#include "string_format.hpp"
#include "ui_freqman.hpp"
#include "utility.hpp"
#include "radio.hpp"
using namespace portapack;
using namespace tonekey;
@@ -112,10 +113,14 @@ SPECOptionsView::SPECOptionsView(
: View{parent_rect} {
set_style(style);
add_children({&label_config,
&options_config,
&text_speed,
&field_speed});
add_children({
&label_config,
&options_config,
&text_speed,
&field_speed,
&text_rx_cal,
hackrf_r9 ? &field_rx_iq_phase_cal_2839 : &field_rx_iq_phase_cal_2837 // max2839 has 6 bits [0..63], max2837 has 5 bits [0..31]
});
options_config.set_selected_index(view->get_spec_bw_index());
options_config.on_change = [this, view](size_t n, OptionsField::value_t bw) {
@@ -126,6 +131,18 @@ SPECOptionsView::SPECOptionsView(
field_speed.on_change = [this, view](int32_t v) {
view->set_spec_trigger(v);
};
if (hackrf_r9) { // MAX2839 has 6 bits RX IQ CAL phasse adjustment.
field_rx_iq_phase_cal_2839.set_value(view->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_2839.on_change = [this, view](int32_t v) {
view->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
};
} else { // MAX2837 has 5 bits RX IQ CAL phase adjustment.
field_rx_iq_phase_cal_2837.set_value(view->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_2837.on_change = [this, view](int32_t v) {
view->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
};
}
}
/* AnalogAudioView *******************************************************/
@@ -213,6 +230,15 @@ void AnalogAudioView::set_spec_bw(size_t index, uint32_t bw) {
receiver_model.set_baseband_bandwidth(bw / 2);
}
uint8_t AnalogAudioView::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 AnalogAudioView::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);
}
uint16_t AnalogAudioView::get_spec_trigger() {
return spec_trigger;
}

View File

@@ -133,6 +133,23 @@ class SPECOptionsView : public View {
1,
' ',
};
Text text_rx_cal{
{19 * 8, 0 * 16, 11 * 8, 1 * 16}, // 18 (x col.) x char_size, 12 (length) x 8 blanking space to delete previous chars.
"Rx_IQ_CAL "};
NumberField field_rx_iq_phase_cal_2837{
{28 * 8, 0 * 16},
2,
{0, 31}, // 5 bits IQ CAL phase adjustment.
1,
' ',
};
NumberField field_rx_iq_phase_cal_2839{
{28 * 8, 0 * 16},
2,
{0, 63}, // 6 bits IQ CAL phase adjustment.
1,
' ',
};
};
class AnalogAudioView : public View {
@@ -152,14 +169,22 @@ class AnalogAudioView : public View {
uint16_t get_spec_trigger();
void set_spec_trigger(uint16_t trigger);
uint8_t get_spec_iq_phase_calibration_value();
void set_spec_iq_phase_calibration_value(uint8_t cal_value);
private:
static constexpr ui::Dim header_height = 3 * 16;
NavigationView& nav_;
RxRadioState radio_state_{};
uint8_t iq_phase_calibration_value{15}; // initial default RX IQ phase calibration value , used for both max2837 & max2839
app_settings::SettingsManager settings_{
"rx_audio", app_settings::Mode::RX,
app_settings::Options::UseGlobalTargetFrequency};
"rx_audio",
app_settings::Mode::RX,
app_settings::Options::UseGlobalTargetFrequency,
{
{"iq_phase_calibration"sv, &iq_phase_calibration_value}, // we are saving and restoring that CAL from Settings.
}};
const Rect options_view_rect{0 * 8, 1 * 16, 30 * 8, 1 * 16};
const Rect nbfm_view_rect{0 * 8, 1 * 16, 18 * 8, 1 * 16};