From c889eebc43eab049307189f1639a52793142ff7d Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Thu, 14 Dec 2023 19:48:07 +0800 Subject: [PATCH] =?utf8?q?=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89BUTTON2?= =?utf8?q?=E7=9A=84Function=E8=83=BD=E5=8A=9B=EF=BC=88=E5=A4=8D=E5=88=B6Po?= =?utf8?q?wer=E9=94=AE=E8=83=BD=E5=8A=9B=EF=BC=89=E5=92=8CPower=E9=94=AE?= =?utf8?q?=E7=9A=84=E8=83=BD=E5=8A=9B(Home=E7=95=8C=E9=9D=A2=E5=85=B3?= =?utf8?q?=E9=97=ADLCD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/key/src/KeyInputListener.cpp | 30 +++++++++++++++---- .../wstp/at_service/app/app_at_process.c | 12 +++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp index de89274d8..ede223eed 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/key/src/KeyInputListener.cpp @@ -53,6 +53,7 @@ void KeyInputListener::OnKeyLongPress(const KeyEvent& event) longPressFlag = 1; // 长按标志 uint16 keyID = event.GetKeyId(); + WEARABLE_LOGD("","into key! keyID %u\n",keyID); if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 // 切换到关机/重启卡片 NativeAbility::GetInstance().ChangeSlice(VIEW_REBOOT); @@ -77,17 +78,23 @@ void KeyInputListener::CallVolumeDipSwitchControl(uint8_t model) } } } - +extern "C" { + uint32_t mcu_pm_lcd_on(uint8_t *para, uint32_t para_len); + uint32_t mcu_pm_lcd_off(uint8_t *para, uint32_t para_len); + uint8_t mcu_pms_is_screen_on(void); +} void KeyInputListener::OnKeyRelease(const KeyEvent& event) { uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); uint16 keyID = event.GetKeyId(); if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { // 电源按键 if (longPressFlag == 0 && pressFlag == 1) { // 短按电源键 - if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片 + + + if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片 // 音量+ CallVolumeDipSwitchControl(1); - } else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘 + }else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘 PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM); } else { @@ -95,7 +102,12 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event) if (!MainViewSample::GetInstance()->IsMainView()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面 NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TRANSITION_ZOOM); + //power键要进入休眠 + if(mcu_pms_is_screen_on()){ + mcu_pm_lcd_off(NULL,0); + }else{ + mcu_pm_lcd_on(NULL,0); + } } } } @@ -104,8 +116,16 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event) if (currentViewId == VIEW_MAEKPHONE_SAMPLE || IsCallingNotify() == true) { // 音量卡片 // 音量- CallVolumeDipSwitchControl(0); + } else if (currentViewId != VIEW_MAIN_SAMPLE) { // 主表盘 + PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE, TRANSITION_ZOOM); } else { - // 切换到用户配置的快捷卡片 + PressAlarmNotify(); // 当前为闹钟通知页面时,先处理闹钟再切换页面 + if (!MainViewSample::GetInstance()->IsMainView()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面 + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } else { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TRANSITION_ZOOM); + } } } } diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index ab0ece693..2be8e1a47 100755 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -2309,7 +2309,17 @@ static uint32_t mcu_pms_set_screen_state(uint8_t *para, uint32_t para_len) } return ERRCODE_SUCC; } - +uint8_t mcu_pms_is_screen_on(void) +{ + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + screen_state_t state = display_api->get_screen_state(); + wstp_print("app get screen state = %u, on is %u, off is %u. \r\n", state, SCREEN_ON, SCREEN_OFF); + if( state == SCREEN_ON){ + return 1; + }else{ + return 0; + } +} static uint32_t mcu_pms_get_screen_state(uint8_t *para, uint32_t para_len) { unused(para_len); -- 2.17.1