From 989cde72389e248b3b801135e15a9942d1209beb Mon Sep 17 00:00:00 2001 From: zyj Date: Thu, 9 Nov 2023 16:07:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Date&Time=E7=9A=84UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIFlowMenuCommonItem/MenuGeneral.c | 211 ++++++++++++++++-- .../UIFlowMenuCommonItem/MenuGeneral.h | 1 + .../UIFlowMenuCommonOptionEventCallback.c | 5 + 3 files changed, 194 insertions(+), 23 deletions(-) diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.c index 3fb8e8d05..17b3eafa0 100644 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.c @@ -1047,6 +1047,9 @@ void Option_Operating_Time_Key(lv_obj_t* obj, uint32_t key) // -------------------------------------------------------------------------- static int DateTimeIndex = 0; static lv_obj_t* DateTimeMatrixObj = NULL; +static lv_obj_t* DateTimeImage = NULL; +static lv_obj_t* DateTimeLabel1 = NULL; +static lv_obj_t* DateTimeLabel2 = NULL; static SF_PARA_TIME_S gDateTime; static char DateTimeMOBuf[3] = {'0', '1', 0}; static char DateTimeDDBuf[3] = {'0', '1', 0}; @@ -1072,6 +1075,12 @@ static const char* DateTimeMap[12] = static void update_DateTime_Time_msg(lv_obj_t* obj) { + if(DateTimeMatrixObj == NULL || DateTimeImage == NULL) + { + DBG_ERR("DateTime component is not initialized"); + return; + } + // UIMenuStoreInfo *puiPara = sf_ui_para_get(); snprintf(DateTimeMOBuf, 3, "%02d", gDateTime.Mon); snprintf(DateTimeDDBuf, 3, "%02d", gDateTime.Day); @@ -1079,14 +1088,32 @@ static void update_DateTime_Time_msg(lv_obj_t* obj) snprintf(DateTimeHHBuf, 3, "%02d", gDateTime.Hour); snprintf(DateTimeMIBuf, 3, "%02d", gDateTime.Min); snprintf(DateTimeSSBuf, 3, "%02d", gDateTime.Sec); + lv_btnmatrix_set_map(DateTimeMatrixObj, DateTimeMap); lv_btnmatrix_set_focused_btn(DateTimeMatrixObj, DateTimeIndex); - lv_btnmatrix_set_map(DateTimeMatrixObj, DateTimeMap); + + if(DateTimeIndex == 0) + lv_obj_set_x(DateTimeImage, 20); + else if(DateTimeIndex == 2) + lv_obj_set_x(DateTimeImage, 60); + else if(DateTimeIndex == 4) + lv_obj_set_x(DateTimeImage, 112); + else if(DateTimeIndex == 6) + lv_obj_set_x(DateTimeImage, 188); + else if(DateTimeIndex == 8) + lv_obj_set_x(DateTimeImage, 228); + else //if(DateTimeIndex == 10) + lv_obj_set_x(DateTimeImage, 268); } void show_DateTime_page(lv_obj_t* obj, int defaultTime) { - OperatingTimeIndex = 0; + if(DateTimeMatrixObj != NULL || DateTimeImage != NULL || DateTimeLabel1 != NULL || DateTimeLabel2 != NULL) + { + DBG_ERR("DateTime component is initialized"); + return; + } + DateTimeIndex = 0; init_Matrix_style(); @@ -1124,48 +1151,84 @@ void show_DateTime_page(lv_obj_t* obj, int defaultTime) lv_obj_set_hidden(DateTimeMatrixObj, false); lv_obj_set_click(DateTimeMatrixObj, true); lv_obj_set_drag(DateTimeMatrixObj, false); - lv_obj_set_pos(DateTimeMatrixObj, 25, 58); - lv_obj_set_size(DateTimeMatrixObj, 270, 140); + lv_obj_set_pos(DateTimeMatrixObj, 20, 108); + lv_obj_set_size(DateTimeMatrixObj, 280, 24); lv_btnmatrix_set_map(DateTimeMatrixObj, DateTimeMap); lv_btnmatrix_set_one_check(DateTimeMatrixObj, true); lv_btnmatrix_set_align(DateTimeMatrixObj, LV_LABEL_ALIGN_CENTER); lv_btnmatrix_set_focused_btn(DateTimeMatrixObj,0); lv_btnmatrix_set_one_check(DateTimeMatrixObj, false); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 0, 2); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 2, 2); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 4, 4); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 6, 2); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 8, 2); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 10, 2); - lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 5, 2); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 0, 4); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 2, 4); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 4, 7); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 6, 4); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 8, 4); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 10, 4); + lv_btnmatrix_set_btn_width(DateTimeMatrixObj, 5, 4); lv_obj_add_style(DateTimeMatrixObj, 0, &gMatrixStylebg); lv_obj_add_style(DateTimeMatrixObj, 1, &gMatrixStylebtn); + + DateTimeImage = lv_img_create(obj, NULL); + lv_obj_set_hidden(DateTimeImage, false); + lv_obj_set_click(DateTimeImage, false); + lv_obj_set_drag(DateTimeImage, false); + lv_obj_set_pos(DateTimeImage, 20, 78); + lv_obj_set_size(DateTimeImage, 32, 88); + lv_img_set_src(DateTimeImage, &sf_pwd_down_up); + + static lv_style_t LabelStyle = {0}; + lv_style_init(&LabelStyle); + lv_style_copy(&LabelStyle, &gStyleLabel0); + lv_style_set_text_font(&LabelStyle,LV_STATE_DEFAULT,&sf_ui_text_bold_20_1bpp); + DateTimeLabel1 = lv_label_create(obj, NULL); + lv_label_set_text(DateTimeLabel1, "Date Time"); + lv_obj_set_pos(DateTimeLabel1, 56, 60); + lv_obj_set_size(DateTimeLabel1, 200, 24); + lv_obj_add_style(DateTimeLabel1, 0, &LabelStyle); + + DateTimeLabel2 = lv_label_create(obj, NULL); + lv_label_set_text(DateTimeLabel2, "MM:DD:YYYY MM:DD:SS"); + lv_label_set_align(DateTimeLabel2, LV_LABEL_ALIGN_CENTER); + lv_obj_set_pos(DateTimeLabel2, 28, 155); + lv_obj_set_size(DateTimeLabel2, 270, 21); + lv_obj_add_style(DateTimeLabel2, 0, &gStyleLabel0); } void hidde_DateTime_page(void) { + printf("[%s]\n", __FUNCTION__); + DateTimeIndex = 0; if(DateTimeMatrixObj) { lv_obj_del(DateTimeMatrixObj); + DateTimeMatrixObj = NULL; + } + if(DateTimeImage) + { + lv_obj_del(DateTimeImage); + DateTimeImage = NULL; + } + if(DateTimeLabel1) + { + lv_obj_del(DateTimeLabel1); + DateTimeLabel1 = NULL; + } + if(DateTimeLabel2) + { + lv_obj_del(DateTimeLabel2); + DateTimeLabel2 = NULL; } } void Option_DateTime_Key(lv_obj_t* obj, uint32_t key) { - if(DateTimeMatrixObj == NULL) - { - printf("DateTimeMatrixObj is NULL"); - return; - } + printf("[%s]key:%d\n", __FUNCTION__, key); - // char result[2]; UIMenuStoreInfo *puiPara = sf_ui_para_get(); - printf("key:%d\n",key); switch(key) { case LV_USER_KEY_NEXT: - printf("\033[33m[Option_DateTime_Key]s\033[0m\n"); if(DateTimeIndex == 0) { if(gDateTime.Mon > 0 && gDateTime.Mon <= 12) @@ -1211,7 +1274,6 @@ void Option_DateTime_Key(lv_obj_t* obj, uint32_t key) update_DateTime_Time_msg(obj); break; case LV_USER_KEY_PREV: - printf("\033[33m[Option_DateTime_Key]w\033[0m\n"); if(DateTimeIndex == 0) { if(gDateTime.Mon >= 12) @@ -1257,17 +1319,14 @@ void Option_DateTime_Key(lv_obj_t* obj, uint32_t key) update_DateTime_Time_msg(obj); break; case LV_USER_KEY_LEFT: - printf("\033[33m[Option_DateTime_Key]a\033[0m\n"); DateTimeIndex = (DateTimeIndex - 2 + 12) % 12; update_DateTime_Time_msg(obj); break; case LV_USER_KEY_RIGHT: - printf("\033[33m[Option_DateTime_Key]d\033[0m\n"); DateTimeIndex = (DateTimeIndex + 2) % 12; update_DateTime_Time_msg(obj); break; case LV_KEY_ENTER: - printf("\033[33m[Option_DateTime_Key]SELECT\033[0m\n"); puiPara->DateAuto = SF_DATE_MANUAL; sf_sys_rtc_time_set(&gDateTime); system("hwclock -s"); @@ -1281,3 +1340,109 @@ void Option_DateTime_Key(lv_obj_t* obj, uint32_t key) } } +void Option_DateTime_Key_Long_Press(lv_obj_t* obj, uint32_t key) +{ + printf("[%s]key:%d\n", __FUNCTION__, key); + + switch(key) + { + case LV_USER_KEY_NEXT: + if(DateTimeIndex == 0) + { + if(gDateTime.Mon > 0 && gDateTime.Mon <= 12) + gDateTime.Mon--; + else + gDateTime.Mon = 12; + } + else if(DateTimeIndex == 2) + { + if(gDateTime.Day > 0 && gDateTime.Day <= 31) + gDateTime.Day--; + else + gDateTime.Day = 31; + } + else if(DateTimeIndex == 4) + { + if(gDateTime.Year > 0 && gDateTime.Year <= 4000) + gDateTime.Year--; + else + gDateTime.Year = 4000; + } + else if(DateTimeIndex == 6) + { + if(gDateTime.Hour > 0 && gDateTime.Hour <= 23) + gDateTime.Hour--; + else + gDateTime.Hour = 23; + } + else if(DateTimeIndex == 8) + { + if(gDateTime.Min > 0 && gDateTime.Min <= 59) + gDateTime.Min--; + else + gDateTime.Min = 59; + } + else if(DateTimeIndex == 10) + { + if(gDateTime.Sec > 0 && gDateTime.Sec <= 59) + gDateTime.Sec--; + else + gDateTime.Sec = 59; + } + update_DateTime_Time_msg(obj); + break; + case LV_USER_KEY_PREV: + if(DateTimeIndex == 0) + { + if(gDateTime.Mon >= 12) + gDateTime.Mon = 0; + else + gDateTime.Mon++; + } + else if(DateTimeIndex == 2) + { + if(gDateTime.Day >= 31) + gDateTime.Day = 0; + else + gDateTime.Day++; + } + else if(DateTimeIndex == 4) + { + if(gDateTime.Year >= 4000) + gDateTime.Year = 0; + else + gDateTime.Year++; + } + else if(DateTimeIndex == 6) + { + if(gDateTime.Hour >= 23) + gDateTime.Hour = 0; + else + gDateTime.Hour++; + } + else if(DateTimeIndex == 8) + { + if(gDateTime.Min >= 59) + gDateTime.Min = 0; + else + gDateTime.Min++; + } + else if(DateTimeIndex == 10) + { + if(gDateTime.Sec >= 59) + gDateTime.Sec = 0; + else + gDateTime.Sec++; + } + update_DateTime_Time_msg(obj); + break; + case LV_USER_KEY_LEFT: + break; + case LV_USER_KEY_RIGHT: + break; + case LV_KEY_ENTER: + break; + default: + break; + } +} diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.h b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.h index a68e147b4..da54980d8 100644 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.h +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonItem/MenuGeneral.h @@ -26,6 +26,7 @@ extern void Option_Delay_Key_Long_Press(lv_obj_t* obj, uint32_t key); extern void Option_Operating_Time_Key(lv_obj_t* obj, uint32_t key); extern void Option_Operating_Time_Key_Long_Press(lv_obj_t* obj, uint32_t key); extern void Option_DateTime_Key(lv_obj_t* obj, uint32_t key); +extern void Option_DateTime_Key_Long_Press(lv_obj_t* obj, uint32_t key); extern unsigned int get_dig_pir_level(void); #endif diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c index 3b503c6f7..950fd82f9 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonOption/UIFlowMenuCommonOptionEventCallback.c @@ -870,6 +870,11 @@ void UIFlowMenuCommonOptionEventCallback(lv_obj_t* obj, lv_event_t event) if(KeyPressingTimeMs > 1 * 1000) Option_Operating_Time_Key_Long_Press(obj, *key); break; + case IDM_DATE_AND_TIME: + KeyPressingTimeMs += LONG_PRESS_INTERVAL; + if(KeyPressingTimeMs > 1 * 1000) + Option_DateTime_Key_Long_Press(obj, *key); + break; default: break; }