507 lines
20 KiB
C
507 lines
20 KiB
C
#include "include.h"
|
||
#include "func.h"
|
||
#include "app_variable.h"
|
||
#include "spirit_island_api.h"
|
||
|
||
#if TRACE_EN
|
||
#define TRACE(...) printf(__VA_ARGS__)
|
||
#else
|
||
#define TRACE(...)
|
||
#endif
|
||
|
||
#define SHAPE_CENTER_Y_ONE (38 + 16) //第1个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_TWO (82 + 18) //第2个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_THR (122 + 18) //第3个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_FOU (162 + 18) //第4个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_FIV (202 + 18) //第5个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_SIX (242 + 18) //第6个矩形框中心点所在y坐标
|
||
#define SHAPE_CENTER_Y_SEV (292 + 18) //第7个矩形框中心点所在y坐标
|
||
// #define SHAPE_CENTER_Y_EIG (332 + 18) //第8个矩形框中心点所在y坐标
|
||
|
||
|
||
//组件ID
|
||
enum {
|
||
//按键
|
||
COMPO_ID_BTN_REDUCE = 1,
|
||
COMPO_ID_BTN_INCREASE,
|
||
COMPO_ID_BTN_SLEEP_SCREEN,
|
||
COMPO_ID_BTN_BESIDELAMP,
|
||
COMPO_ID_BTN_COVER_SCREEN,
|
||
COMPO_ID_BTN_SPIRIT_ISLAND,
|
||
COMPO_ID_BTN_PINCH_ANSWER,
|
||
COMPO_ID_BTN_RAISE,
|
||
//图像
|
||
COMPO_ID_PIC_LEVEL1, //亮度等级 1~5
|
||
COMPO_ID_PIC_LEVEL2,
|
||
COMPO_ID_PIC_LEVEL3,
|
||
COMPO_ID_PIC_LEVEL4,
|
||
COMPO_ID_PIC_LEVEL5,
|
||
|
||
COMPO_ID_PIC_NULL,
|
||
COMPO_ID_PIC_SWITCH_THD, //床头钟开关
|
||
COMPO_ID_PIC_SWITCH_CTS, //盖手熄屏开关
|
||
COMPO_ID_PIC_SWITCH_TIS, //灵动岛开关
|
||
COMPO_ID_PIC_SWITCH_TAP, //捏手接听开关
|
||
COMPO_ID_PIC_SWITCH_RTS, //抬手亮屏开关
|
||
// COMPO_ID_PIC_REDUCE_CLICK, //按钮触摸效果图
|
||
// COMPO_ID_PIC_INCREASE_CLICK,
|
||
};
|
||
|
||
typedef struct f_light_t_ {
|
||
page_tp_move_t *ptm;
|
||
int last_y_move;
|
||
u8 light_level;
|
||
} f_light_t;
|
||
|
||
typedef struct light_item_t_ {
|
||
s16 x;
|
||
s16 y;
|
||
s16 w;
|
||
s16 h;
|
||
u16 bind_id;
|
||
u8 alpha;
|
||
u32 res_addr; //图片
|
||
u32 str_idx; //文字
|
||
u16 color;
|
||
bool visible_en;
|
||
} light_item_t;
|
||
|
||
|
||
#define LIGHT_SHAPE_ITEM_CNT ((int)(sizeof(tbl_light_shape_item) / sizeof(tbl_light_shape_item[0])))
|
||
#define GRET_SHAPE_ITEM_CNT ((int)(sizeof(tbl_gret_shape_item) / sizeof(tbl_gret_shape_item[0])))
|
||
#define TXT_ITEM_CNT ((int)(sizeof(tbl_txt_item) / sizeof(tbl_txt_item[0])))
|
||
#define PIC_ITEM_CNT ((int)(sizeof(tbl_pic_item) / sizeof(tbl_pic_item[0])))
|
||
#define BTN_ITEM_CNT ((int)(sizeof(tbl_light_btn_item) / sizeof(tbl_light_btn_item[0])))
|
||
//五个绿色亮度 圆角矩形 item,创建时遍历一下
|
||
static const light_item_t tbl_light_shape_item[] = {
|
||
{.x = 36, .y = SHAPE_CENTER_Y_ONE, .w = 12, .h = 4, .bind_id = COMPO_ID_PIC_LEVEL1, .alpha = 100},
|
||
{.x = 50, .y = SHAPE_CENTER_Y_ONE, .w = 12, .h = 4, .bind_id = COMPO_ID_PIC_LEVEL2, .alpha = 100},
|
||
{.x = 64, .y = SHAPE_CENTER_Y_ONE, .w = 12, .h = 4, .bind_id = COMPO_ID_PIC_LEVEL3, .alpha = 100},
|
||
{.x = 78, .y = SHAPE_CENTER_Y_ONE, .w = 12, .h = 4, .bind_id = COMPO_ID_PIC_LEVEL4, .alpha = 100},
|
||
{.x = 92, .y = SHAPE_CENTER_Y_ONE, .w = 12, .h = 4, .bind_id = COMPO_ID_PIC_LEVEL5, .alpha = 100},
|
||
};
|
||
|
||
//灰色背景item,创建时遍历一下
|
||
static const light_item_t tbl_gret_shape_item[] = {
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_ONE, .w = 126, .h = 32, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_TWO, .w = 126, .h = 36, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_THR, .w = 126, .h = 36, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_FOU, .w = 126, .h = 36, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_FIV, .w = 126, .h = 36, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_SIX, .w = 126, .h = 36, },
|
||
{.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_SEV, .w = 126, .h = 36, },
|
||
// {.x = GUI_SCREEN_CENTER_X, .y = SHAPE_CENTER_Y_EIG, .w = 126, .h = 36, },//屏蔽一个后续放熄屏时钟
|
||
};
|
||
|
||
//文字 item,创建时遍历一下
|
||
static const light_item_t tbl_txt_item[] = {
|
||
{.x = 9, .y = SHAPE_CENTER_Y_ONE - 31, .w = 105, .h = 20, .str_idx = STR_LIGHT , .color = COLOR_GRAY},
|
||
{.x = 7, .y = SHAPE_CENTER_Y_TWO - 15, .w = 80, .h = 20, .str_idx = STR_SETTING_DOUSING, .color = COLOR_WHITE},
|
||
{.x = 7, .y = SHAPE_CENTER_Y_THR - 8, .w = 80, .h = 20, .str_idx = STR_BEDSIED_CLOCK, .color = COLOR_WHITE},
|
||
{.x = 7, .y = SHAPE_CENTER_Y_FOU - 9, .w = 80, .h = 20, .str_idx = STR_COVER_THE_HAND, .color = COLOR_WHITE},
|
||
{.x = 5, .y = SHAPE_CENTER_Y_FIV - 9, .w = 80, .h = 20, .str_idx = STR_SPIRIT_ISLAND, .color = COLOR_WHITE},
|
||
{.x = 6, .y = SHAPE_CENTER_Y_SIX - 9, .w = 80, .h = 20, .str_idx = STR_PINCH_ANSWER, .color = COLOR_WHITE},
|
||
{.x = 5, .y = SHAPE_CENTER_Y_SEV - 31, .w = 105, .h = 20, .str_idx = STR_WAKE_SCREEN, .color = COLOR_GRAY},
|
||
{.x = 6, .y = SHAPE_CENTER_Y_SEV - 9, .w = 80, .h = 20, .str_idx = STR_SETTING_UP, .color = COLOR_WHITE},
|
||
// {.x = 12, .y = SHAPE_CENTER_Y_EIG - 10, .w = 80, .h = 20, .str_idx = , .color = COLOR_WHITE},//屏蔽一个后续放熄屏时钟
|
||
};
|
||
|
||
//图片 item
|
||
static const light_item_t tbl_pic_item[] = {
|
||
{.x = 15, .y = SHAPE_CENTER_Y_ONE, .bind_id = COMPO_ID_PIC_NULL, .res_addr = UI_BUF_SETTING_LIGHT_DOWN_BIN ,},
|
||
{.x = 114, .y = SHAPE_CENTER_Y_ONE, .bind_id = COMPO_ID_PIC_NULL, .res_addr = UI_BUF_SETTING_LIGHT_UP_BIN,},
|
||
{.x = 114, .y = SHAPE_CENTER_Y_TWO, .bind_id = COMPO_ID_PIC_NULL, .res_addr = UI_BUF_COMMON_RIGHT_BIN,},
|
||
{.x = 108, .y = SHAPE_CENTER_Y_THR, .bind_id = COMPO_ID_PIC_SWITCH_THD, .res_addr = UI_BUF_COMMON_OFF_BIN,},
|
||
{.x = 108, .y = SHAPE_CENTER_Y_FOU, .bind_id = COMPO_ID_PIC_SWITCH_CTS, .res_addr = UI_BUF_COMMON_OFF_BIN,},
|
||
{.x = 108, .y = SHAPE_CENTER_Y_FIV, .bind_id = COMPO_ID_PIC_SWITCH_TIS, .res_addr = UI_BUF_COMMON_OFF_BIN,},
|
||
{.x = 108, .y = SHAPE_CENTER_Y_SIX, .bind_id = COMPO_ID_PIC_SWITCH_TAP, .res_addr = UI_BUF_COMMON_OFF_BIN,},
|
||
{.x = 108, .y = SHAPE_CENTER_Y_SEV, .bind_id = COMPO_ID_PIC_SWITCH_RTS, .res_addr = UI_BUF_COMMON_OFF_BIN,},
|
||
};
|
||
|
||
|
||
//触摸 item
|
||
//五个绿色亮度 圆角矩形 item,创建时遍历一下
|
||
static const light_item_t tbl_light_btn_item[] = {
|
||
{.x = 14, .y = SHAPE_CENTER_Y_ONE, .w = 32, .h = 32, .bind_id = COMPO_ID_BTN_REDUCE, },
|
||
{.x = 114, .y = SHAPE_CENTER_Y_ONE, .w = 32, .h = 32, .bind_id = COMPO_ID_BTN_INCREASE, },
|
||
{.x = 64, .y = SHAPE_CENTER_Y_TWO, .w = 126, .h = 36, .bind_id = COMPO_ID_BTN_SLEEP_SCREEN, },
|
||
{.x = 108, .y = SHAPE_CENTER_Y_THR, .w = 32, .h = 36, .bind_id = COMPO_ID_BTN_BESIDELAMP, },
|
||
{.x = 108, .y = SHAPE_CENTER_Y_FOU, .w = 32, .h = 36, .bind_id = COMPO_ID_BTN_COVER_SCREEN, },
|
||
{.x = 108, .y = SHAPE_CENTER_Y_FIV, .w = 32, .h = 36, .bind_id = COMPO_ID_BTN_SPIRIT_ISLAND, },
|
||
{.x = 108, .y = SHAPE_CENTER_Y_SIX, .w = 32, .h = 36, .bind_id = COMPO_ID_BTN_PINCH_ANSWER, },
|
||
{.x = 108, .y = SHAPE_CENTER_Y_SEV, .w = 32, .h = 36, .bind_id = COMPO_ID_BTN_RAISE, },
|
||
};
|
||
|
||
|
||
|
||
|
||
|
||
//创建亮度调节窗体,创建窗体中不要使用功能结构体 func_cb.f_cb
|
||
compo_form_t *func_light_form_create(void)
|
||
{
|
||
//新建窗体和背景
|
||
compo_form_t *frm = compo_form_create(true);
|
||
static char buf[6];
|
||
memset(buf, 0, sizeof(buf));
|
||
// compo_form_add_image(frm, UI_BUF_SETTING_LIGHT_LIGHT_BIN, GUI_SCREEN_CENTER_X, 105);
|
||
// compo_form_add_image(frm, UI_BUF_COMMON_BG1_BIN, GUI_SCREEN_CENTER_X, 200);
|
||
|
||
//设置标题栏
|
||
compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME);
|
||
compo_form_set_title(frm, i18n[STR_DISPLAY_AND_LIGHT]);
|
||
|
||
//创建 圆角矩形背景框
|
||
|
||
compo_shape_t *grey_shape[GRET_SHAPE_ITEM_CNT];
|
||
for(u8 idx =0; idx < GRET_SHAPE_ITEM_CNT; idx++){
|
||
grey_shape[idx] = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,8);
|
||
compo_setid(grey_shape[idx], tbl_gret_shape_item[idx].bind_id);
|
||
compo_shape_set_color(grey_shape[idx], make_color(75, 75, 75));
|
||
compo_shape_set_location(grey_shape[idx], tbl_gret_shape_item[idx].x, tbl_gret_shape_item[idx].y, tbl_gret_shape_item[idx].w, tbl_gret_shape_item[idx].h);
|
||
}
|
||
|
||
//创建顶部 亮度圆角矩形框 左边的黑色线条
|
||
compo_shape_t *grey_btn_one_lef ;
|
||
grey_btn_one_lef = compo_shape_create(frm, COMPO_SHAPE_TYPE_RECTANGLE);
|
||
compo_shape_set_color(grey_btn_one_lef, COLOR_BLACK);
|
||
compo_shape_set_location(grey_btn_one_lef, GUI_SCREEN_CENTER_X-GUI_SCREEN_CENTER_X/2-3, SHAPE_CENTER_Y_ONE, 1, 32);
|
||
|
||
//创建顶部 亮度圆角矩形框 右边的黑色线条
|
||
compo_shape_t *grey_btn_one_rig ;
|
||
grey_btn_one_rig = compo_shape_create(frm, COMPO_SHAPE_TYPE_RECTANGLE);
|
||
compo_shape_set_color(grey_btn_one_rig, COLOR_BLACK);
|
||
compo_shape_set_location(grey_btn_one_rig, GUI_SCREEN_CENTER_X+GUI_SCREEN_CENTER_X/2+3, SHAPE_CENTER_Y_ONE, 1, 32);
|
||
|
||
//新建所有图片
|
||
compo_picturebox_t *pic[PIC_ITEM_CNT];
|
||
for(u8 idx = 0;idx <PIC_ITEM_CNT;idx ++){
|
||
pic[idx] = compo_picturebox_create(frm, tbl_pic_item[idx].res_addr);
|
||
compo_setid(pic[idx], tbl_pic_item[idx].bind_id);
|
||
compo_picturebox_set_pos(pic[idx], tbl_pic_item[idx].x, tbl_pic_item[idx].y);
|
||
}
|
||
|
||
//创建 所有点触区域
|
||
compo_button_t *btn[BTN_ITEM_CNT];
|
||
for(u8 idx = 0;idx <PIC_ITEM_CNT;idx ++){
|
||
btn[idx] = compo_button_create(frm);
|
||
compo_setid(btn[idx], tbl_light_btn_item[idx].bind_id);
|
||
compo_button_set_location(btn[idx], tbl_light_btn_item[idx].x,tbl_light_btn_item[idx].y,tbl_light_btn_item[idx].w,tbl_light_btn_item[idx].h);
|
||
}
|
||
|
||
//亮度中间五个绿色圆角矩形
|
||
compo_shape_t *shape_level[LIGHT_SHAPE_ITEM_CNT];
|
||
for(u8 idx =0; idx < LIGHT_SHAPE_ITEM_CNT; idx++){
|
||
shape_level[idx] = compo_radius_shape_create(frm, COMPO_SHAPE_TYPE_ROUNDED_RECTANGLE,1);
|
||
compo_setid(shape_level[idx], tbl_light_shape_item[idx].bind_id);
|
||
compo_shape_set_color(shape_level[idx], make_color(12, 227, 103));
|
||
compo_shape_set_location(shape_level[idx], tbl_light_shape_item[idx].x, tbl_light_shape_item[idx].y, tbl_light_shape_item[idx].w, tbl_light_shape_item[idx].h);
|
||
compo_shape_set_alpha(shape_level[idx], tbl_light_shape_item[idx].alpha);
|
||
}
|
||
|
||
|
||
printf("%s-->light_level:%d\n",__func__, SysVariable.light_level);
|
||
for (u8 i=0; i<SysVariable.light_level; i++) {
|
||
// compo_picturebox_set_visible(pic_level[i],true);
|
||
compo_shape_set_alpha(shape_level[i], 255);
|
||
|
||
}
|
||
|
||
//创建除了 自动熄屏 时长之外所有的 文字
|
||
compo_textbox_t *txt[TXT_ITEM_CNT];
|
||
for(u8 idx =0; idx < TXT_ITEM_CNT; idx++){
|
||
txt[idx] = compo_textbox_create(frm, 50);
|
||
compo_textbox_set_align_center(txt[idx],FALSE);
|
||
compo_textbox_set_forecolor(txt[idx], tbl_txt_item[idx].color);
|
||
compo_textbox_set_location(txt[idx], tbl_txt_item[idx].x, tbl_txt_item[idx].y, tbl_txt_item[idx].w, tbl_txt_item[idx].h);
|
||
compo_textbox_set_autoroll_mode(txt[idx], TEXT_AUTOROLL_MODE_SROLL_CIRC);
|
||
compo_textbox_set(txt[idx], i18n[tbl_txt_item[idx].str_idx]);
|
||
}
|
||
|
||
//创建 熄屏时长秒数文字
|
||
compo_textbox_t *txt_s = compo_textbox_create(frm, 60);
|
||
compo_textbox_set_align_center(txt_s,FALSE);
|
||
compo_textbox_set_location(txt_s, 7, SHAPE_CENTER_Y_TWO + 2, 80, 20);
|
||
compo_textbox_set_autoroll_mode(txt_s, TEXT_AUTOROLL_MODE_SROLL_CIRC);
|
||
// if(SysVariable.sleep_time == (-1)){
|
||
// compo_textbox_set(txt_s, i18n[STR_NEVER]);
|
||
// }
|
||
// else{
|
||
snprintf(buf, sizeof(buf), "%d s", SysVariable.sleep_time/10);
|
||
compo_textbox_set(txt_s, buf);
|
||
// }
|
||
|
||
return frm;
|
||
}
|
||
|
||
//按钮状态更新
|
||
static void func_light_btn_pic_update(void)
|
||
{
|
||
compo_picturebox_t *thd_pic = compo_getobj_byid(COMPO_ID_PIC_SWITCH_THD);
|
||
compo_picturebox_t *cts_pic = compo_getobj_byid(COMPO_ID_PIC_SWITCH_CTS);
|
||
compo_picturebox_t *tis_pic = compo_getobj_byid(COMPO_ID_PIC_SWITCH_TIS);
|
||
compo_picturebox_t *tap_pic = compo_getobj_byid(COMPO_ID_PIC_SWITCH_TAP);
|
||
compo_picturebox_t *rts_pic = compo_getobj_byid(COMPO_ID_PIC_SWITCH_RTS);
|
||
|
||
//床头钟
|
||
if(SysVariable.charingWatchSwitch) {
|
||
compo_picturebox_set(thd_pic, UI_BUF_COMMON_ON_BIN);
|
||
} else {
|
||
compo_picturebox_set(thd_pic, UI_BUF_COMMON_OFF_BIN);
|
||
}
|
||
|
||
//盖手熄屏
|
||
if(SysVariable.capping_hand_offscreen_flag) {
|
||
compo_picturebox_set(cts_pic, UI_BUF_COMMON_ON_BIN);
|
||
} else {
|
||
compo_picturebox_set(cts_pic, UI_BUF_COMMON_OFF_BIN);
|
||
}
|
||
|
||
//灵动岛
|
||
if(SysVariable.SpiritIslandSwitch) {
|
||
compo_picturebox_set(tis_pic, UI_BUF_COMMON_ON_BIN);
|
||
} else {
|
||
compo_picturebox_set(tis_pic, UI_BUF_COMMON_OFF_BIN);
|
||
}
|
||
|
||
// 捏手接听
|
||
if(SysVariable.handle_knob_flag) {
|
||
compo_picturebox_set(tap_pic, UI_BUF_COMMON_ON_BIN);
|
||
} else {
|
||
compo_picturebox_set(tap_pic, UI_BUF_COMMON_OFF_BIN);
|
||
}
|
||
|
||
//抬手亮屏
|
||
if(SysVariable.funtionSwitch & FUNTION_RAISE_HAND_DISPLAY) {
|
||
compo_picturebox_set(rts_pic, UI_BUF_COMMON_ON_BIN);
|
||
} else {
|
||
compo_picturebox_set(rts_pic, UI_BUF_COMMON_OFF_BIN);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//释放按钮效果处理
|
||
static void func_light_button_release_handle(void)
|
||
{
|
||
// compo_picturebox_t *pic_reduce = compo_getobj_byid(COMPO_ID_PIC_REDUCE_CLICK);
|
||
// compo_picturebox_t *pic_increase = compo_getobj_byid(COMPO_ID_PIC_INCREASE_CLICK);
|
||
// compo_picturebox_set_visible(pic_reduce, false);
|
||
// compo_picturebox_set_visible(pic_increase, false);
|
||
}
|
||
|
||
//单击按钮
|
||
static void func_light_button_click(void)
|
||
{
|
||
int id = compo_get_button_id();
|
||
compo_shape_t *shape_level[5];
|
||
shape_level[0] = compo_getobj_byid(COMPO_ID_PIC_LEVEL1);
|
||
shape_level[1] = compo_getobj_byid(COMPO_ID_PIC_LEVEL2);
|
||
shape_level[2] = compo_getobj_byid(COMPO_ID_PIC_LEVEL3);
|
||
shape_level[3] = compo_getobj_byid(COMPO_ID_PIC_LEVEL4);
|
||
shape_level[4] = compo_getobj_byid(COMPO_ID_PIC_LEVEL5);
|
||
|
||
|
||
// compo_picturebox_t *pic_level[5];
|
||
// pic_level[0] = compo_getobj_byid(COMPO_ID_PIC_LEVEL1);
|
||
// pic_level[1] = compo_getobj_byid(COMPO_ID_PIC_LEVEL2);
|
||
// pic_level[2] = compo_getobj_byid(COMPO_ID_PIC_LEVEL3);
|
||
// pic_level[3] = compo_getobj_byid(COMPO_ID_PIC_LEVEL4);
|
||
// pic_level[4] = compo_getobj_byid(COMPO_ID_PIC_LEVEL5);
|
||
|
||
switch (id) {
|
||
//减少亮度
|
||
case COMPO_ID_BTN_REDUCE:
|
||
if (SysVariable.light_level > 1 && SysVariable.light_level <= 5) {
|
||
SysVariable.light_level--;
|
||
}
|
||
break;
|
||
//增加亮度
|
||
case COMPO_ID_BTN_INCREASE:
|
||
if (SysVariable.light_level >= 1 && SysVariable.light_level < 5) {
|
||
SysVariable.light_level++;
|
||
}
|
||
break;
|
||
|
||
//熄屏时长
|
||
case COMPO_ID_BTN_SLEEP_SCREEN:
|
||
//切入应用
|
||
{
|
||
u8 func_sta = FUNC_SET_SUB_DOUSING;
|
||
compo_form_t *frm = func_create_form(func_sta);
|
||
func_switching(FUNC_SWITCH_ZOOM_FADE_ENTER | FUNC_SWITCH_AUTO, NULL);
|
||
compo_form_destroy(frm);
|
||
func_switch_to_assign_screen(func_sta, false);
|
||
}
|
||
// func_cb.sta = FUNC_SET_SUB_DOUSING;
|
||
break;
|
||
|
||
//床头钟
|
||
case COMPO_ID_BTN_BESIDELAMP:
|
||
SysVariable.charingWatchSwitch = !SysVariable.charingWatchSwitch;
|
||
break;
|
||
//盖手熄屏
|
||
case COMPO_ID_BTN_COVER_SCREEN:
|
||
SysVariable.capping_hand_offscreen_flag = !SysVariable.capping_hand_offscreen_flag;
|
||
break;
|
||
//灵动岛
|
||
case COMPO_ID_BTN_SPIRIT_ISLAND:
|
||
SysVariable.SpiritIslandSwitch = !SysVariable.SpiritIslandSwitch;
|
||
if(SysVariable.SpiritIslandSwitch == true){
|
||
if(bt_cb.music_playing == true)
|
||
{
|
||
si_activated_task(music,0);
|
||
}
|
||
}
|
||
break;
|
||
//捏手接听
|
||
case COMPO_ID_BTN_PINCH_ANSWER:
|
||
SysVariable.handle_knob_flag = !SysVariable.handle_knob_flag;
|
||
break;
|
||
//抬手亮屏
|
||
case COMPO_ID_BTN_RAISE:
|
||
if(SysVariable.funtionSwitch & FUNTION_RAISE_HAND_DISPLAY){
|
||
SysVariable.funtionSwitch &= ~(FUNTION_RAISE_HAND_DISPLAY);
|
||
|
||
}else{
|
||
SysVariable.funtionSwitch |= FUNTION_RAISE_HAND_DISPLAY;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
for (u8 i=0; i<5; i++) {
|
||
if (i < SysVariable.light_level) {
|
||
// compo_picturebox_set_visible(pic_level[i],true);
|
||
compo_shape_set_alpha(shape_level[i], 255);
|
||
} else {
|
||
// compo_picturebox_set_visible(pic_level[i],false);
|
||
compo_shape_set_alpha(shape_level[i], 100);
|
||
}
|
||
}
|
||
func_light_btn_pic_update();
|
||
func_light_button_release_handle();
|
||
}
|
||
|
||
|
||
|
||
|
||
//亮度调节功能事件处理
|
||
static void func_light_process(void)
|
||
{
|
||
f_light_t *f_light = (f_light_t *)func_cb.f_cb;
|
||
func_light_btn_pic_update();
|
||
compo_page_move_process(f_light->ptm);
|
||
func_process();
|
||
}
|
||
|
||
|
||
//亮度调节功能消息处理
|
||
static void func_light_message(size_msg_t msg)
|
||
{
|
||
f_light_t *f_light = (f_light_t *)func_cb.f_cb;
|
||
|
||
switch (msg) {
|
||
case MSG_CTP_TOUCH:
|
||
compo_page_move_touch_handler(f_light->ptm);
|
||
break;
|
||
case MSG_CTP_CLICK:
|
||
func_light_button_click();
|
||
uint8_t level_tmp = SysVariable.light_level;
|
||
if(level_tmp < 1)
|
||
{
|
||
level_tmp = 1;
|
||
}
|
||
else if(level_tmp > 5)
|
||
{
|
||
level_tmp = 5;
|
||
}
|
||
tft_bglight_set_level(level_tmp,false);
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_UP:
|
||
case MSG_CTP_SHORT_DOWN:
|
||
|
||
case MSG_CTP_SHORT_LEFT:
|
||
case MSG_CTP_LONG:
|
||
func_light_button_release_handle();
|
||
break;
|
||
|
||
case MSG_CTP_SHORT_RIGHT:
|
||
func_light_button_release_handle();
|
||
func_message(msg);
|
||
break;
|
||
|
||
case MSG_QDEC_BACKWARD:
|
||
if (func_cb.flag_sort) { //快捷应用状态下不滚动页面
|
||
func_message(msg);
|
||
} else {
|
||
compo_page_move_set_by_pages(f_light->ptm, -1);
|
||
}
|
||
break;
|
||
|
||
case MSG_QDEC_FORWARD:
|
||
if (func_cb.flag_sort) {
|
||
func_message(msg);
|
||
} else {
|
||
compo_page_move_set_by_pages(f_light->ptm, 1);
|
||
}
|
||
break;
|
||
|
||
default:
|
||
func_message(msg);
|
||
break;
|
||
}
|
||
}
|
||
|
||
//进入亮度调节功能
|
||
static void func_light_enter(void)
|
||
{
|
||
func_cb.f_cb = func_zalloc(sizeof(f_light_t));
|
||
if(SysVariable.sleep_time != 50&&SysVariable.sleep_time != 100&&SysVariable.sleep_time != 200&&SysVariable.sleep_time != 300&&SysVariable.sleep_time != 600&&SysVariable.sleep_time != 3000)
|
||
{
|
||
SysVariable.sleep_time =50;
|
||
}
|
||
|
||
func_cb.frm_main = func_light_form_create();
|
||
func_light_btn_pic_update();
|
||
f_light_t *f_light = (f_light_t *)func_cb.f_cb;
|
||
f_light->ptm = (page_tp_move_t *)func_zalloc(sizeof(page_tp_move_t));
|
||
|
||
page_move_info_t info = {
|
||
.title_used = true,
|
||
.page_size = 318,
|
||
.page_count = 1,
|
||
.up_over_perc = 10,
|
||
.down_over_perc = 10,
|
||
};
|
||
|
||
|
||
compo_page_move_init(f_light->ptm, func_cb.frm_main->page_body, &info);
|
||
}
|
||
|
||
//退出亮度调节功能
|
||
static void func_light_exit(void)
|
||
{
|
||
f_light_t *f_light = (f_light_t *)func_cb.f_cb;
|
||
func_cb.last = FUNC_LIGHT;
|
||
if (f_light->ptm) {
|
||
func_free(f_light->ptm);
|
||
}
|
||
SysVariable.duty_flag = true;
|
||
}
|
||
|
||
|
||
|
||
//亮度调节功能
|
||
void func_light(void)
|
||
{
|
||
printf("%s\n", __func__);
|
||
func_light_enter();
|
||
while (func_cb.sta == FUNC_LIGHT) {
|
||
func_light_process();
|
||
func_light_message(msg_dequeue());
|
||
}
|
||
func_light_exit();
|
||
}
|