Move common code to LNA/VGA field widgets.

This commit is contained in:
Jared Boone 2016-06-06 10:27:33 -07:00
parent 5ee035fbb3
commit 9190fe7e4f
6 changed files with 10 additions and 49 deletions

View File

@ -108,19 +108,10 @@ AnalogAudioView::AnalogAudioView(
this->on_show_options_frequency();
};
field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v) {
this->on_lna_changed(v);
};
field_lna.on_show_options = [this]() {
this->on_show_options_rf_gain();
};
field_vga.set_value(receiver_model.vga());
field_vga.on_change = [this](int32_t v_db) {
this->on_vga_changed(v_db);
};
field_vga.on_show_options = [this]() {
this->on_show_options_rf_gain();
};
@ -182,14 +173,6 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) {
receiver_model.set_baseband_bandwidth(bandwidth_hz);
}
void AnalogAudioView::on_lna_changed(int32_t v_db) {
receiver_model.set_lna(v_db);
}
void AnalogAudioView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
}
void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode modulation) {
// TODO: Terrible kludge because widget system doesn't notify Waterfall that
// it's being shown or hidden.

View File

@ -150,8 +150,6 @@ private:
void on_tuning_frequency_changed(rf::Frequency f);
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void on_modulation_changed(const ReceiverModel::Mode modulation);
void on_show_options_frequency();
void on_show_options_rf_gain();

View File

@ -51,16 +51,6 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
};
};
field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v) {
this->on_lna_changed(v);
};
field_vga.set_value(receiver_model.vga());
field_vga.on_change = [this](int32_t v_db) {
this->on_vga_changed(v_db);
};
receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::Capture),
.sampling_rate = sampling_rate,
@ -101,12 +91,4 @@ void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) {
receiver_model.set_tuning_frequency(f);
}
void CaptureAppView::on_lna_changed(int32_t v_db) {
receiver_model.set_lna(v_db);
}
void CaptureAppView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
}
} /* namespace ui */

View File

@ -53,8 +53,6 @@ private:
static constexpr uint32_t baseband_bandwidth = 2500000;
void on_tuning_frequency_changed(rf::Frequency f);
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
RSSI rssi {
{ 21 * 8, 0, 6 * 8, 4 },

View File

@ -172,16 +172,6 @@ TPMSAppView::TPMSAppView(NavigationView&) {
&recent_entries_view,
} });
field_lna.set_value(receiver_model.lna());
field_lna.on_change = [this](int32_t v_db) {
receiver_model.set_lna(v_db);
};
field_vga.set_value(receiver_model.vga());
field_vga.on_change = [this](int32_t v_db) {
receiver_model.set_vga(v_db);
};
radio::enable({
tuning_frequency(),
sampling_rate,

View File

@ -314,6 +314,11 @@ LNAGainField::LNAGainField(
' ',
}
{
set_value(receiver_model.lna());
on_change = [](int32_t v) {
receiver_model.set_lna(v);
};
}
void LNAGainField::on_focus() {
@ -334,6 +339,11 @@ VGAGainField::VGAGainField(
' ',
}
{
set_value(receiver_model.vga());
on_change = [](int32_t v) {
receiver_model.set_vga(v);
};
}
void VGAGainField::on_focus() {