#include "include.h" #include "func.h" #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif enum { //图像 COMPO_ID_PIC_DRINK = 1, }; typedef struct f_remind_drink_t_ { } f_remind_drink_t; void *barcode_creat(void *parent, char *str, int x, int y, int h, u8 length, bool dir); //创建喝水提醒窗体 compo_form_t *func_remind_drink_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_DRINK_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_DRINK_BIN, GUI_SCREEN_CENTER_X-3, GUI_SCREEN_CENTER_Y-13); // 创建文本 compo_textbox_t *txt = compo_textbox_create(frm, 110); compo_textbox_set_location(txt, GUI_SCREEN_CENTER_X, 102+14, GUI_SCREEN_WIDTH - GUI_SCREEN_WIDTH/6, GUI_SCREEN_CENTER_Y/2); compo_textbox_set_multiline(txt, true); compo_textbox_set_autoroll_mode(txt, TEXT_AUTOROLL_MODE_SROLL_CIRC); compo_textbox_set(txt, i18n[STR_REMIND_DRINK]); //创建动画 compo_animation_t *animation = compo_animation_create(frm, UI_BUF_REMIND_DRINK_DT_BIN); compo_animation_set_radix(animation, 2); 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, 20); compo_setid(animation, COMPO_ID_PIC_DRINK); return frm; } static void func_animation(void) { if(tick_check_expire(func_cb.enter_tick, 15000)) { func_back_to(); } } //喝水提醒功能事件处理 static void func_remind_drink_process(void) { func_animation(); if(!tick_check_expire(func_cb.enter_tick, 15000)) { reset_sleep_delay_all(); } func_process(); } //喝水提醒功能消息处理 static void func_remind_drink_message(size_msg_t msg) { switch (msg) { case MSG_CTP_CLICK: break; default: func_message(msg); break; } } //进入喝水提醒功能 static void func_remind_drink_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_remind_drink_t)); func_cb.frm_main = func_remind_drink_form_create(); func_cb.enter_tick = tick_get(); sys_cb.motor_flag = 1; set_func_motor(80,10,0,2); } //退出喝水提醒功能 static void func_remind_drink_exit(void) { func_cb.last = FUN_REMIND_DRINK; bsp_motor_stop(MOTOR_PORT); } //喝水提醒功能 void func_remind_drink(void) { printf("%s\n", __func__); func_remind_drink_enter(); while (func_cb.sta == FUN_REMIND_DRINK) { func_remind_drink_process(); func_remind_drink_message(msg_dequeue()); } func_remind_drink_exit(); }