From 8cb8bb414a8a6e7119dd200faa7bc8968af4fe39 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 13 Nov 2025 12:12:53 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E4=BA=A7?= =?utf8?q?=E6=B5=8B=E5=85=85=E7=94=B5=E6=B5=8B=E8=AF=95=EF=BC=8C=E9=A9=AC?= =?utf8?q?=E8=BE=BE=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sdk/zhihui/drivers/charge/hp4570/hp4570.c | 2 +- .../sdk/zhihui/drivers/charge/hp4570/hp4570.h | 2 +- code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c | 27 +++++++++++++++ .../drivers/ppg/pah8009/sensor/pah800x_main.c | 34 +++++++++++++++++++ .../factorytest_protocol.c | 16 ++++++--- 5 files changed, 74 insertions(+), 7 deletions(-) diff --git a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c index 0293c7506..feadedf75 100644 --- a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c +++ b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.c @@ -821,7 +821,7 @@ void hp4570_set_ideadbat_4x_en(bool en){ hp4570_write_reg(HP4570_REG_SYS_CTRL6, value); } -uint8_t hp4507_get_id(void) +uint8_t hp4570_get_id(void) { uint8_t id = 0; hp4570_i2c_addr = HP4570_I2C_ADDR; diff --git a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.h b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.h index d21cba99d..78beef1d7 100644 --- a/code/sdk/zhihui/drivers/charge/hp4570/hp4570.h +++ b/code/sdk/zhihui/drivers/charge/hp4570/hp4570.h @@ -516,5 +516,5 @@ bool hp4570_read_status_watchdog_int(void);// Watch dog time expire IRQ void hp4570_set_iterm_2x_en(bool en);//Terminate charge current X2 enable control void hp4570_set_ipre_4x_en(bool en);//Pre-charge current X4 enable control void hp4570_set_ideadbat_4x_en(bool en);//dead battary charge current X4 enable control -uint8_t hp4507_get_id(void); +uint8_t hp4570_get_id(void); #endif // HP4570_CHARGER_H \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c index e07150639..8df6b1c27 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c @@ -1484,6 +1484,26 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { { CWM_OS_dbgPrintf("CUSTOM_GNSS !!! \r\n"); } + + // if((int)sensorEVT->fData[1] == CUSTOM_ACC_ANY_MOTION) + // { + // CWM_OS_dbgPrintf("CUSTOM_ACC_ANY_MOTION !!! \r\n"); + + // if((int)sensorEVT->fData[2] == 1) + // CWM_Sensor_Enable(IDX_ALGO_ANY_MOTION); + // else + // CWM_Sensor_Disable(IDX_ALGO_ANY_MOTION); + // } + + // if((int)sensorEVT->fData[1] == CUSTOM_ACC) + // { + // CWM_OS_dbgPrintf("CUSTOM_ACC !!! \r\n"); + + // if((int)sensorEVT->fData[2] == 1) + // CWM_Sensor_Enable(IDX_ACCEL); + // else + // CWM_Sensor_Disable(IDX_ACCEL); + // } break; case IDX_ALGO_SHAKE: CWM_OS_dbgPrintf("IDX_ALGO_SHAKE\n"); @@ -2139,6 +2159,13 @@ int cywee_start(void) CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl); //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); + + // memset(&scl, 0, sizeof(scl)); + // scl.iData[0] = 1; + // scl.iData[1] = 1; + // scl.iData[2] = 60 * 1000; + // CWM_SettingControl(SCL_LOW_POWER_MODE, &scl); + CWM_Sensor_Enable(IDX_REQUEST_SENSOR); // //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP); diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c index 537405afe..91e9e2ff7 100644 --- a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c @@ -35,6 +35,9 @@ static float hr = 0.0f; static float hr_grader =0.0f; static ppg_mems_data_t ppg_mems_data_alg; +static FILE *logFp = NULL; +static uint8_t *log_swtich = 0; + // spo2 algorithm void *pBuffer = NULL; void *hr_pBuffer = NULL; @@ -1731,6 +1734,18 @@ static void report_spo2_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t r ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret, mySpO2,myHR,hr_grader,correlation, MEMS_RMS,trust_flag,no_value_reason,SignalPeriodicity, time_accu); + + + if(logFp) + { + fprintf(logFp,"%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %f, %f, %d, %f, %d\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret, mySpO2,myHR,hr_grader,correlation, MEMS_RMS,trust_flag,no_value_reason,SignalPeriodicity, time_accu); + } + } else { @@ -1741,6 +1756,15 @@ static void report_spo2_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t r ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret); + if(logFp) + { + fprintf(logFp,"%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret); + } } } @@ -1902,6 +1926,12 @@ void pah8009_control(char *mode,uint8_t enable) pah_sensor_stop(); work_mode = 0; + + if(logFp) + { + fclose(logFp); + logFp = NULL; + } // if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag()) // { // pah8009_wearstatus_update(history_wear_status); @@ -1925,6 +1955,10 @@ void pah8009_control(char *mode,uint8_t enable) ppg_only_sensor_start(); work_mode = 2; time_out = 20; + + if(log_swtich && logFp == NULL) + logFp = fopen("/user/userdata/spo2log.txt", "w"); + } else if (strcmp(mode, "leaklight") == 0) { // md = FT_LEAK_LIGHT_MODE; factory_test_mode(factory_test_leak_light_target_sample, 0, 0, 0, 0); diff --git a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c index a6e8acb87..50ec080a1 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-11-10 15:57:04 + * @LastEditTime: 2025-11-13 11:44:44 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -763,9 +763,15 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t bool state; state = uapi_get_charger_plug_status(); - if (!state) - send_data[1] |= state << 0; - +#ifdef ENABLE_HP4570 + id = hp4570_get_id(); + if (state != 1 || id != 0x2) + send_data[1] |= 1 << 0; +#else + if (!state) + send_data[1] |= 1 << 0; +#endif + uapi_cywee_get_id(&id); if(id != 0x44) send_data[1] |= 1 << 1; @@ -980,7 +986,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint g_ble_vibrator_timer = osTimerNew((osTimerFunc_t)ble_vibrator_check_timer_callback, osTimerPeriodic, NULL, NULL); if(g_ble_vibrator_timer) - osTimerStart(g_ble_vibrator_timer,500); + osTimerStart(g_ble_vibrator_timer,1000); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_VIBRATOR, -- 2.17.1