#include "NativeAbility.h"
#include "battery_hal.h"
-#define MAX_UNWARE_COUNT 20
+#define MAX_UNWARE_COUNT 30
#define MAX_VALID_SPO2_COUNT 30
#define MAX_DISVALID_SPO2_COUNT 100
namespace OHOS
{\r
#endif\r
\r
-#define MAX_UNWEAR_COUNT 20\r
+#define MAX_UNWEAR_COUNT 30\r
#define MAX_VALID_HRS_COUNT 40\r
#define MAX_DISVALID_HRS_COUNT 70\r
#define HEARTTEST 1 //[0 开启测试 1 关闭]\r
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-03-28 14:17:43
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-07-26 10:02:53
+ * @LastEditTime: 2024-08-17 17:04:07
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/MotionRecognitionPresenter.cpp
*/
#include "AppViewIDs.h"
#include "ConfigModel.h"
#include <UiConfig.h>
#include "cywee_service.h"
+#include "custom_runtime.h"
namespace OHOS
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is enable!");
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_AR_ALERT,NULL);
ConfigModel::GetInstance()->SetMotionRecognition(true);
+ uapi_dev_runtime_set_motion_recognition_status(1);
break;
case UICheckBox::UNSELECTED:
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MotionRecognition is disable!");
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_AR_ALERT,NULL);
ConfigModel::GetInstance()->SetMotionRecognition(false);
+ uapi_dev_runtime_set_motion_recognition_status(0);
break;
default:
break;
sportdata->distance = cyweeInfo->distance;
sportdata->calories = cyweeInfo->calories;
- sportdata->cdc = cyweeInfo->step_frequency;
- sportdata->std = cyweeInfo->step_length;
+ // sportdata->cdc = cyweeInfo->step_frequency;
+ // sportdata->std = cyweeInfo->step_length;
+
sportdata->pc = cyweeInfo->pace;
// 更新最慢配速
{
sportdata->apc = cyweeInfo->avg_pace;
sportdata->fpc = cyweeInfo->max_pace;
+ sportdata->cdc = cyweeInfo->avg_step_freq;
+ sportdata->std = cyweeInfo->avg_step_len;
}
/*打印函数*/
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_t failed, ret = %d", rets);
return;
}
-
- /*更新卡路里数据*/
- if(c_activity_result_t->calories!=0)
+ if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_NORMAL)
{
- set_calories_data(c_activity_result_t->calories);
+ /*更新卡路里数据*/
+ if(c_activity_result_t->calories!=0)
+ {
+ set_calories_data(c_activity_result_t->calories);
#if DIALDATASET
- DialModelCalorie::GetInstance()->UpdateCalorie(get_calories_data());
+ DialModelCalorie::GetInstance()->UpdateCalorie(get_calories_data());
#endif
- }
-
-
- /*更新距离数据*/
- if(c_activity_result_t->distance!=0)
- {
- set_distance_data(c_activity_result_t->distance);
+ }
+ /*更新距离数据*/
+ if(c_activity_result_t->distance!=0)
+ {
+ set_distance_data(c_activity_result_t->distance);
#if DIALDATASET
- DialModelDistance::GetInstance()->UpdateDistance(get_distance_data());
+ DialModelDistance::GetInstance()->UpdateDistance(get_distance_data());
#endif
+ }
}
-
- /*更新卡路里数据*/
- if(c_activity_result_t->MHR_zone>=2)
+ else if(c_activity_result_t->activity_mode == SPORT_ACTIVE_MODE_FREE_TRAINING && c_activity_result_t->MHR_zone >= 2)
{
- set_fat_time_data();
+ /*更新燃脂时间数据*/
+ set_fat_time_data(1);
}
-
+
free(c_activity_result_t);
c_activity_result_t = NULL;
}
void MsgCenterNotifyActivityExtraInfoProc(const Topic topic, Request* req)
{
unused(topic);
+ cywee_activity_result_extre_info_t* c_activity_result_extre_info_t = (cywee_activity_result_extre_info_t *) malloc(req->len);
+ if(c_activity_result_extre_info_t==NULL)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Memory allocation failure");
+ return;
+ }
+
+ int rets = memcpy_s(c_activity_result_extre_info_t, req->len, (cywee_activity_result_extre_info_t*)req->data, req->len);
+ if (rets != EOK)
+ {
+ free(c_activity_result_extre_info_t);
+ c_activity_result_extre_info_t = NULL;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s c_activity_result_extre_info_t failed, ret = %d", rets);
+ return;
+ }
+
+ /*更新燃脂时间数据*/
+ set_fat_time_data(c_activity_result_extre_info_t->ativity_zone_high_duration);
+
+ free(c_activity_result_extre_info_t);
+ c_activity_result_extre_info_t = NULL;
}
void MsgCenterNotifyArAlertProc(const Topic topic, Request* req)
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-04-17 09:32:03
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-15 18:23:37
+ * @LastEditTime: 2024-08-17 10:47:17
* @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h
*/
#ifndef _CONFIG_MODEL_C_H_
int get_sedentary_time_from_config_model(void);
int get_sedentary_interval_from_config_model(void);
bool get_motion_recognition_from_config_model(void);
+int get_config_heart_from_config_model(void);
//设置睡眠频率
void set_config_heart(int heartRateDetectionFreq);
// 设置心率检测频率
OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED, heartRateDetectionFreq);
}
+
+// 获取心率检测周期
+int get_config_heart_from_config_model(void)
+{
+ int time = 0;
+ time = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_HEARTRATE_DETECTED);
+ return time;
+}
+
//获取久坐提醒开关
int get_sedentary_switch_from_config_model(void)
{
void set_distance_data(uint32_t data);
int get_distance_data(void );
-void set_fat_time_data(void);
+void set_fat_time_data(int time);
int get_fat_time_data(void);
void cywee_get_chipinfo(char *databuf,uint8_t len);
uint8_t cywee_ble_service_flag = 0;
+static uint8_t is_abs_static_state = 0;
+
int cm__hs1__init(void);
int cm__hs1__deinit(void);
+
+void cywee_set_abs_static(void)
+{
+ int time = get_config_heart_from_config_model();
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = time * 60;
+ CWM_SettingControl(SCL_ABS_STATIC_CONFIG, &scl);
+}
+
void cywee_log_switch(int cmd)
{
if(cmd)
return new_distance+history_distances;
}
-void set_fat_time_data(void)
+void set_fat_time_data(int time)
{
- new_fat++;
+ new_fat += time;
}
int get_fat_time_data(void)
void cywee_wearstatus_update(int wearstatus)
{
- CWM_OS_dbgPrintf("111wearstatus : %d\r\n",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;
CWM_CustomSensorInput(&csd);
+ CWM_OS_dbgPrintf("111wearstatus : %d\r\n",wearstatus);
}
//0:resume , 1:pause
break;
case IDX_ALGO_ABSOLUTE_STATIC:
CWM_OS_dbgPrintf("IDX_ALGO_ABSOLUTE_STATIC\n");
+ is_abs_static_state = 1;
break;
case IDX_ALGO_SPV:
CWM_OS_dbgPrintf("IDX_ALGO_SPV\n");
//设置运动识别
cywee_ar_alert_switch(get_motion_recognition_from_config_model());
+ //设置绝对静止
+ cywee_set_abs_static();
+
//呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
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_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC);
//CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
cywee_restoreData();
cywee_set_user_info();
cywee_activity_mode_change(SPORT_ACTIVE_MODE_NORMAL);
-
- cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP);
+ //cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP);
//cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING);
ppg_sensor_data_t ppg_s_data;\r
\r
static int cywee_data = 0;\r
-int wear_mode_status = -1;\r
+static int wear_status = -1;\r
\r
static uint8_t hx3695_chip_id = 0;\r
\r
func(HX3695_MSG_TYPE_STATIC_HRS_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t));\r
}\r
}\r
- //if(hrs_mode_state)\r
- if(hrs_mode_state || uapi_dev_runtime_get_sleep_status() == 1)\r
+ if(hrs_mode_state)\r
{\r
cywee_data = hrsresult.lastesthrs;\r
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
}\r
\r
\r
-void hx3695_wearstatus_update(void)\r
+void hx3695_hrs_wearstatus_update(void)\r
{\r
- if(wear_mode_status != hrsresult.wearstatus)\r
+ if(wear_status != hrsresult.wearstatus)\r
{\r
- wear_mode_status = hrsresult.wearstatus;\r
- cywee_data = wear_mode_status;\r
+ wear_status = hrsresult.wearstatus;\r
+ cywee_data = wear_status;\r
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data);\r
}\r
+ if(wear_status)\r
+ cywee_data = hrsresult.lastesthrs;\r
+ else\r
+ cywee_data = 0;\r
+ do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&cywee_data);\r
}\r
\r
#ifdef HRS_ALG_LIB\r
}\r
//PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
//PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
- PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsensordata[ii].x,gsensordata[ii].y,gsensordata[ii].z,ppg_s_data.green_cur);\r
+ //PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsensordata[ii].x,gsensordata[ii].y,gsensordata[ii].z,ppg_s_data.green_cur);\r
\r
}\r
hrs_wear_status = hx3695_hrs_get_wear_status();\r
hx3695_check_touch_read(&ppg_s_data);\r
hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count);\r
// PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status);\r
- if(wear_mode_status != hx3695_wear_status)\r
+ if(wear_status != hx3695_wear_status)\r
{\r
- wear_mode_status = hx3695_wear_status;\r
- cywee_data = wear_mode_status;\r
+ wear_status = hx3695_wear_status;\r
+ cywee_data = wear_status;\r
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,&cywee_data);\r
}\r
\r
void heart_rate_meas_timeout_handler(void * p_context);\r
void wear_mode_timeout_handler(void * p_context);\r
void Efuse_Mode_Check(void);\r
-void hx3695_wearstatus_update(void);\r
+void hx3695_hrs_wearstatus_update(void);\r
#include "hx3695_hal.h"\r
\r
#endif\r
* @Author: penglei 1624952103@qq.com
* @Date: 2024-03-13 15:08:38
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-14 09:48:59
+ * @LastEditTime: 2024-08-17 11:11:47
* @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c
* @Description:
*
{
#ifdef HRS_ALG_LIB
hx3695_hrs_disable();
- hx3695_wearstatus_update();
+ hx3695_hrs_wearstatus_update();
#endif
}else if(md == HRV_MODE)
{
uint8_t drinkremind_status;
uint8_t train_status;//训练状态
uint8_t saveele_status;//省电模式状态
+ uint8_t motion_recognition_status;//运动识别开关状态
} runtime_status_t;
uint8_t uapi_dev_runtime_get_saveele_status(void)
{
return g_runtime.saveele_status;
+}
+
+/*设置运动识别状态*/
+void uapi_dev_runtime_set_motion_recognition_status(uint8_t status)
+{
+ g_runtime.motion_recognition_status = status;
+}
+uint8_t uapi_dev_runtime_get_motion_recognition_status(void)
+{
+ return g_runtime.motion_recognition_status;
}
\ No newline at end of file
void uapi_dev_runtime_set_saveele_status(uint8_t status);
uint8_t uapi_dev_runtime_get_saveele_status(void);
+/*运动识别*/
+void uapi_dev_runtime_set_motion_recognition_status(uint8_t status);
+uint8_t uapi_dev_runtime_get_motion_recognition_status(void);
+
/***************************************cat1 runtime 变量设置获取函数**************************************************/
if(isopen)
{
power_on_cat1();
+ uapi_dev_runtime_set_cat1_powerstat(1);
#ifdef SUPPORT_TCPIP
tcp_thread_id = tcp_get_thread_id();
ret = uapi_resume_thread(tcp_thread_id);
else
{
power_off_cat1();
+ uapi_dev_runtime_set_cat1_powerstat(0);
#ifdef SUPPORT_TCPIP
tcp_thread_id = tcp_get_thread_id();
ret = uapi_suspend_thread(tcp_thread_id);
uapi_dev_runtime_set_saveele_status(1);
//关闭蓝牙
- stop_custom_ble_service();
+ if(uapi_dev_runtime_get_bt_powerstat())
+ stop_custom_ble_service();
//关闭cat1
- uapi_set4GCapability(false);
+ if(uapi_dev_runtime_get_cat1_powerstat())
+ uapi_set4GCapability(false);
+ //停止心率周期检测
- //停止心率周期检测(runtime)
-
//进入normal模式
do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE,NULL);
+ //关闭运动识别
+ if(uapi_dev_runtime_get_motion_recognition_status())
+ do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_AR_ALERT,NULL);
+
//关闭音乐
}
uapi_dev_runtime_set_saveele_status(0);
//打开蓝牙
- start_custom_ble_service();
+ if(uapi_dev_runtime_get_bt_powerstat())
+ start_custom_ble_service();
//打开cat1
- uapi_set4GCapability(true);
+ if(uapi_dev_runtime_get_cat1_powerstat())
+ uapi_set4GCapability(true);
//开启心率周期检测(runtime)
+ //开启运动识别
+ if(uapi_dev_runtime_get_motion_recognition_status())
+ do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_AR_ALERT,NULL);
}