From: luozheng <1732036298@qq.com> Date: Tue, 26 May 2026 08:29:35 +0000 (+0800) Subject: 优化步数显示 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=261725b7b3029727f028fae2c36e8a93943a2476;p=mirrors%2FFD230.git 优化步数显示 --- diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c index 246bd435b..3162d7d2a 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.c @@ -52,13 +52,39 @@ uint32_t cywee_step_calc_ui_total(uint32_t file_sum, int32_t hour_delta) uint32_t raw = file_sum + hour_part; if (algo > 0 && raw > algo) { - STEP_CORRECT_PRINT("展示兜底: 文件%u + 本小时%d = %u > 算法%u -> UI=%u\r\n", + STEP_CORRECT_PRINT("展示兜底[偏高]: 文件%u + 本小时%d = %u > 算法%u -> UI=%u\r\n", + file_sum, hour_delta, raw, algo, algo); + return algo; + } + /* 重启后:快照=历史、无整点文件,本小时被算成0 */ + if (algo > 0 && raw < algo) { + STEP_CORRECT_PRINT("展示兜底[偏低]: 文件%u + 本小时%d = %u < 算法%u -> UI=%u\r\n", file_sum, hour_delta, raw, algo, algo); return algo; } return raw; } +int32_t cywee_step_get_ble_sync_hour_delta(void) +{ + uint32_t file_sum = cywee_parse_today_step_file_sum(); + int32_t hour_raw = 0; + + (void)cywee_get_now_hour_data(&hour_raw, STEP); + uint32_t ui_total = cywee_step_calc_ui_total(file_sum, hour_raw); + int32_t sync_delta = (int32_t)ui_total - (int32_t)file_sum; + + if (sync_delta < 0) { + sync_delta = 0; + } + if (sync_delta != hour_raw) { + STEP_CORRECT_PRINT( + "BLE同步纠正: 文件%u 原本小时%d -> 同步本小时%d (展示合计%u)\r\n", + file_sum, hour_raw, sync_delta, ui_total); + } + return sync_delta; +} + void cywee_step_simulate_abnormal_correct_print(void) { #if STEP_DEBUG @@ -488,12 +514,18 @@ void cywee_restoreData(void) CWM_OS_restoreData(&history_step,sizeof(int),STEP); CWM_OS_OneHourAgo_restoreData(&history_step_,sizeof(int),STEP); - if (history_step_ <= 0 && history_step > 0) { + { uint32_t file_sum = cywee_parse_today_step_file_sum(); - history_step_ = (file_sum > 0 && file_sum <= (uint32_t)history_step) ? - (int)file_sum : history_step; - STEP_CORRECT_PRINT("恢复纠正: 快照丢失 用文件累计=%u 或主文件=%d -> 快照=%d\r\n", - file_sum, history_step, history_step_); + if (history_step_ <= 0 && history_step > 0) { + history_step_ = (file_sum > 0 && file_sum <= (uint32_t)history_step) ? + (int)file_sum : 0; + STEP_CORRECT_PRINT("恢复纠正: 快照丢失 文件=%u 历史=%d -> 快照=%d\r\n", + file_sum, history_step, history_step_); + } else if (file_sum == 0 && history_step > 0 && history_step_ >= history_step) { + STEP_CORRECT_PRINT("恢复纠正: 无整点文件 快照%d>=历史%d -> 快照清零\r\n", + history_step_, history_step); + history_step_ = 0; + } } cywee_set_sport_data(history_step,HISTORY_STEP); cywee_set_sport_data(history_step_,HISTORY_STEP_); @@ -974,6 +1006,15 @@ int32_t cywee_get_now_hour_data(void*value, uint8_t type) total, snap, file_sum, data); } else { data = total - snap; + if (data == 0 && total > 0 && snap >= total) { + int file_sum = (int)cywee_parse_today_step_file_sum(); + if (file_sum == 0) { + data = total; + STEP_CORRECT_PRINT( + "本小时纠正: 快照%d>=合计%d 且无整点文件 -> 本小时=%d\r\n", + snap, total, data); + } + } STEP_DBG_PRINT("当前小时 历史步数=%u 当前步数=%u 一小时前=%u 本小时步数=%d\r\n", cywee_get_sport_data(HISTORY_STEP), cywee_get_sport_data(STEP), cywee_get_sport_data(HISTORY_STEP_), data); diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h index c76eff477..1619285f1 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h @@ -90,6 +90,8 @@ void cywee_fat_history_save(uint32_t time); uint32_t cywee_step_get_algo_daily_total(void); /* 活动页展示:文件累计 + 本小时,异常时以算法总步数兜底 */ uint32_t cywee_step_calc_ui_total(uint32_t file_sum, int32_t hour_delta); +/* BLE 同步今日末条:与活动页一致的本小时步数增量 */ +int32_t cywee_step_get_ble_sync_hour_delta(void); /* 模拟典型异常场景并输出纠正说明(STEP_DEBUG 时有效) */ void cywee_step_simulate_abnormal_correct_print(void); diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h index c2ecf81b7..c69d3cb48 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -21,7 +21,7 @@ extern "C" { /* 步数异常调试(日志搜「步数调试」):定位结束后翻倍等问题,验证完成后改为 0 */ #ifndef STEP_DEBUG -#define STEP_DEBUG 1 +#define STEP_DEBUG 0 #endif #define SLEEP_TIME_PATH "/user/userdata/sleep/%s/sleep_time.bin" diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp index 22d82adaf..3716a4467 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp @@ -614,18 +614,13 @@ char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) switch (type) { case 0x43: //同步步数历史数据 - - if( cywee_get_now_hour_data(&value,STEP)) - { - if(value>0) - { - memcpy(buf+size,&creationTime,4); - size+=4; - memcpy(buf+size,&value,4); - size+=4; - } + value = cywee_step_get_ble_sync_hour_delta(); + if (value > 0) { + memcpy(buf + size, &creationTime, 4); + size += 4; + memcpy(buf + size, &value, 4); + size += 4; } - break; case 0x44://同步燃脂时间数据 if(cywee_get_now_hour_data(&value_16,FAT))