Skip to content

Commit 1df3183

Browse files
gullradrielgullradriel
and
gullradriel
authored
Wefax warning fix modulation fix (#2543)
* changed order of modulations, changed case to avoid capture * added missing AMAudioFMApt mode to dump pmem * reorder demod, adding missing ones, fix warnings * removed uneeded 'previous_modulation', renamed WFAX to AMFM to match other places * removing uneeded 'previous_modulation' uneeded check in change_modulation * move capture at the end so AMAUdioFMApt is matching the other arrays for position 4 * added AMFM to Recon Level and Scanner * clang + more details in some comments --------- Co-authored-by: gullradriel <[email protected]>
1 parent a17995f commit 1df3183

16 files changed

+64
-31
lines changed

firmware/application/apps/analog_audio_app.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ AMFMAptOptionsView::AMFMAptOptionsView(
116116
});
117117

118118
freqman_set_bandwidth_option(AMFM_MODULATION, options_config); // adding the common message from freqman.cpp to the options_config
119+
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
119120
options_config.set_by_value(receiver_model.amfm_configuration());
120-
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
121121
}
122122

123123
/* SPECOptionsView *******************************************************/
@@ -193,9 +193,10 @@ AnalogAudioView::AnalogAudioView(
193193
};
194194

195195
auto modulation = receiver_model.modulation();
196+
196197
// This app doesn't handle "Capture" mode.
197-
if (modulation > ReceiverModel::Mode::SpectrumAnalysis) // This two should be together in the last index position : SpectrumAnalysis = 4, and Capture = 5
198-
modulation = ReceiverModel::Mode::SpectrumAnalysis; // For sw simplicity , Wefax_mode, should NOT be added between.
198+
if (modulation == ReceiverModel::Mode::Capture)
199+
modulation = ReceiverModel::Mode::SpectrumAnalysis;
199200

200201
options_modulation.set_by_value(toUType(modulation));
201202
options_modulation.on_change = [this](size_t, OptionsField::value_t v) {
@@ -285,10 +286,6 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) {
285286
}
286287

