mcu_hi3321_watch/tjd/ui/app/weather/TjdUiAppWeatherModel.h
2025-05-26 20:15:20 +08:00

129 lines
3.4 KiB
C++

#ifndef TJDUIAPPWEATHERMODEL_H
#define TJDUIAPPWEATHERMODEL_H
#include "player.h"
#include "ui_image_animator.h"
#include "media_thread_adapt.h"
#include "ui_lite_surface_view.h"
#include "rtc_api.h"
#include "sql_weather.h"
#include "video_play_wrapper.h"
#define WEATHER_COMMON_BIN_PATH TJD_IMAGE_PATH"img_weather_common.bin"
#define WEATHER_APP_BIN_PATH TJD_IMAGE_PATH"img_weather_app.bin"
namespace TJD {
enum WeatherType {
UNKNOW_WEATHER = 0, // 未知天气
CLOUDY, // 多云
DUSTSTORM, // 沙尘暴
FOGGY, // 雾霾
HEAVY_RAIN, // 大雨
LIGHT_RAIN, // 小雨
MODERATE_RAIN, // 中雨
PARTLY_CLOUDY, // 局部多云
SHOWER, // 阵雨
SNOWY, // 下雪
SUNNY, // 晴天
THUNDERSTORM, // 雷阵雨
TYPHOON, // 台风
WEATHERTYPE_MAX
};
enum WeatherSlicePage {
SWIPEPAGE = 0,
MINDPAGE,
NO_CONNECT_PAGE,
WEATHERSLICEPAGE_MAX
};
typedef struct {
// std::string weekStr;
uint16_t weekId;
std::string tempStr;
OHOS::ImageInfo *iconSrc;
}PreWeekWeather;
enum Week {
SUNDAY = 0,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
UNKNOW_WEEK,
WEEK_MAX
};
typedef struct {
Week weekDay;
const OHOS::ImageInfo *icon;
int8_t highTemperature;
int8_t lowTemperature;
} WeatherItem;
struct WeatherVideo {
WeatherType id;
char *path;
};
struct WeatherPerView {
WeatherType id;
const int perViewId;
};
int getDayOfWeek(int year, int month, int day);
WeatherType SetCurWeather(uint8_t value);
class TjdWeatherVideo : public OHOS::MediaVideoPlay
{
public:
TjdWeatherVideo(OHOS::Surface *surface, std::string uri)
: MediaVideoPlay(surface, nullptr, uri, true) {}
void SetVideoUri(std::string uri) { uri_ = uri; }
};
class TjdUiAppWeatherModel
{
public:
TjdUiAppWeatherModel();
static TjdUiAppWeatherModel &GetInstance(void);
void LoadCurWeatherData(void);
int8_t LoadWeekWeatherInfo(PreWeekWeather *);
bool GetBtLinkStatus(void);
bool IsNeedUpdateWeather(void);
uint16_t GetCurWeatherType(void);
bool GetDataValid(void);
char *GetLocation(void) { return location; }
uint16_t GetWeather(void) { return weather; }
uint8_t GetUpdateHour(void) { return update_hour; }
uint8_t GetUpdateMin(void) { return update_minute; }
int8_t GetCurTemperature(void) { return now_temperature; }
int8_t GetTemperatureMin(void) { return temperature_min; }
int8_t GetTemperatureMax(void) { return temperature_max; }
int8_t GetHumidity(void) { return now_humidity; }
int8_t GetWindSpeed(void) { return now_wind_speed; }
std::string GetSunRiseTime(void);
std::string GetSunSetTime(void);
static rtc_time GetRTCTime(void);
std::unique_ptr<int[]> weartherTypeRes_{nullptr};
private:
struct rtc_time lastTime{0};
char location[32]{0};
uint16_t weather{0};
uint8_t update_hour{0};
uint8_t update_minute{0};
int8_t now_temperature{0};
int8_t temperature_min{0};
int8_t temperature_max{0};
int8_t now_humidity{0};
int8_t now_wind_speed{0};
};
} // namespace TJD
#endif