From d98ad9e6d3955e2f4e1c922c528b99992ce36618 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Sat, 21 Dec 2024 16:01:12 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0runtime=E8=AE=B0=E5=BD=95?= =?utf8?q?=E9=A1=B9=EF=BC=9A=E5=BF=83=E7=8E=87=E5=BA=95=E5=B1=82=E8=AE=B0?= =?utf8?q?=E5=BD=95=EF=BC=8C=E7=94=B5=E6=B1=A0=E7=94=B5=E5=8E=8B=E5=8F=98?= =?utf8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../application/battery/service/battery_driver.cpp | 11 +++++++++++ .../fd230app/nativeui/heartrate/src/HeartModel.cpp | 6 +++++- .../drivers/peripheral/ppg/service/ppg_service.cpp | 10 ++++++---- code/sdk/drivers/peripheral/ppg/service/ppg_service.h | 4 ++-- .../drivers/peripheral/utils/custom_save_runtime.h | 11 +++++++++-- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/code/sdk/application/battery/service/battery_driver.cpp b/code/sdk/application/battery/service/battery_driver.cpp index 7125b6698..80e0ff35a 100644 --- a/code/sdk/application/battery/service/battery_driver.cpp +++ b/code/sdk/application/battery/service/battery_driver.cpp @@ -620,6 +620,17 @@ static bool adc_get_sample_result(float *voltage, uint8_t channel) { *voltage = adc_trans_systick_to_battery_voltage(stick); get_avg_voltage(voltage); + int IntPart = (int)(*voltage); + int DecimalPart = (int)((*voltage - IntPart) * 1000); + + int DecimalPart_1 = (int)(DecimalPart / 100); + int DecimalPart_2 = (int)((DecimalPart % 100) / 10); + int DecimalPart_3 = (int)(DecimalPart % 10); + // PRINT("*voltage : %.3f \n",*voltage); + // PRINT("DecimalPart_1 : %d , DecimalPart_2 : %d DecimalPart_3 : %d \n",DecimalPart_1,DecimalPart_2,DecimalPart_3); + uint16_t value = DecimalPart_1 << 8 | DecimalPart_2 << 4 | DecimalPart_3 << 0; + uapi_save_runtime_log(RUNTIME_LOG_BAT_VOL | value); + // PRINT("RUNTIME_LOG_BAT_VOL | value : %x \n",RUNTIME_LOG_BAT_VOL | value); if(percernt_installized) { //历史电量不为0 则开机第一个电量为历史电量 diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index c4cc3ab01..b5ad6df72 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -415,7 +415,11 @@ void HeartModel::Heart_Control(HeartState state, HeartCheck check) { display_counter_ = 0; displayheart = 0; uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; - send_ppg_cmd_msg(md); + errcode_t ret = send_ppg_cmd_msg(md); + if(ret != ERRCODE_SUCC) + { + send_ppg_cmd_msg(md); + } heartstate = false; if (checkstate == HeartCheck::CARDCHECK) { //重置传感器状态 diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index 2c801e8f2..10bf17416 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -235,11 +235,11 @@ uint32_t ppg_resume(void) } -void send_ppg_cmd_msg(int cmd) +errcode_t send_ppg_cmd_msg(int cmd) { - int ret; + errcode_t ret; if (ppg_sensor_exist == false) - return ; + return OSAL_FAILURE; PPG_CMD_TYPE_T mail = 0; mail = cmd; @@ -248,7 +248,7 @@ void send_ppg_cmd_msg(int cmd) if (ret != OSAL_SUCCESS) { PRINT_ERR("Error ppg Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret); } - + return ret; } static void ppg_service_check_task(void *arg) @@ -284,6 +284,7 @@ static void ppg_service_check_task(void *arg) continue; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL); + uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE); cmd = "hrs"; enable = 1; uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); @@ -322,6 +323,7 @@ static void ppg_service_check_task(void *arg) enable = 0; wear_mode_state = 0; }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){ + uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE_END); cmd = "hrs"; enable = 0; uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h index 9e2f8ff80..35d25636d 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h +++ b/code/sdk/drivers/peripheral/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: 2024-11-23 22:07:09 + * @LastEditTime: 2024-12-21 11:00:33 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/service/ppg_service.h * @Description: * @@ -51,7 +51,7 @@ void uapi_ppg_service_deinit(void); /** * 测试指令 参数cmd 选项: PPG_SERVICE_CMD_START_CHECK,PPG_SERVICE_CMD_STOP_CHECK */ -void send_ppg_cmd_msg(int cmd); +errcode_t send_ppg_cmd_msg(int cmd); float ppg_service_get_fAzimuth(void); int ppg_service_get_iAccuracy(void); diff --git a/code/sdk/drivers/peripheral/utils/custom_save_runtime.h b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h index 69f86ab95..da2fd7c7c 100644 --- a/code/sdk/drivers/peripheral/utils/custom_save_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_save_runtime.h @@ -1,8 +1,8 @@ /* *@Author:luozheng 1732036298@qq.com *@Date:2024-12-18 10:27:52 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-12-20 16:39:00 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-12-21 11:52:18 *@FilePath:/FD230/code/sdk/drivers/peripheral/utils/custom_save_runtime.h */ /** @@ -130,6 +130,10 @@ extern "C" RUNTIME_LOG_HEART_SPORT_MEASURE, // 运动测量心率暂停或结束 RUNTIME_LOG_OXYGEN_SPORT_MEASURE_END, + //底层测量心率 + RUNTIME_LOG_HEART_DRIVER_MEASURE, + //底层测量心率结束 + RUNTIME_LOG_HEART_DRIVER_MEASURE_END, /*******************************/ // 佩戴 @@ -218,6 +222,9 @@ extern "C" RUNTIME_LOG_VOTE_ID =0x1300, + //电压变化 + RUNTIME_LOG_BAT_VOL =0xf000, + } runtime_log_cmd_Id; errcode_t uapi_save_runtime_log(uint16_t cmd); -- 2.17.1