int total_sleep = sleepModel.get_sleep_total();
int sleep_goal = sleepModel.get_sleep_goal();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepDataRefresh %d %d sleep_goal:%d total_sleep:%d", sleep_hour, sleep_min, sleep_goal, total_sleep);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepDataRefresh %d %d sleep_goal:%d total_sleep:%d", sleep_hour, sleep_min, sleep_goal * 60, total_sleep);
// 补零操作
std::string hour_str = (sleep_hour < 10) ? "0" + std::to_string(sleep_hour) : std::to_string(sleep_hour);
std::string min_str = (sleep_min < 10) ? "0" + std::to_string(sleep_min) : std::to_string(sleep_min);
- // 有数据则刷新
+ // 有数据才刷新
if (sleep_hour != 0 || sleep_min != 0)
{
- if (time_hour != nullptr && time_minute != nullptr)
+ // 更新时间显示
+ if (time_hour != nullptr)
{
time_hour->SetText(hour_str.c_str());
+ }
+ if (time_minute != nullptr)
+ {
time_minute->SetText(min_str.c_str());
}
// 计算进度百分比,确保目标睡眠时间不为零
- float value = 0.0f;
+ float progress_value = 0.0f;
if (sleep_goal > 0)
{
- value = static_cast<float>(total_sleep) / sleep_goal; // 计算进度
- // value = std::clamp(value, 0.0f, 1.0f); // 确保在 0 到 1 之间
+ progress_value = static_cast<float>(total_sleep) / (sleep_goal * 60); // 计算进度
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Progress value: %.2f%%", value * 100); // 显示为百分比
- circleProgress_->SetValue(value);
+
+ // 日志输出进度百分比
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Progress value: %.2f%%", progress_value * 100); // 显示为百分比
+
+ // 更新进度条
+ circleProgress_->SetValue(progress_value * 100); // 更新进度条值,范围为 0 到 100
circleProgress_->SetCapType(CAP_ROUND);
}
-
// 更新目标时间
if (goaltime != nullptr)
{