From: penglei <1624952103@qq.com> Date: Mon, 14 Jul 2025 07:37:24 +0000 (+0800) Subject: 优化底层服务 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~210^2~33^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1958%2Fhead;p=mirrors%2FFD230.git 优化底层服务 --- diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index 0db4ec7fe..f1832a784 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -552,9 +552,6 @@ static void thread_main(const void *unused) #endif -#ifdef ENABLE_CUSTOM_SPI - custom_spi_init(SPI_BUS_0); -#endif /*启动蓝牙ble服务,cywee有重置 mac地址的操作,会需要把 蓝牙服务开启放在cywee服务之后*/ #ifdef CUSTOM_UTILS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index ade20a322..5adfefe27 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-22 16:37:02 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-14 15:27:15 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp */ #include "AppViewIDs.h" @@ -28,7 +28,9 @@ #include "custom_runtime.h" #include "NativeRegisterManager.h" - +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif namespace OHOS { REGIST_SLICE(VIEW_DISPLAY_BRIGHTNESS, DisplayBrightnessView, DisplayBrightnessPresenter); @@ -230,12 +232,16 @@ namespace OHOS { case UICheckBox::SELECTED: WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched on!"); - uapi_take_to_wake(WRIST_RAISE_TO_WAKE_ENABLED); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(WRIST_RAISE_TO_WAKE_ENABLED); // 关闭抬腕亮屏,和息屏 +#endif mmi_flip_wrist_switch_set(true); break; case UICheckBox::UNSELECTED: WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched off!"); - uapi_take_to_wake(WRIST_RAISE_TO_WAKE_DISENABLED); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(WRIST_RAISE_TO_WAKE_DISENABLED); // 关闭抬腕亮屏,和息屏 +#endif mmi_flip_wrist_switch_set(false); break; default: diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp index cf9c3977c..997c0c32a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp @@ -19,6 +19,9 @@ #include "NativeAbility.h" #include #include "uiservice/include/ui_service.h" +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif namespace OHOS { @@ -100,7 +103,9 @@ namespace OHOS uapi_set_screen_on_api(); // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏 - uapi_take_to_wake(0); // 关闭抬腕亮屏,和息屏 +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif NativeAbility::GetInstance().SetCurSlicePriority(0); // 设置Slice优先级为最高,防止弹窗出现 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleepmode/src/SleepModeModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleepmode/src/SleepModeModel.cpp index 672dacd88..2883400b1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleepmode/src/SleepModeModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/sleepmode/src/SleepModeModel.cpp @@ -9,7 +9,9 @@ #include "ui_service.h" #include "ConfigModelC.h" #include "power_display_service.h" - +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif namespace OHOS { @@ -40,7 +42,9 @@ namespace OHOS } // disable flip wrist - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif // turn down brightness const power_display_svr_api_t *display_api = power_display_svr_get_api(); @@ -65,7 +69,9 @@ namespace OHOS // enable flip wrist if(true == mmi_flip_wrist_switch_get()) { - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif } // reset brightness diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp index c89191896..5baf89a76 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/msg_center_customer.cpp @@ -65,6 +65,10 @@ #endif #endif +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_hal.h" +#endif + namespace OHOS { #ifdef __cplusplus @@ -598,15 +602,15 @@ void MsgCenterNotifyArAlertProc(const Topic topic, Request* req) void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyInactivityProc !"); - #ifdef SUPPORT_CYWEE_SERVICE - cywee_inactivity_result_t *cywee_Inactivity_Info = (cywee_inactivity_result_t *)malloc(req->len); +#ifdef SUPPORT_CYWEE_SERVICE + inact_result_t *cywee_Inactivity_Info = (inact_result_t *)malloc(req->len); if (!cywee_Inactivity_Info) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure"); return; } - int rets = memcpy_s(cywee_Inactivity_Info, req->len, (cywee_inactivity_result_t*)req->data, req->len); + int rets = memcpy_s(cywee_Inactivity_Info, req->len, (inact_result_t*)req->data, req->len); if (rets != EOK) { free(cywee_Inactivity_Info); @@ -631,7 +635,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) } else if(cywee_Inactivity_Info->status==9) { - set_stand_falg(); + cywee_set_stand_flag(); } break; default: @@ -640,7 +644,7 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) free(cywee_Inactivity_Info); cywee_Inactivity_Info = NULL; - #endif +#endif } //查找手表通知 diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index 5aa95e8ef..ddf2f183e 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -1012,7 +1012,7 @@ namespace OHOS { // send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE); #ifdef SUPPORT_CYWEE_SERVICE - cywee_log_switch(0); + cywee_set_log_switch(0); #endif WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cwm_ble_switch false"); } @@ -1020,7 +1020,7 @@ namespace OHOS { // send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE); #ifdef SUPPORT_CYWEE_SERVICE - cywee_log_switch(1); + cywee_set_log_switch(1); #endif WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cwm_ble_switch true"); } diff --git a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp index d9be48f58..d731d8a36 100644 --- a/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/fd230/service/msg_center/src/notify/transmitting.cpp @@ -23,6 +23,9 @@ #include "ConfigModelC.h" #include "ConfigModel.h" #include "transmitting.h" +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif // #include "languagecode/LanguageInit.h" namespace OHOS { @@ -159,7 +162,9 @@ namespace OHOS } display_api->set_auto_timeout_function(true); - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif RootView::GetInstance()->Remove(UIViewGroup_transmitting); delete UIViewGroup_transmitting; @@ -1360,7 +1365,9 @@ namespace OHOS display_api->turn_on_screen(); } display_api->set_auto_timeout_function(false); - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(Freetransmitting); diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index d9af678a2..b711eca2f 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -357,6 +357,8 @@ target = { 'SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION', # 'SUPPORT_AT_CUSTOMUTILS', 'SUPPORT_BLE_SERVICE', + 'SUPPORT_PPG_SERVICE', + 'SUPPORT_CYWEE_SERVICE', 'SUPPORT_BATTERY_SERVICE', 'FD230', # 'SUPPORT_AUTO_OTA_SERVER', @@ -384,7 +386,7 @@ target = { 'audio_at_service', 'media_at_service', 'bt_manager_at_service', - "ppg_sensor", + "ppg_sensor_hx3695", # "ppgBleService", "mag_sensor_mmc5603", "vibrator", @@ -401,7 +403,7 @@ target = { "rotary_encoder", "nativelauncher", "ppg_service", - #"cywee_service", + "cywee_service", "batterry_service", "bleservice", "blemoder", @@ -413,9 +415,7 @@ target = { "mag_hal", "mag_service", "cywee_dml", - "cywee_hal", #"cyweeBleService", - "cywee_data", ], 'image_analysis': False, 'fs_image_path':'fd230', @@ -680,7 +680,6 @@ target = { 'CONFIG_PWM_SUPPORT', # 'ACC_LIS2DOC', 'ENABLE_CUSTOM_I2C', - #'ENABLE_CUSTOM_SPI', 'MAG_MMC5603', 'ENABLE_VIBRATOR', 'ENABLE_SLIP', diff --git a/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c b/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c index 9a0f08480..b5e28b1fd 100644 --- a/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c +++ b/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c @@ -404,7 +404,11 @@ ext_errno cst86xx_deinit(void) void cst86xx_get_chip_id(uint16_t *chip_id) { - *chip_id = g_cst86xx_drv.chip_id; + ext_errno ret = cst86xx_tp_i2c_data_read(CST86XX_HW_ID, chip_id, 1); + if (ret != EXT_ERR_SUCCESS) { + tp_err("configuration error (read chip id) 0x%x", ret); + return EXT_ERR_FAILURE; + } } #ifdef __cplusplus diff --git a/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.c b/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.c index aa6f91c5d..40bc8f628 100644 --- a/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.c +++ b/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.c @@ -392,12 +392,12 @@ static ext_errno ft6x46_power_sequence(void) /*get chip id*/ ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); if (ret != EXT_ERR_SUCCESS) { - tp_err("222222222get ic information, error1"); + tp_err("get ic information, error1"); return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID; } ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); if (ret != EXT_ERR_SUCCESS) { - tp_err("3333333get ic information, error2"); + tp_err("get ic information, error2"); return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID; } // tp_print("11111111111111get ic information, chip id = 0x%02x%02x", chip_id[0], chip_id[1]); @@ -973,6 +973,27 @@ ext_errno ft6x46_deinit(void) return EXT_ERR_SUCCESS; } +void ft6x46_get_chip_id(uint16_t *id) +{ + ext_errno ret; + uint8_t chip_id[2] = {0}; + /*get chip id*/ + ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); + if (ret != EXT_ERR_SUCCESS) { + PRINT("get ic information error1"); + } else { + ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); + if (ret != EXT_ERR_SUCCESS) { + PRINT("get ic information error2"); + } else + { + PRINT("TOUCH CHIP ID = 0x%02x%02x \r\n", chip_id[0], chip_id[1]); + *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); + //sprintf(id,"0x%02x%02x", chip_id[0], chip_id[1]); + } + } +} + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.h b/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.h index b0e57762f..ad6cf5c6c 100644 --- a/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.h +++ b/code/sdk/drivers/drivers/driver/touch/ft6x46_touch/ft6x46_touch1.h @@ -412,6 +412,8 @@ ext_errno ft6x46_resume(void); ext_errno ft6x46_suspend(void); ext_errno ft6x46_irq_callback(uint8_t *data_buf, uint8_t data_len); ext_errno ft6x46_host_init_sample(void); +void ft6x46_get_chip_id(uint16_t *id); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c index 84effacc3..c344ceae2 100644 --- a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c +++ b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c @@ -509,3 +509,12 @@ void touch_screen_restart(void) #endif uapi_gpio_enable_interrupt(TOUCH_INT_GPIO); // open tp_int gpio interrupt } + +void touch_getid(uint16_t *id) +{ +#ifdef TPTYPE_FT6X46 + ft6x46_get_chip_id(id); +#elif defined TPTYPE_CST86XX + cst86xx_get_chip_id(id); +#endif +} \ No newline at end of file diff --git a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c index 7faeee72a..2ce09586f 100644 --- a/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c +++ b/code/sdk/middleware/chips/brandy/pm/pm_adapt/pm_core.c @@ -104,23 +104,16 @@ void pm_core_wait_uart_tx_idle(void) #endif void pm_sikey_suspend(void) { - // custom_i2c_suspend(); + custom_i2c_suspend(); -#ifdef ENABLE_CUSTOM_SPI - custom_spi_suspend(); -#endif //ADD alipay I2C3 suspend, alipay_suspend(); } void pm_sikey_resume(void){ - // custom_i2c_resume(); - -#ifdef ENABLE_CUSTOM_SPI - custom_spi_resume(); -#endif - + custom_i2c_resume(); + alipay_resume(); } void pm_core_suspend(void) diff --git a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp index 51e4b05cf..766cdbfef 100644 --- a/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp +++ b/code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp @@ -454,6 +454,9 @@ void ShowGraphicOTALogo(void) void boot_animation_init_deinit(void) { + if(taskcfg.task_handle == NULL) + return; + errcode_t ret = uapi_terminate_thread(taskcfg.task_handle); if(ret != ERRCODE_SUCC) diff --git a/code/sdk/zhihui/4g/cat1Service/include/cat1_utils.h b/code/sdk/zhihui/4g/cat1Service/include/cat1_utils.h index f3eb9cc5d..412bf51aa 100644 --- a/code/sdk/zhihui/4g/cat1Service/include/cat1_utils.h +++ b/code/sdk/zhihui/4g/cat1Service/include/cat1_utils.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-15 11:28:07 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-11 10:48:11 + * @FilePath: /FD230/code/sdk/zhihui/4g/cat1Service/include/cat1_utils.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /** * Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved. \n * @@ -29,9 +37,6 @@ extern "C" { #define TASK_PRIORITY_DFX_MSG (osPriority_t)(18) #define TASK_PRIORITY_TRANSMIT (osPriority_t)(20) -void uapi_poweroff_device(void); -void uapi_reboot_device(void); - /*sntp同步UTC 时间 , 采用默认timezone,或者已经保存的timezone*/ errcode_t cat1_sntp_set_time_utc(uint32_t seconds); diff --git a/code/sdk/zhihui/UI/producttest/include/testPresenter.h b/code/sdk/zhihui/UI/producttest/include/testPresenter.h index f207f7105..b0a5ecad1 100644 --- a/code/sdk/zhihui/UI/producttest/include/testPresenter.h +++ b/code/sdk/zhihui/UI/producttest/include/testPresenter.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-08-23 10:50:37 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-11-05 14:34:43 + * @LastEditTime: 2025-07-11 10:35:58 * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/producttest/include/testPresenter.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -37,7 +37,7 @@ namespace OHOS CHARG, SPEAK, MOTOR, -#ifdef SUPPORT_CAT1_MODEM +#ifdef SUPPORT_CAT1_SERVICE CAT1, #endif BUTTON, diff --git a/code/sdk/zhihui/UI/producttest/include/testView.h b/code/sdk/zhihui/UI/producttest/include/testView.h index b815bb49c..57bbae165 100644 --- a/code/sdk/zhihui/UI/producttest/include/testView.h +++ b/code/sdk/zhihui/UI/producttest/include/testView.h @@ -29,9 +29,12 @@ #include "producttest/include/testbt.h" #include "producttest/include/testSEChipTest.h" #include "producttest/include/testPing.h" +#ifdef SUPPORT_GNSS #include "producttest/include/testGPS.h" +#endif +#ifdef ENABLE_LQBP002TA #include "producttest/include/testpressure.h" - +#endif #ifdef SUPPORT_A5133_SERVICE #include "producttest/include/testA5133.h" #endif @@ -97,8 +100,12 @@ namespace OHOS bool ChangeBTTESTView(int16_t thisView); bool ChangeSEChipTESTView(int16_t thisView); bool ChangePingTESTView(int16_t thisView); +#ifdef SUPPORT_GNSS bool ChangeGPSTESTView(int16_t thisView); +#endif +#ifdef ENABLE_LQBP002TA bool ChangepressureTestTESTView(int16_t thisView); +#endif #ifdef SUPPORT_A5133_SERVICE bool ChangeA5133TESTView(int16_t thisView); #endif @@ -127,9 +134,7 @@ namespace OHOS testCHANINGView *test_charging_view{nullptr}; testSPEAKView *test_speak_view{nullptr}; testMOTORView *test_motor_view{nullptr}; - // #ifdef SUPPORT_CAT1_MODEM testcat1View *test_cat1_view{nullptr}; - // #endif testbuttonView *test_KEY_view{nullptr}; testMagicView *test_MG_view{nullptr}; testhrsenson1View *test_hr_view{nullptr}; @@ -141,9 +146,12 @@ namespace OHOS testSEChipView *test_SEChip_view{nullptr}; testPingView *test_Ping_view{nullptr}; +#ifdef SUPPORT_GNSS testGPSView *test_GPS_view{nullptr}; +#endif +#ifdef ENABLE_LQBP002TA testpressureView * test_pressure_view{nullptr}; - +#endif #ifdef SUPPORT_A5133_SERVICE testA5133View *test_A5133_view{nullptr}; #endif diff --git a/code/sdk/zhihui/UI/producttest/include/testhrsenson.h b/code/sdk/zhihui/UI/producttest/include/testhrsenson.h index 2626277b3..fe2a2605e 100644 --- a/code/sdk/zhihui/UI/producttest/include/testhrsenson.h +++ b/code/sdk/zhihui/UI/producttest/include/testhrsenson.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-07-10 12:16:09 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-11 10:55:46 + * @FilePath: /FD230/code/sdk/zhihui/UI/producttest/include/testhrsenson.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef TEST_HRSENSON_VIEW_H #define TEST_HRSENSON_VIEW_H @@ -77,7 +85,7 @@ namespace OHOS UIScrollView *testhrsensonInitIView(uint8_t); void ClearAll(void); void setgrayvalue(int,int,int); - void setlightvalue(int g,int r,int ir); + void setlightvalue(void); private: UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener); UILabel *InitLabel(LabelConfig &labelConfig); diff --git a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp index e0213e04d..85ae75192 100644 --- a/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testPresenter.cpp @@ -164,16 +164,16 @@ namespace OHOS } if(strcmp(view.GetViewId(),"shutdown") == 0) { - #ifdef FD230_650 + // #ifdef FD230_650 uapi_poweroff_device(); - #endif + // #endif return true; } if(strcmp(view.GetViewId(),"reset") == 0) { - #ifdef FD230_650 + // #ifdef FD230_650 uapi_reboot_device(); - #endif + // #endif return true; } diff --git a/code/sdk/zhihui/UI/producttest/src/testView.cpp b/code/sdk/zhihui/UI/producttest/src/testView.cpp index 2371a3cff..8ea5959bf 100644 --- a/code/sdk/zhihui/UI/producttest/src/testView.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testView.cpp @@ -31,7 +31,7 @@ namespace OHOS {CHARG, "chargingButton", "bat&charger", "chargingButton_next", &testView::ChangchargingTESTView, true}, {SPEAK, "speakButton", "speak", "speakButton_next", &testView::ChangspeakTESTView, true}, {MOTOR, "motorButton", "motor", "motorButton_next", &testView::ChangmotorTESTView, true}, -#ifdef SUPPORT_CAT1_MODEM +#ifdef SUPPORT_CAT1_SERVICE {CAT1, "cat1button", "CAT1", "cat1button_next", &testView::ChangeCAT1TESTView, true}, #endif {BUTTON, "buttonbutton", "button", "buttonbutton_next", &testView::ChangKEYTESTView, true}, @@ -44,7 +44,9 @@ namespace OHOS #if defined(SUPPORT_GNSS) {GPSTEST, "GPSTestbutton", "GPSTest", "GPSTestbutton_next", &testView::ChangeGPSTESTView, true}, #endif +#ifdef ENABLE_LQBP002TA {PRESSURETEST, "pressureTestbutton", "pressureTest", "pressureTestbutton_next", &testView::ChangepressureTestTESTView, true}, +#endif #ifdef AGINGTEST {OLDTEST, "oldtestbutton", "aging", "oldtestexit", &testView::ChangeoldTESTView, true}, #endif @@ -137,7 +139,7 @@ namespace OHOS delete test_motor_view; // 7 test_motor_view = nullptr; } -#ifdef SUPPORT_CAT1_MODEM +#ifdef SUPPORT_CAT1_SERVICE if (test_cat1_view) { delete test_cat1_view; // 8 @@ -615,10 +617,10 @@ namespace OHOS } return true; } - +#if defined(SUPPORT_GNSS) bool testView::ChangeGPSTESTView(int16_t thisView) { -#if defined(SUPPORT_GNSS) + if (SystemScrollView[thisView] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView"); @@ -631,10 +633,11 @@ namespace OHOS SystemScrollView[thisView] = test_GPS_view->testGPSInitIView((uint8_t)thisView); group->Add(SystemScrollView[thisView]); } -#endif + return true; } - +#endif +#ifdef ENABLE_LQBP002TA bool testView::ChangepressureTestTESTView(int16_t thisView) { @@ -653,7 +656,7 @@ namespace OHOS return true; } - +#endif #ifdef SUPPORT_A5133_SERVICE bool testView::ChangeA5133TESTView(int16_t thisView) { @@ -782,7 +785,7 @@ namespace OHOS test_motor_view = nullptr; SystemScrollView[hideView] = nullptr; break; -#ifdef SUPPORT_CAT1_MODEM +#ifdef SUPPORT_CAT1_SERVICE case CAT1: group->Remove(SystemScrollView[hideView]); delete test_cat1_view; @@ -854,13 +857,14 @@ namespace OHOS SystemScrollView[hideView] = nullptr; break; #endif +#if defined(ENABLE_LQBP002TA) case PRESSURETEST: group->Remove(SystemScrollView[hideView]); delete test_pressure_view; test_pressure_view = nullptr; SystemScrollView[hideView] = nullptr; break; - +#endif default: break; } diff --git a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp index 2c0351854..20b4d226e 100644 --- a/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testgsenson.cpp @@ -113,7 +113,9 @@ namespace OHOS MG_TEST_FALG++; gsenson_t t; - // get_gsonsen_xyz(&t); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_get_gsensor_data(1,&t); +#endif char buf[124]={0}; float x_t=t.x; float y_t=t.y; diff --git a/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp b/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp index 55075daaa..bcde2a16f 100644 --- a/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp +++ b/code/sdk/zhihui/UI/producttest/src/testhrsenson.cpp @@ -4,12 +4,6 @@ #include "producttest/include/testhrsenson.h" #include "AlarmClockModel.h" #include "cmsis_os2.h" -#ifdef SUPPORT_CAT1_SERVICE -#include "cat1_server.h" -#include "cat1_ctl.h" -#include "cat1_server_hal.h" -#endif -#include "ppg_service.h" #include "producttest/include/testView.h" #ifdef __cplusplus #if __cplusplus @@ -19,9 +13,12 @@ extern "C" #endif #include "pm_veto.h" #include "pm.h" -#ifdef PPG_VC9202 - #include "vc9202_user.h" + +#ifdef SUPPORT_PPG_SERVICE +#include "ppg_service.h" +#include "ppg_hal.h" #endif + #ifdef __cplusplus #if __cplusplus } @@ -36,7 +33,7 @@ namespace OHOS testhrsenson1View::testhrsenson1View() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testhrsenson1View::testhrsenson1View"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); g_pSystemAboutTheWatchView = this; } @@ -100,55 +97,26 @@ namespace OHOS static bool button_falg=true; void testhrsenson1View:: setgrayvalue(int g,int r,int ir) { - - if(label_hrsenson_value_vison!=NULL) - { - - char buf[124]={0}; - sprintf(buf,"gray:\n green:%d\nred:%d\nir:%d",g,r,ir); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); - label_hrsenson_value_vison->SetText(buf); - RootView::GetInstance()->Invalidate(); -#ifdef SUPPORT_PPG_SERVICE - int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; - send_ppg_cmd_msg(md); -#endif - button_falg=true; - } } - void testhrsenson1View:: setlightvalue(int g,int r,int ir) + void testhrsenson1View:: setlightvalue(void) { char buf[124]={0}; - if(label_hrsenson_value_vison!=nullptr) { -#ifdef PPG_HX3695 - sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",g,r,ir); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); - label_hrsenson_value_vison->SetText(buf); - RootView::GetInstance()->Invalidate(); -#ifdef SUPPORT_PPG_SERVICE - int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; - send_ppg_cmd_msg(md); -#endif - button_falg=true; -#elif defined PPG_VC9202 - //漏光测试 - // send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); - LOS_Msleep(500); - uint32_t led_cur = 0; - uint32_t apre_val = 0; - uint32_t aps_val = 9; - vc9202_get_leaklight_data(&led_cur,&apre_val,&aps_val); -#ifdef SUPPORT_PPG_SERVICE +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); + LOS_Msleep(1000); + uint32_t ch0 = 0; + uint32_t ch1 = 0; + uint32_t ch2 = 0; + ppg_get_leaklight_data(&ch0,&ch1,&ch2); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); -#endif - sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",led_cur,apre_val,aps_val); + sprintf(buf,"leaklight:\ngreen:%d\nred:%d\nir:%d",ch0,ch1,ch2); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",buf); label_hrsenson_value_vison->SetText(buf); RootView::GetInstance()->Invalidate(); button_falg=true; -#endif +#endif } } @@ -189,9 +157,8 @@ namespace OHOS { if(button_1!=NULL) { -#ifdef SUPPORT_PPG_SERVICE - int8_t md = PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST; - send_ppg_cmd_msg(md); +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); #endif button_falg=false; } @@ -201,16 +168,9 @@ namespace OHOS { if(button_2!=NULL) { -#ifdef SUPPORT_PPG_SERVICE - int8_t md = PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST; - send_ppg_cmd_msg(md); -#endif - button_falg=false; -#ifdef PPG_VC9202 - testhrsenson1View::setlightvalue(0,0,0); -#endif + button_falg=false; + testhrsenson1View::setlightvalue(); } - } UILabel *testhrsenson1View::InitLabel(LabelConfig &labelConfig) @@ -332,10 +292,10 @@ namespace OHOS testhrsensonScrollView->SetTouchable(true); testhrsensonScrollView->SetDraggable(true); -#ifdef SUPPORT_PPG_SERVICE + int8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; send_ppg_cmd_msg(md); -#endif + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_P_TEST); if (cnt == 0) { uapi_pm_add_sleep_veto(PM_ID_P_TEST); diff --git a/code/sdk/zhihui/config/src/ConfigModel.cpp b/code/sdk/zhihui/config/src/ConfigModel.cpp index 066ecfcab..86d869db4 100644 --- a/code/sdk/zhihui/config/src/ConfigModel.cpp +++ b/code/sdk/zhihui/config/src/ConfigModel.cpp @@ -17,6 +17,10 @@ #endif #include "../../../../../zhihui/drivers/vibrator/service/vibrator_service.h" +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif + #ifdef SUPPORT_CAT1_SERVICE extern "C" { #include "cat1_server.h" @@ -1371,11 +1375,15 @@ void cm_initializeRaiseToWake(void) bool isOpen = mmi_flip_wrist_switch_get(); if(isOpen == true) { - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif } else { - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif } } diff --git a/code/sdk/zhihui/drivers/cywee/CMakeLists.txt b/code/sdk/zhihui/drivers/cywee/CMakeLists.txt index 863d012cb..f9d166c1b 100644 --- a/code/sdk/zhihui/drivers/cywee/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/cywee/CMakeLists.txt @@ -1,5 +1,3 @@ add_subdirectory_if_exist(service) -add_subdirectory_if_exist(hal) add_subdirectory_if_exist(dml) -add_subdirectory_if_exist(data) add_subdirectory_if_exist(ble_service) \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/cywee/data/CMakeLists.txt b/code/sdk/zhihui/drivers/cywee/data/CMakeLists.txt deleted file mode 100644 index 0d9621ee5..000000000 --- a/code/sdk/zhihui/drivers/cywee/data/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -#=============================================================================== -# @brief cmake file -# Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. -#=============================================================================== - -set(COMPONENT_NAME "cywee_data") - -set(PUBLIC_HEADER -${CMAKE_CURRENT_SOURCE_DIR} -) - -set(SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/cywee_data.c -) - -set(COMPONENT_PUBLIC_CCFLAGS -) - -set(COMPONENT_CCFLAGS - -) - -set(WHOLE_LINK - true -) - -set(MAIN_COMPONENT - false -) - -set(PUBLIC_DEFINES -) - -set(PRIVATE_DEFINES -) - -build_component() diff --git a/code/sdk/zhihui/drivers/cywee/dml/CMakeLists.txt b/code/sdk/zhihui/drivers/cywee/dml/CMakeLists.txt index 1e01c62ff..41f5e79ed 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/cywee/dml/CMakeLists.txt @@ -5,17 +5,18 @@ set(COMPONENT_NAME "cywee_dml") set(SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/main_dml.c +${CMAKE_CURRENT_SOURCE_DIR}/cywee_dml.c ${CMAKE_CURRENT_SOURCE_DIR}/test_api.c ${CMAKE_CURRENT_SOURCE_DIR}/board_yh601s.c ${CMAKE_CURRENT_SOURCE_DIR}/custom_factory_core.c ${CMAKE_CURRENT_SOURCE_DIR}/custom_factory_impl.c +${CMAKE_CURRENT_SOURCE_DIR}/cywee_data.c ) set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR} ) set(PUBLIC_DEFINES - CYWEE_DML + ) set(PRIVATE_HEADER diff --git a/code/sdk/zhihui/drivers/cywee/dml/board_yh601s.c b/code/sdk/zhihui/drivers/cywee/dml/board_yh601s.c index ae489a011..3faad4831 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/board_yh601s.c +++ b/code/sdk/zhihui/drivers/cywee/dml/board_yh601s.c @@ -49,8 +49,6 @@ static uint8_t g_cywee_installed = 0; -extern uint8_t cywee_ble_service_flag; - /************************/ /*** Function Defines ***/ /************************/ @@ -245,7 +243,7 @@ int CWM_OS_dbgOutput(const char * format) { PRINT("%s", format); #ifdef SUPPORT_CYWEE_BLE_SERVICE - if(cywee_ble_service_flag == 1) + if(cywee_dml_get_log_flag()) ble_cywee_server_send_input_report((uint8_t *)format,strlen(format)); #endif return 0; diff --git a/code/sdk/zhihui/drivers/cywee/data/cywee_data.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c similarity index 99% rename from code/sdk/zhihui/drivers/cywee/data/cywee_data.c rename to code/sdk/zhihui/drivers/cywee/dml/cywee_data.c index 72b0e4604..a665ae044 100644 --- a/code/sdk/zhihui/drivers/cywee/data/cywee_data.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c @@ -2,8 +2,8 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-04-08 14:53:31 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-20 17:13:34 - * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/service/cywee_hal.c + * @LastEditTime: 2025-07-10 14:31:06 + * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/service/cywee_dml.c * @Description: * * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. @@ -13,7 +13,7 @@ #include #include #include -#include "cywee_hal.h" +#include "cywee_dml.h" #include "custom_utils.h" #include #include "cywee_data.h" diff --git a/code/sdk/zhihui/drivers/cywee/data/cywee_data.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h similarity index 100% rename from code/sdk/zhihui/drivers/cywee/data/cywee_data.h rename to code/sdk/zhihui/drivers/cywee/dml/cywee_data.h diff --git a/code/sdk/zhihui/drivers/cywee/dml/main_dml.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c similarity index 85% rename from code/sdk/zhihui/drivers/cywee/dml/main_dml.c rename to code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c index 0aaf12d76..f72631aa1 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/main_dml.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c @@ -3,8 +3,8 @@ #include #include #include -#include -#include "cywee_hal.h" +#include +#include "cywee_dml.h" #include "power_display_service.h" #include "broadcast_feature.h" #include "cmsis_os2.h" @@ -20,7 +20,7 @@ #include "custom_save_runtime.h" #include "cywee_data.h" #include "cywee_dml.h" -#include "cywee_hal.h" +#include "cwm_lib_dml.h" #ifdef SUPPORT_GNSS #include "gnss_ctl.h" #include "NMEA0183.h" @@ -111,6 +111,8 @@ static inact_result_t c_inact_result_t = {0}; static inact_ext_result_t c_inact_ext_result_t = {0}; static act_ext_result_t c_act_ext_result_t = {0}; +uint8_t cywee_ble_service_flag = 0; + #define SPORT_CHECK_MS 1000 @@ -123,21 +125,22 @@ int cm__hs1__init(void); int cm__hs1__deinit(void); #endif -SLEEP_T cywee_dml_get_sleep_time_data(void) +void cywee_get_sleep_time_data(SLEEP_T *sleep_data) { - SLEEP_T data = {0}; - data.fall_asleep_timestamp = fall_asleep_timestamp; - data.wake_up_timestamp = wake_up_timestamp; - data.total_time = total_time; - return data; + if (sleep_data == NULL) + return; + + sleep_data->fall_asleep_timestamp = fall_asleep_timestamp; + sleep_data->wake_up_timestamp = wake_up_timestamp; + sleep_data->total_time = total_time; } -uint8_t cywee_dml_get_log_flag(void) +uint8_t cywee_get_log_flag(void) { return cywee_log_flag; } -void cywee_gnss_update(void) +static void cywee_gnss_update(void) { #ifdef SUPPORT_GNSS gps_data_t *gps_data = getGPSGlobaldata(); @@ -165,7 +168,7 @@ void cywee_gnss_update(void) #endif } -void cywee_hrs_update(void) +static void cywee_hrs_update(void) { uint8_t hrs_data = 0; #ifdef SUPPORT_PPG_SERVICE @@ -238,11 +241,11 @@ static void get_sleep_file_day(char *day) uapi_get_YYMMDD_Time_extend(day, '\0', 0); } -void cywee_dml_check_acc(void) +void cywee_check_acc(void) { if(!timeout) { - cywee_dml_restart_acc(); + cywee_restart_acc(); } else { @@ -250,7 +253,7 @@ void cywee_dml_check_acc(void) } } -void clean_sleep_data(void) +static void clean_sleep_data(void) { total_time = 0; total_deep_sleep_time = 0; @@ -271,28 +274,252 @@ void clean_sleep_data(void) wake_up_flag = 0; } -void cywee_set_sleep_time_data(inact_ext_result_t *sleep_data) +static void cywee_set_sleep_time_data(inact_ext_result_t *sleep_data) { memset(&sleep_time, 0, sizeof(inact_ext_result_t)); memcpy_s(&sleep_time, sizeof(inact_ext_result_t), sleep_data, sizeof(inact_ext_result_t)); } -void cywee_dml_save_sleep_data(void) +static void cywee_save_sleep_time_data(void) +{ + // if (access(time_file_path, 0) == -1) + { + char day[12] = {0}; + memset(time_file_path, 0, sizeof(time_file_path)); + get_sleep_file_day(day); + sprintf_s(time_file_path, 64, SLEEP_TIME_PATH, day); + } + + FILE *fp; + fp = fopen(time_file_path, "wb+"); + if(fp == NULL) + { + CWM_OS_dbgPrintf("save_sleep_data fopen fail \n"); + return; + } + + uint8_t sleep_type = 1; + fwrite(&sleep_type, 1, 1, fp); + + fwrite(&fall_asleep_timestamp, 1, 4, fp); + + if (wake_up_timestamp == 0) + { + uapi_get_timestampe_ss(&wake_up_timestamp); + } + + fwrite(&wake_up_timestamp, 1, 4, fp); + + total_time = (wake_up_timestamp - fall_asleep_timestamp) / 60; + + uint8_t total_time_hour = (total_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + uint8_t total_time_minute = (total_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + + total_deep_sleep_time += sleep_time.total_deep_sleep_time; + + total_time_hour = (total_deep_sleep_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + total_time_minute = (total_deep_sleep_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + + total_mild_sleep_time += sleep_time.total_mild_sleep_time; + total_time_hour = (total_mild_sleep_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + total_time_minute = (total_mild_sleep_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + + total_rem_sleep_time += sleep_time.total_rem_sleep_time; + total_time_hour = (total_rem_sleep_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + total_time_minute = (total_rem_sleep_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + + total_wake_time = total_time - total_rem_sleep_time - total_mild_sleep_time - + total_deep_sleep_time; + + total_time_hour = (total_wake_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + total_time_minute = (total_wake_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + fclose(fp); + + if (ephemeral_flag) // 临时数据清掉 + { + total_deep_sleep_time -= sleep_time.total_deep_sleep_time; + total_mild_sleep_time -= sleep_time.total_mild_sleep_time; + total_rem_sleep_time -= sleep_time.total_rem_sleep_time; + ephemeral_flag = 0; + } + + // CWM_OS_dbgPrintf("wake_up_timestamp : %d ,fall_asleep_timestamp : %d \n",wake_up_timestamp,fall_asleep_timestamp); + // CWM_OS_dbgPrintf("total_time[%d], total_deep_sleep_time[%d], total_mild_sleep_time[%d], total_rem_sleep_time[%d], total_wake_time[%d] \n", + // total_time,total_deep_sleep_time,total_mild_sleep_time,total_rem_sleep_time,total_wake_time); + + update_sleep_data(fall_asleep_timestamp,wake_up_timestamp,total_time); + +} + +static void cywee_save_sleep_stat_data(void) +{ + memset(status_file_path, 0, sizeof(status_file_path)); + char day[12] = {0}; + get_sleep_file_day(day); + sprintf_s(status_file_path, 64, SLEEP_STATUS_PATH, day); + if (access(status_file_path, 0) == -1) // 文件不存在 直接写入 + { + uapi_save_file_data(status_file_path,(uint8_t *)sleep_stat,stat_num * sizeof(SLEEP_STAT_T),"wb+"); + } + else // 文件已存在 需要判断是否需要补上清醒状态 + { + + FILE *fp = fopen(status_file_path, "rb+"); + if (fp == NULL) + { + CWM_OS_dbgPrintf("save_sleep_data fopen fail \n"); + return; + } + + fseek(fp, -sizeof(SLEEP_STAT_T), SEEK_END); + SLEEP_STAT_T sleep_status = {0, 0}; + fread(&sleep_status, sizeof(SLEEP_STAT_T), 1, fp); + if (sleep_status.stat == 4) // 如果存在出睡睡觉 替换为清醒 + { + sleep_status.stat = 3; // 清醒状态 + // sleep_status.timestamp = history_wake_up_timestamp; // 清醒状态时间为上一次的出睡时间 + fseek(fp, -sizeof(SLEEP_STAT_T), SEEK_END); + fwrite(&sleep_status, sizeof(SLEEP_STAT_T), 1, fp); // 补上清醒状态 + // fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); //写入本次睡眠状态 + if(sleep_stat[0].stat == 0) + { + sleep_stat[0].stat = 1; + fwrite(sleep_stat, sizeof(SLEEP_STAT_T),stat_num, fp); // 跳过入睡状态写入文件 + } + else + fwrite(sleep_stat, sizeof(SLEEP_STAT_T), stat_num, fp); + + } + else // 不满足补清醒状态条件 直接写入本次睡眠状态 + { + fseek(fp, 0, SEEK_END); + fwrite(sleep_stat, sizeof(SLEEP_STAT_T), stat_num, fp); + } + fclose(fp); + } + + stat_num = 0; + memset(sleep_stat,0,SLEEP_STATUS_LENGTH * sizeof(SLEEP_STAT_T)); + + if(wake_up_flag) + uapi_dev_runtime_set_sleep_status(0); + +} + +static void cywee_set_sleep_stat_data(inact_result_t c_inact_result_t) +{ + uint32_t timestamp = 0; + if(stat_num < SLEEP_STATUS_LENGTH) + { + uapi_get_timestampe_ss_extend(×tamp,current_year,c_inact_result_t.month,c_inact_result_t.day,c_inact_result_t.hour,c_inact_result_t.minute,0); + + sleep_stat[stat_num].timestamp = timestamp; + sleep_stat[stat_num].stat = c_inact_result_t.status; + // CWM_OS_dbgPrintf("stat : %d , timestamp : %d \n", sleep_stat[stat_num].stat,sleep_stat[stat_num].timestamp); + if(sleep_stat[stat_num].stat == 0) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 + { + if(fall_asleep_timestamp == 0) + fall_asleep_timestamp = sleep_stat[stat_num].timestamp; + } + else if(sleep_stat[stat_num].stat == 4) + { + //目前cywee出睡时间戳有bug 暂时先用系统时间戳 + if(sleep_stat[stat_num].timestamp < fall_asleep_timestamp) //如果出睡时间戳小于入睡时间戳 获取系统时间戳作为出睡时间戳 + { + uapi_get_timestampe_ss(×tamp); + sleep_stat[stat_num].timestamp = timestamp; + } + wake_up_timestamp = sleep_stat[stat_num].timestamp; + sleep_update_timestamp = wake_up_timestamp; + } + stat_num ++; + } +} + +static void cywee_save_nap_time_data() +{ + if (access(nap_file_path, 0) == -1) //如果小睡文件不存在,创建睡眠文件夹 + { + char day[12] = {0}; + memset(dir_path,0,sizeof(dir_path)); + memset(nap_file_path,0,sizeof(nap_file_path)); + + uapi_get_YYMMDD_Time(day, '\0'); + sprintf_s(dir_path, 64, SLEEP_DIR_PATH, day); + uapi_create_folder(dir_path); + sprintf_s(nap_file_path, 64, NAP_PATH, day); + } + + + uint32_t size = uapi_get_file_size(nap_file_path); + + FILE *fp; + fp = fopen(nap_file_path, "ab+"); //小睡数据全部存入一个文件 + if(fp==NULL) + { + CWM_OS_dbgPrintf("save_nap_sleep_data %s fopen fail \n", nap_file_path); + return; + } + + uint8_t id=size/14+1; + + uint16_t nap_size=12; + fwrite(&nap_size, 1, 2, fp); + + fwrite(&id, 1, 1, fp); + + uint8_t sleep_type = 0; //不存睡眠类型 改用文件名判断 + fwrite(&sleep_type, 1, 1, fp); + + fwrite(&fall_asleep_timestamp, 1, 4, fp); + + fwrite(&wake_up_timestamp, 1, 4, fp); + + uint16_t total_time = sleep_time.total_time; + + uint8_t total_time_hour = (total_time / 60); + fwrite(&total_time_hour, 1, 1, fp); + + uint8_t total_time_minute = (total_time % 60); + fwrite(&total_time_minute, 1, 1, fp); + + // CWM_OS_dbgPrintf("save_nap_sleep_data succ \n"); + + fclose(fp); + +} + +void cywee_save_sleep_data(void) { uapi_dev_runtime_set_sleep_storage_status(1); - cywee_save_sleep_time_data(sleep_time); + cywee_save_sleep_time_data(); cywee_save_sleep_stat_data(); uapi_dev_runtime_set_sleep_storage_status(0); } -void cywee_dml_save_nap_data(void) +void cywee_save_nap_data(void) { uapi_dev_runtime_set_sleep_storage_status(1); - cywee_save_nap_data(sleep_time); + cywee_save_nap_time_data(); uapi_dev_runtime_set_sleep_storage_status(0); } -void static wear_file_check(SLEEP_STAT_T newStruct, const char *filename) +static void wear_file_check(SLEEP_STAT_T newStruct, const char *filename) { FILE *fp; uint16_t count = 0; @@ -349,35 +576,6 @@ void cywee_custom_save_wear_data(void) } -void cywee_set_sleep_stat_data(inact_result_t c_inact_result_t) -{ - uint32_t timestamp = 0; - if(stat_num < SLEEP_STATUS_LENGTH) - { - uapi_get_timestampe_ss_extend(×tamp,current_year,c_inact_result_t.month,c_inact_result_t.day,c_inact_result_t.hour,c_inact_result_t.minute,0); - - sleep_stat[stat_num].timestamp = timestamp; - sleep_stat[stat_num].stat = c_inact_result_t.status; - // CWM_OS_dbgPrintf("stat : %d , timestamp : %d \n", sleep_stat[stat_num].stat,sleep_stat[stat_num].timestamp); - if(sleep_stat[stat_num].stat == 0) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 - { - if(fall_asleep_timestamp == 0) - fall_asleep_timestamp = sleep_stat[stat_num].timestamp; - } - else if(sleep_stat[stat_num].stat == 4) - { - //目前cywee出睡时间戳有bug 暂时先用系统时间戳 - if(sleep_stat[stat_num].timestamp < fall_asleep_timestamp) //如果出睡时间戳小于入睡时间戳 获取系统时间戳作为出睡时间戳 - { - uapi_get_timestampe_ss(×tamp); - sleep_stat[stat_num].timestamp = timestamp; - } - wake_up_timestamp = sleep_stat[stat_num].timestamp; - sleep_update_timestamp = wake_up_timestamp; - } - stat_num ++; - } -} static void cywee_set_abs_static(void) { @@ -388,7 +586,7 @@ static void cywee_set_abs_static(void) CWM_SettingControl(SCL_ABS_STATIC_CONFIG, &scl); } -void cywee_dml_set_log_switch(int cmd) +void cywee_set_log_switch(int cmd) { if(cmd) { @@ -409,7 +607,7 @@ void cywee_dml_set_log_switch(int cmd) } } -void cywee_dml_restart_acc(void) +void cywee_restart_acc(void) { uint32_t tm = 0; uapi_get_timestampe_ss(&tm); @@ -426,12 +624,12 @@ void cywee_dml_restart_acc(void) CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl); } -uint8_t cywee_dml_get_static_state(void) +uint8_t cywee_get_static_state(void) { return is_static_state; } -uint8_t cywee_dml_get_active_state(void) +uint8_t cywee_get_active_state(void) { return cywee_is_active; } @@ -446,7 +644,7 @@ void cywee_sensor_stop(void) CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl); } -void cywee_dml_set_sedentary_switch(int cmd) +void cywee_set_sedentary_switch(int cmd) { // CWM_OS_dbgPrintf("cywee_set_sedentary_switch : %d \n",cmd); //设置久坐 0关,1开 @@ -456,23 +654,23 @@ void cywee_dml_set_sedentary_switch(int cmd) CWM_SettingControl(SCL_SEDENTARY, &scl); } -void cywee_dml_set_sedentary_interval(int interval) +void cywee_set_sedentary_interval(int interval) { sedentary_interval = interval; } -void cywee_dml_get_chipinfo(char *databuf,uint8_t len) +void cywee_get_chipinfo(char *databuf,uint8_t len) { memcpy_s(databuf,len,chipInfo,strlen(chipInfo)); } -void cywee_dml_get_version(char *databuf,uint8_t len) +void cywee_get_version(char *databuf,uint8_t len) { memcpy_s(databuf,len,cywee_version,strlen(cywee_version)); } -uint32_t cywee_dml_get_sport_data(uint8_t type) +uint32_t cywee_get_sport_data(uint8_t type) { uint32_t data = 0; switch (type) @@ -518,7 +716,7 @@ uint32_t cywee_dml_get_sport_data(uint8_t type) return 0; } -void cywee_dml_set_sport_data(uint32_t data,uint8_t type) +void cywee_set_sport_data(uint32_t data,uint8_t type) { switch (type) { @@ -560,18 +758,18 @@ void cywee_dml_set_sport_data(uint32_t data,uint8_t type) } } -void cywee_dml_set_stand_flag(void) +void cywee_set_stand_flag(void) { stand_flag = 1; } -uint8_t cywee_dml_get_stand_flag(void) +uint8_t cywee_get_stand_flag(void) { return stand_flag; } -void cywee_dml_ar_alert_switch(int cmd) +void cywee_ar_alert_switch(int cmd) { memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; @@ -579,7 +777,7 @@ void cywee_dml_ar_alert_switch(int cmd) CWM_SettingControl(SCL_AR_ALERT_CONFIG, &scl); } -void cywee_dml_hand_updown_switch(int cmd) +void cywee_hand_updown_switch(int cmd) { if(cmd == 1) CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP); @@ -587,7 +785,7 @@ void cywee_dml_hand_updown_switch(int cmd) CWM_Sensor_Disable(IDX_ALGO_WATCH_HANDUP); } -void cywee_dml_reset_history_daily_data(void) +void cywee_reset_history_daily_data(void) { stepcount=0; new_distance=0; @@ -606,7 +804,7 @@ void cywee_dml_reset_history_daily_data(void) // new_fat = 0; //当前燃脂数据 } -void cywee_dml_reset_daily_data(void) +void cywee_reset_daily_data(void) { memset(&scl, 0, sizeof(scl)); CWM_SettingControl(SCL_RESET_DAILY_INFO, &scl); @@ -618,7 +816,7 @@ void cywee_dml_reset_daily_data(void) } //INT[1] : 0 立即输出,但不中止睡眠。 1 立即输出且中止睡眠 -void cywee_dml_get_sleep_data(int cmd) +void cywee_get_sleep_data(int cmd) { // CWM_OS_dbgPrintf("cywee_get_sleep_data\n"); memset(&scl, 0, sizeof(scl)); @@ -628,7 +826,7 @@ void cywee_dml_get_sleep_data(int cmd) } //1.age 2.sex 3.weight 4.height 5.method -void cywee_dml_set_user_info(void) +void cywee_set_user_info(void) { int user_info[5] = {0}; get_user_info_from_config_model(user_info); @@ -652,7 +850,7 @@ void cywee_dml_set_user_info(void) int minute;// int[5] = minute (0 - 59) int second;// int[6] = second (0 - 59) */ -void cywee_dml_time_sync(void) +void cywee_time_sync(void) { time_t rawtime; struct tm* timeinfo; @@ -683,7 +881,7 @@ void cywee_dml_time_sync(void) uapi_create_folder(dir_path); } -void cywee_dml_oncharging_update(int oncharging_status) +void cywee_oncharging_update(int oncharging_status) { // CWM_OS_dbgPrintf("oncharging : %d\r\n",oncharging_status); memset(&csd, 0, sizeof(CUSTOM_ON_CHARGING)); @@ -692,7 +890,7 @@ void cywee_dml_oncharging_update(int oncharging_status) CWM_CustomSensorInput(&csd); } -void cywee_dml_wearstatus_update(int wearstatus) +void cywee_wearstatus_update(int wearstatus) { #if 1 uapi_dev_runtime_set_wear_status(wearstatus); @@ -707,7 +905,7 @@ void cywee_dml_wearstatus_update(int wearstatus) } //0:resume , 1:pause -void cywee_dml_set_activity_mode_setstatus(int cmd) +void cywee_set_activity_mode_setstatus(int cmd) { memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; @@ -730,7 +928,7 @@ void cywee_dml_set_activity_mode_setstatus(int cmd) } } -void cywee_dml_inactivity_mode_change(int mode) +void cywee_inactivity_mode_change(int mode) { // cywee_time_sync(); clean_sleep_data(); @@ -801,7 +999,7 @@ void cywee_dml_inactivity_mode_change(int mode) } } -void cywee_dml_activity_mode_change(int mode) +void cywee_activity_mode_change(int mode) { if(mode != SPORT_ACTIVE_MODE_NORMAL) cywee_sport_timer_start_check(SPORT_CHECK_MS); @@ -868,7 +1066,7 @@ void cywee_dml_activity_mode_change(int mode) } } -void cywee_dml_get_gsensor_data(uint8_t cnt,gsenson_t t[]) +void cywee_get_gsensor_data(uint8_t cnt,gsenson_t t[]) { if(t == NULL) return; @@ -1145,6 +1343,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { c_inact_ext_result_t.total_wake_time = (int)sensorEVT->fData[4]; c_inact_ext_result_t.total_rem_sleep_time = (int)sensorEVT->fData[5]; + cywee_set_sleep_time_data(&c_inact_ext_result_t); do_custom_fileoperate_service_check_msg(CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_SAVE, NULL, 0); // cywee_func(CYWEE_MSG_TYPE_INACTIVITY_ACCUMULATE_TIME_UPDATE,&c_inact_ext_result_t,sizeof(inact_ext_result_t)); @@ -1276,13 +1475,13 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { // sleep_flag_t.timestamp = abs_static_timestampe; // uapi_save_sleep_flag(&sleep_flag_t,sizeof(SLEEP_FLAG_T)); uapi_dev_runtime_set_absolute_static_status(1); - cywee_dml_get_sleep_data(1); + cywee_get_sleep_data(1); } else { - cywee_dml_inactivity_mode_change(INACTIVITY_MODE_NOTHING); + cywee_inactivity_mode_change(INACTIVITY_MODE_NOTHING); LOS_Msleep(50); - cywee_dml_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); + cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); } } @@ -1314,7 +1513,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { } #ifdef AP_ENABLE_DML_SDO_LISTEN -//void CWM_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) { +//void CWM_APSensorDataOutput_listen(const dml_sensorData_t * pSdo) { // if (pSdo->validData & DML_SENSOR_DATA_VALID_DT) // CWM_OS_dbgPrintf("==dt: %d us\n", pSdo->dt_us); @@ -1333,7 +1532,7 @@ struct AccelerationData { static struct AccelerationData rawdata[25]; //自定义buffer,用来缓存sensor数据 static int AccdataCount = 0; //fifo长度 -void CWM_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) +void CWM_APSensorDataOutput_listen(const dml_sensorData_t * pSdo) { if(AccdataCount < 25) { @@ -1381,7 +1580,7 @@ void CWM_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) #endif -int cywee_main_dml(void) +int cywee_start(void) { if (cywee_installized == 1) { @@ -1538,7 +1737,7 @@ int cywee_main_dml(void) // This API allows customers to develop custom features. // Specific settingControl commands needs to be called for this API to work. // No need to enable or implement this function for general usage. - CWM_Dml_sensorDataOutput_register(CWM_AP_dmlSensorDataOutput_listen); + CWM_Dml_sensorDataOutput_register(CWM_APSensorDataOutput_listen); #endif //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); @@ -1656,7 +1855,7 @@ int cywee_main_dml(void) CWM_SettingControl(SCL_INACTIVITY_CONFIG, &scl); //设置运动识别 - cywee_dml_ar_alert_switch(get_motion_recognition_from_config_model()); + cywee_ar_alert_switch(get_motion_recognition_from_config_model()); //设置绝对静止 cywee_set_abs_static(); @@ -1689,11 +1888,11 @@ int cywee_main_dml(void) //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); // cywee_restoreData(); - cywee_dml_set_user_info(); + cywee_set_user_info(); - cywee_dml_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL); + cywee_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL); - cywee_dml_oncharging_update(get_charge_stat()); //初始化时检查充电状态 + cywee_oncharging_update(get_charge_stat()); //初始化时检查充电状态 g_sport_timer = osTimerNew((osTimerFunc_t)cywee_service_check_timer_callback, osTimerPeriodic, NULL, NULL); //cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP); @@ -1731,7 +1930,7 @@ int cwm_lib_process(void) //运行算法 #endif -void cywee_dml_int_handler(void) +void cywee_int_handler(void) { timeout = 1; // if(cywee_switch == 1) @@ -1745,17 +1944,17 @@ void cywee_dml_int_handler(void) } -act_result_t cywee_dml_get_act_data(void) +void cywee_get_act_data(act_result_t *data) { - act_result_t data = {0}; - memcpy_s(&data,sizeof(act_result_t),&c_act_result_t,sizeof(act_result_t)); - return data; + if(data == NULL) + return; + memcpy_s(data,sizeof(act_result_t),&c_act_result_t,sizeof(act_result_t)); } -act_ext_result_t cywee_dml_get_act_ext_data(void) +void cywee_get_act_ext_data(act_ext_result_t *data) { - act_ext_result_t data = {0}; - memcpy_s(&data,sizeof(act_ext_result_t),&c_act_result_t,sizeof(act_ext_result_t)); - return data; + if(data == NULL) + return; + memcpy_s(data,sizeof(act_ext_result_t),&c_act_result_t,sizeof(act_ext_result_t)); } diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.h index 18c434f6e..064067e73 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.h @@ -2,8 +2,8 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-05-19 14:25:40 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-21 11:53:41 - * @FilePath: /FD230/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.h + * @LastEditTime: 2025-07-10 15:28:10 + * @FilePath: /FD230/code/sdk/zhihui/drivers/cywee/dml/cywee.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ /** @@ -40,31 +40,6 @@ extern int CWM_OS_i2cTransfer(uint16_t slaveAddr, uint16_t reg, int regLength, u extern void* CWM_OS_malloc(int size); extern void CWM_OS_free(void *ptr); - -/********************CYWEE LIB*************************/ - -#define SPORT_ACTIVE_MODE_NORMAL 1001 // 一般模式(生活模式) normal(base) 1001 -#define SPORT_ACTIVE_MODE_TREADMILL 1002 // 跑步機 treadmill 1002 -#define SPORT_ACTIVE_MODE_OUTDOOR_RUNNING 1003 // 戶外跑步 outdoor running 1003 -#define SPORT_ACTIVE_MODE_INDOOR_RUNNING 1006 // 室內跑步 indoor running 1006 -#define SPORT_ACTIVE_MODE_FITNESS_PEDOMETERR 1008 // 防誤觸計步 fitness_pedometer 1008 -#define SPORT_ACTIVE_MODE_FREE_TRAINING 5001 // 自由運動 FreeTraining 5001 -//#define SPORT_ACTIVE_MODE_AR_ALERT 1001 // 長時間動作偵測 AR alert 1001 -#define SPORT_ACTIVE_MODE_AR_ALERT 102 // 長時間動作偵測 AR alert 1001 -#define SPORT_ACTIVE_MODE_EXTRA_INFO 100 // 额外信息 AR alert 1001 - -#define INACTIVITY_MODE_NOTHING 0 // 无作用 -#define INACTIVITY_MODE_SEDENTARY 1 // 久坐和有效站立 -#define INACTIVITY_MODE_SLEEPING 2 // 睡眠 -#define INACTIVITY_MODE_SEDENTARY_AND_NAP 3 // 久坐、有效站立和小睡 -#define INACTIVITY_MODE_NAP 4 // 小睡 - -#define INACTIVITY_MODE_SEDENTARY_OUTPUT 20 // 久坐和有效站立 -#define INACTIVITY_MODE_SLEEPING_OUTPUT 21 // 睡眠 -#define INACTIVITY_MODE_NAP_OUTPUT 22 // 小睡 -#define INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT 31 // 睡眠累计 -#define INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT 32 // 小睡累计 - #pragma pack(1) /** @@ -440,54 +415,6 @@ typedef struct int mag_axis_setting;// int[2] = mag_axis setting (0: default, 1-24: axis_mode) }input_sensor_config_t; -uint8_t cywee_dml_get_log_flag(void); -void cywee_dml_get_gsensor_data(uint8_t cnt,gsenson_t t[]); - -void cywee_dml_set_activity_mode_setstatus(int cmd); -void cywee_dml_oncharging_update(int oncharging_status); -void cywee_dml_wearstatus_update(int wearstatus); -void cywee_hrs_update(void); -void cywee_dml_set_user_info(void); -void cywee_dml_get_sleep_data(int cmd); -void cywee_dml_reset_daily_data(void); -void cywee_dml_inactivity_mode_change(int mode); -void cywee_dml_activity_mode_change(int mode); -void cywee_dml_time_sync(void); -void cywee_dml_hand_updown_switch(int cmd); -void cywee_dml_ar_alert_switch(int cmd); - -void cywee_dml_set_stand_flag(void); -uint8_t cywee_dml_get_stand_flag(void); - -void cywee_dml_get_chipinfo(char *databuf,uint8_t len); -void cywee_dml_set_sedentary_interval(int interval); -void cywee_dml_set_sedentary_switch(int cmd); - -void cywee_sensor_stop(void); -uint8_t cywee_dml_get_active_state(void); -uint8_t cywee_dml_get_static_state(void); -void cywee_dml_restart_acc(void); -void cywee_dml_set_log_switch(int cmd); -void cywee_dml_get_version(char *databuf,uint8_t len); - -void cywee_dml_save_sleep_data(void); -void cywee_dml_save_nap_data(void); - -void cywee_dml_reset_history_daily_data(void); -void cywee_dml_check_acc(void); - -void cywee_custom_save_wear_data(void); - -uint32_t cywee_dml_get_sport_data(uint8_t type); -void cywee_dml_set_sport_data(uint32_t data,uint8_t type); - -int cywee_main_dml(void); -void cywee_dml_int_handler(void); - -act_result_t cywee_dml_get_act_data(void); -act_ext_result_t cywee_dml_get_act_ext_data(void); - -SLEEP_T cywee_dml_get_sleep_time_data(void); #pragma pack() diff --git a/code/sdk/zhihui/drivers/cywee/hal/cywee_hal.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h similarity index 63% rename from code/sdk/zhihui/drivers/cywee/hal/cywee_hal.h rename to code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h index 81ed084ca..454b6620e 100644 --- a/code/sdk/zhihui/drivers/cywee/hal/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -26,6 +26,30 @@ extern "C" { #define SLEEP_DATA_DIR "/user/userdata/sleep/" +/********************CYWEE LIB*************************/ + +#define SPORT_ACTIVE_MODE_NORMAL 1001 // 一般模式(生活模式) normal(base) 1001 +#define SPORT_ACTIVE_MODE_TREADMILL 1002 // 跑步機 treadmill 1002 +#define SPORT_ACTIVE_MODE_OUTDOOR_RUNNING 1003 // 戶外跑步 outdoor running 1003 +#define SPORT_ACTIVE_MODE_INDOOR_RUNNING 1006 // 室內跑步 indoor running 1006 +#define SPORT_ACTIVE_MODE_FITNESS_PEDOMETERR 1008 // 防誤觸計步 fitness_pedometer 1008 +#define SPORT_ACTIVE_MODE_FREE_TRAINING 5001 // 自由運動 FreeTraining 5001 +//#define SPORT_ACTIVE_MODE_AR_ALERT 1001 // 長時間動作偵測 AR alert 1001 +#define SPORT_ACTIVE_MODE_AR_ALERT 102 // 長時間動作偵測 AR alert 1001 +#define SPORT_ACTIVE_MODE_EXTRA_INFO 100 // 额外信息 AR alert 1001 + +#define INACTIVITY_MODE_NOTHING 0 // 无作用 +#define INACTIVITY_MODE_SEDENTARY 1 // 久坐和有效站立 +#define INACTIVITY_MODE_SLEEPING 2 // 睡眠 +#define INACTIVITY_MODE_SEDENTARY_AND_NAP 3 // 久坐、有效站立和小睡 +#define INACTIVITY_MODE_NAP 4 // 小睡 + +#define INACTIVITY_MODE_SEDENTARY_OUTPUT 20 // 久坐和有效站立 +#define INACTIVITY_MODE_SLEEPING_OUTPUT 21 // 睡眠 +#define INACTIVITY_MODE_NAP_OUTPUT 22 // 小睡 +#define INACTIVITY_MODE_SLEEPING_ACCUMULATE_TIME_OUTPUT 31 // 睡眠累计 +#define INACTIVITY_MODE_NAP_ACCUMULATE_TIME_OUTPUT 32 // 小睡累计 + typedef struct { float x; float y; @@ -135,14 +159,12 @@ typedef struct #pragma pack() -void cywee_start(void); -void cywee_stop(void); -void cywee_int_handler(void); +uint8_t cywee_get_log_flag(void); +void cywee_get_gsensor_data(uint8_t cnt,gsenson_t t[]); void cywee_set_activity_mode_setstatus(int cmd); void cywee_oncharging_update(int oncharging_status); void cywee_wearstatus_update(int wearstatus); -void cywee_hrs_update(void); void cywee_set_user_info(void); void cywee_get_sleep_data(int cmd); void cywee_reset_daily_data(void); @@ -151,15 +173,14 @@ void cywee_activity_mode_change(int mode); void cywee_time_sync(void); void cywee_hand_updown_switch(int cmd); void cywee_ar_alert_switch(int cmd); -\ -void cywee_set_stand_falg(void); -uint8_t cywee_get_stand_falg(void); -uint8_t cywee_get_now_stand_count(void); + +void cywee_set_stand_flag(void); +uint8_t cywee_get_stand_flag(void); void cywee_get_chipinfo(char *databuf,uint8_t len); void cywee_set_sedentary_interval(int interval); void cywee_set_sedentary_switch(int cmd); -// void cywee_get_acc_switch(int cmd); + void cywee_sensor_stop(void); uint8_t cywee_get_active_state(void); uint8_t cywee_get_static_state(void); @@ -167,21 +188,25 @@ void cywee_restart_acc(void); void cywee_set_log_switch(int cmd); void cywee_get_version(char *databuf,uint8_t len); -void cywee_custom_save_sleep_data(void); -void cywee_custom_save_nap_data(void); +void cywee_save_sleep_data(void); +void cywee_save_nap_data(void); + void cywee_reset_history_daily_data(void); void cywee_check_acc(void); void cywee_custom_save_wear_data(void); uint32_t cywee_get_sport_data(uint8_t type); -void cywee_dml_set_sport_data(uint32_t data,uint8_t type); +void cywee_set_sport_data(uint32_t data,uint8_t type); + +int cywee_start(void); +void cywee_sensor_stop(void); +void cywee_int_handler(void); -act_result_t cywee_get_act_data(void); -act_ext_result_t cywee_get_act_ext_data(void); +void cywee_get_act_data(act_result_t *data); +void cywee_get_act_ext_data(act_ext_result_t *data); -void cywee_get_gsensor_data(uint8_t cnt,gsenson_t *data); -SLEEP_T cywee_get_sleep_time_data(void); +void cywee_get_sleep_time_data(SLEEP_T *sleep_data); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/drivers/cywee/doc/CWM lib Sensor Info_Gnt_Fd230_20240222.xlsx b/code/sdk/zhihui/drivers/cywee/doc/CWM lib Sensor Info_Gnt_Fd230_20240222.xlsx deleted file mode 100644 index 2a05d1011..000000000 Binary files a/code/sdk/zhihui/drivers/cywee/doc/CWM lib Sensor Info_Gnt_Fd230_20240222.xlsx and /dev/null differ diff --git a/code/sdk/zhihui/drivers/cywee/doc/Cwm_Dml_Info__LIS2DOC__20230816.xlsx b/code/sdk/zhihui/drivers/cywee/doc/Cwm_Dml_Info__LIS2DOC__20230816.xlsx deleted file mode 100644 index deabcfe13..000000000 Binary files a/code/sdk/zhihui/drivers/cywee/doc/Cwm_Dml_Info__LIS2DOC__20230816.xlsx and /dev/null differ diff --git a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion Driver Manger Lib Porting Guide_v1.0 1.pdf b/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion Driver Manger Lib Porting Guide_v1.0 1.pdf deleted file mode 100644 index 1c96a75ba..000000000 Binary files a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion Driver Manger Lib Porting Guide_v1.0 1.pdf and /dev/null differ diff --git a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_Algo Lib_Tutorial_v1.3_20200903 1.pdf b/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_Algo Lib_Tutorial_v1.3_20200903 1.pdf deleted file mode 100644 index 8dabff9a0..000000000 Binary files a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_Algo Lib_Tutorial_v1.3_20200903 1.pdf and /dev/null differ diff --git a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_MotionSensor_Adjust_Guide_v1.6 1.pdf b/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_MotionSensor_Adjust_Guide_v1.6 1.pdf deleted file mode 100644 index 1bab92dbc..000000000 Binary files a/code/sdk/zhihui/drivers/cywee/doc/CyweeMotion_MotionSensor_Adjust_Guide_v1.6 1.pdf and /dev/null differ diff --git a/code/sdk/zhihui/drivers/cywee/hal/CMakeLists.txt b/code/sdk/zhihui/drivers/cywee/hal/CMakeLists.txt deleted file mode 100644 index 8e04ed0d8..000000000 --- a/code/sdk/zhihui/drivers/cywee/hal/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -#=============================================================================== -# @brief cmake file -# Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. -#=============================================================================== - -set(COMPONENT_NAME "cywee_hal") - -set(PUBLIC_HEADER -${CMAKE_CURRENT_SOURCE_DIR} -) - -set(SOURCES -${CMAKE_CURRENT_SOURCE_DIR}/cywee_hal.c -) - -set(COMPONENT_PUBLIC_CCFLAGS -) - -set(COMPONENT_CCFLAGS - -) - -set(WHOLE_LINK - true -) - -set(MAIN_COMPONENT - false -) - -set(PUBLIC_DEFINES -) - -set(PRIVATE_DEFINES -) - -build_component() diff --git a/code/sdk/zhihui/drivers/cywee/hal/cywee_hal.c b/code/sdk/zhihui/drivers/cywee/hal/cywee_hal.c deleted file mode 100644 index ea45918c1..000000000 --- a/code/sdk/zhihui/drivers/cywee/hal/cywee_hal.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-04-08 14:53:31 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-20 16:53:48 - * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/service/cywee_hal.c - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. - */ - -#include -#include -#include -#include - -#include "cywee_hal.h" - -#include "custom_utils.h" - -#ifdef CYWEE_DML -#include "cywee_dml.h" -#endif - -// cywee_msg_callback_t g_cywee_send_msg_toUI = NULL; - -// uint32_t cywee_register_msg_callback(cywee_msg_callback_t cywee_func) -// { -// g_cywee_send_msg_toUI = cywee_func; -// return 0; -// } - -// cywee_msg_callback_t cywee_get_send_msg_callback_func(void) -// { -// return g_cywee_send_msg_toUI; -// } - -void cywee_start(void) -{ -#ifdef CYWEE_DML - cywee_main_dml(); -#endif -} - -void cywee_stop(void) -{ -#ifdef CYWEE_DML - cywee_sensor_stop(); -#endif -} - -void cywee_int_handler(void) -{ -#ifdef CYWEE_DML - cywee_dml_int_handler(); -#endif -} - -act_result_t cywee_get_act_data(void) -{ - act_result_t data = {0}; -#ifdef CYWEE_DML - data = cywee_dml_get_act_data(); -#endif - return data; -} -act_ext_result_t cywee_get_act_ext_data(void) -{ - act_ext_result_t data = {0}; -#ifdef CYWEE_DML - data = cywee_dml_get_act_ext_data(); -#endif - return data; -} - -void cywee_activity_mode_change(int mode) -{ -#ifdef CYWEE_DML - cywee_dml_activity_mode_change(mode); -#endif -} - -void cywee_inactivity_mode_change(int mode) -{ -#ifdef CYWEE_DML - cywee_dml_inactivity_mode_change(mode); -#endif -} - -void cywee_set_activity_mode_setstatus(int mode) -{ -#ifdef CYWEE_DML - cywee_dml_set_activity_mode_setstatus(mode); -#endif -} - -void cywee_get_gsensor_data(uint8_t cnt,gsenson_t *data) -{ -#ifdef CYWEE_DML - cywee_dml_get_gsensor_data(cnt,data); -#endif -} - -void cywee_wearstatus_update(int wearstatus) -{ -#ifdef CYWEE_DML - - cywee_dml_wearstatus_update(wearstatus); - - do_custom_fileoperate_service_check_msg( - CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_SAVE, NULL, 0); -#endif -} - -void cywee_oncharging_update(int oncharging_status) -{ -#ifdef CYWEE_DML - cywee_dml_oncharging_update(oncharging_status); -#endif -} - -void cywee_time_sync(void) -{ -#ifdef CYWEE_DML - cywee_dml_time_sync(); -#endif -} - -void cywee_reset_daily_data(void) -{ -#ifdef CYWEE_DML - cywee_dml_reset_daily_data(); -#endif -} - -void cywee_hand_updown_switch(int cmd) -{ -#ifdef CYWEE_DML - cywee_dml_hand_updown_switch(cmd); -#endif -} - -void cywee_get_sleep_data(int cmd) -{ -#ifdef CYWEE_DML - cywee_dml_get_sleep_data(cmd); -#endif -} - -void cywee_ar_alert_switch(int cmd) -{ -#ifdef CYWEE_DML - cywee_dml_ar_alert_switch(cmd); -#endif -} - -void cywee_check_acc(void) -{ -#ifdef CYWEE_DML - cywee_dml_check_acc(); -#endif -} - -void cywee_set_log_switch(int cmd) -{ -#ifdef CYWEE_DML - cywee_dml_set_log_switch(cmd); -#endif -} - -uint8_t cywee_get_static_state(void) -{ -#ifdef CYWEE_DML - return cywee_dml_get_static_state(); -#endif - return 0; -} - -void cywee_set_sedentary_switch(int cmd) -{ -#ifdef CYWEE_DML - cywee_dml_set_sedentary_switch(cmd); -#endif -} - -void cywee_set_sedentary_interval(int interval) -{ -#ifdef CYWEE_DML - cywee_dml_set_sedentary_interval(interval); -#endif -} - -void cywee_get_version(char *databuf,uint8_t len) -{ -#ifdef CYWEE_DML - cywee_dml_get_version(databuf,len); -#endif -} - -void cywee_get_chipinfo(char *databuf,uint8_t len) -{ -#ifdef CYWEE_DML - cywee_dml_get_chipinfo(databuf,len); -#endif -} - -uint8_t cywee_get_active_state(void) -{ -#ifdef CYWEE_DML - return cywee_dml_get_active_state(); -#endif - return 0; -} - -void cywee_restart_acc(void) -{ -#ifdef CYWEE_DML - cywee_dml_restart_acc(); -#endif -} - -void cywee_custom_save_sleep_data(void) -{ -#ifdef CYWEE_DML - cywee_dml_save_sleep_data(); -#endif -} - -void cywee_custom_save_nap_data(void) -{ -#ifdef CYWEE_DML - cywee_dml_save_nap_data(); -#endif -} - -void cywee_reset_history_daily_data(void) -{ -#ifdef CYWEE_DML - cywee_dml_reset_history_daily_data(); -#endif -} - -void cywee_set_user_info(void) -{ -#ifdef CYWEE_DML - cywee_dml_set_user_info(); -#endif -} - -void cywee_set_stand_falg(void) -{ -#ifdef CYWEE_DML - cywee_dml_set_stand_falg(); -#endif -} - -uint8_t cywee_get_stand_falg(void) -{ -#ifdef CYWEE_DML - return cywee_dml_get_stand_falg(); -#endif - return 0; -} - -uint32_t cywee_get_sport_data(uint8_t type) -{ - uint32_t data = 0; -#ifdef CYWEE_DML - data = cywee_dml_get_sport_data(type); -#endif - return data; -} - -void cywee_set_sport_data(uint32_t data,uint8_t type) -{ -#ifdef CYWEE_DML - cywee_dml_set_sport_data(data,type); -#endif -} - -SLEEP_T cywee_get_sleep_time_data(void) -{ - SLEEP_T data = {0}; -#ifdef CYWEE_DML - data = cywee_dml_get_sleep_time_data(); -#endif - return data; -} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/cywee/service/CMakeLists.txt b/code/sdk/zhihui/drivers/cywee/service/CMakeLists.txt index 8bf223dc7..7811c6564 100644 --- a/code/sdk/zhihui/drivers/cywee/service/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/cywee/service/CMakeLists.txt @@ -31,7 +31,6 @@ set(MAIN_COMPONENT ) set(PUBLIC_DEFINES - SUPPORT_CYWEE_SERVICE SUPPORT_AT_CYWEE ) diff --git a/code/sdk/zhihui/drivers/cywee/service/cywee_service.c b/code/sdk/zhihui/drivers/cywee/service/cywee_service.c index 56cafd620..e8c88ad5e 100644 --- a/code/sdk/zhihui/drivers/cywee/service/cywee_service.c +++ b/code/sdk/zhihui/drivers/cywee/service/cywee_service.c @@ -263,7 +263,7 @@ static void cywee_service_check_task(void const *arg) case CYWEE_SERVICE_CMD_START_CHECK: //cywee_service_running_stat = true; - cywee_main_dml(); + cywee_start(); //cywee_service_timer_start_check(CYWEE_CHECK_MS); break; @@ -469,6 +469,14 @@ void cywee_int_callback(pin_t pin, uintptr_t param) do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TIMER_CHECK, NULL); } +void cywee_hand_wake_switch(uint8_t cmd) +{ + if(!cmd) + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_HAND_UPDOWN,NULL); + else + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_HAND_UPDOWN,NULL); +} + // void cywee_service_service_resume(void) // { // PRINT("cywee_service_service resume!\r\n"); diff --git a/code/sdk/zhihui/drivers/cywee/service/cywee_service.h b/code/sdk/zhihui/drivers/cywee/service/cywee_service.h index 4f7841902..2e19c493f 100644 --- a/code/sdk/zhihui/drivers/cywee/service/cywee_service.h +++ b/code/sdk/zhihui/drivers/cywee/service/cywee_service.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-26 20:29:58 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-10-28 20:02:18 + * @LastEditTime: 2025-07-11 14:44:49 * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h * @Description: * @@ -106,6 +106,8 @@ void uapi_cywee_service_deinit(void); void do_cywee_service_check_msg(int cmd, int *data); void cywee_int_callback(pin_t pin, uintptr_t param); +void cywee_hand_wake_switch(uint8_t cmd); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/code/sdk/zhihui/drivers/mag/hal/mag_hal.c b/code/sdk/zhihui/drivers/mag/hal/mag_hal.c index bb6ba40da..124b501d9 100644 --- a/code/sdk/zhihui/drivers/mag/hal/mag_hal.c +++ b/code/sdk/zhihui/drivers/mag/hal/mag_hal.c @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-16 11:36:48 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-11 14:23:20 + * @FilePath: /FD230/code/sdk/zhihui/drivers/mag/hal/mag_hal.c + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #include #include diff --git a/code/sdk/zhihui/drivers/mag/hal/mag_hal.h b/code/sdk/zhihui/drivers/mag/hal/mag_hal.h index bad16d6db..591ec7163 100644 --- a/code/sdk/zhihui/drivers/mag/hal/mag_hal.h +++ b/code/sdk/zhihui/drivers/mag/hal/mag_hal.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:26 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-16 14:25:27 + * @LastEditTime: 2025-07-11 14:23:42 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h * @Description: * diff --git a/code/sdk/zhihui/drivers/mag/service/mag_service.c b/code/sdk/zhihui/drivers/mag/service/mag_service.c index 2b089b671..97a439fb4 100644 --- a/code/sdk/zhihui/drivers/mag/service/mag_service.c +++ b/code/sdk/zhihui/drivers/mag/service/mag_service.c @@ -141,7 +141,7 @@ errcode_t uapi_mag_service_init(void) { //TODO 设置磁力计检测是否存在标识 PRINT("MMC5603 not found!\r\n"); - // return ERRCODE_FAIL; + return ERRCODE_FAIL; } g_mag_sensor_exist = true; diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c index 0884b8c87..936ce3a23 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-13 15:08:38 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-16 18:45:57 + * @LastEditTime: 2025-07-11 10:56:20 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c * @Description: * @@ -26,12 +26,23 @@ #ifdef PPG_HX3695 #include "tyhx_hrs_custom.h" #include "hx3695.h" +#include "hx3695_factory_test.h" #endif +#ifdef PPG_PAH8009 +#include "pah800x_main.h" +#endif + +#ifdef PPG_GH3X2X +// #include "gh3x2x_afe_drv.h" +#endif + + #ifdef SUPPORT_CYWEE_SERVICE #include "cywee_service.h" #endif + // S_AGPIO_L26 心率复位 PPG reset #define GPIO_PIN_PRG_RESET S_AGPIO_L26 // S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 @@ -39,7 +50,7 @@ void ppg_power_on(void) { -#ifdef PPG_HX3695 + // printf("ppg_power_on\n"); uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_HIGH); @@ -48,12 +59,11 @@ void ppg_power_on(void) uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_HIGH); LOS_Mdelay(50); -#endif } void ppg_power_off(void) { -#ifdef PPG_HX3695 + // printf("ppg_power_off\n"); uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_LOW); @@ -62,9 +72,8 @@ void ppg_power_off(void) uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_LOW); LOS_Mdelay(50); -#endif } -/*获取心率值*/ + uint8_t ppg_get_hrs(void) { uint8_t hrs = 0; @@ -74,7 +83,7 @@ uint8_t ppg_get_hrs(void) #endif return hrs; } -/*获取spo2*/ + uint8_t ppg_get_spo2(void) { uint8_t spo2 = 0; @@ -83,7 +92,7 @@ uint8_t ppg_get_spo2(void) #endif return spo2; } -/*获取配置状态*/ + uint8_t ppg_get_wear_status(void) { uint8_t wear_status = 0; @@ -93,103 +102,81 @@ uint8_t ppg_get_wear_status(void) return wear_status; } -uint8_t ppg_get_chip_id(void) +uint16_t ppg_get_chip_id(void) { - uint8_t chip_id = 0; + uint16_t chip_id = 0; + ppg_power_on(); #ifdef PPG_HX3695 chip_id = hx3695_chip_check(); +#elif defined PPG_PAH8009 + chip_id = pah8009_get_chip_id(); +#elif defined PPG_GH3X2X + // chip_id = GH3X2X_AFE_GetChipId(); #endif + ppg_power_off(); return chip_id; } -void ppg_wear_timer_handler(void) +void ppg_timer_handler(uint8_t mode) { - // printf("ppg_wear_timer_handler\n"); + // printf("ppg_agc_timer_handler\n"); #ifdef PPG_HX3695 + if(mode == AGC_TIMER_MODE) + agc_timeout_handler(NULL); + else if(mode == HRS_TIMER_MODE) + heart_rate_meas_timeout_handler(NULL); + else if(mode == WEAR_TIMER_MODE) wear_mode_timeout_handler(NULL); +#elif defined PPG_PAH8009 + pah8009_timer_handler(); #endif } -void ppg_hrs_timer_handler(void) + +void ppg_int_handler(void) { - // printf("ppg_hrs_timer_handler\n"); -#ifdef PPG_HX3695 - heart_rate_meas_timeout_handler(NULL); +#ifdef PPG_PAH8009 + pah8009_int_handler(); +#elif defined PPG_PAH8009 + hal_gh3x2x_afe_int_handler_call_back(); + GH3X2X_AFE_ChipPro(); #endif } -void ppg_agc_timer_handler(void) +void ppg_send_cmd_to_driver(char* mode, uint8_t enable) { - // printf("ppg_agc_timer_handler\n"); + // printf("ppg_send_cmd_to_driver \n"); + if(enable) + ppg_power_on(); #ifdef PPG_HX3695 - agc_timeout_handler(NULL); + hx3695_control(mode,enable); +#elif defined PPG_PAH8009 + pah8009_control(mode,enable); +#elif defined PPG_GH3X2X + // gh3x2x_control(mode,enable); #endif + if(!enable) + ppg_power_off(); } - -void ppg_send_cmd_to_driver(char* mode, uint8_t enable) +void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2) { - // printf("ppg_send_cmd_to_driver \n"); #ifdef PPG_HX3695 - WORK_MODE_T md = NULL_MODE; - if (strcmp(mode, "hrs") == 0) { - md = HRS_MODE; - } else if (strcmp(mode, "hrv") == 0) { - md = HRV_MODE; - } else if (strcmp(mode, "spo2") == 0) { - md = SPO2_MODE; - } else if (strcmp(mode, "leaklight") == 0) { - md = FT_LEAK_LIGHT_MODE; - } else if (strcmp(mode, "graycard") == 0) { - md = FT_GRAY_CARD_MODE; - } else if (strcmp(mode, "ledoff") == 0) { - md = FT_LED_OFF_MODE; - } else if (strcmp(mode, "wear") == 0) { - md = WEAR_MODE; - } else if (strcmp(mode, "single") == 0) { - md = FT_SINGLE_CHECK_MODE; - } - - - if (enable == 1 || md == FT_LED_OFF_MODE) { - // ppg_service_running_stat = true; - uapi_pm_control(PM_APP_WAKE_NEEDED); - ppg_power_on(); - //custom_i2c_reset(); - hx3695_init(md); - } else { - - // ppg_service_running_stat = false; - if(md == HRS_MODE|| md == FT_LEAK_LIGHT_MODE || md == FT_GRAY_CARD_MODE || md == WEAR_MODE || md == FT_SINGLE_CHECK_MODE) - { -#ifdef HRS_ALG_LIB - hx3695_hrs_disable(); - // PRINT("uapi_dev_runtime_get_sleep_monitoring_status : %d \n",uapi_dev_runtime_get_sleep_monitoring_status()); - // PRINT("uapi_dev_runtime_get_hrs_passivity_flag : %d \n",uapi_dev_runtime_get_hrs_passivity_flag()); - if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag())//处于睡眠监测 且在心率周期检测期间 上报活体佩戴 - { - hx3695_wearstatus_update(); - uapi_dev_runtime_set_hrs_passivity(0);//清除被动检测runtime - } -#endif - }else if(md == HRV_MODE) - { -#ifdef HRV_ALG_LIB - hx3695_hrv_disable(); -#endif - }else if(md == SPO2_MODE) - { -#ifdef SPO2_ALG_LIB - hx3695_spo2_disable(); + hx3695_get_factory_data(ch0,ch1,ch2); +#elif defined PPG_VC9202 + vc9202_get_leaklight_data(ch0,ch1,ch2); +#elif defined PPG_PAH8009 + pah8009_get_leaklight_data(ch0,ch1,ch2); #endif - } - else{ -#ifdef HRS_ALG_LIB - hx3695_hrs_disable(); -#endif - } - uapi_pm_control(PM_APP_WAKE_NONEED); - ppg_power_off(); - } +} + +uint32_t ppg_get_factory_data(void) +{ + uint32_t data = 0; +#ifdef PPG_PAH8009 + data = pah8009_get_factory_data(); +#elif defined PPG_HX3695 + #endif -} \ No newline at end of file + return data; +} diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h index 5e1931247..ad98eb73c 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h @@ -2,8 +2,8 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:26 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-16 10:53:11 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h + * @LastEditTime: 2025-07-09 16:12:34 + * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/ppg/ppg_hal.h * @Description: * * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. @@ -17,34 +17,37 @@ extern "C" { #endif /* __cplusplus */ #include "stdint.h" -#include "tyhx_hrs_custom.h" + #define AGC_TIMER_MODE 0 #define HRS_TIMER_MODE 1 #define WEAR_TIMER_MODE 2 #ifdef PPG_HX3695 -#define PPG_CHIP_ID 0X65 +#define PPG_CHIP_ID 0x65 +#elif defined PPG_PAH8009 +#define PPG_CHIP_ID 0x8008 +#elif defined PPG_GH3X2X +#define PPG_CHIP_ID 0x3 #else #define PPG_CHIP_ID 0 #endif typedef uint32_t PPG_CMD_TYPE_T ; + void ppg_send_cmd_to_driver(char* mode, uint8_t enable); -// void ppg_timer_handler(uint8_t mode); -void ppg_agc_timer_handler(void); -void ppg_wear_timer_handler(void); -void ppg_hrs_timer_handler(void); -uint8_t ppg_get_chip_id(void); +void ppg_timer_handler(uint8_t mode); +uint16_t ppg_get_chip_id(void); uint8_t ppg_get_hrs(void); uint8_t ppg_get_spo2(void); uint8_t ppg_get_wear_status(void); - void ppg_wear_status_update(uint8_t status); - void ppg_power_on(void); void ppg_power_off(void); +void ppg_int_handler(void); +void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2); +uint32_t ppg_get_factory_data(void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/CMakeLists.txt b/code/sdk/zhihui/drivers/ppg/hx3695/CMakeLists.txt index c11b318b8..243189e8d 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/ppg/hx3695/CMakeLists.txt @@ -2,7 +2,7 @@ # @brief cmake file # Copyright (c) @CompanyNameMagicTag 2022-2023. All rights reserved. #=============================================================================== -set(COMPONENT_NAME "ppg_sensor") +set(COMPONENT_NAME "ppg_sensor_hx3695") if("PPG_HX3695" IN_LIST DEFINES) set(SOURCES ${SOURCES} diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c index 84ab85463..ad7483d30 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c +++ b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c @@ -392,7 +392,7 @@ uint8_t hx3695_chip_check(void) } } - printf(" hx3695 chip_id: 0x%x \r\n", chip_id); + printf("hx3695 chip id: 0x%x \r\n", chip_id); return chip_id; } @@ -2985,18 +2985,11 @@ void hx3695_hrs_ppg_Int_handle(void) if(hrsresult.wearstatus == MSG_HRS_WEAR) { - if(hrsresult.hr_living == MSG_LIVING_TRUE) - { - wear_status = 1; - if(hrsresult.lastesthrs > 30 && hrsresult.lastesthrs < 220) - get_avg_hrs(hrsresult.lastesthrs); - } - else - { - wear_status = 0; - } + wear_status = 1; + if(hrsresult.lastesthrs > 30 && hrsresult.lastesthrs < 220) + get_avg_hrs(hrsresult.lastesthrs); } - else + else if(hrsresult.wearstatus == MSG_HRS_NO_WEAR || hrsresult.hr_living == MSG_LIVING_FAIL) { hrsresult.wearstatus = MSG_HRS_NO_WEAR; hrsresult.lastesthrs = 0; @@ -3005,6 +2998,7 @@ void hx3695_hrs_ppg_Int_handle(void) // hx3695_msg_callback_t func = hx3695_get_send_msg_callback_func(); + // if(func != NULL) // { // if(his_wear == hrsresult.wearstatus) @@ -3062,9 +3056,10 @@ void hx3695_hrs_ppg_Int_handle(void) } } + // PRINT("hrsresult.wearstatus: %d, hr_living: %d, hr_result:%d \r\n",hrsresult.wearstatus,hrsresult.hr_living,hrsresult.lastesthrs); - //PRINT("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n", - //alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs); + PRINT("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n", + alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs); if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE) { @@ -3845,4 +3840,61 @@ void hx3695_lab_test_Int_handle(void) } #endif -#endif //CHIP_HX3695 \ No newline at end of file +void hx3695_control(char *mode,uint8_t enable) +{ + WORK_MODE_T md = NULL_MODE; + if (strcmp(mode, "hrs") == 0) { + md = HRS_MODE; + } else if (strcmp(mode, "hrv") == 0) { + md = HRV_MODE; + } else if (strcmp(mode, "spo2") == 0) { + md = SPO2_MODE; + } else if (strcmp(mode, "leaklight") == 0) { + md = FT_LEAK_LIGHT_MODE; + } else if (strcmp(mode, "graycard") == 0) { + md = FT_GRAY_CARD_MODE; + } else if (strcmp(mode, "ledoff") == 0) { + md = FT_LED_OFF_MODE; + } else if (strcmp(mode, "wear") == 0) { + md = WEAR_MODE; + } else if (strcmp(mode, "single") == 0) { + md = FT_SINGLE_CHECK_MODE; + } + + + if (enable == 1 || md == FT_LED_OFF_MODE) { + hx3695_init(md); + } else { + if(md == HRS_MODE|| md == FT_LEAK_LIGHT_MODE || md == FT_GRAY_CARD_MODE || md == WEAR_MODE || md == FT_SINGLE_CHECK_MODE) + { +#ifdef HRS_ALG_LIB + hx3695_hrs_disable(); + // PRINT("uapi_dev_runtime_get_sleep_monitoring_status : %d \n",uapi_dev_runtime_get_sleep_monitoring_status()); + // PRINT("uapi_dev_runtime_get_hrs_passivity_flag : %d \n",uapi_dev_runtime_get_hrs_passivity_flag()); + if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag())//处于睡眠监测 且在心率周期检测期间 上报活体佩戴 + { + hx3695_wearstatus_update(); + uapi_dev_runtime_set_hrs_passivity(0);//清除被动检测runtime + } +#endif + }else if(md == HRV_MODE) + { +#ifdef HRV_ALG_LIB + hx3695_hrv_disable(); +#endif + }else if(md == SPO2_MODE) + { +#ifdef SPO2_ALG_LIB + hx3695_spo2_disable(); +#endif + } + else{ +#ifdef HRS_ALG_LIB + hx3695_hrs_disable(); +#endif + } + } +} + +#endif //CHIP_HX3695 + diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.c b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.c index 2a6dd6aec..37992c20f 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.c +++ b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.c @@ -8,6 +8,10 @@ #include "hx3695.h" #include "hx3695_factory_test.h" +static uint32_t factory_green = 0; +static uint32_t factory_red = 0; +static uint32_t factory_ir = 0; + void hx3695_factory_wear_mode_config(void) { uint16_t sample_rate = 10; /*config the data rate of chip alps2_fm ,uint is Hz*/ @@ -2882,23 +2886,18 @@ FT_RESULTS_t hx3695_factroy_test(TEST_MODE_t test_mode) hx3695_factory_ft_leak_light_test_config(); hx3695_delay_ms(50); ft_result = hx3695_factory_ft_leak_light_test_get_result(); - hrsresult.leak_green = ft_result.gr_data_final; - hrsresult.leak_red = ft_result.red_data_final; - hrsresult.leak_ir = ft_result.ir_data_final; - TYHX_LOG("leak_green =%d\r\n",hrsresult.leak_green); - TYHX_LOG("leak_red =%d\r\n",hrsresult.leak_red); - TYHX_LOG("leak_ir =%d\r\n",hrsresult.leak_ir); + factory_green = ft_result.gr_data_final; + factory_red = ft_result.red_data_final; + factory_ir = ft_result.ir_data_final; + printf("factory_green : %d, factory_red:%d, factory_ir:%d\n",factory_green,factory_red,factory_ir); break; case GRAY_CARD_TEST: hx3695_factory_ft_card_test_config(); hx3695_delay_ms(50); ft_result = hx3695_factory_ft_card_test_get_result(); - hrsresult.card_green = ft_result.gr_data_final; - hrsresult.card_red = ft_result.red_data_final; - hrsresult.card_ir = ft_result.ir_data_final; - TYHX_LOG("card_green =%d\r\n",hrsresult.card_green); - TYHX_LOG("card_red =%d\r\n",hrsresult.card_red); - TYHX_LOG("card_ir =%d\r\n",hrsresult.card_ir); + factory_green = ft_result.gr_data_final; + factory_red = ft_result.red_data_final; + factory_ir = ft_result.ir_data_final; break; case FT_INT_TEST: hx3695_factory_ft_int_test_config(); @@ -2919,3 +2918,14 @@ FT_RESULTS_t hx3695_factroy_test(TEST_MODE_t test_mode) return ft_result; } + +void hx3695_get_factory_data(uint32_t *green,uint32_t *red,uint32_t *ir) +{ + *green = factory_green; + *red = factory_red; + *ir = factory_ir; + + factory_green = 0; + factory_red = 0; + factory_ir = 0; +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.h b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.h index 7abd190f5..397a97176 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.h +++ b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-15 11:28:07 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-11 11:03:23 + * @FilePath: /FD230/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_factory_test.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef _HX3695_FACTORY_TEST_H_ #define _HX3695_FACTORY_TEST_H_ @@ -38,6 +46,8 @@ FT_RESULTS_t hx3695_factroy_test(TEST_MODE_t test_mode); void hx3695_lab_test(uint32_t test_mode); void hx3695_lab_test_read(void); +void hx3695_get_factory_data(uint32_t *green,uint32_t *red,uint32_t *ir); + #endif // _HX3695_FACTORY_TEST_H_ diff --git a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_hrs_custom.c b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_hrs_custom.c index 2347c705a..6c94a3ebb 100644 --- a/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_hrs_custom.c +++ b/code/sdk/zhihui/drivers/ppg/hx3695/hx3695_hrs_custom.c @@ -48,7 +48,7 @@ static uint8_t g_hx3695_timer_installed = 0; static void timer40_func(void) { #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_AGC_TIMER_CALLBACK); #endif // agc_timeout_handler(NULL); } @@ -56,7 +56,7 @@ static void timer40_func(void) static void timer320_func(void) { #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_HRS_TIMER_CALLBACK); #endif // heart_rate_meas_timeout_handler(NULL); } @@ -64,7 +64,7 @@ static void timer320_func(void) static void timer5000_func(void) { #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TIMER_CALLBACK); #endif // heart_rate_meas_timeout_handler(NULL); } diff --git a/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp b/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp index 941901604..ab4458e83 100644 --- a/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp +++ b/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp @@ -246,16 +246,6 @@ void uapi_ppg_service_deinit(void) ppg_service_running_stat = false; } -uint32_t ppg_suspend(void) -{ - return custom_i2c_suspend(); -} -uint32_t ppg_resume(void) -{ - return custom_i2c_resume(); -} - - errcode_t send_ppg_cmd_msg(int cmd) { errcode_t ret; @@ -298,23 +288,23 @@ static void ppg_service_check_task(void *arg) } char* cmd = "hrs"; int enable = 1; - if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK){ + if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_HRS_TIMER_CALLBACK){ // #ifdef PPG_HX3695 // heart_rate_meas_timeout_handler(NULL); // #endif - ppg_hrs_timer_handler(); + ppg_timer_handler(HRS_TIMER_MODE); continue; - }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK){ + }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_AGC_TIMER_CALLBACK){ // #ifdef PPG_HX3695 // agc_timeout_handler(NULL); // #endif - ppg_agc_timer_handler(); + ppg_timer_handler(AGC_TIMER_MODE); continue; - }else if(mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK){ + }else if(mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TIMER_CALLBACK){ // #ifdef PPG_HX3695 // wear_mode_timeout_handler(NULL); // #endif - ppg_wear_timer_handler(); + ppg_timer_handler(WEAR_TIMER_MODE); continue; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL); @@ -460,17 +450,13 @@ errcode_t uapi_ppg_service_init(void) { PRINT("uapi_ppg_service_init !\r\n"); - ppg_power_on(); - if (ppg_get_chip_id() != PPG_CHIP_ID) { //TODO 没找到3695,退出线程 PRINT("ppg not exist!\r\n"); - ppg_power_off(); return ERRCODE_FAIL; } - ppg_power_off(); ppg_sensor_exist = true; diff --git a/code/sdk/zhihui/drivers/ppg/service/ppg_service.h b/code/sdk/zhihui/drivers/ppg/service/ppg_service.h index 012a1d8df..641ab0523 100644 --- a/code/sdk/zhihui/drivers/ppg/service/ppg_service.h +++ b/code/sdk/zhihui/drivers/ppg/service/ppg_service.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-27 09:07:00 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-01-06 16:57:23 + * @LastEditTime: 2025-07-11 10:59:44 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/service/ppg_service.h * @Description: * @@ -30,9 +30,10 @@ extern "C" { #include "errcode.h" #include "platform_core.h" -#define PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK 0x09 -#define PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK 0x0A -#define PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK 0x10 +#define PPG_SERVICE_CMD_TYPE_INT_HANDLER 0x08 +#define PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TIMER_CALLBACK 0x09 +#define PPG_SERVICE_CMD_TYPE_DO_PPG_AGC_TIMER_CALLBACK 0x0A +#define PPG_SERVICE_CMD_TYPE_DO_PPG_HRS_TIMER_CALLBACK 0x10 #define PPG_SERVICE_CMD_TYPE_DO_PPG_TEST 0x11 #define PPG_SERVICE_CMD_TYPE_DO_HRV_TEST 0x12 #define PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST 0x13 @@ -46,7 +47,6 @@ extern "C" { #define PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST 0x23 #define PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE 0x24 #define PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE 0x25 -#define PPG_SERVICE_CMD_TYPE_INT_HANDLER 0x26 #define PPG_SERVICE_CMD_TYPE_FPC_TEST 0x27 #define PPG_SERVICE_CMD_TYPE_FACTORY_TEST 0x28 diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp index 86b36ee9a..2e9c9dad1 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp @@ -2293,11 +2293,15 @@ void Set_RaiseToWake(bool value) //抬婉亮屏开关 mmi_flip_wrist_switch_set(value); if(true == value) { - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif } else { - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif } SendMsgToUIService(UI_UPDATE_RAISETOBRIGHTNESS,0,nullptr,0); @@ -3938,11 +3942,15 @@ void Set_RaiseToWake(bool value) //抬婉亮屏开关 mmi_flip_wrist_switch_set(value); if(true == value) { - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif } else { - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif } return; diff --git a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c index 0e172a13b..fe67e5dbb 100644 --- a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c +++ b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-20 11:31:30 + * @LastEditTime: 2025-07-14 15:28:33 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -19,7 +19,6 @@ #include "app_common_api.h" #include "lcd_private.h" #include "app_at_process.h" -#include "cywee_hal.h" #ifdef SUPPORT_PPG_SERVICE #include "ppg_service.h" @@ -49,6 +48,7 @@ #include "battery_service.h" #ifdef SUPPORT_CYWEE_SERVICE #include "cywee_service.h" +#include "cywee_hal.h" #endif #include "broadcast_feature.h" #ifdef SUPPORT_TCPIP @@ -472,7 +472,8 @@ void aging_task(void) return; } uapi_get_timestampe_ss(¤t_time); - mmc5603_getdata(&fAzimuth); + // mmc5603_getdata(&fAzimuth); + fAzimuth = mag_get_fAzimuth(); if(fAzimuth < 0) { aging_t.mag_error++; @@ -641,8 +642,10 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t if(id != 0x44) send_data[1] |= 1 << 1; - unsigned char mmc_id; - mmc5603_getid(&mmc_id); + uint8_t mmc_id; +#ifdef SUPPORT_MAG_SERVICE + mmc_id = mag_get_chip_id(); +#endif if(mmc_id != 0x10) send_data[1] |= 2 << 4; @@ -651,7 +654,7 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t if(tp_id != 0x6456) send_data[1] |= 1 << 4; - uapi_ppg_get_id(&id); + // uapi_ppg_get_id(&id); if(id != 0x65) send_data[1] |= 1 << 3; @@ -1376,7 +1379,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //获取原始数据 int16_t x,y; - get_tp_info(&x,&y); + // get_tp_info(&x,&y); uint8_t databuf[5] = {0}; databuf[1] = (uint8_t)((x & 0XFF00) >> 8); @@ -1465,22 +1468,24 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if(testitem == 0x01) { //获取 ppg_id - uint8_t ppg_id; - uapi_ppg_get_id(&ppg_id); + uint16_t ppg_id; +#ifdef SUPPORT_PPG_SERVICE + ppg_id = ppg_get_chip_id(); +#endif PRINT("0x%x\n",ppg_id); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x01, &ppg_id, - 1); + 2); } else if(testitem == 0x02) { //关闭所有LED uint8_t send_data = 0x00; - #ifdef SUPPORT_PPG_SERVICE +#ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LED_OFF_MODE_TEST); - #endif +#endif factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x02, @@ -1712,7 +1717,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint float fAzimuth = 0; do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); LOS_Msleep(500); - mmc5603_getdata(&fAzimuth); + // mmc5603_getdata(&fAzimuth); + fAzimuth = mag_get_fAzimuth(); do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); uint8_t databuf[2] = {0}; diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index a66847ae4..30506b5b3 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -77,15 +77,10 @@ #include "custom_utils.h" #include "custom_save_runtime.h" -#ifdef FD230_650 + #include "microtar.h" -#include "mag_service.h" -#include "ppg_service.h" #include "broadcast_feature.h" -#include "battery_service.h" -#include "cywee_hal.h" -#endif #ifdef SUPPORT_A5133_SERVICE #include "A5133main.h" #include "service/a5133_service.h" @@ -94,9 +89,7 @@ #ifdef FD230_COMPONENT #include "bluetooth/include/BluetoothModelC.h" #endif -#ifdef PPG_VC9202 -#include "vc9202_user.h" -#endif + #ifdef TPTYPE_CST86XX #include "cst86xx_touch1.h" #endif @@ -105,6 +98,15 @@ #include "bleEvent.h" #endif +#ifdef SUPPORT_PPG_SERVICE +#include "ppg_service.h" +#include "ppg_hal.h" +#endif + +#ifdef SUPPORT_BATTERY_SERVICE +#include "battery_service.h" +#endif + #ifdef SUPPORT_CYWEE_SERVICE #include "cywee_hal.h" #include "cywee_service.h" @@ -112,9 +114,11 @@ #ifdef SUPORT_MAG_SERVICE #include "mag_hal.h" +#include "mag_service.h" #endif - +#include "audio_base_type.h" #include +#include "audio_service.h" errcode_t uapi_create_osThread_custom(app_task_definition_t *task_cfg) { @@ -348,9 +352,9 @@ void shutdown_reboot_prejobs_task(void) // cm_sync_all_config_to_disk(); //保存电量 - #ifdef FD230_650 +#ifdef SUPPORT_BATTERY_SERVICE send_battery_svr_cmd_msg(BATTERY_CMD_SAVE_PERCENT); - #endif +#endif //重启前要保存时间 @@ -1503,32 +1507,38 @@ int get_save_runtime_vote_status(void) return ERRCODE_SUCC; } + +// int32_t StreamMgrSetTypeVolume(int32_t streamType, float typeVolume); + +// bool StreamMgrGetTypeVolume(int32_t streamType, float *typeVolume); + /*系统声音设置*/ -void uapi_systemVolumeSet(int32_t sounding) +void uapi_systemVolumeSet(int32_t volume) { - #ifdef FD230_COMPONENT - SystemVolumeSet(sounding); - #endif + printf("uapi_systemVolume:%d\n",volume); + AudioServiceSetVolume(AUDIO_STREAM_MUSIC, volume); } /*系统声音获取*/ -int uapi_systemVolumeGet(void) +int32_t uapi_systemVolumeGet(void) { - return SystemVolumeGet(); + // return SystemVolumeGet(); + return AudioServiceGetVolume(AUDIO_STREAM_MUSIC); } + //通话音量设置 -void uapi_callVolumeSet(int32_t sounding) +void uapi_callVolumeSet(int32_t volume) { - #ifdef FD230_COMPONENT - CallVolumeSet(sounding); - #endif + printf("uapi_callVolumeSet:%d\n",volume); + AudioServiceSetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, volume); + AudioServiceSetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, volume); } //通话音量获取 -int uapi_callVolumeGet(void) +int32_t uapi_callVolumeGet(void) { - return CallVolumeGet(); + return AudioServiceGetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE); } //设置4G能力开关是否开启 @@ -1538,9 +1548,19 @@ void uapi_set4GCapability(bool isopen) void *tcp_thread_id = NULL; if(isopen) { - #ifdef SUPPORT_CAT1_SERVICE + if(uapi_dev_runtime_get_cat1_powerstat()) + { + return; + } + + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_CAT1); + if (cnt == 0) + { + uapi_pm_add_sleep_veto(PM_ID_CAT1); + } + + // uapi_save_runtime_log(RUNTIME_LOG_CAT1_4G_OPEN); power_on_cat1(); - #endif // if(!uapi_dev_runtime_get_saveele_status()) { uapi_dev_runtime_set_cat1_powerstat(1); @@ -1550,18 +1570,31 @@ void uapi_set4GCapability(bool isopen) #ifdef SUPPORT_TCPIP tcp_thread_id = tcp_get_thread_id(); - ret = uapi_resume_thread(tcp_thread_id); - if(ret != ERRCODE_SUCC) - PRINT("tcpip_thread_resume failed ret : %d \n",ret); - else - PRINT("tcpip_thread_resume succed\n"); + if(tcp_thread_id != NULL) + { + ret = uapi_resume_thread(tcp_thread_id); + if(ret != ERRCODE_SUCC) + PRINT("tcpip_thread_resume failed ret : %d \n",ret); + else + PRINT("tcpip_thread_resume succed\n"); + } + #endif + + cnt = pm_veto_get_id_cnt(PM_ID_CAT1); + if (cnt == 1) + { + uapi_pm_remove_sleep_veto(PM_ID_CAT1); + } } else { - #ifdef SUPPORT_CAT1_SERVICE + if(!uapi_dev_runtime_get_cat1_powerstat()) + { + return; + } + // uapi_save_runtime_log(RUNTIME_LOG_CAT1_4G_CLOSE); power_off_cat1(); - #endif // if(!uapi_dev_runtime_get_saveele_status()) { uapi_dev_runtime_set_cat1_powerstat(0); @@ -1569,20 +1602,24 @@ void uapi_set4GCapability(bool isopen) /*4G 开电有时有干扰进日志串口,因此关闭4G才开启日志串口*/ // uapi_custom_set_uart_rx_enable_flag(true); + #ifdef SUPPORT_TCPIP + tcp_thread_id = tcp_get_thread_id(); + if(tcp_thread_id != NULL) + { + ret = uapi_suspend_thread(tcp_thread_id); + if(ret != ERRCODE_SUCC) + PRINT("tcpip_thread_suspend failed ret : %d \n",ret); + else + PRINT("tcpip_thread_suspend succed\n"); + } + #endif + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_CAT1); if (cnt == 1) { uapi_pm_remove_sleep_veto(PM_ID_CAT1); } - #ifdef SUPPORT_TCPIP - tcp_thread_id = tcp_get_thread_id(); - ret = uapi_suspend_thread(tcp_thread_id); - if(ret != ERRCODE_SUCC) - PRINT("tcpip_thread_suspend failed ret : %d \n",ret); - else - PRINT("tcpip_thread_suspend succed\n"); - #endif } } @@ -1920,20 +1957,14 @@ errcode_t uapi_get_fw_version(uint8_t *_major, uint8_t *_mid,uint8_t *_minor) return ERRCODE_SUCC; } -void uapi_take_to_wake(int cmd) -{ - #ifdef FD230_650 - if(cmd == 1) - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_HAND_UPDOWN,NULL); - else - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_HAND_UPDOWN,NULL); - #endif -} #include "lcd_common.h" void lcd_getid(uint32_t *id) { + if(id == NULL) + return; + lcd_drv_common *lcd_drv_comm_api = NULL; lcd_drv_cfg *lcd_cfg = NULL; @@ -1943,118 +1974,11 @@ void lcd_getid(uint32_t *id) } else { - lcd_cfg = lcd_drv_comm_api->get_lcd_config(); - if (lcd_cfg == NULL) { - PRINT("lcd_cfg is null.\r\n"); - }else - { - PRINT("LCD ID : 0x%x\r\n",(uint32_t)lcd_cfg->lcd_id); - *id = (uint32_t)lcd_cfg->lcd_id; - } - } -} -#ifdef TPTYPE_FT6X46 -#include "ft6x46_ctrl.h" -#include "ft6x46_touch1.h" -#define FTS_REG_CHIP_ID 0xA3 -#define FTS_REG_CHIP_ID2 0x9F -/*Max point numbers of touch trace*/ -#define MAX_POINTS_TOUCH_TRACE 1 -/*Length of touch information*/ -#define MAX_LEN_TOUCH_INFO (MAX_POINTS_TOUCH_TRACE * 6 + 2) -#define FTS_MAX_POINTS_SUPPORT 10 - -struct fts_ts_event { - int x; /*x coordinate */ - int y; /*y coordinate */ - int p; /* pressure */ - int type; /* touch event flag: 0 -- down; 1-- up; 2 -- contact */ - int id; /*touch ID */ - int area; /*touch area*/ -}; - - -void get_tp_info(int16_t *x,int16_t *y) -{ - uint8_t i = 0; - uint8_t base = 0; - uint8_t regaddr = 0x01; - uint8_t buf[MAX_LEN_TOUCH_INFO];/*A maximum of two points are supported*/ - - struct fts_ts_event events[FTS_MAX_POINTS_SUPPORT]; /* multi-touch */ - /*read touch information from reg0x01*/ - tp_ft6x46_i2c_data_read(regaddr, buf, MAX_LEN_TOUCH_INFO); - - memset(events, 0xFF, sizeof(struct fts_ts_event) * FTS_MAX_POINTS_SUPPORT); - - for (i = 0; i < MAX_POINTS_TOUCH_TRACE; i++) - { - base = 2 + i * 6; - - events[i].x = ((buf[base] & 0x0F) << 8) + buf[base + 1]; - events[i].y = ((buf[base + 2] & 0x0F) << 8) + buf[base + 3]; - - *x = events[i].x; - *y = events[i].y; - - PRINT("X : %d, y : %d \r\n",*x,*y); + lcd_drv_comm_api->get_chip_id(id); + PRINT("LCD ID : 0x%x\r\n",*id); } } -#else -void get_tp_info(int16_t *x,int16_t *y) -{ - -} -#endif - -void touch_getid(uint16_t *id) -{ -#ifdef TPTYPE_FT6X46 - ext_errno ret; - uint8_t chip_id[2] = { 0 }; - /*get chip id*/ - ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); - if (ret != EXT_ERR_SUCCESS) { - PRINT("get ic information error1"); - } else { - ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); - if (ret != EXT_ERR_SUCCESS) { - PRINT("get ic information error2"); - } else - { - PRINT("TOUCH CHIP ID = 0x%02x%02x \r\n", chip_id[0], chip_id[1]); - *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); - //sprintf(id,"0x%02x%02x", chip_id[0], chip_id[1]); - } - } -#elif defined TPTYPE_CST86XX - cst86xx_get_chip_id(id); - -#endif -} - -void touch_getstate(void) -{ - int32_t state; - state = uapi_get_screen_state(); - PRINT("Screen On state : %d\r\n",state); -} - -void mmc5603_getid(unsigned char *id) -{ - #ifdef SUPORT_MAG_SERVICE - *id = mag_get_chip_id(); - #endif -} - -void mmc5603_getdata(float *fAzimuth) -{ - *fAzimuth = mag_service_get_fAzimuth(); - PRINT("Azimuth : %f\n",*fAzimuth); -} - - #include "flash.h" void flash_getid(uint32_t *id) @@ -2485,16 +2409,6 @@ uint32_t uapi_calendar_recover_date(void) // get_current_time(&tv, &tm); // } -void uapi_ppg_get_id(uint8_t *chip_id) -{ -#ifdef SUPPORT_PPG_SERVICE - *chip_id = ppg_get_chip_id(); -#endif -#ifdef PPG_VC9202 - uint8_t id = 0; - vc9202_usr_get_chip_id(chip_id,&id); -#endif -} #include "hal_i2c.h" #include "i2c.h" @@ -2774,6 +2688,7 @@ uint32_t custom_spi_resume(void) uint32_t custom_i2c_suspend(void) { i2c_save_reg(I2C_BUS_2); + i2c_save_reg(I2C_BUS_1); #ifdef ENABLE_BN02 i2c_save_reg(I2C_BUS_0); #endif @@ -2782,6 +2697,7 @@ uint32_t custom_i2c_suspend(void) uint32_t custom_i2c_resume(void) { i2c_recovery_reg(I2C_BUS_2); + i2c_recovery_reg(I2C_BUS_1); #ifdef ENABLE_BN02 i2c_recovery_reg(I2C_BUS_0); #endif @@ -2823,7 +2739,9 @@ void uapi_enter_power_saving_mode(void) uapi_dev_runtime_set_saveele_status(1); //关闭抬腕亮屏 - uapi_take_to_wake(0); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(0); // 关闭抬腕亮屏,和息屏 +#endif //亮度最低 uapi_setScreenBrightness(51); @@ -2869,7 +2787,9 @@ void uapi_exit_power_saving_mode(void) //打开抬腕亮屏 if(mmi_flip_wrist_switch_get()) { - uapi_take_to_wake(1); +#ifdef SUPPORT_CYWEE_SERVICE + cywee_hand_wake_switch(1); // 关闭抬腕亮屏,和息屏 +#endif } //恢复亮度 @@ -3074,7 +2994,7 @@ errcode_t custom_i2c_test(void) unsigned char mmc_id = 0; uint8_t cywee_id = 0; - uapi_ppg_get_id(&ppg_id); + // uapi_ppg_get_id(&ppg_id); if(ppg_id != 0x65) return ERRCODE_FAIL; PRINT("ppg_id[%x] \n",ppg_id); @@ -3229,7 +3149,7 @@ void uapi_aging_test(uint32_t test_time) LOS_Msleep(6000); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); #endif - uapi_ppg_get_id(&ppg_id); + // uapi_ppg_get_id(&ppg_id); //if(ft_result.gr_data_final < 10000 || ft_result.red_data_final < 10000 || ft_result.ir_data_final < 10000) if(ppg_id != 0x65) { diff --git a/code/sdk/zhihui/utils/custom_utils.h b/code/sdk/zhihui/utils/custom_utils.h index cff261e5c..59af9761d 100644 --- a/code/sdk/zhihui/utils/custom_utils.h +++ b/code/sdk/zhihui/utils/custom_utils.h @@ -129,9 +129,9 @@ void uapi_setScreenDuration(int32_t time); int32_t uapi_get_screen_state(void); void uapi_systemVolumeSet(int32_t sounding); -int uapi_systemVolumeGet(void); +int32_t uapi_systemVolumeGet(void); void uapi_callVolumeSet(int32_t sounding); -int uapi_callVolumeGet(void); +int32_t uapi_callVolumeGet(void); // void uapi_vibrationModeSet(int value); void uapi_set4GCapability(bool isopen); @@ -166,40 +166,17 @@ errcode_t uapi_get_fw_version(uint8_t *_major, uint8_t *_mid,uint8_t *_minor); //判断文件夹是否存在 bool uapi_create_dir(const char *path); -// 使能翻腕亮灭屏功能接口 -// cmd: 1-active;other-deactive -void uapi_take_to_wake(int cmd); - - -//获取lcd id -void lcd_getid(uint32_t *id); - -//获取TP ID -void touch_getid(uint16_t *id); -void get_tp_info(int16_t *x,int16_t *y); - -//获取触摸屏状态 -void touch_getstate(void); - -//获取MMC5063 ID -void mmc5603_getid(unsigned char *id); -void mmc5603_getdata(float *fAzimuth); //flash整片擦除 void flash_getid(uint32_t *id); void flash_erase(void); -void get_gsensor_single(uint8_t *databuf); - - void shutdown_reboot_prejobs(uint8_t type); void start_shutdown_or_reboot(uint8_t type); uint8_t is_doing_shutdown_or_reboot(void); - - bool start_custom_ble_service(void); bool stop_custom_ble_service(void); @@ -338,7 +315,7 @@ void uapi_cywee_get_version(char *databuf,uint8_t len); void uapi_cywee_save_mac_key(const uint8_t *key_data,uint16_t len); uint8_t* uapi_cywee_get_mac_key(void); void uapi_get_sleep_date_on_log(char *time); -void uapi_ppg_get_id(uint8_t *chip_id); + int32_t uapi_microhone_switch(bool isopen); @@ -429,7 +406,8 @@ errcode_t touch_resume_in_cmd_queue(void); */ void BtInitSpp(void); - +void uapi_poweroff_device(void); +void uapi_reboot_device(void); void mcu_reset(void); void mcu_poweroff(void); diff --git a/code/sdk/zhihui/utils/custom_utils_at_cmd.c b/code/sdk/zhihui/utils/custom_utils_at_cmd.c index 980acb708..7ba55444a 100644 --- a/code/sdk/zhihui/utils/custom_utils_at_cmd.c +++ b/code/sdk/zhihui/utils/custom_utils_at_cmd.c @@ -165,7 +165,8 @@ static uint32_t custom_lcd_getid(uint8_t *para, uint32_t paraLen, char *strCommo UNUSED(strCommonCmd); - //lcd_getid(); + uint32_t id; + lcd_getid(&id); return ERRCODE_SUCC; } @@ -185,7 +186,7 @@ static uint32_t custom_touch_getstate(uint8_t *para, uint32_t paraLen, char *str UNUSED(strCommonCmd); - touch_getstate(); + // touch_getstate(); return ERRCODE_SUCC; } @@ -281,7 +282,7 @@ static uint32_t custom_get_tpinfo(uint8_t *para, uint32_t paraLen, char *strComm UNUSED(strCommonCmd); - get_tp_info(&x,&y); + // get_tp_info(&x,&y); return ERRCODE_SUCC; } @@ -330,7 +331,7 @@ static uint32_t custom_get_ppg_id(uint8_t *para, uint32_t paraLen, char *strComm UNUSED(strCommonCmd); uint8_t chip_id = 0; - uapi_ppg_get_id(&chip_id); + // uapi_ppg_get_id(&chip_id); wstp_print("ppg_id[%x]\n",chip_id); return ERRCODE_SUCC; } @@ -341,7 +342,9 @@ static uint32_t custom_get_mmc_id(uint8_t *para, uint32_t paraLen, char *strComm UNUSED(strCommonCmd); unsigned char id; - mmc5603_getid(&id); +#ifdef SUPPORT_MAG_SERVICE + id = mag_get_chip_id(); +#endif wstp_print("mmc5603 id : 0x%X \r\n",id); return ERRCODE_SUCC; }