mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-10-22 21:22:14 +00:00
feat(cardputerzero): adapt Cardputer Zero
This commit is contained in:
1 parent
9862b6c1c3
commit
71c443910e
169 files changed
+10392
-1273
No files matched your search
@@ -1,20 +1,61 @@
|
||||
#include "ui/ui_common.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
|
||||
#include "platform/ui/time_runtime.h"
|
||||
#include "ui/widgets/top_bar.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void noop_top_bar_battery_update()
|
||||
bool resolve_display_time(std::tm& out)
|
||||
{
|
||||
if (::platform::ui::time::localtime_now(&out))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::time_t now = std::time(nullptr);
|
||||
if (now <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::time_t local = ::platform::ui::time::apply_timezone_offset(now);
|
||||
const std::tm* tmp = std::gmtime(&local);
|
||||
if (!tmp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
out = *tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
void format_top_bar_time(char* out, std::size_t out_len)
|
||||
{
|
||||
if (!out || out_len == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::tm info{};
|
||||
if (!resolve_display_time(info) ||
|
||||
std::strftime(out, out_len, "%H:%M", &info) == 0)
|
||||
{
|
||||
std::snprintf(out, out_len, "--:--");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void ui_update_top_bar_battery(ui::widgets::TopBar& bar)
|
||||
{
|
||||
(void)bar;
|
||||
noop_top_bar_battery_update();
|
||||
char time_buf[16] = "--:--";
|
||||
|
||||
format_top_bar_time(time_buf, sizeof(time_buf));
|
||||
ui::widgets::top_bar_set_right_text_ascii(bar, time_buf);
|
||||
}
|
||||
|
||||
int ui_get_timezone_offset_min()
|
||||
|
||||
Reference in new issue
Block a user