WIP updating header

This commit is contained in:
jLynx 2022-03-24 19:08:07 +13:00
parent 2030118d9f
commit 32f957cead
2 changed files with 36 additions and 5 deletions

View File

@ -149,9 +149,15 @@ TPMSAppView::TPMSAppView(NavigationView&) {
&field_lna, &field_lna,
&field_vga, &field_vga,
&options_type, &options_type,
&recent_entries_view, // &recent_entries_view,
// &recent_entries_view_psi,
}); });
// remove_children({
// &recent_entries_view,
// // &recent_entries_view_psi,
// });
radio::enable({ radio::enable({
tuning_frequency(), tuning_frequency(),
sampling_rate, sampling_rate,
@ -170,9 +176,13 @@ TPMSAppView::TPMSAppView(NavigationView&) {
options_type.on_change = [this](size_t, int32_t i) { options_type.on_change = [this](size_t, int32_t i) {
if (i == 0){ if (i == 0){
tpms::format::use_kpa = true; tpms::format::use_kpa = true;
remove_child(&recent_entries_view_psi);
add_child(&recent_entries_view);
} }
if(i == 1){ if(i == 1){
tpms::format::use_kpa = false; tpms::format::use_kpa = false;
remove_child(&recent_entries_view);
add_child(&recent_entries_view_psi);
} }
}; };
@ -197,6 +207,7 @@ void TPMSAppView::focus() {
void TPMSAppView::set_parent_rect(const Rect new_parent_rect) { void TPMSAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect); View::set_parent_rect(new_parent_rect);
recent_entries_view.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height }); recent_entries_view.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height });
recent_entries_view_psi.set_parent_rect({ 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height });
} }
void TPMSAppView::on_packet(const tpms::Packet& packet) { void TPMSAppView::on_packet(const tpms::Packet& packet) {
@ -209,13 +220,23 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) {
const auto reading = reading_opt.value(); const auto reading = reading_opt.value();
auto& entry = ::on_packet(recent, TPMSRecentEntry::Key { reading.type(), reading.id() }); auto& entry = ::on_packet(recent, TPMSRecentEntry::Key { reading.type(), reading.id() });
entry.update(reading); entry.update(reading);
if(tpms::format::use_kpa){
recent_entries_view.set_dirty(); recent_entries_view.set_dirty();
} else {
recent_entries_view_psi.set_dirty();
}
} }
} }
void TPMSAppView::on_show_list() { void TPMSAppView::on_show_list() {
if(tpms::format::use_kpa){
recent_entries_view.hidden(false); recent_entries_view.hidden(false);
recent_entries_view.focus(); recent_entries_view.focus();
} else {
recent_entries_view_psi.hidden(false);
recent_entries_view_psi.focus();
}
} }
void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) { void TPMSAppView::on_band_changed(const uint32_t new_band_frequency) {

View File

@ -172,6 +172,16 @@ private:
} }; } };
TPMSRecentEntriesView recent_entries_view { columns, recent }; TPMSRecentEntriesView recent_entries_view { columns, recent };
const RecentEntriesColumns columns_psi { {
{ "Tp", 2 },
{ "ID", 8 },
{ "PSI", 3 },
{ "C", 3 },
{ "Cnt", 3 },
{ "Fl", 2 },
} };
TPMSRecentEntriesView recent_entries_view_psi { columns_psi, recent };
uint32_t target_frequency_ = initial_target_frequency; uint32_t target_frequency_ = initial_target_frequency;
void on_packet(const tpms::Packet& packet); void on_packet(const tpms::Packet& packet);