From d8c26975bd34f51c2db4ec3684ac832667b36f36 Mon Sep 17 00:00:00 2001 From: xiaojiazhu Date: Fri, 17 Nov 2023 14:47:56 +0800 Subject: [PATCH] Fixed bug of password screen. --- .../UIFlowPasswordEventCallback.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPassword/UIFlowPasswordEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPassword/UIFlowPasswordEventCallback.c index 482d3bbeb..625eb75bc 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPassword/UIFlowPasswordEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPassword/UIFlowPasswordEventCallback.c @@ -1,6 +1,7 @@ #include "PrjInc.h" #include "UIFlowLVGL/UIFlowLVGL.h" #include "UIFlowLVGL/UIFlowWrnMsg/UIFlowWrnMsgAPI.h" +#include "UIFlowLVGL_SPORTCAM.h" #include "sf_mcu.h" #include "sf_common.h" #include @@ -32,6 +33,8 @@ static const char* PasswordMap[7] = }; #define LONG_PRESS_INTERVAL 500 static unsigned long KeyRightPressingTimeMs = 0; +static unsigned long KeyUpPressingTimeMs = 0; +static unsigned long KeyDownPressingTimeMs = 0; static lv_group_t* gp = NULL; static void set_indev_keypad_group(lv_obj_t* obj) @@ -228,6 +231,11 @@ static void UIFlowPassword_Key(lv_obj_t* obj, uint32_t key) switch(key) { case LV_USER_KEY_NEXT: + if (KeyDownPressingTimeMs >= LONG_PRESS_INTERVAL) + { + KeyDownPressingTimeMs = 0; + break; + } printf("\033[33m[UIFlowPassword_Key]s\033[0m\n"); if(PasswordIndex >= 0 && PasswordIndex <= 5) { @@ -236,6 +244,11 @@ static void UIFlowPassword_Key(lv_obj_t* obj, uint32_t key) update_Password_msg(obj); break; case LV_USER_KEY_PREV: + if (KeyUpPressingTimeMs >= LONG_PRESS_INTERVAL) + { + KeyUpPressingTimeMs = 0; + break; + } printf("\033[33m[UIFlowPassword_Key]w\033[0m\n"); if(PasswordIndex >= 0 && PasswordIndex <= 5) { @@ -313,6 +326,32 @@ void UIFlowPassword_KeyLongPress(lv_obj_t* obj, uint32_t key) printf("Super password is wrong.\n"); break; } + case LV_USER_KEY_NEXT: + { + KeyDownPressingTimeMs += LONG_PRESS_INTERVAL; + if (KeyDownPressingTimeMs % 1000 == 0) + { + if(PasswordIndex >= 0 && PasswordIndex <= 5) + { + PwdStr[PasswordIndex] = (PwdStr[PasswordIndex] - '0' + 10 - 1) % 10 + '0'; + } + update_Password_msg(obj); + } + break; + } + case LV_USER_KEY_PREV: + { + KeyUpPressingTimeMs += LONG_PRESS_INTERVAL; + if (KeyUpPressingTimeMs % 1000 == 0) + { + if(PasswordIndex >= 0 && PasswordIndex <= 5) + { + PwdStr[PasswordIndex] = (PwdStr[PasswordIndex] - '0' + 1) % 10 + '0'; + } + update_Password_msg(obj); + } + break; + } default: break; }