static uint32_t sleep_update_timestamp = 0;
static uint32_t nap_update_timestamp = 0;
+ /*获取最新睡眠时间戳*/
+ uint32_t get_sleep_update_timestamp(void)
+ {
+ if(nap_update_timestamp<=sleep_update_timestamp)
+ return sleep_update_timestamp;
+ else
+ return nap_update_timestamp;
+ }
+
bool save_nap_data(NAP_T *data)
{
struct stat info;
data->wake_up_timestamp =wake_up_timestamp;
data->total_time = total_time;
+ sleep_update_timestamp = wake_up_timestamp;
+
fclose(fp);
return true;
-}
+ }
void set_sleep_data(SLEEP_T *data)
{
return true;
}
+ std::string SleepModel::GetUpdateSleepTime()
+ {
+ sleep_time_str.clear();
+ // 获取睡眠最新时间
+ uint32_t sleep_time = get_sleep_update_timestamp();
+ // 获取时间戳
+ update_time_info(sleep_time, sleep_time_str);
+ return sleep_time_str;
+ }
void SleepModel::update_sleep(SLEEP_T *data)
{
if (data == nullptr)
circleProgress_->SetValue(progress_value * 100); // 更新进度条值,范围为 0 到 100
circleProgress_->SetCapType(CAP_ROUND);
}
- // 更新目标时间
- if (goaltime != nullptr)
- {
- UpdateLabel(goaltime, sleep_goal, STR_SLEEPMGOAL);
+ // 更新时间
+ if (sleep_update_time != nullptr)
+ {
+ std::string update_time = sleepModel.GetUpdateSleepTime();
+ if (!update_time.empty()) // 检查返回值是否有效
+ {
+ std::string update_time_str = update_time + " 更新"; // 拼接字符串
+ sleep_update_time->SetText(update_time_str.c_str());
+ // UpdateLabel(sleep_update_time, sleep_goal, STR_SLEEPMGOAL); // TODO: 多国语言支持
+ }
}
-
// 刷新视图
RootView::GetInstance()->Invalidate();
}
delete time_minute;
time_minute = nullptr;
}
- if (goaltime != nullptr)
+ if (sleep_update_time != nullptr)
{
- delete goaltime;
- goaltime = nullptr;
+ delete sleep_update_time;
+ sleep_update_time = nullptr;
}
if (roomimage != nullptr)
{
InitImageView(upiconimage, 213, 360, 40, 40, "image", upimagePath);
InitImageView(progress_image, 28, 80, 100, 100, "image", prossimagePath);
/*初始化目标时间*/
- InitLabelExt(goaltime, 83, 330, 300, 35, "lablegoal", STR_SLEEPMGOAL, DEFAULT_VECTOR_FONT_FILENAME, 30);
- goaltime->SetTextColor(Color::Gray());
+ InitLabelExt(sleep_update_time, 83, 330, 300, 35, "lablegoal", STR_SLEEPMGOAL, DEFAULT_VECTOR_FONT_FILENAME, 30);
+ sleep_update_time->SetTextColor(Color::Gray());
/*初始化睡眠时间*/
time_hour = new UILabel();
time_hour->SetPosition(84, 237);
Add(minute);
Add(time_hour);
Add(time_minute);
- Add(goaltime);
+ Add(sleep_update_time);
Add(upiconimage);
Add(roomimage);