mcu_ab568x/app/projects/AB5682C_128/functions/func_remind_alarm.c
2025-05-30 18:03:10 +08:00

148 lines
3.7 KiB
C

#include "include.h"
#include "func.h"
#include "app_variable.h"
#if TRACE_EN
#define TRACE(...) printf(__VA_ARGS__)
#else
#define TRACE(...)
#endif
typedef struct f_remind_alarm_t_ {
u32 enter_tick;
} f_remind_alarm_t;
//组件ID
enum {
//图像
COMPO_ID_PIC_ALARM = 1,
COMPO_ID_PIC_DT,
};
//创建logo窗体
compo_form_t *func_remind_alarm_form_create(void)
{
//新建窗体
compo_form_t *frm = compo_form_create(true);
// compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_REMIND_ALARM_BIN);
// compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y);
compo_form_add_image(frm, UI_BUF_REMIND_ALARM_BIN, GUI_SCREEN_CENTER_X-3, GUI_SCREEN_CENTER_Y-13);
//创建动画
// compo_animation_t *animation = compo_animation_create(frm, UI_BUF_REMIND_ALARM_BIN);
// compo_animation_set_pos(animation, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y);
// compo_animation_set_radix(animation, 1);
// compo_animation_set_interval(animation, 10);
// compo_setid(animation, COMPO_ID_PIC_ALARM);
// compo_animation_set_roll(animation, UI_BUF_REMIND_ALARM_BIN);
// 创建动画
compo_animation_t *animation = compo_animation_create(frm, UI_BUF_REMIND_CLOCK_DT_BIN);
compo_animation_set_radix(animation, 3);
compo_animation_set_pos(animation, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y-6);
compo_animation_set_size(animation,20, 28);
compo_animation_set_interval(animation, 70);
// compo_setid(animation, COMPO_ID_PIC_DT);
return frm;
}
static void func_remind_alarm_animation(void)
{
f_remind_alarm_t *f_logo_switching = (f_remind_alarm_t *)func_cb.f_cb;
if (tick_check_expire(func_cb.enter_tick, 15000)) {
// func_cb.sta = FUNC_CLOCK;
func_back_to();
}
compo_animation_t *animation = compo_getobj_byid(COMPO_ID_PIC_ALARM);
if (animation->interval == 0) {
return;
}
static s32 dx;
static u32 tick;
if (tick_check_expire(tick, animation->interval)){
tick = tick_get();
compo_animation_manual_next(animation);
}
}
//logo事件处理
static void func_remind_alarm_process(void)
{
func_remind_alarm_animation();
reset_sleep_delay_all();
func_process();
}
//logo消息处理
static void func_remind_alarm_message(size_msg_t msg)
{
static u32 res_tick = 0;
switch (msg) {
case MSG_CTP_CLICK:
break;
case KU_BACK:
case KU_LEFT:
case KU_RIGHT:
case MSG_CTP_SHORT_UP:
break;
case MSG_CTP_SHORT_DOWN:
break;
case MSG_CTP_LONG:
break;
/* 8s长按强制重启 */
case K_BACK:
res_tick = tick_get();
break;
case KL_BACK:
case KH_BACK:
case KLH_BACK:
if (tick_check_expire(res_tick, 8000)) {
user_cfg_info_write();
WDT_RST();
}
break;
default:
func_message(msg);
break;
}
}
//进入logo
static void func_remind_alarm_enter(void)
{
func_cb.f_cb = func_zalloc(sizeof(f_remind_alarm_t));
func_cb.frm_main = func_remind_alarm_form_create();
func_cb.enter_tick = tick_get();
sys_cb.motor_flag = 1;
set_func_motor(80,10,10,10);
}
//退出logo
static void func_remind_alarm_exit(void)
{
func_cb.last = FUNC_REMIND_ALARM;
bsp_motor_stop(MOTOR_PORT);
}
//logo
void func_remind_alarm(void)
{
printf("%s\n", __func__);
func_remind_alarm_enter();
while (func_cb.sta == FUNC_REMIND_ALARM) {
func_remind_alarm_process();
func_remind_alarm_message(msg_dequeue());
}
func_remind_alarm_exit();
}