287288
void AnalogAudioView::on_modulation_changed(ReceiverModel::Mode modulation) {
288-
// This app doesn't know what to do with "Capture" mode.
289-
if (modulation > ReceiverModel::Mode::SpectrumAnalysis)
290-
modulation = ReceiverModel::Mode::SpectrumAnalysis;
291-
292289
baseband::spectrum_streaming_stop();
293290
update_modulation(modulation);
294291
on_show_options_modulation();

firmware/application/apps/analog_audio_app.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,13 @@ class AnalogAudioView : public View {
224224
OptionsField options_modulation{
225225
{0 * 8, 0 * 16},
226226
4,
227-
{{" AM ", toUType(ReceiverModel::Mode::AMAudio)},
228-
{"NFM ", toUType(ReceiverModel::Mode::NarrowbandFMAudio)},
229-
{"WFM ", toUType(ReceiverModel::Mode::WidebandFMAudio)},
230-
{"WFAX", toUType(ReceiverModel::Mode::AMAudioFMApt)}, // Added to handle HF WeatherFax , SSB (USB demod) + Tone_Subcarrier FM demod
231-
{"SPEC", toUType(ReceiverModel::Mode::SpectrumAnalysis)}}};
227+
{
228+
{" AM ", toUType(ReceiverModel::Mode::AMAudio)},
229+
{"NFM ", toUType(ReceiverModel::Mode::NarrowbandFMAudio)},
230+
{"WFM ", toUType(ReceiverModel::Mode::WidebandFMAudio)},
231+
{"SPEC", toUType(ReceiverModel::Mode::SpectrumAnalysis)},
232+
{"AMFM", toUType(ReceiverModel::Mode::AMAudioFMApt)} // Added to handle HF WeatherFax , SSB (USB demod) + Tone_Subcarrier FM demod
233+
}};
232234

233235
AudioVolumeField field_volume{
234236
{28 * 8, 0 * 16}};

firmware/application/apps/ui_freqman.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using option_db_t = std::pair<std::string_view, int32_t>;
4545
using options_db_t = std::vector<option_db_t>;
4646

4747
extern options_db_t freqman_modulations;
48-
extern options_db_t freqman_bandwidths[4];
48+
extern options_db_t freqman_bandwidths[5];
4949
extern options_db_t freqman_steps;
5050
extern options_db_t freqman_steps_short;
5151

firmware/application/apps/ui_level.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ size_t LevelView::change_mode(freqman_index_t new_mod) {
277277
field_bw.set_by_value(0);
278278
field_bw.on_change = [this](size_t index, OptionsField::value_t n) { radio_bw = index ; receiver_model.set_wfm_configuration(n); };
279279
break;
280+
case AMFM_MODULATION:
281+
audio_sampling_rate = audio::Rate::Hz_12000;
282+
freqman_set_bandwidth_option(new_mod, field_bw);
283+
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
284+
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
285+
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
286+
field_bw.set_by_value(0);
287+
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
288+
break;
280289
case SPEC_MODULATION:
281290
audio_sampling_rate = audio::Rate::Hz_24000;
282291
freqman_set_bandwidth_option(new_mod, field_bw);

firmware/application/apps/ui_recon.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,16 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
12271227
text_ctcss.set(" ");
12281228
recording_sampling_rate = 48000;
12291229
break;
1230+
case AMFM_MODULATION:
1231+
freqman_set_bandwidth_option(new_mod, field_bw);
1232+
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
1233+
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
1234+
receiver_model.set_amfm_configuration(5); // Fix index 5 manually, not from freqman: set to RX AM (USB+FM) mode to demod audio tone, and get Wefax_APT signal.
1235+
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
1236+
field_bw.set_by_value(0);
1237+
text_ctcss.set(" ");
1238+
recording_sampling_rate = 12000;
1239+
break;
12301240
case SPEC_MODULATION:
12311241
freqman_set_bandwidth_option(new_mod, field_bw);
12321242
baseband::run_image(portapack::spi_flash::image_tag_capture);

firmware/application/apps/ui_scanner.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,14 @@ void ScannerView::change_mode(freqman_index_t new_mod) {
725725
field_bw.set_by_value(receiver_model.wfm_configuration());
726726
field_bw.on_change = [this](size_t, OptionsField::value_t n) { receiver_model.set_wfm_configuration(n); };
727727
break;
728+
case AMFM_MODULATION:
729+
freqman_set_bandwidth_option(new_mod, field_bw);
730+
baseband::run_image(portapack::spi_flash::image_tag_am_audio);
731+
receiver_model.set_modulation(ReceiverModel::Mode::AMAudioFMApt);
732+
receiver_model.set_amfm_configuration(5);
733+
field_bw.set_by_value(0);
734+
field_bw.on_change = [this](size_t, OptionsField::value_t n) { (void)n; };
735+
break;
728736
default:
729737
break;
730738
}

firmware/application/baseband_api.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ static void send_message(const Message* const message) {
6666

6767
void AMConfig::apply() const {
6868
const AMConfigureMessage message{
69-
taps_6k0_decim_0, // common FIR filter taps pre-decim_0 to all 6 x AM mod types.(AM-9K, AM-6K, USB, LSB, CW, WFAX)
69+
taps_6k0_decim_0, // common FIR filter taps pre-decim_0 to all 6 x AM mod types.(AM-9K, AM-6K, USB, LSB, CW, AMFM-WFAX)
7070
taps_6k0_decim_1, // common FIR filter taps pre-decim_1 to all 6 x AM mod. types. (")
7171
decim_2, // var decim_2 FIR taps filter , variable values, depending selected AM mod(AM 9k / 6k and all rest AM modes)
72-
channel, // var channel FIR taps filter , variable values, depending selected AM mode, each one different (DSB-9K, DSB-6K, USB-3K, LSB-3K,CW,WFAX)
72+
channel, // var channel FIR taps filter , variable values, depending selected AM mode, each one different (DSB-9K, DSB-6K, USB-3K, LSB-3K,CW,AMFM-WFAX)
7373
modulation, // var parameter . enum class Modulation : int32_t {DSB = 0, SSB = 1, SSB_FM = 2}
7474
audio_12k_iir_filter_config}; // var parameter , 300 Hz hpf all except Wefax (1.500Hz lpf)
7575
send_message(&message);

firmware/application/freqman.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ enum freqman_entry_modulation : uint8_t {
4141
AM_MODULATION = 0,
4242
NFM_MODULATION,
4343
WFM_MODULATION,
44-
AMFM_MODULATION, // Added for Wefax.
45-
SPEC_MODULATION
44+
SPEC_MODULATION,
45+
AMFM_MODULATION // Added for Wefax.
4646
};
4747

4848
// TODO: Can these be removed after Recon is migrated to FreqmanDB?

firmware/application/freqman_db.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ options_t freqman_modulations = {
4949
{"NFM", 1},
5050
{"WFM", 2},
5151
{"SPEC", 3},
52+
{"AMFM", 4},
5253
};
5354

5455
options_t freqman_bandwidths[5] = {
@@ -72,10 +73,6 @@ options_t freqman_bandwidths[5] = {
7273
{"180k", 1},
7374
{"200k", 0},
7475
},
75-
{
76-
// AMFM for Wefax-
77-
{"USB+FM", 5}, // Fixed RX demodul AM config Index 5 : USB+FM for Audio Weather fax (Wfax) tones.
78-
},
7976
{
8077
// SPEC -- TODO: these should be indexes.
8178
{"12k5", 12500},
@@ -103,7 +100,12 @@ options_t freqman_bandwidths[5] = {
103100
{"4500k", 4500000},
104101
{"5000k", 5500000},
105102
{"5500k", 5500000}, // Max capture, needs /4 decimation, (22Mhz sampling ADC).
106-
}};
103+
},
104+
{
105+
// AMFM for Wefax-
106+
{"USB+FM", 5}, // Fixed RX demodul AM config Index 5 : USB+FM for Audio Weather fax (WFAX) tones.
107+
},
108+
};
107109

108110
// TODO: these should be indexes.
109111
options_t freqman_steps = {

firmware/application/receiver_model.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class ReceiverModel {
4040
AMAudio = 0,
4141
NarrowbandFMAudio = 1,
4242
WidebandFMAudio = 2,
43-
AMAudioFMApt = 3, // Added to handle HF WeatherFax , SSB (USB demod) + Tone_Subcarrier FM demod
44-
SpectrumAnalysis = 4,
45-
Capture = 5
43+
SpectrumAnalysis = 3,
44+
AMAudioFMApt = 4, // Added to handle HF WeatherFax , SSB (USB demod) + Tone_Subcarrier FM demod
45+
Capture = 5,
4646
};
4747

4848
struct settings_t {

firmware/baseband/audio_output.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void AudioOutput::on_block(const buffer_f32_t& audio) {
7272
if (do_processing) {
7373
const auto audio_present_now = squelch.execute(audio);
7474

75-
hpf.execute_in_place(audio); // IIRBiquadFilter name is "hpf", but we will call with "hpf-coef" for all except WFAX with "lpf-coef".
75+
hpf.execute_in_place(audio); // IIRBiquadFilter name is "hpf", but we will call with "hpf-coef" for all except AMFM (WFAX) with "lpf-coef"
7676
deemph.execute_in_place(audio);
7777

7878
audio_present_history = (audio_present_history << 1) | (audio_present_now ? 1 : 0);

firmware/baseband/dsp_demodulate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static inline float angle_precise(const complex32_t t) {
7979
return atan2f(t.imag(), t.real());
8080
}
8181

82-
buffer_f32_t SSB_FM::execute( // Added to handle WFAX (HF weather map )-
82+
buffer_f32_t SSB_FM::execute( // Added to handle AMFM (WFAX, HF weather map )
8383
const buffer_c16_t& src, // input arg , pointer Complex c16 i,q buffer.
8484
const buffer_f32_t& dst) { // input arg , pointer f32 buffer audio demodulated
8585
complex16_t* src_p = src.p; // removed const ; init src_p pointer with the mem address pointed by src.p.

firmware/baseband/dsp_demodulate.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class SSB {
4848
static constexpr float k = 1.0f / 32768.0f;
4949
};
5050

51-
class SSB_FM { // Added to handle WFAX-
51+
class SSB_FM { // Added to handle AMFM for WFAX
5252
public:
5353
buffer_f32_t execute(
5454
const buffer_c16_t& src,
5555
const buffer_f32_t& dst);
5656

5757
private:
5858
static constexpr float k = 1.0f / 32768.0f;
59-
dsp::Real_to_Complex real_to_complex; // It is a member variable of SSB_FM.
59+
dsp::Real_to_Complex real_to_complex{}; // It is a member variable of SSB_FM.
6060
};
6161

6262
class FM {

firmware/baseband/proc_am_audio.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ buffer_f32_t NarrowbandAMAudio::demodulate(const buffer_c16_t& channel) {
6565
return demod_ssb_fm.execute(channel, audio_buffer); // Calling a derivative of demod_ssb (USB) , but with different FIR taps + FM audio tones demod.
6666
break;
6767

68+
// return demod am as a default
6869
default:
70+
return demod_am.execute(channel, audio_buffer);
6971
break;
7072
}
7173
}

firmware/common/dsp_sos_config.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ constexpr iir_biquad_df2_config_t half_band_lpf_config[5] = {
3434
{1.0f, 0.08720754, 1.0f, 1.0f, 0.00220944f, 0.98743139f}};
3535

3636
// scipy.signal.iirfilter(ftype="ellip", N = 10, rp = 0.5, rs = 60.0, Wn = 0.99, btype = 'lowpass', output="sos")
37-
// 6khz cutofff @fs:12Khz , used in WFAX demod.
37+
// 6khz cutofff @fs:12Khz , used in AMFM demod for WFAX
3838
constexpr iir_biquad_df2_config_t full_band_lpf_config[5] = {
3939
{0.88095275f, 1.76184993f, 0.88095275f, 1.0f, 1.89055677f, 0.89616378f},
4040
{1.0f, 1.99958798f, 1.0f, 1.0f, 1.9781807f, 0.98002549f},
@@ -43,7 +43,7 @@ constexpr iir_biquad_df2_config_t full_band_lpf_config[5] = {
4343
{1.0f, 1.99909558f, 1.0f, 1.0f, 1.9986187f, 0.99960319f}};
4444

4545
// scipy.signal.iirfilter(ftype="ellip", N = 10, rp = 0.5 , rs = 60.0, Wn = 0.25, btype = 'lowpass', output="sos")
46-
// 1.5khz cutofff @fs:12Khz, used in WFAX demod.
46+
// 1.5khz cutofff @fs:12Khz, used in AMFM demod for WFAX
4747
constexpr iir_biquad_df2_config_t quarter_band_lpf_config[5] = {
4848
{0.00349312f, 0.00319397f, 0.00349312f, 1.0f, -1.53025211f, 0.6203438f},
4949
{1.0f, -0.83483341f, 1.0f, 1.0f, -1.47619047f, 0.77120659f},

firmware/common/portapack_persistent_memory.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,9 @@ bool debug_dump() {
13291329
case ReceiverModel::Mode::Capture:
13301330
pmem_dump_file.write_line("modulation: Mode::Capture");
13311331
break;
1332+
case ReceiverModel::Mode::AMAudioFMApt:
1333+
pmem_dump_file.write_line("modulation: Mode::AMAudioFMApt");
1334+
break;
13321335
default:
13331336
pmem_dump_file.write_line("modulation: !!unknown mode!!");
13341337
break;

0 commit comments

Comments
 (0)