#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_sedentary_t_ { } f_sedentary_t; // 组件ID enum { COMPO_ID_BIN_SIT_REMIND_SWITCH = 1, COMPO_ID_SEDENTARY_SHOW_TIME, }; // 久坐设置页面 compo_form_t *func_sedentary_form_create(void) { // 新建窗体 compo_form_t *frm = compo_form_create(true); // 设置标题栏 compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME); compo_form_set_title(frm, i18n[STR_SEDENTARINESS]); /* 创建灰色圆角矩形框 */ u16 compo_h = 44 + 33; compo_shape_t *grey_btn_sit = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE, 16); compo_shape_set_color(grey_btn_sit, make_color(75, 75, 75)); compo_shape_set_location(grey_btn_sit, GUI_SCREEN_CENTER_X, compo_h, 236, 66); /* 创建 左边 文本框 */ compo_h = 56; compo_textbox_t *txt_sit = compo_textbox_create(frm, 50); compo_textbox_set_align_center(txt_sit, FALSE); compo_textbox_set_location(txt_sit, 22, compo_h, 140, 30); compo_textbox_set_autoroll_mode(txt_sit, TEXT_AUTOROLL_MODE_SROLL_CIRC); compo_textbox_set(txt_sit, i18n[STR_INTERVAL_REMINDER]); compo_h = 81; compo_textbox_t *txt_sit_time = compo_textbox_create(frm, 50); compo_textbox_set_align_center(txt_sit_time, FALSE); compo_textbox_set_location(txt_sit_time, 22, compo_h, 140, 30); compo_textbox_set_autoroll_mode(txt_sit_time, TEXT_AUTOROLL_MODE_SROLL_CIRC); char text_buf[TEXTBOX_TEXT_BUF_LEN] = {0}; sprintf(text_buf, "%d%s", SysVariable.remind.sedentaryInterval, i18n[STR_MIN_SIMPLY]); compo_textbox_set(txt_sit_time, text_buf); compo_setid(txt_sit_time, COMPO_ID_SEDENTARY_SHOW_TIME); /* 创建按钮 */ compo_h = 64 + 14; compo_button_t *btn_sit; if (SysVariable.funtionSwitch & FUNTION_REMIND_SIT_LONG) btn_sit = compo_button_create_by_image(frm, UI_BUF_COMMON_ON_BIN); else btn_sit = compo_button_create_by_image(frm, UI_BUF_COMMON_OFF_BIN); compo_setid(btn_sit, COMPO_ID_BIN_SIT_REMIND_SWITCH); compo_button_set_pos(btn_sit, 195, compo_h); /* 创建背景 */ //compo_picturebox_t *bg = compo_picturebox_create(frm, UI_BUF_SEDENTARY_SIT_BG_BIN); //compo_picturebox_set_pos(bg, GUI_SCREEN_CENTER_X, GUI_SCREEN_CENTER_Y + 60); return frm; } // 开关按钮更新 static void func_sedentary_restart(void) { compo_button_t *btn = NULL; btn = (compo_button_t *)compo_getobj_byid(COMPO_ID_BIN_SIT_REMIND_SWITCH); if (SysVariable.funtionSwitch & FUNTION_REMIND_SIT_LONG) compo_button_set_bgimg(btn, UI_BUF_COMMON_ON_BIN); else compo_button_set_bgimg(btn, UI_BUF_COMMON_OFF_BIN); } // 久坐设置功能事件处理 static void func_sedentary_process(void) { compo_textbox_t *txt_sit_time = compo_getobj_byid(COMPO_ID_SEDENTARY_SHOW_TIME); char text_buf[30] = {0}; sprintf(text_buf, "%d%s", SysVariable.remind.sedentaryInterval, i18n[STR_MIN_SIMPLY]); compo_textbox_set(txt_sit_time, text_buf); func_sedentary_restart(); func_process(); } // 单击按钮 static void func_notice_button_click(void) { int id = compo_get_button_id(); switch (id) { case COMPO_ID_BIN_SIT_REMIND_SWITCH: if (SysVariable.funtionSwitch & FUNTION_REMIND_SIT_LONG) SysVariable.funtionSwitch &= ~FUNTION_REMIND_SIT_LONG; else SysVariable.funtionSwitch |= FUNTION_REMIND_SIT_LONG; ble_function_protocol_packetsend(); break; default: break; } func_sedentary_restart(); } // 久坐设置功能消息处理 static void func_sedentary_message(size_msg_t msg) { switch (msg) { case MSG_CTP_CLICK: func_notice_button_click(); break; default: func_message(msg); break; } } // 进入久坐设置功能 static void func_sedentary_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_sedentary_t)); func_cb.frm_main = func_sedentary_form_create(); func_sedentary_restart(); } // 退出久坐设置功能 static void func_sedentary_exit(void) { func_cb.last = FUNC_SEDENTARY; SysVariable.duty_flag = true; } // 久坐设置功能 void func_sedentary(void) { func_sedentary_enter(); while (func_cb.sta == FUNC_SEDENTARY) { func_sedentary_process(); func_sedentary_message(msg_dequeue()); } func_sedentary_exit(); }