Files
trail-mate/modules/ui_shared/src/ui/loop_shell.cpp
T
vicliuandGitHub d320b6511d Unify PlatformIO and ESP-IDF around a shared UI/runtime shellRefactor/repo structure (#11)
* Unify PlatformIO and ESP-IDF around a shared UI/runtime shell
2026-03-12 01:17:46 +08:00

49 lines
894 B
C++

#include "ui/loop_shell.h"
namespace ui::loop_shell
{
void tick(const Hooks& hooks)
{
const uint32_t now_ms = hooks.now_ms ? hooks.now_ms() : 0;
if (hooks.is_overlay_active && hooks.is_overlay_active())
{
if (hooks.display_tick_if_due)
{
hooks.display_tick_if_due(now_ms);
}
if (hooks.yield_now)
{
hooks.yield_now();
}
if (hooks.sleep_ms)
{
hooks.sleep_ms(hooks.overlay_sleep_ms);
}
return;
}
if (hooks.handle_power_button)
{
hooks.handle_power_button();
}
if (hooks.update_runtime)
{
hooks.update_runtime();
}
if (hooks.display_tick_if_due)
{
hooks.display_tick_if_due(now_ms);
}
if (hooks.sleep_ms)
{
hooks.sleep_ms(hooks.idle_sleep_ms);
}
}
} // namespace ui::loop_shell