From: Caisking <3449750381@qq.com> Date: Sun, 7 Apr 2024 01:59:18 +0000 (+0800) Subject: 表盘增加卡路里、距离、天气Model X-Git-Tag: release_V1.2.70_20241020_135402~1200^2~32 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=cc4c3f24d41f922230139b982a22e448ce899bec;p=mirrors%2FFD230.git 表盘增加卡路里、距离、天气Model --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h index 545d6ef63..a35b08a90 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h @@ -35,6 +35,8 @@ enum class DialDataType DATA_TYPE_CHARGE, // 充电状态 DATA_TYPE_DIALPATH, // 表盘路径 DATA_TYPE_SPO2, // 血氧 + DATA_TYPE_DISTANCE, // 距离 + DATA_TYPE_WEATHER, // 天气 DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h new file mode 100644 index 000000000..a464b1b82 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelDistance + * Author: + * Create: 2023-12 + */ + +#ifndef DIAL_MODEL_Distance_H +#define DIAL_MODEL_Distance_H + +#include "DialBaseModel.h" + +namespace OHOS +{ + class DialModelDistance : public DialBaseModel + { + public: + DialModelDistance() {} + virtual ~DialModelDistance() {} + static DialModelDistance *GetInstance() + { + static DialModelDistance instance; + return &instance; + } + bool GetDialFloatData(DialDataType &type, float &out) override; + void UpdateDistance(int16_t Distance); + int GetDistanceData(void); + + private: + float distance_ = 0; // 67.0: default Distance value as reference + }; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h new file mode 100644 index 000000000..214dd3f99 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelWeather + * Author: + * Create: 2023-12 + */ + +#ifndef DIAL_MODEL_Weather_H +#define DIAL_MODEL_Weather_H + +#include "DialBaseModel.h" + +namespace OHOS +{ + class DialModelWeather : public DialBaseModel + { + public: + DialModelWeather() {} + virtual ~DialModelWeather() {} + static DialModelWeather *GetInstance() + { + static DialModelWeather instance; + return &instance; + } + bool GetDialFloatData(DialDataType &type, float &out) override; + void UpdateWeather(int16_t Weather); + int GetWeatherData(void); + + private: + float Weather_ = 0; // 默认晴天 + }; +} +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp new file mode 100644 index 000000000..0b69c57c4 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelDistance + * Author: + * Create: 2023-12 + */ + +#include "RegisterDialModel.h" +#include "DialModelDistance.h" +#include "wearable_log.h" +REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DISTANCE, OHOS::DialModelDistance::GetInstance()); + +namespace OHOS +{ + bool DialModelDistance::GetDialFloatData(DialDataType &type, float &out) + { + (void)type; + out = distance_; + //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialModelDistance %d", distance_); + return true; + } + + void DialModelDistance::UpdateDistance(int16_t distance) + { + distance_ = static_cast(distance); + if (onChangeListener_ != nullptr) + { + onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_DISTANCE, distance_); + } + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp new file mode 100644 index 000000000..5888f0e3b --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelWeather + * Author: + * Create: 2023-12 + */ + +#include "RegisterDialModel.h" +#include "DialModelWeather.h" +#include "wearable_log.h" +REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEATHER, OHOS::DialModelWeather::GetInstance()); + +namespace OHOS +{ + bool DialModelWeather::GetDialFloatData(DialDataType &type, float &out) + { + (void)type; + out = Weather_; + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialModelWeather %d", Weather_); + return true; + } + + void DialModelWeather::UpdateWeather(int16_t Weather) + { + Weather_ = static_cast(Weather); + if (onChangeListener_ != nullptr) + { + onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_WEATHER, Weather_); + } + } +}