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
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_);
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);