knob_os/src/ui/Splash.h

45 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
// Splash.h —— 启动动画
//
// 为什么单独做一层:开机时各模块初始化是阻塞的,如果直接往下跑,
// 屏幕会停在第一帧直到全部完成,看起来像"死机"。
// 这里把初始化拆成若干步,每步之间主动泵几帧 LVGL,进度环走的是真实进度,
// 既好看又能在启动卡住时一眼看出卡在哪一步。
#include <lvgl.h>
namespace ui {
class Splash {
public:
void build();
// pct: 0~100 真实进度;text: 当前步骤;settleMs: 本步停留时长(泵帧用)
void step(int pct, const char* text, uint32_t settleMs = 0);
// 收尾:环扩散 + 整体淡出,然后自毁
void finish();
// 手动泵帧(初始化阶段调用,替代 delay)
static void pump(uint32_t ms);
// ---- 仅调试用 ----
// 开机动画只在启动那几秒存在,串口命令赶不上。这两个接口让它能重播并停在
// 中途,方便截图检查(见 services/RemoteDebug.cpp 的 v / x 命令)。
void replay();
void dismiss();
private:
void applyPct(int pct, bool animate);
lv_obj_t* _root = nullptr;
lv_obj_t* _arc = nullptr;
lv_obj_t* _dot = nullptr;
lv_obj_t* _name = nullptr;
lv_obj_t* _step = nullptr;
int _pct = 0;
};
extern Splash splash;
} // namespace ui