Legacy Initialization, Analog Audio App, and Aliasing fixes. (#3052)

* Added PRO button to analog_audio.cpp for debugging metallic ringing sounds in Audio app. Ensured consitency to 4MHz in analog_audio.cpp

* Restored blutooth after loss.

* Added several sampling rates to analog_audio for testing.

* Ran format-code.sh

* Fixed 0x03 mode for DC/Q-INV/Q-SHFT being set at every tuning and sample rate change. This was the root cause for loss of bluetooth before. Sample rate, and frequency can now be changed without need for manually resetting DC/Q-INV/Q-SHIFT settings. Updated method for setting frequncies in praline so that we have more testing options.

* Ran format-code.sh and cleaned up stale comments.

* Addressed comments, and removed commented line, opting for higher register values, 5E and 5D. Added WFM Debug View to support testing demodulation ringing.

* Addressed comments in PR conversation to clean comments and ensure consistency at initializtion accross updated methods and displays.

* Ran format-code.sh

* Set initial legacy state. Improved readability of clocking initialization settings. Updated set_sampling_frequency, and udpate_bandwidth to set decimation values in the fpga_registers to avoid aliasing in low band frequencies.

* Updated clock_manager to use correct clock and clock parameters for audio pll. Ran format-code.sh.
This commit is contained in:
stafur
2026-02-27 23:43:19 -05:00
committed by GitHub
parent 56adca3bf6
commit b2bf0f2459
10 changed files with 179 additions and 143 deletions
+32 -12
View File
@@ -208,16 +208,41 @@ PralineOptionsView::PralineOptionsView(Rect parent_rect, const Style* style) {
&label_qi, &options_qi, &label_qs, &options_qs,
&label_dec, &options_dec});
// 1. READ the current state from hardware
fpga_reg_1 = radio::debug::fpga::register_read(1);
uint32_t fpga_reg_2 = radio::debug::fpga::register_read(2);
// 2. INITIALIZE UI WIDGETS based on read bits
options_dc.set_by_value((fpga_reg_1 & 0x01) ? 1 : 0); // Bit 0
options_qi.set_by_value((fpga_reg_1 & 0x02) ? 1 : 0); // Bit 1
options_qs.set_by_value((fpga_reg_1 & 0x04) ? 1 : 0); // Bit 2
options_dec.set_by_value(fpga_reg_2);
options_sr.set_value(receiver_model.sampling_rate() / 1000);
options_dc.set_by_value(1);
options_qi.set_by_value(0);
options_qs.set_by_value(0);
options_dec.set_by_value(0);
options_sr.on_change = [this](int32_t v) { receiver_model.set_sampling_rate(static_cast<uint32_t>(v) * 1000); };
options_dc.on_change = [this](size_t, OptionsField::value_t v) { if (v) fpga_reg_1 |= 0x01; else fpga_reg_1 &= ~0x01; update_fpga_ctrl(); };
options_qi.on_change = [this](size_t, OptionsField::value_t v) { if (v) fpga_reg_1 |= 0x02; else fpga_reg_1 &= ~0x02; update_fpga_ctrl(); };
options_qs.on_change = [this](size_t, OptionsField::value_t v) { if (v) fpga_reg_1 |= 0x04; else fpga_reg_1 &= ~0x04; update_fpga_ctrl(); };
options_dc.on_change = [this](size_t, OptionsField::value_t v) {
if (v)
fpga_reg_1 |= 0x01;
else
fpga_reg_1 &= ~0x01;
update_fpga_ctrl();
};
options_qi.on_change = [this](size_t, OptionsField::value_t v) {
if (v)
fpga_reg_1 |= 0x02;
else
fpga_reg_1 &= ~0x02;
update_fpga_ctrl();
};
options_qs.on_change = [this](size_t, OptionsField::value_t v) {
if (v)
fpga_reg_1 |= 0x04;
else
fpga_reg_1 &= ~0x04;
update_fpga_ctrl();
};
options_dec.on_change = [this](size_t, OptionsField::value_t v) { radio::debug::fpga::register_write(2, v); };
}
@@ -549,13 +574,8 @@ void AnalogAudioView::update_modulation(ReceiverModel::Mode modulation) {
const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis);
receiver_model.set_modulation(modulation);
#ifdef PRALINE
receiver_model.set_sampling_rate(is_wideband_spectrum_mode ? spec_bw : 4000000);
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? spec_bw / 2 : 2000000);
#else
receiver_model.set_sampling_rate(is_wideband_spectrum_mode ? spec_bw : 3072000);
receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? spec_bw / 2 : 1750000);
#endif
receiver_model.set_hidden_offset(modulation == ReceiverModel::Mode::AMAudioFMApt ? -2200 : 0); // wefax needs to be shifted, see wefax rx app.
@@ -67,7 +67,7 @@ class PralineOptionsView : public View {
Text label_dec{{UI_POS_X(26), UI_POS_Y(0), UI_POS_WIDTH(1), UI_POS_HEIGHT(1)}, "D"};
OptionsField options_dec{{UI_POS_X(28), UI_POS_Y(0)}, 2, {{" 1", 0}, {" 2", 1}, {" 4", 2}, {" 8", 3}, {"16", 4}}};
uint8_t fpga_reg_1{0x01}; // Tracks DC, QI, QS bits
uint8_t fpga_reg_1{0x00}; // Tracks DC, QI, QS bits
void update_fpga_ctrl();
};
#endif
+3 -3
View File
@@ -745,7 +745,7 @@ void WFMAudioDebugView::refresh() {
// === De-emphasis Status ===
// We can't directly read the M4 de-emphasis config, but we can indicate what SHOULD be set
// 75µs for USA, 50µs for Europe
text_deemph.set("Check M4 config");
text_deemph.set("Chk M4 cfg.");
text_deemph.set_style(Theme::getInstance()->fg_orange);
// === Status Summary ===
@@ -756,7 +756,7 @@ void WFMAudioDebugView::refresh() {
if (sample_rate_ok && lpf_ok && dc_ok) {
text_status.set("Hardware config looks OK.");
text_status.set_style(Theme::getInstance()->fg_green);
text_status2.set("If ringy: Check de-emphasis in M4!");
text_status2.set("If ringy: Chk d-emph in M4!");
text_status2.set_style(Theme::getInstance()->fg_orange);
} else {
std::string issues = "Issues: ";
@@ -765,7 +765,7 @@ void WFMAudioDebugView::refresh() {
if (!dc_ok) issues += "DC_Block ";
text_status.set(issues);
text_status.set_style(Theme::getInstance()->fg_red);
text_status2.set("Fix above before checking audio.");
text_status2.set("Fix before checking audio.");
text_status2.set_style(Theme::getInstance()->fg_red);
}
}
+6 -6
View File
@@ -523,17 +523,17 @@ class WFMAudioDebugView : public View {
Text text_lbl_fpga_r1{{0, 140, 140, 16}, "Reg1 (Ctrl):"};
Text text_fpga_r1{{150, 140, 90, 16}, "---"};
Text text_lbl_dc_q{{0, 156, 140, 16}, "DC/Q/QS:"};
Text text_dc_q{{150, 156, 90, 16}, "---"};
Text text_lbl_dc_q{{0, 156, 70, 16}, "DC/Q/QS:"};
Text text_dc_q{{72, 156, 168, 16}, "---"};
// Audio section
Text text_section3{{0, 176, 240, 16}, "--- Audio Path ---"};
Text text_lbl_expected{{0, 192, 140, 16}, "Expected Audio:"};
Text text_expected{{150, 192, 90, 16}, "---"};
Text text_lbl_expected{{0, 192, 96, 16}, "Expctd Aud:"};
Text text_expected{{98, 192, 142, 16}, "---"};
Text text_lbl_deemph{{0, 208, 140, 16}, "De-emph Config:"};
Text text_deemph{{150, 208, 90, 16}, "---"};
Text text_lbl_deemph{{0, 208, 96, 16}, "D-emph Cfg:"};
Text text_deemph{{98, 208, 132, 16}, "---"};
// Status
Text text_status{{0, 228, 240, 16}, "---"};