CustomSensorData csd;
-void free_training_task(void)
-{
- ppg_send_cmd_to_driver("hrs",1);
-}
-
-errcode_t free_training_init(void)
-{
- app_task_definition_t taskcfg={0};
- taskcfg.create_queue_handle = NULL;
- taskcfg.attr.name="free_training_service";
- taskcfg.attr.priority = TASK_PRIORITY_CMD;
- taskcfg.attr.stack_size = 1024*8;
- taskcfg.func = free_training_task;
- taskcfg.use_mem = USE_EXTEND_MEM;
-
- errcode_t ret=uapi_create_osThread_custom(&taskcfg);
- if(ret != ERRCODE_SUCC)
- {
- PRINT("create free_training_task failed %d!\r\n",ret);
- return ERRCODE_FAIL;
- }
-
- return ERRCODE_SUCC;
-}
+// void time_sync(void)
+// {
+// 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);
+// }
void cywee_hrs_check_timer_callback(void)
}
+void free_training_task(void)
+{
+ ppg_send_cmd_to_driver("hrs",1);
+}
+
+void free_training_deinit(void)
+{
+ if(free_training_installized == 0)
+ return;
+
+ free_training_installized = 0;
+ osTimerStop(g_cywee_oncharging_timer);
+ osTimerStop(g_cywee_hrs_timer);
+ osTimerDelete(g_cywee_oncharging_timer);
+ osTimerDelete(g_cywee_hrs_timer);
+ ppg_send_cmd_to_driver("hrs",0);
+}
+
+errcode_t free_training_init(void)
+{
+ if(free_training_installized == 1)
+ return ERRCODE_FAIL;
+
+ app_task_definition_t taskcfg={0};
+ taskcfg.create_queue_handle = NULL;
+ taskcfg.attr.name="free_training_service";
+ taskcfg.attr.priority = TASK_PRIORITY_CMD;
+ taskcfg.attr.stack_size = 1024*8;
+ taskcfg.func = free_training_task;
+ taskcfg.use_mem = USE_EXTEND_MEM;
+
+ errcode_t ret=uapi_create_osThread_custom(&taskcfg);
+ if(ret != ERRCODE_SUCC)
+ {
+ PRINT("create free_training_task failed %d!\r\n",ret);
+ return ERRCODE_FAIL;
+ }
+ free_training_installized = 1;
+ g_cywee_hrs_timer = osTimerNew((osTimerFunc_t)cywee_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL);
+ g_cywee_oncharging_timer = osTimerNew((osTimerFunc_t)cywee_oncharging_check_timer_callback, osTimerPeriodic, NULL, NULL);
+
+ return ERRCODE_SUCC;
+}
+
void watch_hand_updown(int fdata)
{
#if defined(SUPPORT_POWER_MANAGER)
CWM_SettingControl(SCL_ACTIVITY_PAUSE, &scl);
}
-void activity_exit(void)
-{
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- CWM_SettingControl(SCL_REQ_ACTIVITY_EXIT, &scl);
- if(cywee_installized == 1)
- cywee_installized = 0;
- if(free_training_installized == 1)
+void cyw_inactivity_mode_change(int mode)
+{
+ switch (mode)
{
- free_training_installized = 0;
- //osTimerStop(g_cywee_wearstatus_timer);
- osTimerStop(g_cywee_oncharging_timer);
- osTimerStop(g_cywee_hrs_timer);
- osTimerDelete(g_cywee_oncharging_timer);
- osTimerDelete(g_cywee_hrs_timer);
- ppg_send_cmd_to_driver("hrs",0);
+ case INACTIVITY_MODE_NOTHING:
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 0;
+ CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ break;
+
+ case INACTIVITY_MODE_SEDENTARY:
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ break;
+
+ case INACTIVITY_MODE_SLEEPING:
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 2;
+ CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ break;
+
+ case INACTIVITY_MODE_SEDENTARY_AND_NAP:
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 3;
+ CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ break;
+
+ case INACTIVITY_MODE_NAP:
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 4;
+ CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ break;
+
+ default:
+ break;
}
}
-void cyw_mode_init(int mode)
+void cyw_activity_mode_change(int mode)
{
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_REQ_ACTIVITY_EXIT, &scl);
+
switch (mode)
{
//一般模式(生活模式)
//自由运动
case SPORT_ACTIVE_MODE_FREE_TRAINING:
- free_training_installized = 1;
free_training_init();
+ free_training_deinit();
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
scl.iData[1] = SPORT_ACTIVE_MODE_FREE_TRAINING;
// case SPORT_ACTIVE_MODE_AR_ALERT:
// break;
- case 2:
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 2;
- CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
- break;
-
- case 1:
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 1;
- CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
- break;
-
default:
break;
}
#endif
-int cywee_main_dml(int cmd) {
+int cywee_main_dml(void)
+{
if (cywee_installized==0)
{
- int i;
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- CWM_SettingControl(SCL_GET_LIB_INFO, &scl);
- CWM_OS_dbgPrintf("version:%d.%d.%d.%d product:%d model:%d\n", scl.iData[1], scl.iData[2], scl.iData[3], scl.iData[4], scl.iData[5], scl.iData[6]);
- CWM_OS_dbgPrintf("[DBG] ach: %d\n", scl.iData[7]);
- #if USE_P813
- os_api api = {
- .GetTimeNs = CWM_OS_GetTimeNs,
- .dbgOutput = CWM_OS_dbgOutput,
- .i2cRead = CWM_OS_i2cRead,
- .i2cWrite = CWM_OS_i2cWrite,
- .uSleep = CWM_OS_uSleep,
- .free = CWM_OS_free,
- .malloc = CWM_OS_malloc,
- .spiRead = NULL,
- .spiWrite = NULL,
- };
- CWM_LibPreInit(&api);
-
- #else
- OsAPI apiOS = {
- .GetTimeNs = CWM_OS_GetTimeNs,
- .dbgOutput = CWM_OS_dbgOutput,
- .i2cRead = CWM_OS_i2cRead,
- .i2cWrite = CWM_OS_i2cWrite,
- .uSleep = CWM_OS_uSleep,
- .free = CWM_OS_free,
- .malloc = CWM_OS_malloc,
- .i2cTransfer = CWM_OS_i2cTransfer,
- .restoreData = CWM_OS_restoreData,
- .saveData = CWM_OS_saveData,
- .spiRead = NULL,
- .spiWrite = NULL,
- .securityCodeWrite = NULL,
- .setGpio = NULL,
- .enableGpioIRQ = NULL,
- .disableGpioIRQ = NULL,
- };
- CWM_LibPreInit(&apiOS);
- #endif
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- //set mcu_chip information, must call this before CWM_LibPostInit()
-
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 2; // 0: mcu_auto_detect 2: skip_mcu_auto_detect
- CWM_SettingControl(SCL_CHIP_VENDOR_CONFIG, &scl);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- CWM_LibPostInit(CWM_AP_SensorListen);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- //get chip information
-
- char chipInfo[64];
-
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 1;
- scl.iData[2] = (int)chipInfo;
- scl.iData[3] = sizeof(chipInfo);
- scl.iData[4] = 0;
- scl.iData[5] = 0;
- scl.iData[6] = 0;
- CWM_SettingControl(SCL_GET_CHIP_INFO, &scl);
- CWM_OS_dbgPrintf("have_security = %d.%d ret_buff_size = %d chipInfo = %s\n", scl.iData[5], scl.iData[6], scl.iData[4], chipInfo);
- CWM_OS_dbgPrintf("chip_settings = %d, %d, %d\n", scl.iData[9], scl.iData[10], scl.iData[11]);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- CWM_Dml_LibInit();
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- #ifdef AP_ENABLE_DML_SDO_LISTEN
- // 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);
- #endif
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- CWM_SettingControl(SCL_DML_GET_LIB_INFO, &scl);
- CWM_OS_dbgPrintf("dml version:%d.%d.%d.%d product:%d model:%d\n", scl.iData[1], scl.iData[2], scl.iData[3], scl.iData[4], scl.iData[5], scl.iData[6]);
-
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 18; //00000000000000000000000000010010 高位在前
- // CWM_SettingControl(SCL_DML_DEBUG, &scl);
-
- //设置acc gyro 相关参数
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[3] = 2;
- scl.iData[4] = 2; //1 anytime 2 fifo
- scl.iData[6] = 5; //先設定5
- scl.iData[7] = 5;
- scl.iData[8] = 52; // for st sensor(52Hz)
- CWM_SettingControl(SCL_DML_DRV_AG_CONFIG, &scl);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- //设定搜寻哪种型号的传感器,以及要搜寻的属性
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 2;
- scl.iData[6] = 3002502;
- scl.iData[7] = (0|1|8|256|1024);
- CWM_SettingControl(SCL_DML_DRV_HW_CONFIG, &scl);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- //搜寻是否接入传感器
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 1;
- CWM_SettingControl(SCL_DML_DRV_INIT, &scl);
- CWM_OS_dbgPrintf("DML device=%d\n", scl.iData[2]);
-
- //获取初始化 driver清单
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- CWM_SettingControl(SCL_DML_GET_INITED_LIST, &scl);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-
- for (i = 0; i < scl.iData[2]; i ++) {
-
- CWM_OS_dbgPrintf("DML device[%d]: hw_id=%d hw_attr=%d\n", i, scl.iData[6 + i * 2], scl.iData[7 + i * 2]);
- }
-
- //设置抬腕功能
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- // scl.iData[1] = 5;
- // scl.iData[2] = 5;
- // scl.iData[3] = 5;
- // scl.iData[4] = 5;
- CWM_SettingControl(SCL_HAND_UPDOWN_CONFIG, &scl);
-
- //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[1] = 1;
- // int[2] = 3,代表開啟acc和gyro感測器 1代表开启acc
- scl.iData[2] = 1;
- 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[3] = 3;
- scl.iData[4] = 5;
- // CWM_SettingControl(SCL_LOG, &scl);
-
-
- 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);
-
- CWM_Sensor_Enable(IDX_ACCEL);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
- // CWM_Sensor_Enable(IDX_GYRO);
- CWM_Sensor_Enable(IDX_ALGO_NO_MOTION);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
- // CWM_Sensor_Enable(IDX_ALGO_ANY_MOTIOIN);
- CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC);
- //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
- CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP);
-
+ CWM_OS_dbgPrintf("cywee_installized skip install\n");
+ return 0;
}
cywee_installized = 1;
- if(cywee_installized == 1)
- CWM_OS_dbgPrintf("cywee_installized skip install\n");
-/*
-int[0] = 1
-int[1] = floor_Height (cm)(設定樓層高度)(default: 380cm = 3.8m)
- (0: default, 150 - 1000)
-int[2] = Anti-misoperation (一般模式時的防誤計步等級) (default: 4)
- (0: default, 1: 最容易誤計步, 2, 3, 4:預設等級, 5, 6, 7: 最不容易誤計步)
-int[3] = 戶外跑步和一般模式時距離、配速和步距的調整 (default: 4)
- (0: default, 1: 距離最短, 2, 3, 4:預設, 5, 6, 7:距離最長)
-int[4] = enable_extra_packet (default: 不發送)
- (0: default, 1: 發送, 2: 不發送)
-int[5] = Treadmill__steps (跑步機校正參數)(steps) (default: 不校正)
- (0: 不校正)
-int[6] = Treadmill__average_step_frequency (跑步機校正參數) (steps/minute) (default: 不校正)
- (0: 不校正)
-int[7] = Treadmill__uncalibration_distance (跑步機校正參數)(meters) (default: 不校正)
- (0: 不校正)
-int[8] = Treadmill__ground_truth_distance (跑步機校正參數: 真實的跑步距離)(meters) (default: 不校正)
- (0: 不校正)
-int[9] = floor_sensitivity (樓層計算嚴謹度)(default: 3)
- (0: default, 1:寬容, 2, 3, 4, 5, 7: 嚴格)
-int[10] = 防高頻誤觸 (default: 開啟)
- (0: default, 1: 開啟, 2: 關閉)
-int[11] = 高步頻走路步距修正 (default: 開啟)
- (0: default, 1: 開啟, 2: 關閉)
-int[12] = 活動程度區間的中度活動步頻 (default: 60)
- (0: default, 60 - 270)
-int[13] = 活動程度區間的高度活動步頻 (default: 120)
- (0: default, 60 - 270)
-*/
- //配置跑步机模式相关参数(进入跑步机模式自动生效)
+ int i;
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_GET_LIB_INFO, &scl);
+ CWM_OS_dbgPrintf("version:%d.%d.%d.%d product:%d model:%d\n", scl.iData[1], scl.iData[2], scl.iData[3], scl.iData[4], scl.iData[5], scl.iData[6]);
+ CWM_OS_dbgPrintf("[DBG] ach: %d\n", scl.iData[7]);
+#if USE_P813
+ os_api api = {
+ .GetTimeNs = CWM_OS_GetTimeNs,
+ .dbgOutput = CWM_OS_dbgOutput,
+ .i2cRead = CWM_OS_i2cRead,
+ .i2cWrite = CWM_OS_i2cWrite,
+ .uSleep = CWM_OS_uSleep,
+ .free = CWM_OS_free,
+ .malloc = CWM_OS_malloc,
+ .spiRead = NULL,
+ .spiWrite = NULL,
+ };
+ CWM_LibPreInit(&api);
+
+#else
+ OsAPI apiOS = {
+ .GetTimeNs = CWM_OS_GetTimeNs,
+ .dbgOutput = CWM_OS_dbgOutput,
+ .i2cRead = CWM_OS_i2cRead,
+ .i2cWrite = CWM_OS_i2cWrite,
+ .uSleep = CWM_OS_uSleep,
+ .free = CWM_OS_free,
+ .malloc = CWM_OS_malloc,
+ .i2cTransfer = CWM_OS_i2cTransfer,
+ .restoreData = CWM_OS_restoreData,
+ .saveData = CWM_OS_saveData,
+ .spiRead = NULL,
+ .spiWrite = NULL,
+ .securityCodeWrite = NULL,
+ .setGpio = NULL,
+ .enableGpioIRQ = NULL,
+ .disableGpioIRQ = NULL,
+ };
+ CWM_LibPreInit(&apiOS);
+#endif
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ //set mcu_chip information, must call this before CWM_LibPostInit()
+
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
- scl.iData[2] = 4;
- scl.iData[3] = 4;
+ scl.iData[1] = 2; // 0: mcu_auto_detect 2: skip_mcu_auto_detect
+ CWM_SettingControl(SCL_CHIP_VENDOR_CONFIG, &scl);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ CWM_LibPostInit(CWM_AP_SensorListen);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ //get chip information
+ char chipInfo[64];
+
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ scl.iData[2] = (int)chipInfo;
+ scl.iData[3] = sizeof(chipInfo);
+ scl.iData[4] = 0;
scl.iData[5] = 0;
scl.iData[6] = 0;
- scl.iData[7] = 0;
- scl.iData[8] = 0;
+ CWM_SettingControl(SCL_GET_CHIP_INFO, &scl);
+ CWM_OS_dbgPrintf("have_security = %d.%d ret_buff_size = %d chipInfo = %s\n", scl.iData[5], scl.iData[6], scl.iData[4], chipInfo);
+ CWM_OS_dbgPrintf("chip_settings = %d, %d, %d\n", scl.iData[9], scl.iData[10], scl.iData[11]);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
- scl.iData[10] = 1;
- scl.iData[11] = 1;
- scl.iData[12] = 60;
- scl.iData[13] = 120;
- CWM_SettingControl(SCL_PEDO_CONFIG, &scl);
+ CWM_Dml_LibInit();
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
-/*
-int[0] = 1
-int[1] = 卡路里計算是否包含基礎卡路里 (default: 不包含基礎卡路里)
- (0: default, 1:包含基礎卡路里, 2:不包含基礎卡路里)
-int[2] = 一般模式1001是否使用心率來計算卡路里 (default: 不使用心率)
- (0: default, 1: 使用心率, 2:不使用心率)
-int[3] = 靜態運動時是否持續計算卡路里 (default: 停止計算)
- (0: default, 1: 持續計算, 2: 停止計算)
-int[4] = 運動模式(包含一般模式1001)時,脫錶後是否持續計算卡路里 (default: 持續計算)
- (0: default, 1: 持續計算, 2: 停止計算)
-int[5] = ar_model (default: on)
- (0: default, 1: on, 2: off)
-int[6] = ar_pedo_mode (default: 平衡)
- (0: 平衡, 1: 計步優先, 2: 防誤觸優先)
-int[7] = 靜止時是否持續計算卡路里 (default: 持續計算)
- (0: default, 1: 持續計算, 2: 停止計算)
-int[8] = motionSensScale活動量的靈敏度 (default: 4)
- (0: default, 1: 最靈敏, 2, 3, 4, 5, 6, 7: 最不靈敏)
-int[9] = 軸向判斷 (default: 有軸向判斷)
- (0: default, 1: 無軸向判斷, 2: 有軸向判斷)
-int[10] = 感測器雜訊度等級 (default: 低雜訊)
- (0: 低雜訊, 1: 高雜訊A, 2 - 4, 5: 高雜訊E)
-*/
+ #ifdef AP_ENABLE_DML_SDO_LISTEN
+ // 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);
+ #endif
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_DML_GET_LIB_INFO, &scl);
+ CWM_OS_dbgPrintf("dml version:%d.%d.%d.%d product:%d model:%d\n", scl.iData[1], scl.iData[2], scl.iData[3], scl.iData[4], scl.iData[5], scl.iData[6]);
+
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 18; //00000000000000000000000000010010 高位在前
+ // CWM_SettingControl(SCL_DML_DEBUG, &scl);
+
+ //设置acc gyro 相关参数
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[3] = 2;
+ scl.iData[4] = 2; //1 anytime 2 fifo
+ scl.iData[6] = 5; //先設定5
+ scl.iData[7] = 5;
+ scl.iData[8] = 52; // for st sensor(52Hz)
+ CWM_SettingControl(SCL_DML_DRV_AG_CONFIG, &scl);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ //设定搜寻哪种型号的传感器,以及要搜寻的属性
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 2;
+ scl.iData[6] = 3002502;
+ scl.iData[7] = (0|1|8|256|1024);
+ CWM_SettingControl(SCL_DML_DRV_HW_CONFIG, &scl);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ //搜寻是否接入传感器
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ CWM_SettingControl(SCL_DML_DRV_INIT, &scl);
+ CWM_OS_dbgPrintf("DML device=%d\n", scl.iData[2]);
+
+ //获取初始化 driver清单
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_DML_GET_INITED_LIST, &scl);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+ for (i = 0; i < scl.iData[2]; i ++) {
+
+ CWM_OS_dbgPrintf("DML device[%d]: hw_id=%d hw_attr=%d\n", i, scl.iData[6 + i * 2], scl.iData[7 + i * 2]);
+ }
+
+ //配置跑步机模式相关参数(进入跑步机模式自动生效)
memset(&scl, 0, sizeof(scl));
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;
+ CWM_SettingControl(SCL_ACTIVITY_CONFIG, &scl);
- // 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);
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 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);
+
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_REQ_SLEEPING_DATA, &scl);
/*
SCL_INACTIVITY_CONFIG
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;
+ CWM_SettingControl(SCL_SEDENTARY, &scl);
-*/
+
+ //设置抬腕功能
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
+ // scl.iData[1] = 5;
+ // scl.iData[2] = 5;
+ // scl.iData[3] = 5;
+ // scl.iData[4] = 5;
+ CWM_SettingControl(SCL_HAND_UPDOWN_CONFIG, &scl);
+
+ //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ // int[2] = 3,代表開啟acc和gyro感測器 1代表开启acc
scl.iData[2] = 1;
- scl.iData[3] = 1;
- scl.iData[4] = 3;
- scl.iData[5] = 1;
- CWM_SettingControl(SCL_SEDENTARY, &scl);
+ 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[3] = 3;
+ scl.iData[4] = 5;
+ // CWM_SettingControl(SCL_LOG, &scl);
+
+ 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);
- g_cywee_hrs_timer = osTimerNew((osTimerFunc_t)cywee_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL);
- //g_cywee_wearstatus_timer = osTimerNew((osTimerFunc_t)cywee_wearstatus_check_timer_callback, osTimerPeriodic, NULL, NULL);
- g_cywee_oncharging_timer = osTimerNew((osTimerFunc_t)cywee_oncharging_check_timer_callback, osTimerPeriodic, NULL, NULL);
+ CWM_Sensor_Enable(IDX_ACCEL);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+ // CWM_Sensor_Enable(IDX_GYRO);
+ CWM_Sensor_Enable(IDX_ALGO_NO_MOTION);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+ // CWM_Sensor_Enable(IDX_ALGO_ANY_MOTIOIN);
+ CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+ CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP);
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = SPORT_ACTIVE_MODE_NORMAL;
+ CWM_SettingControl(SCL_SET_ACTIVITY_MODE, &scl);
+ // CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
+ //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
- cyw_mode_init(cmd);
+ // cyw_activity_mode_change(cmd);
+ // cyw_inactivity_mode_change();
// memset(&scl, 0, sizeof(scl));
// scl.iData[0] = 1;
// scl.iData[1] = SPORT_ACTIVE_MODE_NORMAL; //ACTIVITY_MODE_NORMAL 1001
// CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl);
//CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
+
+
return 0;
}