UI plumbing for PPM adjust in receiver frequency options.

This commit is contained in:
Jared Boone 2015-07-29 16:09:00 -07:00
parent 9db54276c1
commit 67976b73ba
2 changed files with 25 additions and 2 deletions

View File

@ -292,6 +292,10 @@ FrequencyOptionsView::FrequencyOptionsView(
this->on_step_changed(v);
};
field_ppm.on_change = [this](int32_t v) {
this->on_reference_ppm_correction_changed(v);
};
add_children({ {
&text_step,
&options_step,
@ -299,14 +303,15 @@ FrequencyOptionsView::FrequencyOptionsView(
&field_ppm,
&text_ppm,
} });
field_ppm.set_value(0);
}
void FrequencyOptionsView::set_step(rf::Frequency f) {
options_step.set_by_value(f);
}
void FrequencyOptionsView::set_reference_ppm_correction(int32_t v) {
field_ppm.set_value(v);
}
void FrequencyOptionsView::on_step_changed(rf::Frequency v) {
if( on_change_step ) {
@ -314,6 +319,12 @@ void FrequencyOptionsView::on_step_changed(rf::Frequency v) {
}
}
void FrequencyOptionsView::on_reference_ppm_correction_changed(int32_t v) {
if( on_change_reference_ppm_correction ) {
on_change_reference_ppm_correction(v);
}
}
/* RadioGainOptionsView **************************************************/
RadioGainOptionsView::RadioGainOptionsView(
@ -468,6 +479,10 @@ ReceiverView::ReceiverView(
view_frequency_options.on_change_step = [this](rf::Frequency f) {
this->on_frequency_step_changed(f);
};
view_frequency_options.set_reference_ppm_correction(receiver_model.reference_ppm_correction());
view_frequency_options.on_change_reference_ppm_correction = [this](int32_t v) {
this->on_reference_ppm_correction_changed(v);
};
view_rf_gain_options.hidden(true);
view_rf_gain_options.set_rf_amp(receiver_model.rf_amp());
@ -550,6 +565,10 @@ void ReceiverView::on_frequency_step_changed(rf::Frequency f) {
field_frequency.set_step(f);
}
void ReceiverView::on_reference_ppm_correction_changed(int32_t v) {
receiver_model.set_reference_ppm_correction(v);
}
void ReceiverView::on_headphone_volume_changed(int32_t v) {
const auto new_volume = volume_t::decibel(v - 99) + wolfson::wm8731::headphone_gain_range.max;
receiver_model.set_headphone_volume(new_volume);

View File

@ -256,10 +256,12 @@ private:
class FrequencyOptionsView : public View {
public:
std::function<void(rf::Frequency)> on_change_step;
std::function<void(int32_t)> on_change_reference_ppm_correction;
FrequencyOptionsView(const Rect parent_rect, const Style* const style);
void set_step(rf::Frequency f);
void set_reference_ppm_correction(int32_t v);
private:
Text text_step {
@ -283,6 +285,7 @@ private:
};
void on_step_changed(rf::Frequency v);
void on_reference_ppm_correction_changed(int32_t v);
Text text_correction {
{ 17 * 8, 0 * 16, 5 * 8, 16 },
@ -451,6 +454,7 @@ private:
void on_show_options_frequency();
void on_show_options_rf_gain();
void on_frequency_step_changed(rf::Frequency f);
void on_reference_ppm_correction_changed(int32_t v);
void on_headphone_volume_changed(int32_t v);
// void on_baseband_oversampling_changed(int32_t v);
void on_edit_frequency();