#include "TjdUiAppDailyDataModel.h" #include #include #include #include "rtc_api.h" #include "cwm_data_deal.h" namespace TJD { TjdUiAppDailyDataModel &TjdUiAppDailyDataModel::GetInstance(void) { static TjdUiAppDailyDataModel instance; return instance; } void TjdUiAppDailyDataModel::LoadChartData(void) { uint32_t *stepArray; uint16_t *KCALArray, *timeArray, *distanceArray; sql_fit_get_step_daydata(&stepArray); sql_fit_get_calorie_daydata(&KCALArray); sql_fit_get_exertime_daydata(&timeArray); sql_fit_get_distance_daydata(&distanceArray); struct rtc_time localTime; tjd_driver_rtc_get_ops()->get_rtc_time(&localTime); totalStepValue = sql_fit_get_day_step(localTime.tm_wday); totalKCALValue = sql_fit_get_day_calorie(localTime.tm_wday); totalTimeValue = sql_fit_get_day_exercise_time(localTime.tm_wday); totalDistanceValue = sql_fit_get_day_distance(localTime.tm_wday); for (int i=0; i 100) return 100; return present; } return 0; } uint8_t TjdUiAppDailyDataModel::GetKCALPersent(void) { uint32_t present; if (defaultKCALValue != 0) { present = (totalKCALValue/(float)defaultKCALValue)*100; if(present > 100) return 100; return present; } return 0; } uint8_t TjdUiAppDailyDataModel::GetTimePersent(void) { uint32_t present; if (defaultTimeValue != 0) { present = (totalTimeValue/(float)defaultTimeValue)*100; if(present > 100) return 100; return present; } return 0; } uint8_t TjdUiAppDailyDataModel::GetDistancePersent(void) { uint32_t present; if (defaultDistanceValue != 0) { present = (totalDistanceValue/defaultDistanceValue)*100; if(present > 100) return 100; return present; } return 0; } void TjdUiAppDailyDataModel::SetDefaultDailyData(void) { defaultStepValue = 6000; defaultKCALValue = 300; defaultTimeValue = 30; defaultDistanceValue = 3000; } uint8_t TjdUiAppDailyDataModel::RequestDaliyData(void) { queuset_cwm_curdata(); return 0; } } // namespace TJD