mcu_ab568x/userboot240328/app/projects/AB5681G_320/functions/func_breathe.c
2025-05-30 18:03:10 +08:00

94 lines
2.1 KiB
C

#include "include.h"
#include "func.h"
#if TRACE_EN
#define TRACE(...) printf(__VA_ARGS__)
#else
#define TRACE(...)
#endif
typedef struct f_breathe_t_ {
} f_breathe_t;
//创建呼吸窗体,创建窗体中不要使用功能结构体 func_cb.f_cb
compo_form_t *func_breathe_form_create(void)
{
//新建窗体和背景
compo_form_t *frm = compo_form_create(true);
compo_form_add_image(frm, UI_BUF_BREATHE_TIME_BIN, 41, 172);
compo_form_add_image(frm, UI_BUF_BREATHE_BREATHE1_BIN, 160, 172);
compo_form_add_image(frm, UI_BUF_BREATHE_MODE_BIN, 279, 172);
//新建按钮
compo_button_t *btn;
btn = compo_button_create_by_image(frm, UI_BUF_COMMON_BUTTON_BIN);
compo_button_set_pos(btn, 160, 336);
//创建文本
compo_textbox_t *txt_title = compo_textbox_create(frm, 4);
compo_textbox_set_location(txt_title, 30, 22, 140, 40);
compo_textbox_set(txt_title, "呼吸训练");
compo_textbox_t *txt_start = compo_textbox_create(frm, 2);
compo_textbox_set_location(txt_start, 130, 315, 80, 40);
compo_textbox_set(txt_start, "开始");
func_text_time_create(frm); //时间文本框
return frm;
}
//呼吸功能事件处理
static void func_breathe_process(void)
{
func_process();
}
//呼吸功能消息处理
static void func_breathe_message(size_msg_t msg)
{
switch (msg) {
case MSG_CTP_CLICK:
break;
case MSG_CTP_SHORT_UP:
break;
case MSG_CTP_SHORT_DOWN:
break;
case MSG_CTP_LONG:
break;
default:
func_message(msg);
break;
}
}
//进入呼吸功能
static void func_breathe_enter(void)
{
func_cb.f_cb = func_zalloc(sizeof(f_breathe_t));
func_cb.frm_main = func_breathe_form_create();
}
//退出呼吸功能
static void func_breathe_exit(void)
{
func_cb.last = FUNC_BREATHE;
}
//呼吸功能
void func_breathe(void)
{
printf("%s\n", __func__);
func_breathe_enter();
while (func_cb.sta == FUNC_BREATHE) {
func_breathe_process();
func_breathe_message(msg_dequeue());
}
func_breathe_exit();
}