From adb1d000ab1195fed8e674042760980986f25dfb Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Mon, 15 Jul 2024 10:16:07 +0800 Subject: [PATCH] =?utf8?q?=E6=94=B9=E6=AD=A5=E6=95=B0=E4=B8=BA=E7=AE=97?= =?utf8?q?=E6=B3=95=E5=A4=96=E9=83=A8=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BF=AE?= =?utf8?q?=E6=94=B9=E6=95=B4=E7=82=B9=E8=AE=B0=E5=BD=95=E6=95=B0=E6=8D=AE?= =?utf8?q?=E6=97=B6=E9=94=99=E8=AF=AF=E8=AE=B0=E5=BD=95=E4=BA=86=E6=80=BB?= =?utf8?q?=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/activity/src/ActivityModel.cpp | 8 +++-- .../msg_center/src/msg_center_customer.cpp | 2 +- .../drivers/peripheral/cywee/Inc/cywee_hal.h | 2 ++ .../peripheral/cywee/src/board_yh601s.c | 17 ++++++----- .../drivers/peripheral/cywee/src/main_dml.c | 30 ++++++++++++++----- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp index 9a36d0060..cbd4cc506 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp @@ -27,6 +27,7 @@ using namespace std; #ifdef __cplusplus extern "C" { #endif +#include "cywee_hal.h" using namespace OHOS; @@ -121,9 +122,10 @@ static void Notify(void *args, const Topic topic, Request* request) return; } // 计步数据累加 - // uint32 counter = OHOS::ActivityModel::GetInstance()->GetStepCounter(); - // counter += *(uint32_t *)request->data; - uint32 counter = *(uint32_t *)request->data; + uint32 counter =0;// OHOS::ActivityModel::GetInstance()->GetStepCounter(); + counter = *(uint32_t *)request->data; + set_step_data(counter); + counter = get_step_data();//*(uint32_t *)request->data; OHOS::ActivityModel::GetInstance()->ReviseStepCounter(counter); OHOS::DialModelSteps::GetInstance() ->UpdateSteps(counter);//更新表盘步数 GraphicService::GetInstance()->PostGraphicEvent( 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 9d5dbf9af..b34fcd810 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 @@ -75,7 +75,7 @@ const PriorityMapper PRI_MAPPER[] = { {TOPIC_EVENT_INACTIVITY_UPDATE,PRIORITY_TWO}, {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,PRIORITY_TWO}, {TOPIC_EVENT_BLE_TRAINING,PRIORITY_TWO}, - {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_TWO}, + {TOPIC_EVENT_BLE_TRANSMIT,PRIORITY_ONE}, #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION {TOPIC_EVENT_CHARGE_PLUG, PRIORITY_TWO}, {TOPIC_EVENT_CHARGE_UNPLUG, PRIORITY_TWO}, diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 2f26ccb92..a1818f5ad 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -528,6 +528,8 @@ void cywee_ar_alert_switch(int cmd); void step_history_save(void); uint32_t get_step_data(void); +void set_step_data(uint32_t data); + void stand_history_save(void); void calories_history_save(void); void distances_history_save(void); diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index d0f960092..43ea7cda1 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -373,13 +373,13 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty CWM_OS_dbgPrintf(" save path %s \n",path_); - int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的步数值 + int data= *new_data-*history;//新数据减去旧数据,作为这一个小时的值 if(data<0) { data=0; *history=0; - CWM_OS_dbgPrintf("异常 清除步数数据\n"); - return; + //CWM_OS_dbgPrintf("异常 清除步数数据\n"); + //return; } @@ -393,7 +393,7 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty int ret =uapi_get_timestampe_ss(&creationTime); uint8_t creationTime_[4]={0}; memcpy(creationTime_,&creationTime,4); - CWM_OS_dbgPrintf("uapi_get_timestampe_ss %02X %02X %02X %02X\n",creationTime_[0],creationTime_[1],creationTime_[2],creationTime_[3]); + CWM_OS_dbgPrintf("uapi_get_timestampe_ss %02X %02X %02X %02X\n",creationTime_[0],creationTime_[1],creationTime_[2],creationTime_[3]); CWM_OS_dbgPrintf("uapi_get_timestampe_ss %d %d\n",ret,creationTime); @@ -404,13 +404,16 @@ void CWM_OS_saveData_history(int* new_data,int *history ,uint32_t len,uint8_t ty CWM_OS_dbgPrintf("fwrite failed %d\n",ret); } - - ret =fwrite(new_data,1,len,fp); + #ifndef ONE_TIME_CONUT_TOTAL + ret =fwrite(&data,1,len,fp); + #else + ret =fwrite(new_data,1,len,fp); + #endif if(ret==0) { CWM_OS_dbgPrintf("fwrite failed %d\n",ret); } - CWM_OS_dbgPrintf("fwrite data %d\n",*new_data); + CWM_OS_dbgPrintf("fwrite data %d\n",data); *history=*new_data; diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index e5814b9a9..835667bdf 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -47,8 +47,8 @@ static int history_step_=0;//存一个小时前的步数数据,每次保存步 uint8_t stand_falg=0;//站立falg,如果发生站立,一个小时内会被置1; int new_calories=0; //存卡路里数据 -int history_calories=0; //一小时前卡路里数据 -int history_calories_=0; +int history_calories=0; // +int history_calories_=0;//一小时前卡路里数据 int new_distance=0; //存距离数据 int history_distances=0; //历史数据 @@ -107,11 +107,15 @@ void cywee_get_chipinfo(char *databuf,uint8_t len) void cywee_save_data(void) { + stepcount+=history_step; CWM_OS_saveData(&stepcount,sizeof(int),CYWEE_SAVE_DATA_STEP); + new_calories+=history_calories; CWM_OS_saveData(&(new_calories),sizeof(int),CYWEE_SAVE_DATA_CALORIES); + new_distance+=history_distances; CWM_OS_saveData(&(new_distance),sizeof(int),CYWEE_SAVE_DATA_DISTANCE); + new_fat+=history_fat; CWM_OS_saveData(&new_fat,sizeof(int),CYWEE_SAVE_DATA_FAT); @@ -121,21 +125,32 @@ void cywee_restoreData(void) { CWM_OS_restoreData(&history_step,sizeof(int),CYWEE_SAVE_DATA_STEP); history_step_=history_step; + CWM_OS_restoreData(&history_calories,sizeof(int),CYWEE_SAVE_DATA_CALORIES); history_calories_=history_calories; + CWM_OS_restoreData(&history_distances,sizeof(int),CYWEE_SAVE_DATA_DISTANCE); history_distances_=history_distances; + CWM_OS_restoreData(&history_fat,sizeof(int),CYWEE_SAVE_DATA_FAT); history_fat_=history_fat; //WM_OS_restoreData(int* data, uint32_t len,uint8_t type)(int* data, uint32_t len,uint8_t type); } +void set_step_data(uint32_t data) +{ + stepcount=data; +} + + uint32_t get_step_data(void) { - return stepcount; + return stepcount+history_step; } + + int get_calories_data(void) { return new_calories+history_calories; @@ -185,7 +200,8 @@ void stand_history_save(void) void step_history_save(void) { - CWM_OS_saveData_history(&stepcount,&history_step_,sizeof(int),CYWEE_SAVE_DATA_STEP); + int data=get_step_data(); + CWM_OS_saveData_history(&data,&history_step_,sizeof(int),CYWEE_SAVE_DATA_STEP); } @@ -214,7 +230,7 @@ int32_t get_now_hour_data(uint8_t type) switch (type) { case CYWEE_SAVE_DATA_STEP: - return stepcount-history_step_; + return get_step_data()-history_step_; break; case CYWEE_SAVE_DATA_CALORIES: return get_calories_data()-history_calories_; @@ -263,7 +279,7 @@ void cywee_reset_daily_data(void) memset(&scl, 0, sizeof(scl)); CWM_SettingControl(SCL_RESET_DAILY_INFO, &scl); history_step = 0; - history_calories=0; //一小时前卡路里数据 + history_calories=0; //卡路里数据 history_distances=0; //历史数据 history_fat=0; //历史数据 } @@ -793,7 +809,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { CustomEventPublish(TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,&ar_alert_type,sizeof(int)); }else{ - stepcount = (int)sensorEVT->fData[1] + history_step; + stepcount = (int)sensorEVT->fData[1]; memset(&c_activity_result_t,0,sizeof(cywee_activity_result_t)); c_activity_result_t.activity_mode = (int)sensorEVT->fData[0]; c_activity_result_t.steps = stepcount; -- 2.17.1