From e29484b6d9adeedfe09e3b26ed63b97f729ded26 Mon Sep 17 00:00:00 2001 From: cheng Date: Sat, 10 Aug 2024 18:46:02 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E6=8A=AC=E8=85=95=E4=BA=AE?= =?utf8?q?=E5=B1=8F=E7=BF=BB=E8=85=95=E7=81=AD=E5=B1=8F=EF=BC=8C=E5=A2=9E?= =?utf8?q?=E5=8A=A0=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../peripheral/config/include/ConfigModelC.h | 3 ++ .../peripheral/config/src/ConfigModel.cpp | 6 ++++ .../drivers/peripheral/cywee/src/main_dml.c | 15 ++------ .../drivers/peripheral/utils/custom_utils.c | 36 +++++++++++++++++++ .../drivers/peripheral/utils/custom_utils.h | 5 +++ 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index 92f0412e7..4072d1847 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -102,6 +102,9 @@ int get_sedentary_time_from_config_model(void); //设置睡眠频率 void set_config_heart(int heartRateDetectionFreq); +// for c file +bool mmi_flip_wrist_switch_get(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 393bd53f8..4ecbe79e7 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1518,6 +1518,12 @@ int get_sedentary_time_from_config_model(void) return sedentary_time; } +// get flip wrist switch for c file +bool mmi_flip_wrist_switch_get(void) +{ + return (OHOS::ConfigModel::GetInstance()->get_configData_bool(OHOS::ConfigModel::CONFIGMODEL_ITEM_RAISE_TO_WAKE)); +} + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 206b55974..80d7e6d1a 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -667,26 +667,17 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { break; case IDX_ALGO_WATCH_HANDUP: CWM_OS_dbgPrintf("HANDUP_DOWN MSG [%d]\n",(int)sensorEVT->fData[1]); - #if defined(SUPPORT_POWER_MANAGER) - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - #endif if ((int)sensorEVT->fData[1] == 2) { #if defined(SUPPORT_POWER_MANAGER) - //display_api->set_screen_set_keepon_timeout(0); CWM_OS_dbgPrintf("[cwyee] turn_off_screen"); + mmi_screen_on_off_by_flip_wrist(false); #endif }else if ((int)sensorEVT->fData[1] == 1) { #if defined(SUPPORT_POWER_MANAGER) - if (display_api->get_screen_state() != SCREEN_ON) - { - CWM_OS_dbgPrintf("[cwyee] turn_on_screen"); - display_api->turn_on_screen(); - } - // display_api->set_screen_set_keepon_timeout(0); - // display_api->set_screen_set_keepon_timeout(1000); - // uapi_setScreenDuration(1000); + CWM_OS_dbgPrintf("[cwyee] turn_on_screen"); + mmi_screen_on_off_by_flip_wrist(true); #endif } break; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 55eb4cf6a..204b77e4a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1020,6 +1020,7 @@ errcode_t uapi_get_WeekStr(char *p_week) /// @brief 控制屏幕是否常亮 /// @param turnOnFlag 1:常亮屏幕 /// @param turnOnFlag 0:取消常亮 +static bool s_screen_always_on = false; void ScreenAlwaysOnCtr(uint8_t turnOnFlag) { const power_display_svr_api_t *display_api = power_display_svr_get_api(); @@ -1033,10 +1034,45 @@ void ScreenAlwaysOnCtr(uint8_t turnOnFlag) } //当设置的值是-1 的时候,设置屏幕常亮 display_api->set_screen_set_keepon_timeout(-1); + s_screen_always_on = true; } else { display_api->set_screen_set_keepon_timeout(0); + s_screen_always_on = false; + } +} + +// Is the screen always on +bool mmi_screen_always_on_flag_get(void) +{ + return s_screen_always_on; +} + +// value: +// true-turn on screen +// false-turn off screen +void mmi_screen_on_off_by_flip_wrist(bool value) +{ + if(false == mmi_flip_wrist_switch_get()) + { + return; + } + + const power_display_svr_api_t * display_api = power_display_svr_get_api(); + if (false == value) + { + if(false == mmi_screen_always_on_flag_get()) + { + display_api->turn_off_screen(); + } + } + else + { + if (SCREEN_ON != display_api->get_screen_state()) + { + display_api->turn_on_screen(); + } } } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 7ce3caf52..9514c4204 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -102,6 +102,11 @@ char *uapi_get_local_yyyymmdd_date(void); void ScreenAlwaysOnCtr(uint8_t turnOnFlag); +// Is the screen always on +bool mmi_screen_always_on_flag_get(void); + +void mmi_screen_on_off_by_flip_wrist(bool value); + void uapi_setScreenBrightness(int value); void uapi_setScreenDuration(int32_t time); -- 2.17.1