From 9581754b742b83f0871cfda4b7d525f3a062dc67 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 13 Dec 2024 15:51:37 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E6=A0=87=E6=95=B0?= =?utf8?q?=E6=8D=AE=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=AD=98=E5=82=A8=E8=A7=84?= =?utf8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/AlarmClockTimerConfig.cpp | 4 +- .../fd230app/nativeui/goal/src/goalmodel.cpp | 65 +++- .../msg_center/src/msg_center_customer.cpp | 15 +- .../fd230/fs/user/res/makephone/headset_3.bin | 4 +- .../drivers/peripheral/cywee/Inc/cywee_hal.h | 14 +- .../peripheral/cywee/src/board_yh601s.c | 341 +++++++++++++++--- .../drivers/peripheral/cywee/src/main_dml.c | 41 ++- 7 files changed, 404 insertions(+), 80 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 15c1a83fe..2a2c6e188 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -472,9 +472,11 @@ extern "C" { if (curTime->tm_min == 0 && curTime->tm_sec == 0) { AlarmClockEventData unuse; + time_t timetemp=mktime((struct tm*)curTime); + unuse.value=timetemp-60*60; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "on_time_CallBackProc invoked"); GraphicService::GetInstance()->PostGraphicEvent( - std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ON_TIME, unuse)); + std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ON_TIME, unuse)); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp index ee6e55577..3ea42edb6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp @@ -252,6 +252,14 @@ namespace OHOS uint32_t size=0; uint32_t toal_data=0; + time_t currtime; + struct tm *timeinfo_now; + time(&currtime); + timeinfo_now = localtime(&currtime); + + uint8_t mon_now=timeinfo_now->tm_mon; + uint8_t day_now=timeinfo_now->tm_mday; + if (fp != NULL) { fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 @@ -277,9 +285,15 @@ namespace OHOS memcpy(&sing_date,date+i*8+4,4); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date); - if(sing_date>0) + + struct tm *timeinfo; + timeinfo = localtime((time_t *) &timetemp); + + + if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now) toal_data+=sing_date; } + free(date); return toal_data; } @@ -293,6 +307,14 @@ namespace OHOS uint32_t size=0; float toal_data=0; + time_t currtime; + struct tm *timeinfo_now; + time(&currtime); + timeinfo_now = localtime(&currtime); + + uint8_t mon_now=timeinfo_now->tm_mon; + uint8_t day_now=timeinfo_now->tm_mday; + if (fp != NULL) { fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 @@ -318,9 +340,16 @@ namespace OHOS memcpy(&sing_date,date+i*8+4,4); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date); - if(sing_date>0) + + + struct tm *timeinfo; + timeinfo = localtime((time_t *) &timetemp); + + + if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now) toal_data+=sing_date; } + free(date); return toal_data; } @@ -334,6 +363,14 @@ namespace OHOS uint32_t size=0; float toal_data=0; + time_t currtime; + struct tm *timeinfo_now; + time(&currtime); + timeinfo_now = localtime(&currtime); + + uint8_t mon_now=timeinfo_now->tm_mon; + uint8_t day_now=timeinfo_now->tm_mday; + if (fp != NULL) { fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 @@ -360,9 +397,14 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date); - if(sing_date>0) + struct tm *timeinfo; + timeinfo = localtime((time_t *) &timetemp); + + + if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now) toal_data+=sing_date; } + free(date); return toal_data; } @@ -377,6 +419,15 @@ namespace OHOS uint32_t size=0; float toal_data=0; + time_t currtime; + struct tm *timeinfo_now; + time(&currtime); + timeinfo_now = localtime(&currtime); + + uint8_t mon_now=timeinfo_now->tm_mon; + uint8_t day_now=timeinfo_now->tm_mday; + + if (fp != NULL) { fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 @@ -402,9 +453,15 @@ namespace OHOS memcpy(&sing_date,date+i*6+4,2); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time: %d", timetemp); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "data: %d", sing_date); - if(sing_date>0) + + struct tm *timeinfo; + timeinfo = localtime((time_t *) &timetemp); + + + if(sing_date>0 && timeinfo->tm_mday==day_now && timeinfo->tm_mon==mon_now) toal_data+=sing_date; } + free(date); return toal_data; } 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 bcde17478..b48bcac32 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 @@ -382,21 +382,22 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) { unused(req); + AlarmClockEventData* time=(AlarmClockEventData*)req->data; // The alarm notification is not displayed if the incoming call notification is already being processed cywee_save_data(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时步数"); - step_history_save(); + step_history_save(time->value); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时站立数据"); if(get_stand_falg()) - stand_history_save(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据"); - calories_history_save(); + stand_history_save(time->value); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时卡路里数据"); + calories_history_save(time->value); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时距离数据"); - distances_history_save(); + distances_history_save(time->value); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "保存每小时燃脂数据"); - fat_history_save(); -//保存完增加一次读取数据 + fat_history_save(time->value); +// 保存完增加一次读取数据 SendMsgToUIService(UI_UPDATE_GOAL, 0, nullptr, 0); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/headset_3.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/headset_3.bin index ccb14bbf8..6003e4584 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/headset_3.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/makephone/headset_3.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8bc7763c0e9325a91306ce88f3205cd2d0b2e82b053bd981334280faedf552d -size 21624 +oid sha256:b5b15cc0cb4de6bcb92c1880c799f308b7a3a6d3b6666a4816a6734e6a8bde44 +size 5544 diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index e944997bf..4a86e89a9 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -40,8 +40,8 @@ extern void CWM_OS_free(void *ptr); extern void CWM_OS_saveData(int* data, uint32_t len,uint8_t type); extern void CWM_OS_OneHourAgo_saveData(void* data, uint32_t len,uint8_t type); -extern void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t type); -extern void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len); +extern void CWM_OS_saveData_history(void* new_data,void *history ,uint32_t len,uint8_t type,uint32_t time); +extern void CWM_OS_saveData_STAND_history(uint8_t *falg,uint32_t len,uint32_t time); extern uint8_t get_stand_count(void); extern void CWM_OS_restoreData(int* data, uint32_t len,uint8_t type); extern void CWM_OS_OneHourAgo_restoreData(void* data, uint32_t len,uint8_t type); @@ -537,14 +537,14 @@ void cywee_time_sync(void); void cywee_hand_updown_switch(int cmd); void cywee_ar_alert_switch(int cmd); -void step_history_save(void); +void step_history_save(uint32_t); 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); -void fat_history_save(void); +void stand_history_save(uint32_t); +void calories_history_save(uint32_t); +void distances_history_save(uint32_t); +void fat_history_save(uint32_t); int32_t get_now_hour_data(void*value, uint8_t type); void cywee_goal_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 f62faa8cd..72703636c 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -30,6 +30,8 @@ #include "OsApi.h" #include "los_printf.h" #include "cywee_ble_Service.h" +#include "custom_utils.h" + /*********************/ /*** Macro Defines ***/ /*********************/ @@ -375,13 +377,114 @@ void CWM_OS_OneHourAgo_saveData(void* data, uint32_t len,uint8_t type){ fclose(fp); } +typedef struct time_and_32_date +{ + uint32_t time; + uint32_t data; + +}time_and_32_date_t; + + +typedef struct time_and_float_date +{ + uint32_t time; + float data; + +}time_and_float_date_t; + +typedef struct time_and_16_date +{ + uint16_t time; + float data; + +}time_and_16_date_t; + + +uint8_t time_is_repetition(uint32_t time,void *data,char *path,void *data_array,uint8_t type) +{ + uint8_t is_repetition=0; + if(type==0) + { + time_and_32_date_t * p= (time_and_32_date_t*)data_array; + FILE *fp=fopen(path,"rb+"); + if (fp == NULL) return 0; + fseek(fp, 0, SEEK_END); // 将文件指针移动到文件末尾 + uint32_t size = ftell(fp); // 获取当前文件指针位置,即文件大小 + fseek(fp, 0, SEEK_SET); // 将文件指针移回文件开头 + + for(int i=0;i