Files
MeowOS-For-R3P2/patch_v2/sdk/meow_ui_sys.h
T

60 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* meow_ui_sys.h — SDK 内置系统状态读取器 + 全局状态栏(A-0 核心)。
*
* 供 meow_ui 内部各 TU 协作(绘制后端 present() 前置覆盖 + 输入层事件循环 1s 轻刷)。
* 不随 meow_ui.h 发布给应用。应用侧只通过公共 API 控制显隐/全屏:
* meow_ui_set_statusbar() / meow_ui_statusbar_visible() /
* meow_ui_set_fullscreen() / meow_ui_statusbar_height()。
*
* 数据源与 launcher 的 meow_sys 同源单点一致:
* - 电量 /sys/class/power_supply/battery/{capacity,status}
* - WiFi /sys/class/net/wlan0/operstate
* - 蓝牙 实际 powered(hciconfig -a hci0 的 UP;spawn 贵 → 缓存 30s 刷一次)
* - 音量 /usr/data/meow/settings.conf 的 audio.volume(launcher 同文件;
* 0-100 并 clamp 到 audio.volume_max 上限,与 launcher vol_clamp 口径一致)
* - 时钟 localtime_r(每秒在绘制时现取)
*/
#ifndef MEOW_UI_SYS_H
#define MEOW_UI_SYS_H
#include "meow_ui.h"
/* 系统快照(状态栏数据源)。时钟不走这里——绘制时现取 localtime。 */
typedef struct meow_sys_state {
int batt; /* 电量 %;-1=未知 */
int charging; /* 1=充电/满 */
int wifi_on; /* operstate==up */
int bt_seen; /* hci0 节点存在 */
int bt_on; /* 实际上电(hciconfig UP) */
int vol; /* 音量 0-100 */
} meow_sys_state;
/* 顶部状态栏几何(与 launcher SB_BAR_H=28 / SB_FONT=20 对齐,视觉统一)。
* 高度 40→28(用户定),字号 28→20(28px 栏放不下 28 号;20 号按 (高-行高)/2 垂直居中)。 */
#define MUI_SBAR_H 28
#define MUI_SBAR_FONT 20
/* 首次全量读取;失败仍返回 0(字段置 -1/0)。 */
int meow_ui_sys_init(void);
/* 1s 轻刷:电量/WiFi/音量(便宜);蓝牙 30s 缓存刷新。 */
void meow_ui_sys_refresh(void);
/* 当前快照(内部只读)。 */
const meow_sys_state *meow_ui_sys_get(void);
/* 状态栏是否应绘制(= set_statusbar(1) 且 非 fullscreen)。 */
int meow_ui_sys_statusbar_active(void);
/* 状态栏高度(px):active 时 28,否则 0(供 meow_ui_statusbar_height 用)。 */
int meow_ui_sys_statusbar_height(void);
/* 自上次渲染后状态栏数据是否已变(1s 轻刷/显隐切换置位);读取即清除。
* 渲染后端 present() 用它决定是否重画顶部条(配合脏区/整帧判断)。 */
int meow_ui_sys_statusbar_force(void);
/* 把状态栏画进 back_buf(顶部 MUI_SBAR_H 行)+ 标脏。调用方负责随后上屏。 */
void meow_ui_sys_statusbar_render(void);
#endif /* MEOW_UI_SYS_H */