TPMS: Allow band selection: 315 or 433.92 (~434) MHz.

This commit is contained in:
Jared Boone 2016-06-21 15:36:57 -07:00
parent b34512e3d6
commit 3cdce88e5d
2 changed files with 31 additions and 1 deletions

View File

@ -167,6 +167,7 @@ TPMSAppView::TPMSAppView(NavigationView&) {
add_children({ {
&rssi,
&channel,
&options_band,
&field_rf_amp,
&field_lna,
&field_vga,
@ -190,6 +191,11 @@ TPMSAppView::TPMSAppView(NavigationView&) {
.decimation_factor = 1,
});
options_band.on_change = [this](size_t, OptionsField::value_t v) {
this->on_band_changed(v);
};
options_band.set_by_value(target_frequency());
logger = std::make_unique<TPMSLogger>();
if( logger ) {
logger->append("tpms.txt");
@ -228,8 +234,17 @@ void TPMSAppView::on_show_list() {
recent_entries_view.focus();
}
void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) {
set_target_frequency(new_band_frequency);
}
void TPMSAppView::set_target_frequency(const uint32_t new_value) {
target_frequency_ = new_value;
radio::set_tuning_frequency(tuning_frequency());
}
uint32_t TPMSAppView::target_frequency() const {
return initial_target_frequency;
return target_frequency_;
}
uint32_t TPMSAppView::tuning_frequency() const {

View File

@ -129,6 +129,15 @@ private:
{ 21 * 8, 5, 6 * 8, 4 },
};
OptionsField options_band {
{ 0 * 8, 0 * 16 },
3,
{
{ "315", 315000000 },
{ "434", 433920000 },
}
};
RFAmpField field_rf_amp {
{ 13 * 8, 0 * 16 }
};
@ -146,10 +155,16 @@ private:
TPMSRecentEntriesView recent_entries_view { recent };
uint32_t target_frequency_ = initial_target_frequency;
void on_packet(const tpms::Packet& packet);
void on_show_list();
void on_band_changed(const uint32_t new_band_frequency);
uint32_t target_frequency() const;
void set_target_frequency(const uint32_t new_value);
uint32_t tuning_frequency() const;
};