From cc4c3f24d41f922230139b982a22e448ce899bec Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Sun, 7 Apr 2024 09:59:18 +0800 Subject: [PATCH] =?utf8?q?=E8=A1=A8=E7=9B=98=E5=A2=9E=E5=8A=A0=E5=8D=A1?= =?utf8?q?=E8=B7=AF=E9=87=8C=E3=80=81=E8=B7=9D=E7=A6=BB=E3=80=81=E5=A4=A9?= =?utf8?q?=E6=B0=94Model?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/main/include/dial/DialDataBase.h | 2 ++ .../main/include/dial/DialModelDistance.h | 33 +++++++++++++++++++ .../main/include/dial/DialModelWeather.h | 33 +++++++++++++++++++ .../main/src/dial/DialModelDistance.cpp | 31 +++++++++++++++++ .../main/src/dial/DialModelWeather.cpp | 31 +++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp 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_); + } + } +} -- 2.17.1