From a2a0f13b06a38c8b7ec3ab8a87ed83f856555fb4 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 5 Sep 2024 11:41:55 +0800 Subject: [PATCH] =?utf8?q?cywee=E6=9B=B4=E6=94=B9=E4=B8=BADML=E5=88=86?= =?utf8?q?=E7=A6=BB=E6=A8=A1=E5=BC=8F=20=EF=BC=8C=E4=BC=98=E5=8C=96?= =?utf8?q?=E7=9D=A1=E7=9C=A0=E6=A8=A1=E5=BC=8F=E7=BB=9D=E5=AF=B9=E9=9D=99?= =?utf8?q?=E6=AD=A2=E5=A4=84=E7=90=86=20=E4=BC=98=E5=8C=96=E7=9D=A1?= =?utf8?q?=E7=9C=A0=E6=95=B0=E6=8D=AE=E6=96=87=E4=BB=B6=E5=AD=98=E5=82=A8?= =?utf8?q?=20=E4=BF=AE=E6=94=B9=E8=93=9D=E7=89=99=E5=B9=BF=E6=92=AD?= =?utf8?q?=E9=97=B4=E9=9A=94=E4=B8=BA150=20=E4=BF=AE=E5=A4=8DBUG=20#463=20?= =?utf8?q?"=E8=A1=80=E6=B0=A7=E8=84=B1=E8=85=95=E6=B5=8B=E9=87=8F=E6=8F=90?= =?utf8?q?=E7=A4=BA=E5=93=8D=E5=BA=94=E6=85=A2=EF=BC=8C=E8=84=B1=E8=85=95?= =?utf8?q?=E5=BE=88=E4=B9=85=E6=89=8D=E4=BC=9A=E6=8F=90=E7=A4=BA"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/AlarmClockTimerConfig.cpp | 4 + .../bloodoxygen/src/BloodOxygenModel.cpp | 2 +- .../nativeui/sleep/include/SleepModel.h | 9 +- .../nativeui/sleep/src/SleepModel.cpp | 167 ++++++++++-------- .../ble_service/bleservice/bleService.c | 16 +- .../msg_center/src/msg_center_customer.cpp | 9 + .../peripheral/cywee/src/board_yh601s.c | 2 +- .../drivers/peripheral/cywee/src/main_dml.c | 148 ++++++++++++++-- .../drivers/peripheral/utils/custom_runtime.c | 12 ++ .../drivers/peripheral/utils/custom_runtime.h | 3 + .../drivers/peripheral/utils/custom_utils.c | 58 +++--- 11 files changed, 303 insertions(+), 127 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 07aa04754..d1cd281b1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -36,6 +36,7 @@ #include "AppViewIDs.h" #include "player/include/PlayersView.h" #include "record/include/RecordingPlayerView.h" + #ifdef __cplusplus extern "C" { @@ -407,6 +408,7 @@ extern "C" { // 设置状态为小睡 uapi_dev_runtime_set_nap_status(0); // 清零小睡状态 + uapi_dev_runtime_set_absolute_static_status(0); // 清零绝对静止状态 uapi_dev_runtime_set_nap_monitoring_status(1); uapi_dev_runtime_set_sleep_monitoring_status(0); OHOS::SleepModel::GetInstance().ReInitData(); // 更新睡眠数据 @@ -418,6 +420,8 @@ extern "C" else if ((!WAKE_TIME_RANGE) && (uapi_dev_runtime_get_sleep_monitoring_status() == 0)) { uapi_dev_runtime_set_sleep_status(0); // 清零睡眠状态 + uapi_dev_runtime_set_absolute_static_status(0); // 清零绝对静止状态 + OHOS::clean_sleep_data(); // 清零睡眠文件存储数据 uapi_dev_runtime_set_sleep_monitoring_status(1); uapi_dev_runtime_set_nap_monitoring_status(0); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); // 强制获取小睡数据,结束小睡 diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index c6cf4d21d..14b7171ac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -14,7 +14,7 @@ extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #include "NativeAbility.h" #include "battery_hal.h" -#define MAX_UNWARE_COUNT 30 +#define MAX_UNWARE_COUNT 10 #define MAX_VALID_SPO2_COUNT 30 #define MAX_DISVALID_SPO2_COUNT 100 namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h index 0f5fb2cae..999d9c4bd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-09-03 14:30:14 + * @LastEditTime: 2024-09-04 19:02:28 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h * @Description: * @@ -26,7 +26,10 @@ // #include "sleep/include/SleepControlPresenter.h" #include "string" -#define SLEEP_PATH "user/userdata/sleep/%s/sleep_%d.bin" +#define SLEEP_TIME_PATH "user/userdata/sleep/%s/sleep_time.bin" +#define SLEEP_STATUS_PATH "user/userdata/sleep/%s/sleep_status.bin" + +#define NAP_PATH "user/userdata/sleep/%s/nap_%d.bin" #define SLEEP_DIR_PATH "user/userdata/sleep/%s" @@ -72,7 +75,7 @@ namespace OHOS void set_sleep_data(SLEEP_T *data); bool save_sleep_data(SLEEP_T *data); bool read_sleep_data(SLEEP_T *data); - + void clean_sleep_data(void); // 睡眠状态 enum class SLEEPSTATE { diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index 1db41a71f..38fa102a5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: SLEPPNOTIFY24-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: SLEPPNOTIFY24-06-28 16:52:58 + * @LastEditTime: 2024-09-05 09:33:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp * @Description: * @@ -84,7 +84,7 @@ namespace OHOS uint32_t creationTime; int ret = uapi_get_timestampe_ss(&creationTime); - sprintf_s(file_path, 64, SLEEP_PATH, day, creationTime); + sprintf_s(file_path, 64, NAP_PATH, day, creationTime); FILE *fp; fp = fopen(file_path, "wb+"); @@ -129,11 +129,34 @@ namespace OHOS return fread(data, 1, size, fp); } + static uint16_t total_time = 0; + static uint16_t total_deep_sleep_time = 0; + static uint16_t total_mild_sleep_time = 0; + static uint16_t total_rem_sleep_time = 0; + static uint16_t total_wake_time = 0;; + static char time_file_path[64] = {0}; + static char status_file_path[64] = {0}; + + static uint32_t fall_asleep_timestamp = 0; + + void clean_sleep_data(void) + { + total_time = 0; + total_deep_sleep_time = 0; + total_mild_sleep_time = 0; + total_rem_sleep_time = 0; + total_wake_time = 0; + memset(time_file_path,0,sizeof(time_file_path)); + memset(status_file_path,0,sizeof(status_file_path)); + fall_asleep_timestamp = 0; + } + + bool save_sleep_data(SLEEP_T *data) { + struct stat info; char dir_path[64] = {0}; - char file_path[64] = {0}; char day[12] = {0}; uapi_get_YYMMDD_Time(day, '\0'); @@ -154,30 +177,36 @@ namespace OHOS return false; // Failed to create folder } } + - uint32_t creationTime; - int ret = uapi_get_timestampe_ss(&creationTime); - sprintf_s(file_path, 64, SLEEP_PATH, day, creationTime); + if(access(time_file_path, F_OK) == -1) + { + memset(time_file_path,0,sizeof(time_file_path)); + sprintf_s(time_file_path, 64, SLEEP_TIME_PATH, day); + } FILE *fp; - fp = fopen(file_path, "wb+"); + fp = fopen(time_file_path, "wb+"); if (fp == NULL) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_nap_sleep_data fopen fail"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); return false; } uint8_t sleep_type = 1; fwrite(&sleep_type, 1, 1, fp); - uint32_t fall_asleep_timestamp = data->fall_asleep_timestamp; + if(fall_asleep_timestamp == 0) + { + fall_asleep_timestamp = data->fall_asleep_timestamp; + } fwrite(&fall_asleep_timestamp, 1, 4, fp); uint32_t wake_up_timestamp = data->wake_up_timestamp; fwrite(&wake_up_timestamp, 1, 4, fp); - uint16_t total_time = data->total_time; + total_time = (wake_up_timestamp - fall_asleep_timestamp) / 60; uint8_t total_time_hour = (total_time / 60); fwrite(&total_time_hour, 1, 1, fp); @@ -185,7 +214,7 @@ namespace OHOS uint8_t total_time_minute = (total_time % 60); fwrite(&total_time_minute, 1, 1, fp); - uint16_t total_deep_sleep_time = data->total_deep_sleep_time; + total_deep_sleep_time += data->total_deep_sleep_time; total_time_hour = (total_deep_sleep_time / 60); fwrite(&total_time_hour, 1, 1, fp); @@ -193,27 +222,45 @@ namespace OHOS total_time_minute = (total_deep_sleep_time % 60); fwrite(&total_time_minute, 1, 1, fp); - uint16_t total_mild_sleep_time = data->total_mild_sleep_time; + total_mild_sleep_time += data->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); - uint16_t total_rem_sleep_time = data->total_rem_sleep_time; + total_rem_sleep_time += data->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); - uint16_t total_wake_time = data->total_wake_time; + 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(access(status_file_path, F_OK) == -1) + { + memset(status_file_path,0,sizeof(status_file_path)); + sprintf_s(status_file_path, 64, SLEEP_STATUS_PATH, day); + fp = fopen(time_file_path, "wb+"); + } + else + { + fp = fopen(time_file_path, "ab+"); + } + + if (fp == NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); + return false; + } fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); fclose(fp); @@ -237,69 +284,49 @@ namespace OHOS uapi_get_YYMMDD_Time(day, '\0'); char file_path[64] = {0}; - sprintf_s(file_path, 64, "%s%s/", SLEEP_DATA_DIR, day); - - // 打开目录 - DIR *dir; - struct dirent *ent; - if ((dir = opendir(file_path)) != NULL) + sprintf_s(file_path, 64, SLEEP_TIME_PATH, day); + + FILE *fp = fopen(file_path, "rb"); + if (fp == NULL) { - while ((ent = readdir(dir)) != NULL) - { - char file_name[64]; - sprintf_s(file_name, 64, "%s%s", file_path, ent->d_name); - - if (is_regular_file(file_name)) // 判断是否为文件 - { - FILE *fp = fopen(file_name, "rb"); - if (fp == NULL) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "read_sleep_data fopen fail"); - continue; - } - - // 读取睡眠类型 - uint8_t sleep_type; - fread(&sleep_type, 1, 1, fp); - - if (sleep_type == 0) - { - fclose(fp); - continue; - } - - // 入睡时间 - uint32_t fall_asleep_timestamp; - fread(&fall_asleep_timestamp, 1, 4, fp); - - // 起床时间 - uint32_t wake_up_timestamp; - fread(&wake_up_timestamp, 1, 4, fp); - - // 睡眠总时间 - uint8_t total_time_hour, total_time_minute; - fread(&total_time_hour, 1, 1, fp); - fread(&total_time_minute, 1, 1, fp); - uint16_t total_time = total_time_hour * 60 + total_time_minute; - - // 累加睡眠数据 - data->fall_asleep_timestamp = (data->fall_asleep_timestamp == 0) ? fall_asleep_timestamp : min(data->fall_asleep_timestamp, fall_asleep_timestamp); - data->wake_up_timestamp = max(data->wake_up_timestamp, wake_up_timestamp); - data->total_time += total_time; - - fclose(fp); - } - } - closedir(dir); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "read_sleep_data fopen fail"); + return false; } - else + + // 读取睡眠类型 + uint8_t sleep_type; + fread(&sleep_type, 1, 1, fp); + + if (sleep_type == 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cannot open directory"); + fclose(fp); return false; } + // 入睡时间 + uint32_t fall_asleep_timestamp; + fread(&fall_asleep_timestamp, 1, 4, fp); + + // 起床时间 + uint32_t wake_up_timestamp; + fread(&wake_up_timestamp, 1, 4, fp); + + // 睡眠总时间 + uint8_t total_time_hour, total_time_minute; + fread(&total_time_hour, 1, 1, fp); + fread(&total_time_minute, 1, 1, fp); + uint16_t total_time = total_time_hour * 60 + total_time_minute; + + // 累加睡眠数据 + data->fall_asleep_timestamp = fall_asleep_timestamp; + data->wake_up_timestamp =wake_up_timestamp; + data->total_time = total_time; + + fclose(fp); + return true; - } +} + void set_sleep_data(SLEEP_T *data) { memset(&sleep_data, 0, sizeof(SLEEP_T)); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 3475fe435..ff4f62cda 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -425,14 +425,14 @@ void svr_pair_result_cbt_cb(uint16_t conn_id, const bd_addr_t *addr, errcode_t s hand_watch_first_time_Paired(); svr_ble_adv_stop(); - // gap_conn_param_update_t conn_param = { 0 }; - // conn_param.conn_handle = conn_id; /* param 0: conn_handle */ - // conn_param.interval_min =140*16; /* param 1: interval_min */ - // conn_param.interval_max = 160*16; /* param 2: interval_max */ - // conn_param.slave_latency = 20; /* param 3: slave_latency */ - // conn_param.timeout_multiplier = 160*32; /* param 4: timeout_multiplier */ - // errcode_t ret = gap_ble_connect_param_update(&conn_param); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap ble update connection parameters ret: %u\n", ret); + gap_conn_param_update_t conn_param = { 0 }; + conn_param.conn_handle = conn_id; /* param 0: conn_handle */ + conn_param.interval_min =150; /* param 1: interval_min */ + conn_param.interval_max = 150; /* param 2: interval_max */ + conn_param.slave_latency = 20; /* param 3: slave_latency */ + conn_param.timeout_multiplier = 160*32; /* param 4: timeout_multiplier */ + errcode_t ret = gap_ble_connect_param_update(&conn_param); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"gap ble update connection parameters ret: %u\n", ret); } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index e259cdbe6..ac5d03121 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -1322,6 +1322,15 @@ void MsgCenterNotifyInactivityAccumulateTimeProc(const Topic topic, Request* req { unused(topic); + if(uapi_dev_runtime_get_absolute_static_status()) + { + memset(&sleep_data,0,sizeof(SLEEP_T)); + state_num = 0; + fall_asleep_state_num = 0; + uapi_dev_runtime_set_absolute_static_status(0); + return; + } + cywee_inactivity_accumulate_time_t *cywee_Inactivity_Accumulate_Time_Info = (cywee_inactivity_accumulate_time_t *)malloc(req->len); if (!cywee_Inactivity_Accumulate_Time_Info) { diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index e637801c3..f3e49d73a 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -240,7 +240,7 @@ void CWM_OS_free(void *ptr) int CWM_OS_dbgOutput(const char * format) { PRINT("%s", format); - if(cywee_ble_service_flag) + if(cywee_ble_service_flag == 1) ble_cywee_server_send_input_report((uint8_t *)format,strlen(format)); return 0; } diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index a53dd5cf3..94f61d1b8 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -78,10 +78,11 @@ static uint8_t is_static_state = 0; uint8_t cywee_ble_service_flag = 0; -static uint8_t is_abs_static_state = 0; - static char cywee_version[20] = {0}; +static uint32_t abs_static_timestampe = 0; +static uint32_t asleep_timestampe = 0; + #ifdef CYWEE_MAC_ACTIVE int cm__hs1__mac_c0_init(void); int cm__hs1__mac_c0r_init(void); @@ -467,11 +468,6 @@ void cywee_oncharging_update(int oncharging_status) void cywee_wearstatus_update(int wearstatus) { - if(is_abs_static_state == 1) - { - wearstatus = 0; - is_abs_static_state = 0; - } memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); csd.sensorType = CUSTOM_OFFBODY_DETECT; csd.fData[0] = wearstatus; @@ -839,10 +835,14 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 if(c_inactivity_result_t.status == 6) + { uapi_dev_runtime_set_sleep_status(1); + uapi_get_timestampe_ss(&asleep_timestampe); + } else if(c_inactivity_result_t.status == 4 || c_inactivity_result_t.status == 13) + { uapi_dev_runtime_set_sleep_status(0); - + } cywee_func(CYWEE_MSG_TYPE_INACTIVITY_UPDATE,&c_inactivity_result_t,sizeof(cywee_inactivity_result_t)); }else if((int)sensorEVT->fData[0] == 31){ @@ -961,7 +961,22 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { break; case IDX_ALGO_ABSOLUTE_STATIC: CWM_OS_dbgPrintf("IDX_ALGO_ABSOLUTE_STATIC\n"); - is_abs_static_state = 1; + if(uapi_dev_runtime_get_sleep_status()) + { + uapi_get_timestampe_ss(&abs_static_timestampe); + if((abs_static_timestampe - asleep_timestampe) >= 60 * 90) + { + uapi_dev_runtime_set_absolute_static_status(1); + cywee_get_sleep_data(); + } + else + { + cywee_inactivity_mode_change(INACTIVITY_MODE_NOTHING); + LOS_Msleep(50); + cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); + } + } + break; case IDX_ALGO_SPV: CWM_OS_dbgPrintf("IDX_ALGO_SPV\n"); @@ -990,14 +1005,76 @@ 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_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) { + + // if (pSdo->validData & DML_SENSOR_DATA_VALID_DT) + // CWM_OS_dbgPrintf("==dt: %d us\n", pSdo->dt_us); + + // if (pSdo->validData & DML_SENSOR_DATA_VALID_ACC) + // CWM_OS_dbgPrintf("==acc: x=%.3f, y=%.3f, z=%.3f\n", pSdo->acc_data[0], pSdo->acc_data[1], pSdo->acc_data[2]); +//} + +/*增加DML sensor数据输出*/ +struct AccelerationData { + float dt; + float acc_x; + float acc_y; + float acc_z; +}; +struct AccelerationData rawdata[25]; //自定义buffer,用来缓存sensor数据 +int AccdataCount = 0; //fifo长度 + +void CWM_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) +{ if (pSdo->validData & DML_SENSOR_DATA_VALID_DT) - CWM_OS_dbgPrintf("==dt: %d us\n", pSdo->dt_us); - + { + //CWM_OS_dbgPrintf("dt: %d us\n", pSdo->dt_us); + rawdata[AccdataCount].dt = pSdo->dt_us; + } if (pSdo->validData & DML_SENSOR_DATA_VALID_ACC) - CWM_OS_dbgPrintf("==acc: x=%.3f, y=%.3f, z=%.3f\n", pSdo->acc_data[0], pSdo->acc_data[1], pSdo->acc_data[2]); + { + //CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",pSdo->acc_data[0], pSdo->acc_data[1], pSdo->acc_data[2]); + rawdata[AccdataCount].acc_x = pSdo->acc_data[0]; + rawdata[AccdataCount].acc_y = pSdo->acc_data[1]; + rawdata[AccdataCount].acc_z = pSdo->acc_data[2]; + + gxyz_t.x = pSdo->acc_data[0]; + gxyz_t.y = pSdo->acc_data[1]; + gxyz_t.z = pSdo->acc_data[2]; + + if(get_acc_swtich) + { + if(num_falg==25) + { + left_falg++; + right_falg++; + right_falg=right_falg%25; + left_falg=left_falg%25; + gxyz_t_queue[right_falg].x= pSdo->acc_data[0]; + gxyz_t_queue[right_falg].y= pSdo->acc_data[1]; + gxyz_t_queue[right_falg].z= pSdo->acc_data[2]; + } + else + { + //left_falg++; + right_falg++; + right_falg=right_falg%25; + //left_falg=left_falg%16; + num_falg++; + gxyz_t_queue[right_falg].x= pSdo->acc_data[0]; + gxyz_t_queue[right_falg].y= pSdo->acc_data[1]; + gxyz_t_queue[right_falg].z= pSdo->acc_data[2]; + //CWM_OS_dbgPrintf("write: x=%d, y=%d, z=%d\n", gxyz_t_queue[right_falg].x ,gxyz_t_queue[right_falg].y ,gxyz_t_queue[right_falg].z); + + } + } + + AccdataCount++; + AccdataCount = AccdataCount % 25; + } } + #endif int cywee_main_dml(void) @@ -1139,8 +1216,12 @@ int cywee_main_dml(void) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; +#ifdef AP_ENABLE_DML_SDO_LISTEN + scl.iData[2] = 4+16; //分离式DML +#else scl.iData[1] = 18; //00000000000000000000000000010010 高位在前 - // CWM_SettingControl(SCL_DML_DEBUG, &scl); +#endif + //CWM_SettingControl(SCL_DML_DEBUG, &scl); //设置acc gyro 相关参数 memset(&scl, 0, sizeof(scl)); @@ -1176,6 +1257,9 @@ int cywee_main_dml(void) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = 1; +#ifdef AP_ENABLE_DML_SDO_LISTEN + scl.iData[3] = 3; +#endif CWM_SettingControl(SCL_DML_DRV_INIT, &scl); CWM_OS_dbgPrintf("DML device=%d\n", scl.iData[2]); @@ -1247,7 +1331,9 @@ int cywee_main_dml(void) CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT); // CWM_Sensor_Enable(IDX_ALGO_SEDENTARY); // CWM_Sensor_Enable(IDX_ALGO_SLEEP); +#ifndef AP_ENABLE_DML_SDO_LISTEN CWM_Sensor_Enable(IDX_ACCEL); +#endif //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); // CWM_Sensor_Enable(IDX_GYRO); CWM_Sensor_Enable(IDX_ALGO_NO_MOTION); @@ -1267,8 +1353,42 @@ int cywee_main_dml(void) return 0; } +#ifdef AP_ENABLE_DML_SDO_LISTEN + +int cwm_lib_process(void) //运行算法 +{ + int i,ret; + CWM_Dml_process(); //分离式DML,获取sensor数据输出 + + CWM_CustomSensorInput_Fifo_Start(CUSTOM_ACC,CWM_OS_GetTimeNs(), 40 * 1000000); + for (uint16_t i=0; id_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) - { - snprintf(filePath, sizeof(filePath), "%s/%s", directoryPath, entry->d_name); - uapi_analysis_sleep_data(filePath); - } - } - closedir(dir); } extern void save_file_main(void); -- 2.17.1