#include "include.h" #include "func.h" #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif typedef struct f_remind_sit_t { u32 enter_tick; } f_remind_sit_t; //组件ID enum { //图像 COMPO_ID_PIC_SIT = 1, }; void *barcode_creat(void *parent, char *str, int x, int y, int h, u8 length, bool dir); //创建久坐提醒窗体 compo_form_t *func_remind_sit_form_create(void) { //新建窗体 compo_form_t *frm = compo_form_create(true); //创建按键 //compo_button_t *btn = compo_button_create_by_image(frm, UI_BUF_REMIND_ICON_SIT_BIN); //compo_button_set_pos(btn, GUI_SCREEN_CENTER_X-10, GUI_SCREEN_CENTER_Y-25); compo_form_add_image(frm, UI_BUF_REMIND_ICON_SIT_BIN, GUI_SCREEN_CENTER_X-10, GUI_SCREEN_CENTER_Y-25); // 创建文本 compo_textbox_t *txt = compo_textbox_create(frm, 110); compo_textbox_set_location(txt, GUI_SCREEN_CENTER_X, 216, 200, 60); compo_textbox_set_multiline(txt, true); compo_textbox_set_autoroll_mode(txt, TEXT_AUTOROLL_MODE_SROLL_CIRC); compo_textbox_set(txt, i18n[STR_REMIND_SIT]); // 创建动画 compo_animation_t *animation = compo_animation_create(frm, UI_BUF_REMIND_SEDENTARY_DT_BIN); compo_animation_set_radix(animation, 2); compo_animation_set_pos(animation, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y-15); compo_animation_set_size(animation,36, 53); compo_animation_set_interval(animation, 70); compo_setid(animation, COMPO_ID_PIC_SIT); return frm; } static void func_animation(void) { if(tick_check_expire(func_cb.enter_tick, 15000)) { func_back_to(); } } //久坐提醒功能事件处理 static void func_remind_sit_process(void) { func_animation(); if(!tick_check_expire(func_cb.enter_tick, 15000)) { reset_sleep_delay_all(); } func_process(); } //久坐提醒功能消息处理 static void func_remind_sit_message(size_msg_t msg) { switch (msg) { case MSG_CTP_CLICK: break; default: func_message(msg); break; } } //进入久坐提醒功能 static void func_remind_sit_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_remind_sit_t)); func_cb.frm_main = func_remind_sit_form_create(); func_cb.enter_tick = tick_get(); sys_cb.motor_flag = 1; set_func_motor(80,10,10,1); } //退出久坐提醒功能 static void func_remind_sit_exit(void) { func_cb.last = FUN_REMIND_SIT; bsp_motor_stop(MOTOR_PORT); } //久坐提醒功能 void func_remind_sit(void) { printf("%s\n", __func__); func_remind_sit_enter(); while (func_cb.sta == FUN_REMIND_SIT) { func_remind_sit_process(); func_remind_sit_message(msg_dequeue()); } func_remind_sit_exit(); }