mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-24 00:08:24 +00:00
Add wideband spectrum processor.
This commit is contained in:
@@ -92,20 +92,10 @@ uint32_t ReceiverModel::sampling_rate() const {
|
||||
return baseband_configuration.sampling_rate;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_sampling_rate(uint32_t hz) {
|
||||
baseband_configuration.sampling_rate = hz;
|
||||
update_baseband_configuration();
|
||||
}
|
||||
|
||||
uint32_t ReceiverModel::modulation() const {
|
||||
return baseband_configuration.mode;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_modulation(uint32_t v) {
|
||||
baseband_configuration.mode = v;
|
||||
update_modulation();
|
||||
}
|
||||
|
||||
volume_t ReceiverModel::headphone_volume() const {
|
||||
return headphone_volume_;
|
||||
}
|
||||
@@ -120,11 +110,6 @@ uint32_t ReceiverModel::baseband_oversampling() const {
|
||||
return baseband_configuration.decimation_factor;
|
||||
}
|
||||
|
||||
void ReceiverModel::set_baseband_oversampling(uint32_t v) {
|
||||
baseband_configuration.decimation_factor = v;
|
||||
update_baseband_configuration();
|
||||
}
|
||||
|
||||
void ReceiverModel::enable() {
|
||||
radio::set_direction(rf::Direction::Receive);
|
||||
update_tuning_frequency();
|
||||
@@ -153,7 +138,11 @@ void ReceiverModel::disable() {
|
||||
}
|
||||
|
||||
int32_t ReceiverModel::tuning_offset() {
|
||||
return -(sampling_rate() / 4);
|
||||
if( baseband_configuration.mode == 4 ) {
|
||||
return 0;
|
||||
} else {
|
||||
return -(sampling_rate() / 4);
|
||||
}
|
||||
}
|
||||
|
||||
void ReceiverModel::update_tuning_frequency() {
|
||||
@@ -176,7 +165,8 @@ void ReceiverModel::update_vga() {
|
||||
radio::set_vga_gain(vga_gain_db_);
|
||||
}
|
||||
|
||||
void ReceiverModel::update_modulation() {
|
||||
void ReceiverModel::set_baseband_configuration(const BasebandConfiguration config) {
|
||||
baseband_configuration = config;
|
||||
update_baseband_configuration();
|
||||
}
|
||||
|
||||
|
@@ -61,20 +61,19 @@ public:
|
||||
void set_vga(int32_t v_db);
|
||||
|
||||
uint32_t sampling_rate() const;
|
||||
void set_sampling_rate(uint32_t hz);
|
||||
|
||||
uint32_t modulation() const;
|
||||
void set_modulation(uint32_t v);
|
||||
|
||||
volume_t headphone_volume() const;
|
||||
void set_headphone_volume(volume_t v);
|
||||
|
||||
uint32_t baseband_oversampling() const;
|
||||
void set_baseband_oversampling(uint32_t v);
|
||||
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
void set_baseband_configuration(const BasebandConfiguration config);
|
||||
|
||||
private:
|
||||
rf::Frequency frequency_step_ { 25000 };
|
||||
bool rf_amp_ { false };
|
||||
@@ -96,7 +95,6 @@ private:
|
||||
void update_lna();
|
||||
void update_baseband_bandwidth();
|
||||
void update_vga();
|
||||
void update_modulation();
|
||||
void update_baseband_configuration();
|
||||
void update_headphone_volume();
|
||||
|
||||
|
@@ -538,13 +538,35 @@ void ReceiverView::on_vga_changed(int32_t v_db) {
|
||||
}
|
||||
|
||||
void ReceiverView::on_modulation_changed(int32_t modulation) {
|
||||
if( modulation == 3 ) {
|
||||
/* TODO: This is TERRIBLE!!! */
|
||||
receiver_model.set_sampling_rate(2457600);
|
||||
} else {
|
||||
receiver_model.set_sampling_rate(3072000);
|
||||
/* TODO: This is TERRIBLE!!! */
|
||||
switch(modulation) {
|
||||
case 3:
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = modulation,
|
||||
.sampling_rate = 2457600,
|
||||
.decimation_factor = 4,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = modulation,
|
||||
.sampling_rate = 20000000,
|
||||
.decimation_factor = 1,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(12000000);
|
||||
break;
|
||||
|
||||
default:
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = modulation,
|
||||
.sampling_rate = 3072000,
|
||||
.decimation_factor = 4,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
break;
|
||||
}
|
||||
receiver_model.set_modulation(modulation);
|
||||
}
|
||||
|
||||
void ReceiverView::on_show_options_frequency() {
|
||||
|
@@ -419,6 +419,7 @@ private:
|
||||
{ "NFM ", 1 },
|
||||
{ "WFM ", 2 },
|
||||
{ "FSK ", 3 },
|
||||
{ "SPEC", 4 },
|
||||
}
|
||||
};
|
||||
/*
|
||||
|
Reference in New Issue
Block a user