From bf2a04ab572d8c978dcf2e49f29b8021bd38bc1e Mon Sep 17 00:00:00 2001 From: klockee Date: Mon, 3 Aug 2020 05:48:26 -0400 Subject: [PATCH 1/4] Fix title in splash screen --- firmware/application/ui_navigation.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 32fdafcc4..b8ada3ba7 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -557,6 +557,9 @@ SystemView::SystemView( if (portapack::persistent_memory::config_splash()) navigation_view.push(); + status_view.set_back_enabled(false); + status_view.set_title_image_enabled(true); + this->status_view.set_dirty(); //else // navigation_view.push(); From 9c9021f63b2d47973be6341e44bfa393cc295631 Mon Sep 17 00:00:00 2001 From: klockee Date: Wed, 5 Aug 2020 01:03:51 -0400 Subject: [PATCH 2/4] Added new toolbar in main menu --- firmware/application/ui/ui_btngrid.cpp | 9 +++ firmware/application/ui/ui_btngrid.hpp | 1 + firmware/application/ui_navigation.cpp | 82 ++++++++++++++++++++++++-- firmware/application/ui_navigation.hpp | 58 +++++++++++++++++- firmware/common/message.hpp | 9 +++ firmware/common/ui_widget.cpp | 10 ++++ firmware/common/ui_widget.hpp | 10 ++++ 7 files changed, 174 insertions(+), 5 deletions(-) diff --git a/firmware/application/ui/ui_btngrid.cpp b/firmware/application/ui/ui_btngrid.cpp index 0c756af4e..2ad7907eb 100644 --- a/firmware/application/ui/ui_btngrid.cpp +++ b/firmware/application/ui/ui_btngrid.cpp @@ -95,6 +95,15 @@ void BtnGridView::set_parent_rect(const Rect new_parent_rect) { update_items(); } +void BtnGridView::set_arrow_enabled(bool new_value) { + if(new_value){ + add_child(&arrow_more); + } + else{ + remove_child(&arrow_more); + } +}; + void BtnGridView::on_tick_second() { if (more && blink) arrow_more.set_foreground(Color::white()); diff --git a/firmware/application/ui/ui_btngrid.hpp b/firmware/application/ui/ui_btngrid.hpp index 1ce14ccac..5f922f78b 100644 --- a/firmware/application/ui/ui_btngrid.hpp +++ b/firmware/application/ui/ui_btngrid.hpp @@ -62,6 +62,7 @@ public: uint32_t highlighted_index(); void set_parent_rect(const Rect new_parent_rect) override; + void set_arrow_enabled(bool new_value); void on_focus() override; void on_blur() override; bool on_key(const KeyEvent event) override; diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index b8ada3ba7..bd2dfce1f 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -306,6 +306,56 @@ void SystemStatusView::on_title() { nav_.push(); } +/* Information View *****************************************************/ + +InformationView::InformationView( + NavigationView& nav +) : nav_ (nav) +{ + static constexpr Style style_infobar { + .font = font::fixed_8x16, + .background = {33, 33, 33}, + .foreground = Color::white(), + }; + + add_children({ + &backdrop, + &version, + &test, + &time + }); + + test.on_select = [this](ImageButton&){ + update_time(); + }; + + this->set_focusable(true); + this->set_visible(true); + time.set_focusable(true); + version.set_style(&style_infobar); + + time.on_select = [this](Button&) { + this->on_time(); + }; + + refresh(); +} + +void InformationView::refresh() { + update_time(); + set_dirty(); +} + +void InformationView::on_time(){ + update_time(); +} + +void InformationView::update_time() { + rtcGetTime(&RTCD1, &datetime); + time.set_text(to_string_datetime(datetime)); + set_dirty(); +} + /* Navigation ************************************************************/ bool NavigationView::is_top() const { @@ -502,6 +552,7 @@ SystemMenuView::SystemMenuView(NavigationView& nav) { //{ "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push(); } } }); set_max_rows(2); // allow wider buttons + set_arrow_enabled(false); //set_highlighted(1); // Startup selection } @@ -522,6 +573,7 @@ SystemView::SystemView( set_style(&style_default); constexpr ui::Dim status_view_height = 16; + constexpr ui::Dim info_view_height = 16; add_child(&status_view); status_view.set_parent_rect({ @@ -532,18 +584,36 @@ SystemView::SystemView( this->navigation_view.pop(); }; + add_child(&info_view); + info_view.set_parent_rect({ + {0, 19 * 16}, + { parent_rect.width(), info_view_height } + }); + add_child(&navigation_view); navigation_view.set_parent_rect({ { 0, status_view_height }, - { parent_rect.width(), static_cast(parent_rect.height() - status_view_height) } + { parent_rect.width(), static_cast(parent_rect.height() - status_view_height - info_view_height) } }); navigation_view.on_view_changed = [this](const View& new_view) { + + if(!this->navigation_view.is_top()){ + remove_child(&info_view); + } + else{ + add_child(&info_view); + this->info_view.update_time(); + } + this->status_view.set_back_enabled(!this->navigation_view.is_top()); this->status_view.set_title_image_enabled(this->navigation_view.is_top()); - this->status_view.set_dirty(); this->status_view.set_title(new_view.title()); + this->status_view.set_dirty(); + + + //this->info_view.focus(); }; - + // portapack::persistent_memory::set_playdead_sequence(0x8D1); @@ -559,7 +629,7 @@ SystemView::SystemView( navigation_view.push(); status_view.set_back_enabled(false); status_view.set_title_image_enabled(true); - this->status_view.set_dirty(); + status_view.set_dirty(); //else // navigation_view.push(); @@ -570,6 +640,10 @@ Context& SystemView::context() const { return context_; } +void SystemView::on_tick_second() { + this->info_view.update_time(); +} + /* ***********************************************************************/ void BMPView::focus() { diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index 8754d35d9..d2f162817 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -110,7 +110,7 @@ public: void set_title(const std::string new_value); private: - static constexpr auto default_title = " v1.1.1"; // TODO: Move the version somewhere + static constexpr auto default_title = ""; NavigationView& nav_; @@ -208,6 +208,59 @@ private: }; }; +class InformationView : public View { +public: + InformationView(NavigationView& nav); + void update_time(); + + +private: + void refresh(); + static constexpr auto version_string = "v1.1.1"; + NavigationView& nav_; + + void on_time(); + + rtc::RTC datetime; + + Rectangle backdrop { + { 0, 0 * 16, 240, 16 }, + {33, 33, 33} + }; + + Text version { + {0, 0, 11 * 8, 16}, + version_string + }; + + ImageButton test { + {80, 0, 16, 16}, + &bitmap_icon_camera, + Color::white(), + Color::dark_grey() + }; + + Button time { + {120, 0, 11 * 8, 16}, + "" + }; +/* + LiveDateTime ltime { + {120, 0, 11 * 8, 16} + }; +*/ + + + + MessageHandlerRegistration message_handler_refresh { + Message::ID::InfoRefresh, + [this](const Message* const p) { + (void)p; + this->refresh(); + } + }; +}; + class BMPView : public View { public: BMPView(NavigationView& nav); @@ -261,7 +314,10 @@ public: Context& context() const override; private: + void on_tick_second(); + SystemStatusView status_view { navigation_view }; + InformationView info_view { navigation_view }; NavigationView navigation_view { }; Context& context_; }; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index eeecc9d09..12d0c0683 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -111,6 +111,7 @@ public: AudioLevelReport = 51, CodedSquelch = 52, AudioSpectrum = 53, + InfoRefresh = 54, MAX }; @@ -234,6 +235,14 @@ public: } }; +class InfoRefreshMessage : public Message { +public: + constexpr InfoRefreshMessage( + ) : Message { ID::InfoRefresh } + { + } +}; + class AudioStatisticsMessage : public Message { public: constexpr AudioStatisticsMessage( diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 01639e0c5..857221ca2 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -1046,6 +1046,16 @@ bool NewButton::on_touch(const TouchEvent event) { return false; } } +/* DateTimeButton ********************************************************/ + +DateTimeButton::DateTimeButton( + Rect parent_rect, + std::string text +) : Button { parent_rect , text_} +{ + set_focusable(true); +} + /* Image *****************************************************************/ diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 61ffeb725..71621e824 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -428,6 +428,16 @@ private: const Bitmap* bitmap_; }; +class DateTimeButton : public Button { +public: + DateTimeButton(Rect parent_rect, std::string text); + void paint(Painter& painter) override; +private: + std::string text_; + void on_tick_second(); + +}; + class Image : public Widget { public: Image(); From b300cc258e317f19168b407c7bd835bc46c49acc Mon Sep 17 00:00:00 2001 From: klockee Date: Sat, 8 Aug 2020 04:24:57 -0400 Subject: [PATCH 3/4] Cleaned up and tweaked --- firmware/application/ui_navigation.cpp | 51 ++++++-------------------- firmware/application/ui_navigation.hpp | 35 ++---------------- firmware/common/message.hpp | 9 ----- firmware/common/ui_widget.cpp | 29 +++++++++------ firmware/common/ui_widget.hpp | 18 ++++----- 5 files changed, 38 insertions(+), 104 deletions(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index bd2dfce1f..d3f403be8 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -321,38 +321,14 @@ InformationView::InformationView( add_children({ &backdrop, &version, - &test, - &time + <ime }); - test.on_select = [this](ImageButton&){ - update_time(); - }; - - this->set_focusable(true); - this->set_visible(true); - time.set_focusable(true); version.set_style(&style_infobar); + ltime.set_style(&style_infobar); + ltime.set_seconds_enabled(true); + ltime.set_date_enabled(false); - time.on_select = [this](Button&) { - this->on_time(); - }; - - refresh(); -} - -void InformationView::refresh() { - update_time(); - set_dirty(); -} - -void InformationView::on_time(){ - update_time(); -} - -void InformationView::update_time() { - rtcGetTime(&RTCD1, &datetime); - time.set_text(to_string_datetime(datetime)); set_dirty(); } @@ -584,17 +560,18 @@ SystemView::SystemView( this->navigation_view.pop(); }; + add_child(&navigation_view); + navigation_view.set_parent_rect({ + { 0, status_view_height }, + { parent_rect.width(), static_cast(parent_rect.height() - status_view_height) } + }); + add_child(&info_view); info_view.set_parent_rect({ {0, 19 * 16}, { parent_rect.width(), info_view_height } }); - add_child(&navigation_view); - navigation_view.set_parent_rect({ - { 0, status_view_height }, - { parent_rect.width(), static_cast(parent_rect.height() - status_view_height - info_view_height) } - }); navigation_view.on_view_changed = [this](const View& new_view) { if(!this->navigation_view.is_top()){ @@ -602,7 +579,7 @@ SystemView::SystemView( } else{ add_child(&info_view); - this->info_view.update_time(); + //this->info_view.set_dirty(); } this->status_view.set_back_enabled(!this->navigation_view.is_top()); @@ -610,8 +587,6 @@ SystemView::SystemView( this->status_view.set_title(new_view.title()); this->status_view.set_dirty(); - - //this->info_view.focus(); }; @@ -640,10 +615,6 @@ Context& SystemView::context() const { return context_; } -void SystemView::on_tick_second() { - this->info_view.update_time(); -} - /* ***********************************************************************/ void BMPView::focus() { diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index d2f162817..0f1da9b3d 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -211,54 +211,27 @@ private: class InformationView : public View { public: InformationView(NavigationView& nav); - void update_time(); - private: void refresh(); static constexpr auto version_string = "v1.1.1"; NavigationView& nav_; - void on_time(); - rtc::RTC datetime; Rectangle backdrop { - { 0, 0 * 16, 240, 16 }, - {33, 33, 33} + { 0, 0 * 16, 240, 16 }, + {33, 33, 33} }; Text version { {0, 0, 11 * 8, 16}, version_string }; - - ImageButton test { - {80, 0, 16, 16}, - &bitmap_icon_camera, - Color::white(), - Color::dark_grey() - }; - Button time { - {120, 0, 11 * 8, 16}, - "" - }; -/* LiveDateTime ltime { - {120, 0, 11 * 8, 16} + {176, 0, 8 * 8, 16} }; -*/ - - - - MessageHandlerRegistration message_handler_refresh { - Message::ID::InfoRefresh, - [this](const Message* const p) { - (void)p; - this->refresh(); - } - }; }; class BMPView : public View { @@ -314,8 +287,6 @@ public: Context& context() const override; private: - void on_tick_second(); - SystemStatusView status_view { navigation_view }; InformationView info_view { navigation_view }; NavigationView navigation_view { }; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 12d0c0683..eeecc9d09 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -111,7 +111,6 @@ public: AudioLevelReport = 51, CodedSquelch = 52, AudioSpectrum = 53, - InfoRefresh = 54, MAX }; @@ -235,14 +234,6 @@ public: } }; -class InfoRefreshMessage : public Message { -public: - constexpr InfoRefreshMessage( - ) : Message { ID::InfoRefresh } - { - } -}; - class AudioStatisticsMessage : public Message { public: constexpr AudioStatisticsMessage( diff --git a/firmware/common/ui_widget.cpp b/firmware/common/ui_widget.cpp index 857221ca2..1372410d3 100644 --- a/firmware/common/ui_widget.cpp +++ b/firmware/common/ui_widget.cpp @@ -409,10 +409,17 @@ void Labels::paint(Painter& painter) { void LiveDateTime::on_tick_second() { rtcGetTime(&RTCD1, &datetime); + text = ""; - text = to_string_dec_uint(datetime.month(), 2, '0') + "/" + to_string_dec_uint(datetime.day(), 2, '0') + " " + - to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0'); + if(date_enabled){ + text = to_string_dec_uint(datetime.month(), 2, '0') + "/" + to_string_dec_uint(datetime.day(), 2, '0') + " "; + } + text = text + to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0'); + + if(seconds_enabled){ + text = text + ":" + to_string_dec_uint(datetime.second(), 2, '0'); + } set_dirty(); } @@ -444,6 +451,14 @@ void LiveDateTime::paint(Painter& painter) { ); } +void LiveDateTime::set_date_enabled(bool new_value){ + this->date_enabled = new_value; +} + +void LiveDateTime::set_seconds_enabled(bool new_value) { + this->seconds_enabled = new_value; +} + /* BigFrequency **********************************************************/ BigFrequency::BigFrequency( @@ -1046,16 +1061,6 @@ bool NewButton::on_touch(const TouchEvent event) { return false; } } -/* DateTimeButton ********************************************************/ - -DateTimeButton::DateTimeButton( - Rect parent_rect, - std::string text -) : Button { parent_rect , text_} -{ - set_focusable(true); -} - /* Image *****************************************************************/ diff --git a/firmware/common/ui_widget.hpp b/firmware/common/ui_widget.hpp index 71621e824..5b592c486 100644 --- a/firmware/common/ui_widget.hpp +++ b/firmware/common/ui_widget.hpp @@ -243,7 +243,10 @@ public: ~LiveDateTime(); void paint(Painter& painter) override; - + + void set_seconds_enabled(bool new_value); + void set_date_enabled(bool new_value); + std::string& string() { return text; } @@ -251,6 +254,9 @@ public: private: void on_tick_second(); + bool date_enabled = true; + bool seconds_enabled = false; + rtc::RTC datetime { }; SignalToken signal_token_tick_second { }; std::string text { }; @@ -428,16 +434,6 @@ private: const Bitmap* bitmap_; }; -class DateTimeButton : public Button { -public: - DateTimeButton(Rect parent_rect, std::string text); - void paint(Painter& painter) override; -private: - std::string text_; - void on_tick_second(); - -}; - class Image : public Widget { public: Image(); From 90d2dbb49ce32c1359f1a39e894c4fa09b8da972 Mon Sep 17 00:00:00 2001 From: klockee Date: Sat, 8 Aug 2020 04:48:29 -0400 Subject: [PATCH 4/4] More cleanup --- firmware/application/ui_navigation.cpp | 1 - firmware/application/ui_navigation.hpp | 3 --- 2 files changed, 4 deletions(-) diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index d3f403be8..42b2fdb3d 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -579,7 +579,6 @@ SystemView::SystemView( } else{ add_child(&info_view); - //this->info_view.set_dirty(); } this->status_view.set_back_enabled(!this->navigation_view.is_top()); diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index 0f1da9b3d..e626c1154 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -213,12 +213,9 @@ public: InformationView(NavigationView& nav); private: - void refresh(); static constexpr auto version_string = "v1.1.1"; NavigationView& nav_; - rtc::RTC datetime; - Rectangle backdrop { { 0, 0 * 16, 240, 16 }, {33, 33, 33}