Move RF amp control code into new class.

This commit is contained in:
Jared Boone 2016-06-06 10:13:36 -07:00
parent a0e7fdf90b
commit 5ee035fbb3
4 changed files with 25 additions and 35 deletions

View File

@ -182,10 +182,6 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) {
receiver_model.set_baseband_bandwidth(bandwidth_hz);
}
void AnalogAudioView::on_rf_amp_changed(bool v) {
receiver_model.set_rf_amp(v);
}
void AnalogAudioView::on_lna_changed(int32_t v_db) {
receiver_model.set_lna(v_db);
}
@ -245,11 +241,6 @@ void AnalogAudioView::on_show_options_frequency() {
void AnalogAudioView::on_show_options_rf_gain() {
auto widget = std::make_unique<RadioGainOptionsView>(options_view_rect, &style_options_group);
widget->set_rf_amp(receiver_model.rf_amp());
widget->on_change_rf_amp = [this](bool enable) {
this->on_rf_amp_changed(enable);
};
set_options_widget(std::move(widget));
field_lna.set_style(&style_options_group);
}

View File

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

View File

@ -269,6 +269,25 @@ void FrequencyOptionsView::on_reference_ppm_correction_changed(int32_t v) {
}
}
/* RFAmpField ************************************************************/
RFAmpField::RFAmpField(
Point parent_pos
) : NumberField {
parent_pos,
1,
{ 0, 1 },
1,
' ',
}
{
set_value(receiver_model.rf_amp());
on_change = [](int32_t v) {
receiver_model.set_rf_amp(v);
};
}
/* RadioGainOptionsView **************************************************/
RadioGainOptionsView::RadioGainOptionsView(
@ -282,20 +301,6 @@ RadioGainOptionsView::RadioGainOptionsView(
&label_rf_amp,
&field_rf_amp,
} });
field_rf_amp.on_change = [this](int32_t v) {
this->on_rf_amp_changed(v);
};
}
void RadioGainOptionsView::set_rf_amp(int32_t v_db) {
field_rf_amp.set_value(v_db);
}
void RadioGainOptionsView::on_rf_amp_changed(bool enable) {
if( on_change_rf_amp ) {
on_change_rf_amp(enable);
}
}
/* LNAGainField **********************************************************/

View File

@ -281,29 +281,24 @@ private:
};
};
class RFAmpField : public NumberField {
public:
RFAmpField(Point parent_pos);
};
class RadioGainOptionsView : public View {
public:
std::function<void(bool)> on_change_rf_amp;
RadioGainOptionsView(const Rect parent_rect, const Style* const style);
void set_rf_amp(int32_t v_db);
private:
Text label_rf_amp {
{ 0 * 8, 0 * 16, 3 * 8, 1 * 16 },
"Amp"
};
NumberField field_rf_amp {
RFAmpField field_rf_amp {
{ 4 * 8, 0 * 16},
1,
{ 0, 1 },
1,
' ',
};
void on_rf_amp_changed(bool enable);
};
class LNAGainField : public NumberField {