mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 11:44:31 +00:00
Cleaned up and tweaked
This commit is contained in:
parent
9c9021f63b
commit
b300cc258e
@ -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<ui::Dim>(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<ui::Dim>(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() {
|
||||
|
@ -211,16 +211,12 @@ 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 {
|
||||
@ -233,31 +229,8 @@ private:
|
||||
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();
|
||||
}
|
||||
{176, 0, 8 * 8, 16}
|
||||
};
|
||||
};
|
||||
|
||||
@ -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 { };
|
||||
|
@ -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(
|
||||
|
@ -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 *****************************************************************/
|
||||
|
||||
|
@ -244,6 +244,9 @@ public:
|
||||
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user