From 93735778805009cd02854bbff30842eb75fb4e83 Mon Sep 17 00:00:00 2001 From: xiaojiazhu <258828110@qq.com> Date: Thu, 19 Oct 2023 13:51:19 +0800 Subject: [PATCH] GUI show auto off time. --- .../UIFlowMenuCommonConfirmEventCallback.c | 31 ++++++++++------ .../UIFlowPhoto/UIFlowPhotoEventCallback.c | 6 ++++ .../UIFlowPlay/UIFlowPlayEventCallback.c | 1 + .../UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h | 2 +- .../UIFlowWrnMsg/UIFlowWrnMsgEventCallback.c | 35 ++++++++++++++++++- .../lib/source/sifar/code/include/sf_common.h | 1 + .../sifar/code/source/common/sf_common.c | 5 +++ 7 files changed, 68 insertions(+), 13 deletions(-) diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonConfirm/UIFlowMenuCommonConfirmEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonConfirm/UIFlowMenuCommonConfirmEventCallback.c index ab1297e12..96c4439c2 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonConfirm/UIFlowMenuCommonConfirmEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowMenuCommonConfirm/UIFlowMenuCommonConfirmEventCallback.c @@ -184,6 +184,7 @@ void UIFlowMenuCommonConfirm_OnChildScrClose(lv_obj_t* obj, const LV_USER_EVENT_ } } +static void UIFlowMenuCommonConfirm_MessageBox_ValueChanged(lv_obj_t* obj, uint32_t* value); /*************************************************************************** * @@ -216,14 +217,19 @@ static void UIFlowMenuCommonConfirm_MessageBox_Key(lv_obj_t* obj, uint32_t key) break; } - // case LV_USER_KEY_SHUTTER2: - // { - // if(gp){ - // // printf("ssssssssssssssssssssssssssss send enter key.\n"); - // lv_group_send_data(gp, LV_USER_KEY_SHUTTER2); - // } - // break; - // } + case LV_USER_KEY_SHUTTER2: + { + // if(gp){ + // lv_group_send_data(gp, LV_KEY_ENTER); + // } + // break; + static int todo = 8; + lv_event_send(obj, LV_EVENT_CLICKED, &todo); + break; + // uint32_t todo = 0; + // UIFlowMenuCommonConfirm_MessageBox_ValueChanged(obj, &todo); + break; + } } } @@ -232,14 +238,15 @@ static void UIFlowMenuCommonConfirm_MessageBox_ValueChanged(lv_obj_t* obj, uint3 { if(NULL == value) return; - +printf("============== value = %d\n", *value); if (*value == 0) { const char* msgbox_text = lv_msgbox_get_text(obj); const char* erase_text = lv_plugin_get_string(LV_PLUGIN_STRING_ID_STRID_ERASE_THIS)->ptr; if(strcmp(msgbox_text, erase_text) == 0){ - #if(PLAY_MODE) + printf("delete file.\n"); + // #if(PLAY_MODE) UINT32 uiLockStatus; PB_GetParam(PBPRMID_FILE_ATTR_LOCK, &uiLockStatus); if (uiLockStatus) { @@ -250,7 +257,7 @@ static void UIFlowMenuCommonConfirm_MessageBox_ValueChanged(lv_obj_t* obj, uint3 } UIPlay_Delete(PB_DELETE_ONE); UIPlay_PlaySingle(PB_SINGLE_CURR); - #endif + // #endif UIFlowMenuCommonConfirm_CloseScr(); @@ -352,7 +359,9 @@ void message_box_confirm_msg_event_callback(lv_obj_t* obj, lv_event_t event) /* triggered by button release */ case LV_EVENT_VALUE_CHANGED: + case LV_EVENT_CLICKED: { + printf("=============================================================== LV_EVENT_VALUE_CHANGED\n"); UIFlowMenuCommonConfirm_MessageBox_ValueChanged(obj, (uint32_t*)lv_event_get_data()); break; } diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c index 96d43f16e..e6f7490be 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c @@ -1263,6 +1263,12 @@ static void task_update_icons_timer_cb(lv_task_t* task) { // printf(" task_update_icons_timer_cb\n "); update_icons(); + UINT16 autoOffTime = sf_get_auto_off_time(); + if (autoOffTime >= 160) + { + // printf("tttttttttttttttttttttttttttttttttttt time = %d\n", autoOffTime); + UIFlowWrnMsgAPI_Open_StringID(LV_PLUGIN_STRING_ID_STRID_PLEASE_INSERT_SD, 1000 * 30); + } return; } diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPlay/UIFlowPlayEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPlay/UIFlowPlayEventCallback.c index 5fc6514ec..4db70ad9b 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPlay/UIFlowPlayEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPlay/UIFlowPlayEventCallback.c @@ -1203,6 +1203,7 @@ static void play_video(lv_obj_t *obj) printf("now sotp play the video.\n"); g_PlbData.State = PLB_ST_FULL; lv_plugin_img_set_src(image_play_scr_uiflowplay, LV_PLUGIN_IMG_ID_SF_STOP); + lv_label_set_text_fmt(label_playtime_scr_uiflowplay, "%02d:%02d", 0, 0); g_PlbData.VideoPBSpeed = PLB_FWD_MOV_1x; // Close MoviePlay module. diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h index 5ceba7cbc..4871ae337 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h @@ -32,7 +32,7 @@ typedef enum { FLOWWRNMSG_ISSUE_MAX } FLOWWRNMSG_ISSUE; -void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_time_ms); +void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_time_ms); #endif /*UIFLOWWRNMSGAPI_H*/ diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgEventCallback.c index 6cd670d3e..826752386 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgEventCallback.c @@ -9,6 +9,9 @@ static lv_group_t* gp = NULL; static lv_obj_t* msgbox = NULL; // static const char* btn_map[2] = {NULL, ""}; +static lv_task_t* msgbox_timer = NULL; +static lv_plugin_res_id msgID = -1; +static uint16_t autoClose = 0; static NVTEVT evt = NVTEVT_NULL; @@ -23,12 +26,34 @@ static void set_indev_keypad_group(lv_obj_t* obj) lv_indev_set_group(indev, gp); } -void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_time_ms) +static void task_msgbox_timer_cb(lv_task_t* task) +{ +#define BUF_LENGTH 256 + char buf[BUF_LENGTH] = {0}; + printf(" task_msgbox_timer_cb\n "); + // LV_PLUGIN_STRING_ID_STRID_PLEASE_INSERT_SD + if(LV_PLUGIN_STRING_ID_STRID_PLEASE_INSERT_SD == msgID) + { + const lv_plugin_string_t* string = lv_plugin_get_string(msgID); + + if(string){ + snprintf(buf, BUF_LENGTH, "%s (%d)", string->ptr, autoClose/1000); + lv_msgbox_set_text(msgbox, buf); + } + autoClose = autoClose - 1000; + } + // update_icons(); + return; +} + +void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_time_ms) { if(msgbox){ DBG_WRN("warning message box is already opened and not closed yet, ignore request"); return; } + msgID = id; + autoClose = auto_close_time_ms; #if (DRAM_SIZE_64MB_DISP_OFF == ENABLE) { return; @@ -83,6 +108,9 @@ void UIFlowWrnMsgAPI_Open_StringID(lv_plugin_res_id id, uint16_t auto_close_tim } set_indev_keypad_group(msgbox); + if(msgbox_timer == NULL){ + msgbox_timer = lv_task_create(task_msgbox_timer_cb, 1000, LV_TASK_PRIO_MID, NULL); + } lv_plugin_scr_open(UIFlowWrnMsg, NULL); } @@ -132,6 +160,11 @@ void UIFlowWrnMsgEventCallback(lv_obj_t* obj, lv_event_t event) void UIFlowWrnMsg_CloseScr(NVTEVT e) { + if(msgbox_timer){ + lv_task_del(msgbox_timer); + msgbox_timer = NULL; + // update_selftimer(); + } evt = e; lv_msgbox_start_auto_close(msgbox, 0); } diff --git a/code/lib/source/sifar/code/include/sf_common.h b/code/lib/source/sifar/code/include/sf_common.h index 81416ad53..8d0c6c145 100755 --- a/code/lib/source/sifar/code/include/sf_common.h +++ b/code/lib/source/sifar/code/include/sf_common.h @@ -21,6 +21,7 @@ void sf_set_pir_power_off_flag(BOOL flag); BOOL sf_get_pir_statu_flag(void); void sf_set_pir_statu_flag(BOOL flag); void sf_set_auto_off_time(UINT16 time); +UINT16 sf_get_auto_off_time(void); UINT8 sf_get_fw_update(void); void sf_set_fw_update(UINT8 flag); UINT8 sf_get_module_update(void); diff --git a/code/lib/source/sifar/code/source/common/sf_common.c b/code/lib/source/sifar/code/source/common/sf_common.c index 31cdfad4e..ff67e5069 100755 --- a/code/lib/source/sifar/code/source/common/sf_common.c +++ b/code/lib/source/sifar/code/source/common/sf_common.c @@ -158,6 +158,11 @@ void sf_set_auto_off_time(UINT16 time) AutoOfftime = time; } +UINT16 sf_get_auto_off_time(void) +{ + return AutoOfftime; +} + void sf_set_wifi_socket(int fd) { WifiSocket = fd;