From: penglei <1624952103@qq.com> Date: Tue, 9 Apr 2024 11:44:26 +0000 (+0800) Subject: 优化运动切换函数 X-Git-Tag: release_V1.2.70_20241020_135402~1220 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a1d4a8582a11405e13866c9aa21b0ad56af04a0a;p=mirrors%2FFD230.git 优化运动切换函数 --- diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index d3d6a1b2e..20b8d14c6 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -299,39 +299,6 @@ void ble_leaklight_check_timer_callback(void) leaklight_flag++; } -void get_rtc(uint32_t *msc) -{ - char time_data[64] = {0}; - uint8_t send_data1[20] = {0}; - uint8_t send_data2[7] = {0}; - - uint8_t i = 0; - get_system_time(time_data); - uint8_t len = strlen(time_data); - //1970-01-01 00:00:26 - PRINT("time_data : %s , len : %d\r\n",time_data,len); - - for (int j = 0; j < len; j ++) - { - if(time_data[j] >= '0' && time_data[j] <= '9' ) - { - send_data1[i++] = (time_data[j] - '0'); - } - } - - i = 0; - for(int j = 0; j < 14 ; j+=2) - { - send_data2[i++] = send_data1[j] * 10 + send_data1[j+1]; - } - - *msc = ((((send_data2[0] * 100 + send_data2[1] - 1970) * 365 - + (send_data2[2] -1)* 30 + (send_data2[3] - 1) ) * 24 - + send_data2[4]) * 60 + send_data2[5]) * 60 - + send_data2[6]; - -} - void aging_task(void) { while(aging_t.flag == 0xfdfd0002 && aging_time) @@ -1475,7 +1442,7 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) } - }else{ + }else{ printf("crc error!\r\n"); return ERRCODE_FAIL; } diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index 2eb18f0e6..c1968c8df 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -289,7 +289,7 @@ errcode_t uapi_cywee_service_init(void) g_cywee_service_timer = osTimerNew((osTimerFunc_t)cywee_service_check_timer_callback, osTimerPeriodic, NULL, NULL); cywee_register_msg_callback(cywee_msg_callback); - //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_START_CHECK); + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE); return ERRCODE_SUCC; } diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 6b53f68e3..88f8c04ef 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -71,6 +71,7 @@ void activity_exit(void) scl.iData[0] = 1; CWM_SettingControl(SCL_REQ_ACTIVITY_EXIT, &scl); cywee_installized = 0; + CWM_Sensor_Disable(IDX_ALGO_ACTIVITY_OUTPUT); } void cyw_mode_init(int mode) @@ -133,6 +134,22 @@ void cyw_mode_init(int mode) // case SPORT_ACTIVE_MODE_AR_ALERT: // break; + case 2: + PRINT("222\r\n"); + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = 2; + CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl); + break; + + case 1: + PRINT("333\r\n"); + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = 1; + CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl); + break; + default: break; } @@ -275,6 +292,22 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { case IDX_ALGO_SHAKE: CWM_OS_dbgPrintf("IDX_ALGO_SHAKE\n"); break; + case IDX_ALGO_INACTIVITY_OUTPUT: + CWM_OS_dbgPrintf("IDX_ALGO_INACTIVITY_OUTPUT\n"); + if((int)sensorEVT->fData[0] == 21) + { + CWM_OS_dbgPrintf("sleep status[%d], month[%d], day[%d], hour[%d], min[%d], mintue[%d], inactivity_mode_number[%d]\n", + (int)sensorEVT->fData[2], + (int)sensorEVT->fData[3], + (int)sensorEVT->fData[4], + (int)sensorEVT->fData[5], + (int)sensorEVT->fData[6], + (int)sensorEVT->fData[8], + (int)sensorEVT->fData[9], + (int)sensorEVT->fData[10], + (int)sensorEVT->fData[15]); + } + break; case IDX_ALGO_ACTIVITY_OUTPUT: if((int)sensorEVT->fData[0] == 100) { @@ -369,23 +402,6 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { CustomEventPublish(TOPIC_EVENT_STEPDATA_UPDATE,&stepcount,sizeof(int)); } - -// [0] = activity_mode (1001~1xxx) -// [1] = steps (steps)(步數) -// [2] = distance (meters)(距離) -// [3] = calories (Kcal)(卡路里) -// [4] = reserved -// [5] = step frequency (steps/minute)(步頻) -// [6] = step length (meters)(步長)(步幅) -// [7] = pace (minutes/Km)(配速) -// [8] = BMR calories (Kcal)(基礎卡路里) -// [9] = current elevation (meters) (海拔高度,需要氣壓計) -// [10] = floors up (floors) (爬升樓層,需要氣壓計) -// [11] = floors down (floors) (下降樓層,需要氣壓計) -// [12] = elevation up (meters) (爬升高度,需要氣壓計) -// [13] = elevation down (meters) (下降高度,需要氣壓計) -// [14] = is_pause (是否暫停活動) -// (0: 活動中, 1: 暫停活動) break; case IDX_ALGO_ANY_MOTION: CWM_OS_dbgPrintf("IDX_ALGO_ANY_MOTION\n"); @@ -665,6 +681,114 @@ int[10] = 感測器雜訊度等級 (default: 低雜訊) scl.iData[0] = 1; CWM_SettingControl(SCL_PEDO_CONFIG, &scl); +/* +SCL_SLEEP_CONFIG + +int[0] = 1 +int[1] = reserved +int[2] = 是否使用心率來判斷睡眠狀態 (default: 不使用心率) +(0: default, 1: 使用心率, 2: 不使用心率) +int[3] = 入睡難易度 (default: 4) +(0: default, 1:不容易入睡, 2, 3, 4:標準, 5, 6, 7:容易入睡) +int[4] = 出睡難易度 (default: 4) +(0: default, 1:不容易出睡, 2, 3, 4:標準, 5, 6, 7:容易出睡) +int[5] = reserved +int[6] = 清醒難易度 (default: 4) +(0: default, 1:不容易清醒, 2, 3, 4:標準, 5, 6, 7:容易清醒) +int[7] = 硬體訊號等級 (default: 1) + (0: default, 1: 低雜訊, 2, 3, 4, 5, 6, 7: 高雜訊) +int[8] = reserved +int[9] = 睡眠間距 (default: 60) + (0: default, 1 - 180) +int[10] = 無心率時是否輸出REM (default: 會輸出REM) + (0: default, 1: 禁止輸出REM, 2: 會輸出REM) +int[11] = 長時間小睡 (default: turn_off) + (0: default, 1: turn_on, 2: turn_off) +int[12] = 靜態活動角度靈敏度 (default: 13) + (0: default, 1: 較難入睡 - 30: 容易入睡) +*/ + + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[3] = 7; + scl.iData[4] = 7; + scl.iData[6] = 7; + scl.iData[7] = 7; + scl.iData[9] = 1; + CWM_SettingControl(SCL_SLEEP_CONFIG, &scl); + +/* +SCL_REQ_SLEEPING_DATA +int[0] = 1 +int[1] = terminate_sleep +(0: 立刻輸出狀態,但不中止此段睡眠偵測, +1: 立刻輸出狀態,並中止此段睡眠偵測) +*/ + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = 1; + CWM_SettingControl(SCL_REQ_SLEEPING_DATA, &scl); + +/* +SCL_INACTIVITY_CONFIG +int[0] = 1 +int[1] = 感測器雜訊度等級 (default: 低雜訊) + (0: 低雜訊, 1: 高雜訊) +*/ + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = 1; + CWM_SettingControl(SCL_INACTIVITY_CONFIG, &scl); + + /* + SCL_DATE_TIME + int[0] = 1 + int[1] = year (1900 - 2100) + int[2] = month (1 - 12) + int[3] = day (1 - 31) + int[4] = hour (0 - 23) + int[5] = minute (0 - 59) + int[6] = second (0 - 59) + */ + char databuf[64] = {0}; + int year,month,day,hour,min,sec; + uapi_get_yyyymmddhhmmss_Date(databuf); + PRINT("databuf : %s \r\n",databuf); + sscanf(databuf, "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &min, &sec); + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = year; + scl.iData[2] = month; + scl.iData[3] = day; + scl.iData[4] = hour; + scl.iData[5] = min; + scl.iData[6] = sec; + CWM_SettingControl(SCL_DATE_TIME, &scl); + +/* +SCL_SEDENTARY + +int[0] = 1 +int[1] = reserved +int[2] = is_reminder_on (提醒功能)(default: turn_off) + (0: default, 1: turn on, 2: turn off) +int[3] = reminder_time (minutes)(提醒時間)(default: 5) + (0:default, 1 - 10) +int[4] = release_level (解除久坐狀態的等級)(default: 3) + (0:default, 1:容易解除, 2, 3, 4, 5:不容易解除) +int[5] = release_mode (解除久坐的算法模式)(default: 行走模式) + (0: default, 1: 行走模式, 2: 活動量模式) + +*/ + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[2] = 1; + // int[2] = 3,代表開啟acc和gyro感測器 1代表开启acc + scl.iData[3] = 1; + scl.iData[4] = 3; + scl.iData[5] = 1; + CWM_SettingControl(SCL_SEDENTARY, &scl); + //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式 memset(&scl, 0, sizeof(scl)); @@ -684,7 +808,6 @@ int[10] = 感測器雜訊度等級 (default: 低雜訊) CWM_Sensor_Enable(IDX_REQUEST_SENSOR); // //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); - CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT); CWM_Sensor_Enable(IDX_ALGO_ACTIVITY_OUTPUT); @@ -699,17 +822,6 @@ int[10] = 感測器雜訊度等級 (default: 低雜訊) //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP); - /* - SPORT_ACTIVE_MODE_NORMAL 1001 // 一般模式(生活模式) normal(base) 1001 - SPORT_ACTIVE_MODE_TREADMILL 1002 // 跑步機 treadmill 1002 - SPORT_ACTIVE_MODE_OUTDOOR_RUNNING 1003 // 戶外跑步 outdoor running 1003 - SPORT_ACTIVE_MODE_INDOOR_RUNNING 1006 // 室內跑步 indoor running 1006 - SPORT_ACTIVE_MODE_FITNESS_PEDOMETERR 1008 // 防誤觸計步 fitness_pedometer 1008 - SPORT_ACTIVE_MODE_FREE_TRAINING 5001 // 自由運動 FreeTraining 5001 - SPORT_ACTIVE_MODE_AR_ALERT 1001 // 長時間動作偵測 AR alert 1001 - */ - - cyw_mode_init(cmd); // memset(&scl, 0, sizeof(scl));