//
//驗證//密碼//人臉//刷卡 #include "baseapp.h" static lv_group_t* appGroupBtn; static lv_obj_t* infoMeterLVGLBrushCard=NULL; static lv_obj_t* infoTextareaMeterPasswdValue; static lv_obj_t* appObjCamera; static lv_obj_t* appObjCameraAiFaceImg; static lv_obj_t* appObjCameraAnim; static lv_obj_t* appObjInfoData; static int passwdTextTotal; #define CAMERA_SHOW_WIDTH 640 #define CAMERA_SHOW_HEIGH 480 #define CAMERA_SHOW_HEIGH_ANIM_MIN -250 #define CAMERA_SHOW_HEIGH_ANIM_MAX +50 static StructObject objs[]={ // {{APP_HANDLE_KEY_TYPE__TEXT,APP_UI_ALIGN_B_MIDDLE,0,-150,&infoTextareaMeterPasswdValue},{APP_FONT_DEFAULT,APP_STYLE_FONT_COLOR_BLUE,{"請輸入密碼","Please enter the password"}}}, // {{APP_HANDLE_KEY_TYPE_CANVAS,APP_UI_ALIGN_C_MIDDLE,0,-100,&appObjCamera},{APP_FONT_DEFAULT,APP_STYLE_DEFAULT,{CAMERA_SHOW_WIDTH,CAMERA_SHOW_HEIGH}}}, // {{APP_HANDLE_KEY_TYPE___IMG,APP_UI_ALIGN_C_MIDDLE,0,-100,&appObjCameraAiFaceImg},{0,0,{"image/reachtruck/600_aiface.png"}}}, // {{APP_HANDLE_KEY_TYPE___IMG,APP_UI_ALIGN_C_MIDDLE,0,CAMERA_SHOW_HEIGH_ANIM_MIN,&appObjCameraAnim},{0,0,{"image/reachtruck/600_anim.png"}}}, {{APP_HANDLE_KEY_TYPE_LABEL,APP_UI_ALIGN_B_MIDDLE,0,-30,&appObjInfoData},{APP_FONT_DEFAULT,APP_STYLE_FONT_COLOR_BLUE,{"test"}}} }; // 遮罩 static lv_obj_t * mask_parent; static lv_obj_t * mask_name; static lv_obj_t * mask_state; // void create_mask_obj(void); static void mask_obj_show(char* name){ lv_label_set_text(mask_name,name); lv_label_set_text(mask_state,"please click face btn"); if(lv_obj_has_flag(mask_parent,LV_OBJ_FLAG_HIDDEN)==true){ lv_obj_clear_flag(mask_parent,LV_OBJ_FLAG_HIDDEN); } } static void mask_obj_hide(void){ if(lv_obj_has_flag(mask_parent,LV_OBJ_FLAG_HIDDEN)==false){ lv_obj_add_flag(mask_parent,LV_OBJ_FLAG_HIDDEN); } } // 取消 回撥函式 static void event_cb_btn_cancel(lv_event_t * e) { // lv_obj_t * obj = lv_event_get_target(e); mask_obj_hide(); mydebug; } // 刪除 回撥函式 static void event_cb_btn_del(lv_event_t * e) { mask_obj_hide(); mydebug; } // 重新錄入 回撥函式 static void event_cb_btn_record(lv_event_t * e) { mask_obj_hide(); mydebug; } static void create_mask_obj(void){ mask_parent = lv_obj_create(appObjUiParent); lv_obj_set_size(mask_parent, lv_obj_get_width(appObjUiParent)-1, lv_obj_get_height(appObjUiParent)-1); lv_obj_set_style_bg_color(mask_parent,lv_color_hex(0x145B7D),LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(mask_parent,LV_OPA_30,LV_STATE_DEFAULT); lv_obj_center(mask_parent); lv_obj_t * mask_p = lv_obj_create(mask_parent); lv_obj_set_size(mask_p, 600, 400); lv_obj_set_style_bg_color(mask_p,lv_color_hex(0xfffef9),LV_STATE_DEFAULT); // lv_obj_set_style_bg_opa(mask_P,LV_OPA_30,LV_STATE_DEFAULT); lv_obj_center(mask_p); // 姓名 mask_name = lv_label_create(mask_p); lv_obj_align(mask_name,LV_ALIGN_TOP_MID,0,30); lv_label_set_text(mask_name,"mask_name"); // 狀態 mask_state = lv_label_create(mask_p); lv_obj_align(mask_state,LV_ALIGN_CENTER,0,0); lv_label_set_text(mask_state,"mask_state"); // 取消 lv_obj_t * btn_cancel = lv_btn_create(mask_p); lv_obj_set_size(btn_cancel,45,45); lv_obj_set_style_radius(btn_cancel, LV_PCT(40), LV_PART_MAIN); lv_obj_align(btn_cancel,LV_ALIGN_TOP_RIGHT,0,0); lv_obj_add_event_cb(btn_cancel, event_cb_btn_cancel, LV_EVENT_CLICKED, NULL); lv_obj_t * btn_cancel_name = lv_label_create(btn_cancel); lv_obj_center(btn_cancel_name); // lv_obj_set_style_text_font() lv_label_set_text(btn_cancel_name,"X"); // 刪除 lv_obj_t * btn_del = lv_btn_create(mask_p); lv_obj_set_size(btn_del,100,50); lv_obj_set_style_radius(btn_del, 5, LV_PART_MAIN); lv_obj_align(btn_del,LV_ALIGN_BOTTOM_MID,-200,-10); lv_obj_add_event_cb(btn_del, event_cb_btn_del, LV_EVENT_CLICKED, NULL); lv_obj_t * btn_del_name = lv_label_create(btn_del); lv_obj_center(btn_del_name); lv_label_set_text(btn_del_name,"DEL"); // 重新錄入 lv_obj_t * btn_record = lv_btn_create(mask_p); lv_obj_set_size(btn_record,100,50); lv_obj_set_style_radius(btn_record, 5, LV_PART_MAIN); lv_obj_align(btn_record,LV_ALIGN_BOTTOM_MID,200,-10); lv_obj_add_event_cb(btn_record, event_cb_btn_record, LV_EVENT_CLICKED, NULL); lv_obj_t * btn_record_name = lv_label_create(btn_record); lv_obj_center(btn_record_name); lv_label_set_text(btn_record_name,"FACE"); } // 表格 static uint16_t selected_row = LV_TABLE_CELL_NONE; static lv_obj_t * table1; // 重繪的回撥 static void table_event_begin_cb(lv_event_t* e){ lv_obj_draw_part_dsc_t* dsc = (lv_obj_draw_part_dsc_t*)lv_event_get_param(e); if (dsc->part == LV_PART_ITEMS) { uint32_t row = dsc->id / lv_table_get_col_cnt(table1); uint32_t col = dsc->id - row * lv_table_get_col_cnt(table1); // dsc->label_dsc->align = LV_TEXT_ALIGN_CENTER;//文字居中 if (row == selected_row) { dsc->rect_dsc->bg_color = lv_color_hex(0xD9D6C3); dsc->rect_dsc->bg_opa = LV_OPA_60; } } } // 表格的事件回撥函式 static void table_event_cb(lv_event_t * e) { // lv_obj_t * obj = lv_event_get_target(e); lv_obj_t * obj = table1; uint16_t col, row; lv_table_get_selected_cell(obj, &row, &col); // 獲取被按下的單元格 // mydebugNum(row); // mydebugNum(col); if(selected_row == row) { mydebugNum(selected_row); mask_obj_show(lv_table_get_cell_value(obj,row, 1)); } else { selected_row = row; mydebugNum(selected_row); } } static void create_table_and_styles(void) { // 建立表格 #define table_header_height 60 #define table_header_offset 15 lv_obj_t * table_col = lv_table_create(appObjUiParent); lv_table_set_col_cnt(table_col, 4); // 假定有4列 lv_table_set_row_cnt(table_col, 1); // 假定有1 lv_obj_set_size(table_col, lv_obj_get_width(appObjUiParent)-200, table_header_height); lv_table_set_cell_value(table_col, 0, 0, "ID"); lv_table_set_cell_value(table_col, 0, 1, "NAME"); lv_table_set_cell_value(table_col, 0, 2, "TEL"); lv_table_set_cell_value(table_col, 0, 3, "IDENTIFY"); lv_obj_set_style_text_align(table_col,LV_TEXT_ALIGN_CENTER,LV_PART_ITEMS); lv_obj_set_style_bg_color(table_col,lv_color_hex(0xD3D7D4),LV_PART_ITEMS); lv_obj_set_style_border_side(table_col,LV_BORDER_SIDE_NONE,LV_PART_ITEMS); lv_obj_set_style_bg_color(table_col,lv_color_hex(0xD3D7D4),LV_PART_MAIN); int col_w[]={120,180,200,300}; for(uint16_t col = 0; col < lv_table_get_col_cnt(table_col); col++){lv_table_set_col_width(table_col, col, col_w[col]);} lv_obj_align(table_col, LV_ALIGN_TOP_MID, 0, table_header_offset); table1 = lv_table_create(appObjUiParent); lv_table_set_col_cnt(table1, 4); // 假定有4列 lv_table_set_row_cnt(table1, 100); // 假定有10行 lv_obj_set_size(table1, lv_obj_get_width(appObjUiParent)-200, lv_obj_get_height(appObjUiParent)-table_header_offset*2-table_header_height); // int col_w[]={100,150,200,430}; for(uint16_t col = 0; col < lv_table_get_col_cnt(table1); col++){lv_table_set_col_width(table1, col, col_w[col]);} lv_obj_set_style_text_align(table1,LV_TEXT_ALIGN_CENTER,LV_PART_ITEMS); lv_obj_set_style_bg_color(table1,lv_color_hex(0xF6F5EC),LV_PART_ITEMS); lv_obj_set_style_border_width(table1,2,LV_PART_ITEMS); lv_obj_set_style_border_side(table1,LV_BORDER_SIDE_BOTTOM,LV_PART_ITEMS); lv_obj_set_style_bg_color(table1,lv_color_hex(0xF6F5EC),LV_PART_MAIN); lv_obj_align(table1, LV_ALIGN_TOP_MID, 0, table_header_height+table_header_offset); // 設定表格單元格的內容,此處以文字"Cell x-y"為例 for(uint16_t row = 0; row < lv_table_get_row_cnt(table1); row++) { // lv_table_set_cell_value_fmt(table1, row, col, "Cell %d-%d", row, col); // lv_table_set_cell_value_fmt(table1, row, 0, "%d", 65530-row); lv_table_set_cell_value(table1, row, 0, "---"); lv_table_set_cell_value_fmt(table1, row, 1, "name_%d", row); lv_table_set_cell_value_fmt(table1, row, 2, "15597683%d", 999-row); lv_table_set_cell_value_fmt(table1, row, 3, "41132519950707%d", 9999-row); } // for(uint16_t col = 0; col < lv_table_get_col_cnt(table1); col++) { } // 重繪事件 lv_obj_add_event_cb(table1, table_event_begin_cb, LV_EVENT_DRAW_PART_BEGIN, NULL); // 設定表格的事件回撥 lv_obj_add_event_cb(table1, table_event_cb, LV_EVENT_CLICKED, NULL); } static void timerCameraShow(lv_timer_t* timer){ // if(appObjCamera==NULL){ // mydebugUs; // lv_timer_del(timer); // return; // } // } static int HandleRecv(int type,void* param,int len){ return 0; } //釋放 static int Release(void){ appObjCamera=NULL; infoTextareaMeterPasswdValue=NULL; appObjInfoData=NULL; lv_group_del(appGroupBtn); mydebug; return 0; } static void TIME_TEST_PAGE_TIP3333(lv_timer_t* timer){ HandlePageLevelUp(); } //初始化 static int Init(void){ mydebug; for(int i=0;i<(sizeof(objs)/sizeof(StructObject));i++){ HandleCreateObject(appObjUiParent,&objs[i]); } // 建立表格和樣式 create_table_and_styles(); create_mask_obj(); mask_obj_hide(); // lv_timer_set_repeat_count(lv_timer_create(TIME_TEST_PAGE_TIP3333,3000,NULL),1); // lv_timer_create(timerCameraShow, 5, NULL); appGroupBtn = lv_group_create(); currentAppUseDefaultButtonGroup = appGroupBtn;//使用自定義按鈕 currentAppFuncRelease=Release; currentAppFuncHandleKey=NULL; currentAppFuncHandleRecv=NULL; //自動跳轉 // lv_timer_set_repeat_count(lv_timer_create(mytime,5000,NULL),1); // lv_timer_set_repeat_count(lv_timer_create(timerCameraHandle__,2000,NULL),1); return 0; } //預處理 int PreproccessLanguageSelect(void) { listHandlePageInit[APP_UI_MENU_LANGUAGE] = Init; return 0; }
//