TraingModel::GetInstance()->GetSportState() == ExerciseState::End) {
return;
}
- //训练基本信息更新
- // if (request->msgId == TOPIC_EVENT_ACTIVITY_UPDATE) {
- // act_result_t *cyweeInfo = new act_result_t();
- // int rets = memcpy_s(cyweeInfo, sizeof(act_result_t),
- // (act_result_t *)request->data, request->len);
- // if (rets != EOK) {
- // delete cyweeInfo; // 处理内存分配失败的情况
- // cyweeInfo = NULL;
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- // "memcpy_s act_result_t fail ret = %d", rets);
- // return;
- // }
- // TraingModel::GetInstance()->AnalysisData(cyweeInfo);
- // // 更新其他目标完成度
- // TraingModel::GetInstance()->CheckSportTag();
- // delete cyweeInfo; // 释放内存
- // }
- // //训练额外信息
- // if (request->msgId == TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE) {
- // act_ext_result_t *cyweeInfo_ext = new act_ext_result_t();
- // int rets = memcpy_s(cyweeInfo_ext, sizeof(act_ext_result_t),
- // (act_ext_result_t *)request->data, request->len);
- // if (rets != EOK) {
- // delete cyweeInfo_ext; // 处理内存分配失败的情况
- // cyweeInfo_ext = NULL;
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- // "memcpy_s act_ext_result_t fail ret = %d", rets);
- // return;
- // }
- // TraingModel::GetInstance()->AnalysisExtraData(cyweeInfo_ext);
- // delete cyweeInfo_ext; // 释放内存
- // }
- //训练心率
- // if (request->msgId == TOPIC_EVENT_HEARTRATE_UPDATA) {
- // uint8_t heart = *((u_int8_t *)(request->data)); // 进行类型转换
- // TraingModel::GetInstance()->AnalysisHeartData(heart);
- // }
#endif
}
#ifdef __cplusplus
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "spc %d", sportdata->spc);
- // 计算平均心率
- if (sportdata->heart > 50) {
- sportdata->avgheart = Averageheartrate(sportdata->heart);
- }
#if 0
// 心率提醒 目前取值有问题,暂时关闭
}
}
#endif
+
}
#endif
#endif
/*分析运动心率数据*/
void TraingModel::AnalysisHeartData(uint8_t hrs) {
- sportdata->heart = hrs;
- SetIntensity(sportdata->heart); // 设置训练强度
+ sportdata->heart = hrs;
+ // 计算平均心率
+ if (sportdata->heart > 50) {
+ sportdata->avgheart = Averageheartrate(sportdata->heart);
+ SetIntensity(sportdata->avgheart); // 设置训练强度
+ }
}
/*打印函数*/
totalHeartRate += newHeartRate;
return totalHeartRate / heartcount; // 返回计算的平均值
}
+
// 设置训练目标类型以及训练目标
void TraingModel::SetSportTag(ExerciseTag tagtpye, int tag) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "设置目标 tagtpye[%d] tag[%d]",