* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-10 21:13:23
+ * @LastEditTime: 2024-07-12 10:23:32
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/include/RebootModel.h
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%A
*/
void SetExitsView(bool value);
bool RegisterPowerKeyLongPressEvent(void);
bool RegisterPowerKeyDoubleClickEvent(void);
+ bool RegisterFuncKeyPressEvent(void);
+ bool RegisterFuncKeyLongPressEvent(void);
bool RegisterFuncKeyClickEvent(void);
bool RegisterFuncKeyDoubleClickEvent(void);
void RegisterAllKeyEvents(void);
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-28 11:50:42
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-11 20:16:48
+ * @LastEditTime: 2024-07-12 10:42:15
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp
*/
int32_t ret = uapi_button_register_event_cb(HandlePowerKeyDoubleClick, BUTTON_PWR_CLICKUP_2);
if (ret != ERRCODE_SUCC)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Click Event error, ret = %d", ret);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey DoubleClick Event error, ret = %d", ret);
+ return false;
+ }
+ return true;
+ }
+
+ static void HandFuncKeyOnPress(void)
+ {
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+ if (!display_api)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+ return;
+ }
+ display_api->turn_on_screen();
+ return;
+ }
+
+ /*注册功能键的按下事件*/
+ bool RebootModel::RegisterFuncKeyPressEvent(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyPressEvent");
+ // Register FuncKey Press event here
+ int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnPress, BUTTON1_PRESS);
+ if (ret != ERRCODE_SUCC)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Press Event error, ret = %d", ret);
+ return false;
+ }
+ return true;
+ }
+
+ static void HandFuncKeyOnLongPress(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandFuncKeyOnLongPress");
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+ if (!display_api)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+ return;
+ }
+
+ if (display_api->get_screen_state() == SCREEN_ON)
+ {
+ uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+ if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面不做切换
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched");
+ return;
+ }
+ // 全局切换到Ai语音界面
+ NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE);
+ }
+ else
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping AI voice change");
+ }
+ }
+
+ /*注册功能键的长按(2s)事件*/
+ bool RebootModel::RegisterFuncKeyLongPressEvent(void)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootModel::RegisterFuncKeyLongPressEvent");
+ int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S);
+ if (ret != ERRCODE_SUCC)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event error, ret = %d", ret);
return false;
}
return true;
{
RegisterPowerKeyDoubleClickEvent();
RegisterPowerKeyLongPressEvent();
+ RegisterFuncKeyPressEvent();
+ RegisterFuncKeyLongPressEvent();
RegisterFuncKeyClickEvent();
RegisterFuncKeyDoubleClickEvent();
}
power_off_cat1();
}
uapi_gei_btmac_and_chipinfo();
- uapi_func_lcd_on();
}
void startup_post_init(void)
wstp_print("^^^^ BTMAC=%s ^^^^ CyweeChipInfo=%s\n",btaddr_str,chipinfo);
}
-
-static void func_button_callback_press(void)
-{
- const power_display_svr_api_t *display_api = power_display_svr_get_api();
- display_api->turn_on_screen();
-}
-
-void uapi_func_lcd_on(void)
-{
- uapi_button_register_event_cb(func_button_callback_press, 24);
-}
\ No newline at end of file