mcu_hi3321_watch/tjd/ui/app/stress/TjdUiAppStressModel.cpp
2025-05-26 20:15:20 +08:00

64 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "TjdUiAppStressModel.h"
#include "calendar.h"
namespace TJD {
void TjdUiAppStressModel::StressPointArrayInit(void)
{
uint8_t *storeArray;
int32_t num = sql_fit_get_sterss_daydata(&storeArray);
for (int i = 0; i < 24; ++i)
{
array[i].x = i;
array[i].y = storeArray[i];
}
stressPointArray = array;
}
OHOS::Point *TjdUiAppStressModel::GetStressPointArray(void) { return stressPointArray; }
stressPercentage_t TjdUiAppStressModel::GetStressPercentage(void)
{
struct stressPercentage_t percentage = {0};
for(int i = 0; i < 24; ++i )
{
if(array[i].y)
percentage.valid ++;
switch(array[i].y)
{
case 1 ... 29:
percentage.relaxValue ++ ;
break;
case 30 ... 49:
percentage.normalValue ++ ;
break;
case 50 ... 69:
percentage.middleValue ++ ;
break;
case 70 ... 99:
percentage.highValue ++ ;
break;
default:
break;
}
}
return percentage;
}
uint32_t TjdUiAppStressModel::GetCurTimeIndex(void)
{
calendar_t local_time;
uapi_calendar_get_datetime(&local_time);
uint32_t totalMinutes = local_time.hour * 60 + local_time.min;
// 计算索引值每5分钟一个索引
uint32_t index = totalMinutes / 60;
return index;
}
} // namespace TJD