改步数为算法外部管理,修改整点记录数据时错误记录了总值的问题 519/1
authorhcj <1224667075@qq.com>
Mon, 15 Jul 2024 02:16:07 +0000 (10:16 +0800)
committerhcj <1224667075@qq.com>
Mon, 15 Jul 2024 02:16:07 +0000 (10:16 +0800)
code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h
code/sdk/drivers/peripheral/cywee/src/board_yh601s.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c

index 9a36d00..cbd4cc5 100644 (file)
@@ -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(
index 9d5dbf9..b34fcd8 100644 (file)
@@ -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},
index 2f26ccb..a1818f5 100644 (file)
@@ -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);
index d0f9600..43ea7cd 100644 (file)
@@ -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;
 
index e5814b9..835667b 100644 (file)
@@ -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;