Files
MeowOS 4f66da66ad Add 'examples/hello/' from commit 'e88e5a6ff3b0f55671cb64c0a506e552360010e9'
git-subtree-dir: examples/hello
git-subtree-mainline: f44e3bc6d0
git-subtree-split: e88e5a6ff3
2026-09-01 21:08:44 +08:00

34 lines
1.9 KiB
C
Raw Permalink 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.
/* logic/logic.h — 业务层接口(纯 C,不依赖 meow_ui.h / meow_view)。
*
* 分层契约(SDK_VIEW_FRAMEWORK_DESIGN.md §B.1):
* ① UI→业务 = 纯函数命令 + getter(logic_* / notify_* 返回业务态,业务不回调 UI);
* ② 业务→UI = 可选 push 监听器(logic_listener_fn + logic_set_listener);
* ③ view 的 ctx = 视图控制器(biz-UI 绑定点)。
* 本头只声明数据类型与函数原型,不含任何 meow_ui.h / meow_ui_view.h 依赖——
* logic/state.c 因此保持纯 C;logic/notify.c 仅因要用 SDK 通知 API 而 include meow_ui.h。
*/
#ifndef HELLO_LOGIC_H
#define HELLO_LOGIC_H
/* 监听器事件类型(业务态变化 → 通知 UI) */
#define LOGIC_EV_TAPS 1 /* taps 计数变化 */
#define LOGIC_EV_SECS 2 /* secs 秒计数变化 */
#define LOGIC_EV_PROG 3 /* demo 进度值变化(批③ 语义值上收) */
typedef void (*logic_listener_fn)(int ev, void *ctx); /* ctx = 监听器注册时给的视图控制器 */
/* ---- 计数业务态(logic/state.c)---- */
int logic_taps_get(void); /* 返回累计 taps */
void logic_taps_bump(void); /* taps++,并触发监听器(若已注册) */
int logic_secs_get(void); /* 返回过去秒数 */
void logic_secs_add(int n); /* secs += n,并触发监听器(若已注册) */
int logic_prog_get(void); /* 返回 demo 进度值 0..100(批③ 语义值上收) */
void logic_prog_set(int p); /* 设置进度值(clamp 0..100),并触发监听器(若已注册) */
void logic_set_listener(logic_listener_fn cb, void *ctx); /* 注册业务→UI 推送监听器(可 NULL 注销) */
/* ---- 通知业务(logic/notify.c)---- */
void notif_send(int which); /* 按索引发一条通知(数据/超时/优先级在业务层定) */
void notif_cancel(void); /* 取消最近一条发送的通知 */
#endif /* HELLO_LOGIC_H */