表盘增加卡路里、距离、天气Model
authorCaisking <3449750381@qq.com>
Sun, 7 Apr 2024 01:59:18 +0000 (09:59 +0800)
committerCaisking <3449750381@qq.com>
Sun, 7 Apr 2024 01:59:18 +0000 (09:59 +0800)
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDistance.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp [new file with mode: 0644]

index 545d6ef..a35b08a 100644 (file)
@@ -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 (file)
index 0000000..a464b1b
--- /dev/null
@@ -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 (file)
index 0000000..214dd3f
--- /dev/null
@@ -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 (file)
index 0000000..0b69c57
--- /dev/null
@@ -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<float>(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 (file)
index 0000000..5888f0e
--- /dev/null
@@ -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<float>(Weather);
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_WEATHER, Weather_);
+        }
+    }
+}