mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 14:59:24 -05:00
Add frequency correction (WIP).
This commit is contained in:
parent
0ed607b6dd
commit
9dd41ed48d
@ -117,7 +117,8 @@ void set_direction(const rf::Direction new_direction) {
|
||||
}
|
||||
|
||||
bool set_tuning_frequency(const rf::Frequency frequency) {
|
||||
const auto tuning_config = tuning::config::create(frequency);
|
||||
rf::Frequency corrected_frequency = frequency * (1000000 - 10) / 1000000;
|
||||
const auto tuning_config = tuning::config::create(corrected_frequency);
|
||||
if( tuning_config.is_valid() ) {
|
||||
first_if.disable();
|
||||
|
||||
|
@ -98,6 +98,47 @@ SetDateTimeModel SetDateTimeView::form_collect() {
|
||||
};
|
||||
}
|
||||
|
||||
SetFrequencyCorrectionView::SetFrequencyCorrectionView(
|
||||
NavigationView& nav
|
||||
) {
|
||||
button_ok.on_select = [&nav, this](Button&){
|
||||
const auto model = this->form_collect();
|
||||
nav.pop();
|
||||
},
|
||||
|
||||
button_cancel.on_select = [&nav](Button&){
|
||||
nav.pop();
|
||||
},
|
||||
|
||||
add_children({ {
|
||||
&text_title,
|
||||
&field_ppm,
|
||||
&text_ppm,
|
||||
&button_ok,
|
||||
&button_cancel,
|
||||
} });
|
||||
|
||||
SetFrequencyCorrectionModel model {
|
||||
0
|
||||
};
|
||||
|
||||
form_init(model);
|
||||
}
|
||||
|
||||
void SetFrequencyCorrectionView::focus() {
|
||||
button_cancel.focus();
|
||||
}
|
||||
|
||||
void SetFrequencyCorrectionView::form_init(const SetFrequencyCorrectionModel model) {
|
||||
field_ppm.set_value(model.ppm);
|
||||
}
|
||||
|
||||
SetFrequencyCorrectionModel SetFrequencyCorrectionView::form_collect() {
|
||||
return {
|
||||
.ppm = static_cast<int8_t>(field_ppm.value()),
|
||||
};
|
||||
}
|
||||
|
||||
AboutView::AboutView(NavigationView& nav) {
|
||||
add_children({ {
|
||||
&text_title,
|
||||
@ -115,8 +156,9 @@ void AboutView::focus() {
|
||||
}
|
||||
|
||||
SetupMenuView::SetupMenuView(NavigationView& nav) {
|
||||
add_items<2>({ {
|
||||
add_items<3>({ {
|
||||
{ "Date/Time", [&nav](){ nav.push(new SetDateTimeView { nav }); } },
|
||||
{ "Frequency Correction", [&nav](){ nav.push(new SetFrequencyCorrectionView { nav }); } },
|
||||
{ "Touch", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
} });
|
||||
on_left = [&nav](){ nav.pop(); };
|
||||
|
@ -132,6 +132,50 @@ private:
|
||||
SetDateTimeModel form_collect();
|
||||
};
|
||||
|
||||
struct SetFrequencyCorrectionModel {
|
||||
int8_t ppm;
|
||||
};
|
||||
|
||||
class SetFrequencyCorrectionView : public View {
|
||||
public:
|
||||
std::function<void(SetFrequencyCorrectionModel)> on_ok;
|
||||
std::function<void()> on_cancel;
|
||||
|
||||
SetFrequencyCorrectionView(NavigationView& nav);
|
||||
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
Text text_title {
|
||||
{ 5 * 8, 7 * 16, 20 * 8, 16 },
|
||||
"Frequency Correction"
|
||||
};
|
||||
|
||||
NumberField field_ppm {
|
||||
{ 11 * 8, 9 * 16 },
|
||||
3,
|
||||
{ -50, 50 },
|
||||
1,
|
||||
'0',
|
||||
};
|
||||
Text text_ppm {
|
||||
{ 15 * 8, 9 * 16, 3 * 8, 16 },
|
||||
"PPM",
|
||||
};
|
||||
|
||||
Button button_ok {
|
||||
{ 4 * 8, 13 * 16, 8 * 8, 24 },
|
||||
"OK",
|
||||
};
|
||||
Button button_cancel {
|
||||
{ 18 * 8, 13 * 16, 8 * 8, 24 },
|
||||
"Cancel",
|
||||
};
|
||||
|
||||
void form_init(const SetFrequencyCorrectionModel model);
|
||||
SetFrequencyCorrectionModel form_collect();
|
||||
};
|
||||
|
||||
class AboutView : public View {
|
||||
public:
|
||||
AboutView(NavigationView& nav);
|
||||
|
Loading…
Reference in New Issue
Block a user