dialmodel 相关修改
authorCaisking <Casiking@zhihuishixun.com>
Tue, 15 Apr 2025 08:33:18 +0000 (16:33 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 15 Apr 2025 08:33:18 +0000 (16:33 +0800)
79 files changed:
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialBoxProgressView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialDataBase.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialLabelView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCalorie.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCharge.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateEnStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekMDStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDistance.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHeartRate.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourMin.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourTens.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourUnits.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoal.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalValue.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinTens.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinUnits.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPath.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPower.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerMapper.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStandby.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSPO2.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSecondMapper.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoal.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalValue.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSteps.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTime.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTimeStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeather.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeatherStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekEnStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekNum.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekStr.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/OnDialDataUpdateListener.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialArcProgressView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialBoxProgressView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialLabelView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCalorie.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCharge.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateEnStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekMDStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDistance.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHeartRate.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourMin.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourTens.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourUnits.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoal.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalValue.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinTens.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinUnits.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPath.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPower.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerMapper.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStandby.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSPO2.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSecondMapper.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoal.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalValue.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSteps.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTime.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTimeStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeather.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeatherStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekEnStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekNum.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekStr.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialVideoView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/ModelDialDataFactory.cpp

index cc45b4d..25bfeeb 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * Copyright (c) @CompanyNameMagicTag. 2023. All rights reserved.
- */
 
 #ifndef DIAL_BOX_PROGRESS_VIEW_H
 #define DIAL_BOX_PROGRESS_VIEW_H
@@ -8,14 +5,37 @@
 #include "DialView.h"
 #include "components/ui_box_progress.h"
 
+enum DialBoxDataType {
+  // 剩余电量百分比
+  BATTERY_LEVEL = 1,
+  // 步数目标
+  STEP_TARGET = 2,
+  // 卡路里
+  CALORIE_TARGET = 3,
+};
 namespace OHOS {
 class DialBoxProgressView : public UIBoxProgress, public DialView {
 public:
-    DialBoxProgressView();
-    ~DialBoxProgressView() override;
-    void HandleFloatData(float data) override;
+  DialBoxProgressView();
+  ~DialBoxProgressView() override;
+  static DialBoxProgressView *GetInstance() {
+    static DialBoxProgressView instance;
+    return &instance;
+  }
+  void HandleFloatData(float data) override;
+  void UpdataChargColor();
+  void UpdateBatteryColor();
+  void SetViewColor(int64_t color);
+
+  uint32_t DialBoxDataTypeToBitPattern(DialBoxDataType type);
+  uint32_t ConvertToRequiredFormat(DialBoxDataType type, float data);
+  DialBoxDataType ExtractDataType(uint32_t rawData);
+  uint32_t ExtractValue(uint32_t rawData);
+
 private:
-    int32_t value_ = -1;
+  int32_t value_ = -1;
+  int64_t color_ = Color::White().full;
+  DialBoxDataType datatype_ = BATTERY_LEVEL;
 };
-}
+} // namespace OHOS
 #endif
\ No newline at end of file
index 9a695b9..0774736 100644 (file)
@@ -1,39 +1,63 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
- * Description: DialBaseModel
- * Author:
- * Create: 2023-12
- */
-
 #ifndef DIAL_DATA_BASE_H
 #define DIAL_DATA_BASE_H
 
 enum class DialDataType {
-    DATA_TYPE_FLOAT_BASE = 0,
-    DATA_TYPE_STEPS,
-    DATA_TYPE_HEART_RATE,
-    DATA_TYPE_CALORIE,
-    DATA_TYPE_TEMPERATURE,
-    DATA_TYPE_PM25,
-    DATA_TYPE_PRESSURE,
-    DATA_TYPE_AILTITUDE,
-    DATA_TYPE_POWER,
-    DATA_TYPE_CLOCK_ANGLE_H,
-    DATA_TYPE_CLOCK_ANGLE_M,
-    DATA_TYPE_CLOCK_ANGLE_S,
-    DATA_TYPE_CLOCK_ANGLE_MS,
-    DATA_TYPE_TIME_SECOND,
-    DATA_TYPE_TIME_MINUTE,
-    DATA_TYPE_TIME_HOUR,
-    DATA_TYPE_TIME_DATE,
-    DATA_TYPE_TIME_WEEK,
-    DATA_TYPE_TIME_MONTH,
-    DATA_TYPE_TIME_YEAR,
+  DATA_TYPE_FLOAT_BASE = 0,
+  DATA_TYPE_STEPS,          // 运动步数
+  DATA_TYPE_HEART_RATE,     // 心率
+  DATA_TYPE_CALORIE,        // 运动卡路里
+  DATA_TYPE_TEMPERATURE,    // 温度
+  DATA_TYPE_PM25,           // PM2.5
+  DATA_TYPE_PRESSURE,       // 压力
+  DATA_TYPE_AILTITUDE,      // 海拔
+  DATA_TYPE_POWER,          // 电量
+  DATA_TYPE_CLOCK_ANGLE_H,  // 时针角度
+  DATA_TYPE_CLOCK_ANGLE_M,  // 分针角度
+  DATA_TYPE_CLOCK_ANGLE_S,  // 秒针角度
+  DATA_TYPE_CLOCK_ANGLE_MS, // 毫秒针角度
+  DATA_TYPE_TIME_SECOND,    // 秒
+  DATA_TYPE_TIME_MINUTE,    // 分钟
+  DATA_TYPE_TIME_HOUR,      // 小时
+  DATA_TYPE_TIME_DATE,      // 日期
+  DATA_TYPE_TIME_WEEK,      // 星期
+  DATA_TYPE_TIME_MONTH,     // 月份
+  DATA_TYPE_TIME_YEAR,      // 年份
+  /* ------------------------------- 在下面增加新数据类型
+     ------------------------------- */
+  DATA_TYPE_CHARGE,           // 充电状态
+  DATA_TYPE_DIALPATH,         // 表盘路径
+  DATA_TYPE_SPO2,             // 血氧
+  DATA_TYPE_DISTANCE,         // 运动距离
+  DATA_TYPE_WEATHER,          // 天气
+  DATA_TYPE_POWER_STANDBY,    // 备用电量数据类型
+  DATA_TYPE_HOUR_TENS,        // 小时(十位)
+  DATA_TYPE_HOUR_UNITS,       // 小时(单位)
+  DATA_TYPE_MINUTE_TENS,      // 分钟(十位)
+  DATA_TYPE_MINUTE_UNITS,     // 分钟(单位)
+  DATA_TYPE_WEEK_NUM,         // 星期(数字)
+  DATA_TYPE_STEPS_GOAL,       // 运动步数目标
+  DATA_TYPE_SECOND_MAPPER,    // 秒映射
+  DATA_TYPE_POWER_MAPPER,     // 电量映射
+  DATA_TYPE_CALORIE_GOAL,     // 运动卡路里目标
+  DATA_TYPE_STEPS_GOAL_INT,   // 运动步数百分比
+  DATA_TYPE_CALORIE_GOAL_INT, // 运动卡路里目标百分比
 
-    DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff,
+  DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值
+  DATA_TYPE_HOUR_MIN,                  // 时分
 
-    DATA_TYPE_TEXT_BASE = 0x4fff,
+  DATA_TYPE_TEXT_BASE = 0x4fff, // 文本数据类型基值
+  DATA_TYPE_WEEK_STR,           // 星期(string)
+  DATA_TYPE_DATE_STR,           // 日期(string)
+  DATA_TYPE_WEATHER_STR,        // 天气(string)
+  DATA_TYPE_TIMESTR_STR,        // 时间(string)
+  DATA_TYPE_DATE_WEEK_STR,      // 日期(年月日)星期(string)
+  DATA_TYPE_POWER_STR,          // 电量(string)
+  DATA_TYPE_DATE_WEEK_MD_STR,   // 星期(月日)和日期(string)
+  DATA_TYPE_DATE_EN_STR,        // 月份+日期 (英文)
+  DATA_TYPE_WEEK_EN_STR,        // 星期(英文)
+  DATA_TYPE_STEPS_GOAL_STR,     // 运动步数目标(string)
+  DATA_TYPE_CALORIE_GOAL_STR,   // 卡路里目标(string)
 
-    DATA_TYPE_MAX = 0x7fff,
+  DATA_TYPE_MAX = 0x7fff, // 数据类型的最大值
 };
 #endif
index c551313..355656e 100644 (file)
@@ -8,6 +8,7 @@
 #include <cstdint>
 #include "DialView.h"
 #include "components/ui_label.h"
+#include "components/ui_label_ext.h"
 
 namespace OHOS {
 class DialLabelView : public UILabel, public DialView {
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCalorie.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCalorie.h
new file mode 100644 (file)
index 0000000..076ef59
--- /dev/null
@@ -0,0 +1,39 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-31 18:20:02
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelCalorie.h
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelCalorie
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_Calorie_H
+#define DIAL_MODEL_Calorie_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelCalorie : public DialBaseModel
+    {
+    public:
+        DialModelCalorie() {}
+        virtual ~DialModelCalorie() {}
+        static DialModelCalorie *GetInstance()
+        {
+            static DialModelCalorie instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateCalorie(int16_t Calorie);
+        int GetCalorieData(void);
+
+    private:
+        float calorie_ = 0; // 67.0: default Calorie value as reference
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCharge.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelCharge.h
new file mode 100644 (file)
index 0000000..373ed7e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelCharge
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_Charge_H
+#define DIAL_MODEL_Charge_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelCharge : public DialBaseModel
+    {
+    public:
+        DialModelCharge() {}
+        virtual ~DialModelCharge() {}
+        static DialModelCharge *GetInstance()
+        {
+            static DialModelCharge instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdatechargeStatus(int16_t chargeStatus);
+
+    private:
+        int16_t chargeStatus_ = 0; // 默认没有充电 测试为充电
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateEnStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateEnStr.h
new file mode 100644 (file)
index 0000000..75a1066
--- /dev/null
@@ -0,0 +1,28 @@
+
+
+#ifndef DIAL_MODEL_DateEnStr_H
+#define DIAL_MODEL_DateEnStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace OHOS {
+class DialModelDateEnStr : public DialBaseModel {
+public:
+  DialModelDateEnStr() {}
+  virtual ~DialModelDateEnStr() {}
+  static DialModelDateEnStr *GetInstance() {
+    static DialModelDateEnStr instance;
+    return &instance;
+  }
+  bool GetDialTextData(DialDataType &type, std::string *&out,
+                       int16_t &strNum) override;
+  void UpDateEnDateEnStr(const std::string *&dialDateEnStr);
+
+private:
+  std::string dialDateEnStr_;
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateStr.h
new file mode 100644 (file)
index 0000000..c109ff9
--- /dev/null
@@ -0,0 +1,30 @@
+
+
+#ifndef DIAL_MODEL_DateStr_H
+#define DIAL_MODEL_DateStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+    class DialModelDateStr : public DialBaseModel
+    {
+    public:
+        DialModelDateStr() {}
+        virtual ~DialModelDateStr() {}
+        static DialModelDateStr *GetInstance()
+        {
+            static DialModelDateStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateDateStr(const std::string *&dialDateStr);
+
+    private:
+        std::vector<std::string> datestr;
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekMDStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekMDStr.h
new file mode 100644 (file)
index 0000000..d664ba4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-11-03 16:53:17
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-11-03 17:11:53
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDateWeekMDStr.h
+ */
+
+#ifndef DIAL_MODEL_DateWeekMDStr_H
+#define DIAL_MODEL_DateWeekMDStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+    class DialModelDateWeekMDStr : public DialBaseModel
+    {
+    public:
+        DialModelDateWeekMDStr() {}
+        virtual ~DialModelDateWeekMDStr() {}
+        static DialModelDateWeekMDStr *GetInstance()
+        {
+            static DialModelDateWeekMDStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out,int16_t &strNum) override;
+        void UpdateDateWeekStr(const std::string *&dialDateWeekMDStr);
+
+    private:
+        std::string dateweekmdstr;
+    };
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDateWeekStr.h
new file mode 100644 (file)
index 0000000..6ec963e
--- /dev/null
@@ -0,0 +1,28 @@
+
+
+#ifndef DIAL_MODEL_DateWeekStr_H
+#define DIAL_MODEL_DateWeekStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace OHOS {
+class DialModelDateWeekStr : public DialBaseModel {
+public:
+  DialModelDateWeekStr() {}
+  virtual ~DialModelDateWeekStr() {}
+  static DialModelDateWeekStr *GetInstance() {
+    static DialModelDateWeekStr instance;
+    return &instance;
+  }
+  bool GetDialTextData(DialDataType &type, std::string *&out,
+                       int16_t &strNum) override;
+  void UpdateDateWeekStr(const std::string *&dialDateWeekStr);
+
+private:
+  std::string dateweekstr;
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDistance.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelDistance.h
new file mode 100644 (file)
index 0000000..325cb8b
--- /dev/null
@@ -0,0 +1,39 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-31 18:20:02
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelDistance.h
+ */
+/*
+ * 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(float Distance);
+        int GetDistanceData(void);
+
+    private:
+        float distance_ = 0; // 67.0: default Distance value as reference
+    };
+}
+#endif
index 481f394..51fd884 100644 (file)
 
 #include "DialBaseModel.h"
 
-namespace OHOS {
-class DialModelHeartRate : public DialBaseModel {
-public:
-    DialModelHeartRate() {}
-    ~DialModelHeartRate() override {}
-    static DialModelHeartRate* GetInstance()
+namespace OHOS
+{
+    class DialModelHeartRate : public DialBaseModel
     {
-        static DialModelHeartRate instance;
-        return &instance;
-    }
-    bool GetDialFloatData(DialDataType& type, float& out) override;
-    void UpdateHeartRate(int16_t heartRate);
+    public:
+        DialModelHeartRate() {}
+        ~DialModelHeartRate() override {}
+        static DialModelHeartRate *GetInstance()
+        {
+            static DialModelHeartRate instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateHeartRate(int16_t heartRate);
+        int GetHeartData();
 
-private:
-    float heartRate_ = 67.0; // 67.0: default heart value as reference
-};
+    private:
+        float heartRate_ = 0; // 67.0: default heart value as reference
+    };
 }
 #endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourMin.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourMin.h
new file mode 100644 (file)
index 0000000..d28ed1d
--- /dev/null
@@ -0,0 +1,29 @@
+
+#ifndef DIAL_MODEL_HourMin_H
+#define DIAL_MODEL_HourMin_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+    class DialModelHourMin : public DialBaseModel
+    {
+    public:
+        DialModelHourMin() {}
+        virtual ~DialModelHourMin() {}
+        static DialModelHourMin *GetInstance()
+        {
+            static DialModelHourMin instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float *&out, int16_t len) override;
+        void UpdateHourMin(const std::string *&dialHourMin);
+
+    private:
+        float dialhourmin{2};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourTens.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourTens.h
new file mode 100644 (file)
index 0000000..745f19d
--- /dev/null
@@ -0,0 +1,27 @@
+
+#ifndef DIAL_MODEL_HourTens_H
+#define DIAL_MODEL_HourTens_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelHourTens : public DialBaseModel
+    {
+    public:
+        DialModelHourTens() {}
+        ~DialModelHourTens() override {}
+        static DialModelHourTens *GetInstance()
+        {
+            static DialModelHourTens instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateHourTens();
+
+    private:
+        struct tm tblock_;
+        uint8_t hour_tens;
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourUnits.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelHourUnits.h
new file mode 100644 (file)
index 0000000..b517dca
--- /dev/null
@@ -0,0 +1,29 @@
+
+
+#ifndef DIAL_MODEL_HourUnits_H
+#define DIAL_MODEL_HourUnits_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelHourUnits : public DialBaseModel
+    {
+    public:
+        DialModelHourUnits() {}
+        ~DialModelHourUnits() override {}
+        static DialModelHourUnits *GetInstance()
+        {
+            static DialModelHourUnits instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateHourUnits();
+
+    private:
+        struct tm tblock_;
+        uint8_t hour_units;
+     
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoal.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoal.h
new file mode 100644 (file)
index 0000000..c901d94
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcalgoal
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_Kcalgoal_H
+#define DIAL_MODEL_Kcalgoal_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelKcalgoal : public DialBaseModel {
+public:
+  DialModelKcalgoal() {}
+  ~DialModelKcalgoal() override {}
+  static DialModelKcalgoal *GetInstance() {
+    static DialModelKcalgoal instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdateKcalgoal(uint32_t Kcalgoal);
+
+private:
+  float Kcalgoal_ = 0; // 11520.0: default Kcal value as reference
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalStr.h
new file mode 100644 (file)
index 0000000..4b3594f
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcalgoalStr
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_KcalgoalStr_H
+#define DIAL_MODEL_KcalgoalStr_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelKcalgoalStr : public DialBaseModel {
+public:
+  DialModelKcalgoalStr() {}
+  ~DialModelKcalgoalStr() override {}
+  static DialModelKcalgoalStr *GetInstance() {
+    static DialModelKcalgoalStr instance;
+    return &instance;
+  }
+  bool GetDialTextData(DialDataType &type, std::string *&out,
+                       int16_t &strNum) override;
+  
+  void UpdateKcalgoalStr(uint32_t KcalgoalStr);
+
+private:
+  std::string KcalgoalStr_ = "0%";
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalValue.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelKcalgoalValue.h
new file mode 100644 (file)
index 0000000..cbef774
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcalgoalValue
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_KcalgoalValue_H
+#define DIAL_MODEL_KcalgoalValue_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelKcalgoalValue : public DialBaseModel {
+public:
+  DialModelKcalgoalValue() {}
+  ~DialModelKcalgoalValue() override {}
+  static DialModelKcalgoalValue *GetInstance() {
+    static DialModelKcalgoalValue instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdateKcalgoalValue(uint32_t KcalgoalValue);
+
+private:
+  float KcalgoalValue_ = 0; // 11520.0: default Kcal value as reference
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinTens.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinTens.h
new file mode 100644 (file)
index 0000000..7f092b3
--- /dev/null
@@ -0,0 +1,27 @@
+
+#ifndef DIAL_MODEL_MinTens_H
+#define DIAL_MODEL_MinTens_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelMinTens : public DialBaseModel
+    {
+    public:
+        DialModelMinTens() {}
+        ~DialModelMinTens() override {}
+        static DialModelMinTens *GetInstance()
+        {
+            static DialModelMinTens instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateMinTens();
+
+    private:
+        struct tm tblock_;
+        uint8_t min_tens;
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinUnits.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelMinUnits.h
new file mode 100644 (file)
index 0000000..86720f9
--- /dev/null
@@ -0,0 +1,28 @@
+
+
+#ifndef DIAL_MODEL_MinUnits_H
+#define DIAL_MODEL_MinUnits_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelMinUnits : public DialBaseModel
+    {
+    public:
+        DialModelMinUnits() {}
+        ~DialModelMinUnits() override {}
+        static DialModelMinUnits *GetInstance()
+        {
+            static DialModelMinUnits instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateMinUnits();
+
+    private:
+        struct tm tblock_;
+        uint8_t min_units;
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPath.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPath.h
new file mode 100644 (file)
index 0000000..0291902
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef DIAL_MODEL_PATH_H
+#define DIAL_MODEL_PATH_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelPath : public DialBaseModel
+    {
+    public:
+        DialModelPath() {}
+        virtual ~DialModelPath() {}
+        static DialModelPath *GetInstance()
+        {
+            static DialModelPath instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdatePath(const std::string *&DialPath);
+
+    private:
+        std::string DialPath_ = "/user/res/dials/dog.bin";
+    };
+}
+#endif
\ No newline at end of file
index cb6a97c..2837b4d 100644 (file)
@@ -1,29 +1,28 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
- * Description: DialModelPower
- * Author:
- * Create: 2023-12
- */
 
 #ifndef DIAL_MODEL_POWER_H
 #define DIAL_MODEL_POWER_H
 
 #include "DialBaseModel.h"
 
-namespace OHOS {
-class DialModelPower : public DialBaseModel {
-public:
-    DialModelPower() {}
-    ~DialModelPower() override {}
-    static DialModelPower* GetInstance()
+namespace OHOS 
+{
+    class DialModelPower : public DialBaseModel
     {
-        static DialModelPower instance;
-        return &instance;
-    }
-    bool GetDialFloatData(DialDataType& type, float& out) override;
+    public:
+        DialModelPower() {}
+    ~DialModelPower() override {}
+        static DialModelPower *GetInstance()
+        {
+            static DialModelPower instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdatePower();
+        void NotifyPowerUpdate();
 
-private:
-    int16_t power_ = 90; // 90: default power level
-};
+    private:
+        int16_t power_ = 0;
+        bool powerUpdated_{false};
+    };
 }
 #endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerMapper.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerMapper.h
new file mode 100644 (file)
index 0000000..fb7659b
--- /dev/null
@@ -0,0 +1,25 @@
+
+#ifndef DIAL_MODEL_PowerMapper_H
+#define DIAL_MODEL_PowerMapper_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelPowerMapper : public DialBaseModel {
+public:
+  DialModelPowerMapper() {}
+  ~DialModelPowerMapper() override {}
+  static DialModelPowerMapper *GetInstance() {
+    static DialModelPowerMapper instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdatePowerMapper();
+  void NotifyPowerMapperUpdate();
+
+private:
+  float powermapper_ = 0;
+  bool PowerMapperUpdated_{false};
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStandby.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStandby.h
new file mode 100644 (file)
index 0000000..6a52879
--- /dev/null
@@ -0,0 +1,30 @@
+
+
+#ifndef DIAL_MODEL_POWER_STANDBY_H
+#define DIAL_MODEL_POWER_STANDBY_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelPowerStanby : public DialBaseModel
+    {
+    public:
+        DialModelPowerStanby() {}
+        virtual ~DialModelPowerStanby() {}
+        static DialModelPowerStanby *GetInstance()
+        {
+            static DialModelPowerStanby instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdatePowerStanby();
+        void NotifyPowerStanbyUpdate();
+        float SmoothPowerUpdate(float newPower);
+
+    private:
+        uint8_t PowerStanby_ = 0;
+        bool PowerStanbyUpdated_{false};
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelPowerStr.h
new file mode 100644 (file)
index 0000000..2babe9d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-11-02 18:09:28
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-11-02 18:17:44
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelPowerStr.h
+ */
+
+
+#ifndef DIAL_MODEL_POWER_STR_H
+#define DIAL_MODEL_POWER_STR_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelPowerStr : public DialBaseModel
+    {
+    public:
+        DialModelPowerStr() {}
+        virtual ~DialModelPowerStr() {}
+        static DialModelPowerStr *GetInstance()
+        {
+            static DialModelPowerStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateTimeStr(const std::string dialPowerStr);
+
+    private:
+        std::string dialPowerStr_;
+    };
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSPO2.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSPO2.h
new file mode 100644 (file)
index 0000000..7d7ee1e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelSPO2
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_SPO2_H
+#define DIAL_MODEL_SPO2_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS
+{
+    class DialModelSPO2 : public DialBaseModel
+    {
+    public:
+        DialModelSPO2() {}
+        virtual ~DialModelSPO2() {}
+        static DialModelSPO2 *GetInstance()
+        {
+            static DialModelSPO2 instance;
+            return &instance;
+        }
+        bool GetDialFloatData(DialDataType &type, float &out) override;
+        void UpdateSPO2(uint8_t SPO2);
+        int GetSPO2Data();
+
+    private:
+        float SPO2_ = 0; // 97.0: default SPO2 value as reference
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSecondMapper.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelSecondMapper.h
new file mode 100644 (file)
index 0000000..0d6edb2
--- /dev/null
@@ -0,0 +1,25 @@
+
+#ifndef DIAL_MODEL_SecondMapper_H
+#define DIAL_MODEL_SecondMapper_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelSecondMapper : public DialBaseModel {
+public:
+  DialModelSecondMapper() {}
+  ~DialModelSecondMapper() override {}
+  static DialModelSecondMapper *GetInstance() {
+    static DialModelSecondMapper instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdateSecondMapper();
+  float CalculateMappedValue(int min, int sencond);
+
+private:
+  struct tm tblock_;
+  uint8_t secondmapper_;
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoal.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoal.h
new file mode 100644 (file)
index 0000000..77ee2f5
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelStepgoal
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_Stepgoal_H
+#define DIAL_MODEL_Stepgoal_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelStepgoal : public DialBaseModel {
+public:
+  DialModelStepgoal() {}
+  ~DialModelStepgoal() override {}
+  static DialModelStepgoal *GetInstance() {
+    static DialModelStepgoal instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdateStepgoal(uint32_t Stepgoal);
+
+private:
+  float stepgoal_ = 0; // 11520.0: default step value as reference
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalStr.h
new file mode 100644 (file)
index 0000000..29b7d74
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelStepgoalStr
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_StepgoalStr_H
+#define DIAL_MODEL_StepgoalStr_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelStepgoalStr : public DialBaseModel {
+public:
+  DialModelStepgoalStr() {}
+  ~DialModelStepgoalStr() override {}
+  static DialModelStepgoalStr *GetInstance() {
+    static DialModelStepgoalStr instance;
+    return &instance;
+  }
+  bool GetDialTextData(DialDataType &type, std::string *&out,
+                       int16_t &strNum) override;
+  
+  void UpdateStepgoalStr(uint32_t StepgoalStr);
+
+private:
+  std::string StepgoalStr_ = "0%";
+};
+} // namespace OHOS
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalValue.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelStepgoalValue.h
new file mode 100644 (file)
index 0000000..2ec1b3c
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelStepgoalValue
+ * Author:
+ * Create: 2023-12
+ */
+
+#ifndef DIAL_MODEL_StepgoalValue_H
+#define DIAL_MODEL_StepgoalValue_H
+
+#include "DialBaseModel.h"
+
+namespace OHOS {
+class DialModelStepgoalValue : public DialBaseModel {
+public:
+  DialModelStepgoalValue() {}
+  ~DialModelStepgoalValue() override {}
+  static DialModelStepgoalValue *GetInstance() {
+    static DialModelStepgoalValue instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+  void UpdateStepgoalValue(uint32_t StepgoalValue);
+
+private:
+  float stepgoalValue_ = 0; // 11520.0: default Step value as reference
+};
+} // namespace OHOS
+#endif
index e1e9930..b688637 100644 (file)
@@ -21,10 +21,10 @@ public:
         return &instance;
     }
     bool GetDialFloatData(DialDataType& type, float& out) override;
-    void UpdateSteps(int16_t steps);
+    void UpdateSteps(uint32_t steps);
 
-private:
-    float steps_ = 11520.0; // 11520.0: default step value as reference
+  private:
+    float steps_ = 0; // 11520.0: default step value as reference
 };
 }
 #endif
index 7da252b..65067ac 100644 (file)
@@ -24,11 +24,12 @@ public:
     void UpdateTime();
 
 private:
-    struct tm *tblock_;
+    struct tm tblock_;
     uint16_t angleH_ = 0;
     uint16_t angleM_ = 0;
     uint16_t angleS_ = 0;
     float angleMS_ = 0;
+    uint8_t pm_ = 0;
 };
 }
 #endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTimeStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelTimeStr.h
new file mode 100644 (file)
index 0000000..707f159
--- /dev/null
@@ -0,0 +1,28 @@
+
+
+#ifndef DIAL_MODEL_TimeStr_H
+#define DIAL_MODEL_TimeStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS {
+class DialModelTimeStr : public DialBaseModel {
+public:
+  DialModelTimeStr() {}
+  virtual ~DialModelTimeStr() {}
+  static DialModelTimeStr *GetInstance() {
+    static DialModelTimeStr instance;
+    return &instance;
+  }
+  bool GetDialTextData(DialDataType &type, std::string *&out,
+                       int16_t &strNum) override;
+  void UpdateTimeStr(const std::string dialTimeStr);
+
+private:
+  struct tm tblock_;
+  std::string dialTimeStr_ = "00:00";
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeather.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeather.h
new file mode 100644 (file)
index 0000000..c5e7463
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-06-07 11:18:25
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-08-29 17:52:26
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeather.h
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
+/*
+ * 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);
+        void UpdateWeatherStr(std::string text);
+        int GetWeatherData(void);
+
+    private:
+        float Weather_ = 11; // 默认unkown
+        std::string Weather_Str = "/°";
+    };
+}
+#endif
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeatherStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeatherStr.h
new file mode 100644 (file)
index 0000000..6aa88a4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-08-28 16:45:12
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-08-28 16:55:58
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeatherStr.h
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
+
+
+#ifndef DIAL_MODEL_WeatherStr_H
+#define DIAL_MODEL_WeatherStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelWeatherStr : public DialBaseModel
+    {
+    public:
+        DialModelWeatherStr() {}
+        virtual ~DialModelWeatherStr() {}
+        static DialModelWeatherStr *GetInstance()
+        {
+            static DialModelWeatherStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateWeatherStr(const std::string dialWeatherStr);
+
+    private:
+        std::string dialWeatherStr_ = "/°";
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekEnStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekEnStr.h
new file mode 100644 (file)
index 0000000..89c0f90
--- /dev/null
@@ -0,0 +1,34 @@
+/*** 
+ * @Date: 2024-08-03 17:35:36
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-07 11:50:10
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekEnStr.h
+ */
+
+#ifndef DIAL_MODEL_WeekEnStr_H
+#define DIAL_MODEL_WeekEnStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelWeekEnStr : public DialBaseModel
+    {
+    public:
+        DialModelWeekEnStr() {}
+        virtual ~DialModelWeekEnStr() {}
+        static DialModelWeekEnStr *GetInstance()
+        {
+            static DialModelWeekEnStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateWeekEnStr(const std::string *&dialWeekEnStr);
+
+    private:
+        std::string dialWeekEnStr_;
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekNum.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekNum.h
new file mode 100644 (file)
index 0000000..4ce7996
--- /dev/null
@@ -0,0 +1,31 @@
+/***
+ * @Date: 2024-08-03 17:35:36
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-07 11:50:10
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekNum.h
+ */
+
+#ifndef DIAL_MODEL_WeekNum_H
+#define DIAL_MODEL_WeekNum_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS {
+class DialModelWeekNum : public DialBaseModel {
+public:
+  DialModelWeekNum() {}
+  virtual ~DialModelWeekNum() {}
+  static DialModelWeekNum *GetInstance() {
+    static DialModelWeekNum instance;
+    return &instance;
+  }
+  bool GetDialFloatData(DialDataType &type, float &out) override;
+
+private:
+  float dialWeekNum_;
+};
+} // namespace OHOS
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekStr.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialModelWeekStr.h
new file mode 100644 (file)
index 0000000..d36d0a8
--- /dev/null
@@ -0,0 +1,34 @@
+/*** 
+ * @Date: 2024-08-03 17:35:36
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-07 11:50:10
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelWeekStr.h
+ */
+
+#ifndef DIAL_MODEL_WeekStr_H
+#define DIAL_MODEL_WeekStr_H
+
+#include "DialBaseModel.h"
+#include <cstdint>
+#include <string>
+
+namespace OHOS
+{
+    class DialModelWeekStr : public DialBaseModel
+    {
+    public:
+        DialModelWeekStr() {}
+        virtual ~DialModelWeekStr() {}
+        static DialModelWeekStr *GetInstance()
+        {
+            static DialModelWeekStr instance;
+            return &instance;
+        }
+        bool GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum) override;
+        void UpdateWeekStr(const std::string *&dialWeekStr);
+
+    private:
+        std::string dialWeekStr_;
+    };
+}
+#endif
\ No newline at end of file
index 76ada9f..f1b5844 100644 (file)
@@ -114,8 +114,20 @@ public:
 
     void OnInactive() override;
 
+    /*外部接口对表盘进行调用*/
+    void StopDial();
+    void StartDial();
+
+    /*外部接口更新表盘状态*/
+    void UpdateStateShow();
+
     MediaVideoPlay* GetVideoPlay();
 
+private:
+    bool resLoadStatus{false};
+
+
+
 private:
     void ProcessData(DialDataType type, DialView* view);
     std::unordered_map<int16_t, DialView*> dataTypeMap_;
@@ -127,8 +139,10 @@ private:
     std::string filePath_;
     FILE* fp_ = nullptr;
     DialVideoView* video_ = nullptr;
-    UIKaleidoscopeView* kaleidoscope_ = nullptr;
-    DisplayState state_ = DisplayState::NORMAL;
+    UIKaleidoscopeView *kaleidoscope_ = nullptr;
+    UIImageView *dialstateicon_{nullptr}; // 勿扰图标
+    UIImageView *messageicon_{nullptr};     // 未读图标   
+       DisplayState state_ = DisplayState::NORMAL;
 
     typedef struct {
         Rect area;
index 67dadd4..b9ab854 100644 (file)
@@ -13,8 +13,8 @@ DialArcProgressView::~DialArcProgressView(void)
 {
 }
 
-void DialArcProgressView::HandleFloatData(float data)
-{
+void DialArcProgressView::HandleFloatData(float data) {
+    // printf("HandleFloatData: %f\n", data);
     float ratio = data;
     if (ratio > 1.0f) {
         ratio = 1.0f;
index 8084dfb..aacccb8 100644 (file)
-/*
- * Copyright (c) @CompanyNameMagicTag. 2023. All rights reserved.
- */
-
 #include "DialBoxProgressView.h"
+#include "wearable_log.h"
+
+// #include "battery_hal.h"
+// extern uint8_t battery_get_voltage(float *voltage);
+
+// 定义电量宏
+#define BATTERY_LOW_THRESHOLD 10
+#define BATTERY_MEDIUM_THRESHOLD 20
 
+// 从转换后的uint32_t数据中提取数据类型
 namespace OHOS {
 DialBoxProgressView::DialBoxProgressView(void)
-{
+    : value_(0), color_(Color::White().full) // 初始化 color_
+{}
+
+DialBoxProgressView::~DialBoxProgressView(void) {}
+
+/* --------------------------------- 编码解码函数
+ * --------------------------------- */
+
+// 定义用于位操作的掩码和位移值,可根据实际需求调整
+constexpr uint32_t TYPE_MASK = 0xFF000000;
+constexpr uint32_t TYPE_SHIFT = 24;
+constexpr uint32_t VALUE_MASK = 0x00FFFFFF;
+
+uint32_t
+DialBoxProgressView::DialBoxDataTypeToBitPattern(DialBoxDataType type) {
+  return static_cast<uint32_t>(type) << TYPE_SHIFT;
 }
+//增加box不同值颜色绘制
+uint32_t DialBoxProgressView::ConvertToRequiredFormat(DialBoxDataType type,
+                                                      float data) {
+
+  uint32_t typeBitPattern = DialBoxDataTypeToBitPattern(type);
+  uint32_t dataAsInt = static_cast<uint32_t>(data);
+
+  return (typeBitPattern | dataAsInt);
+}
+
+DialBoxDataType DialBoxProgressView::ExtractDataType(uint32_t rawData) {
 
-DialBoxProgressView::~DialBoxProgressView(void)
-{
+  uint32_t typeValue = (rawData & TYPE_MASK) >> TYPE_SHIFT;
+  return static_cast<DialBoxDataType>(typeValue);
 }
 
-void DialBoxProgressView::HandleFloatData(float data)
-{
-    float ratio = data;
-    if (ratio > 1.0f) {
-        ratio = 1.0f;
-    } else if (ratio < 0.0f) {
-        ratio = 0.0f;
-    }
-    int32_t value = ratio * (GetRangeMax() - GetRangeMin());
-    if (value_ == value) {
-        return;
-    }
+uint32_t DialBoxProgressView::ExtractValue(uint32_t rawData) {
+
+  return rawData & VALUE_MASK;
+}
+
+/* -------------------------------------------------------------------------- */
+void DialBoxProgressView::HandleFloatData(float data) {
+  // 获取数据类型
+  datatype_ = ExtractDataType(data); //类型为前4位
+  float value = ExtractValue(data);  //数值为后28位
+  WEARABLE_LOGD("DialBoxProgressView", "HandleFloatData: %d %f", datatype_,
+                value);
+
+  if (datatype_ == BATTERY_LEVEL) {
+    UpdateBatteryColor(); // 在值变化或充电状态变化时更新颜色
+  } else if (datatype_ == STEP_TARGET) {
+    SetViewColor(0xFFf0c440);
+  }
+  if (value != value_) {
     value_ = value;
     SetValue(value_);
+  }
+}
+
+void DialBoxProgressView::UpdateBatteryColor() {
+  // bool isCharging = get_charge_stat(); // 获取充电状态
+  bool isCharging  = false;
+
+  if (isCharging) {
+    SetViewColor(Color::Green().full); // 充电状态为绿色
+    return;
+  }
+
+  // 根据值设置电池颜色
+  if (value_ > BATTERY_MEDIUM_THRESHOLD) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateBatteryColor White: %d",
+                  value_);
+    SetViewColor(Color::White().full);
+  } else if (value_ <= BATTERY_MEDIUM_THRESHOLD &&
+             value_ > BATTERY_LOW_THRESHOLD) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateBatteryColor Yellow: %d",
+                  value_);
+    SetViewColor(Color::Yellow().full);
+  } else if (value_ <= BATTERY_LOW_THRESHOLD && value_ > 0) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateBatteryColor Red: %d",
+                  value_);
+    SetViewColor(Color::Red().full);
+  }
+}
+
+void DialBoxProgressView::SetViewColor(int64_t color) {
+  // 仅在颜色变化时设置
+  if (color != color_) {
+    color_ = color;
+    SetForegroundStyle(STYLE_BACKGROUND_COLOR, color_);
+  }
 }
-}
\ No newline at end of file
+} // namespace OHOS
\ No newline at end of file
index b2e41f5..5f1c60b 100644 (file)
 #include "DialLabelView.h"
 #include "securec.h"
 
-namespace OHOS {
-DialLabelView::DialLabelView(void)
+namespace OHOS
 {
-}
-
-DialLabelView::~DialLabelView(void)
-{
-    if (text_ != nullptr) {
-        UIFree(text_);
+    DialLabelView::DialLabelView(void)
+    {
     }
-}
 
-bool DialLabelView::SetText(const char* text)
-{
-    if (text == nullptr) {
-        return false;
+    DialLabelView::~DialLabelView(void)
+    {
+        if (text_ != nullptr)
+        {
+            UIFree(text_);
+        }
     }
-    UILabel::SetText(text);
-    return true;
-}
 
-void DialLabelView::SetTextWithWildcardInner(const char* text)
-{
-    if (strcmp(text, dstBuf_) == 0) {
-        return;
-    }
-    memset_s(dstBuf_, sizeof(dstBuf_), 0, sizeof(dstBuf_));
-    if (strcpy_s(dstBuf_, MAX_BUF_SIZE, text) != EOK) {
-        GRAPHIC_LOGE("strcpy_s failed!\n");
+    bool DialLabelView::SetText(const char *text)
+    {
+        if (text == nullptr)
+        {
+            return false;
+        }
+        UILabel::SetText(text);
+        return true;
     }
-    UILabel::SetText(dstBuf_);
-}
 
-bool DialLabelView::SetTextWithWildcard(const char* text)
-{
-    if (text == nullptr) {
-        return false;
-    }
-    if (text_ != nullptr) {
-        if (strcmp(text, text_) == 0) {
-            return true;
+    void DialLabelView::SetTextWithWildcardInner(const char *text)
+    {
+        if (strcmp(text, dstBuf_) == 0)
+        {
+            return;
         }
-        UIFree(text_);
-        text_ = nullptr;
+        memset_s(dstBuf_, sizeof(dstBuf_), 0, sizeof(dstBuf_));
+        if (strcpy_s(dstBuf_, MAX_BUF_SIZE, text) != EOK)
+        {
+            GRAPHIC_LOGE("strcpy_s failed!\n");
+        }
+        UILabel::SetText(dstBuf_);
     }
 
-    uint32_t textLen = static_cast<uint32_t>(strlen(text));
-    if (textLen > (MAX_BUF_SIZE - 1)) {
-        return false;
-    }
-    text_ = static_cast<char*>(UIMalloc(++textLen));
-    if (text_ == nullptr) {
-        return false;
-    }
-    if (strcpy_s(text_, textLen, text) != EOK) {
-        GRAPHIC_LOGE("strcpy_s failed");
-        UIFree(text_);
-        text_ = nullptr;
-        return false;
+    bool DialLabelView::SetTextWithWildcard(const char *text)
+    {
+        if (text == nullptr)
+        {
+            return false;
+        }
+        if (text_ != nullptr)
+        {
+            if (strcmp(text, text_) == 0)
+            {
+                return true;
+            }
+            UIFree(text_);
+            text_ = nullptr;
+        }
+
+        uint32_t textLen = static_cast<uint32_t>(strlen(text));
+        if (textLen > (MAX_BUF_SIZE - 1))
+        {
+            return false;
+        }
+        text_ = static_cast<char *>(UIMalloc(++textLen));
+        if (text_ == nullptr)
+        {
+            return false;
+        }
+           if (strcpy_s(text_, textLen, text) != EOK) {
+               GRAPHIC_LOGE("strcpy_s failed");
+               UIFree(text_);
+               text_ = nullptr;
+               return false;
+           }
+        return true;
     }
-    return true;
-}
 
-void DialLabelView::HandleTextData(const std::string* data, uint16_t num)
-{
-    char tempBuf[MAX_BUF_SIZE] = {0};
-    if (num == 1) {
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str()) < 0) {
-            GRAPHIC_LOGE("snprintf_s failed.\n");
+    void DialLabelView::HandleTextData(const std::string *data, uint16_t num)
+    {
+        if (num == 0 || data == nullptr)
+        {
+            GRAPHIC_LOGE("Invalid data or num.");
             return;
         }
-    } else if (num == 2) { // 2: wildcard cnt
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str(), data[1].c_str()) < 0) {
-            GRAPHIC_LOGE("snprintf_s failed.\n");
+
+        // printf("HandleTextData called with num: %d, data[0]: %s\n", num, data[0].c_str());
+
+        char tempBuf[MAX_BUF_SIZE] = {0};
+
+        int ret;
+        switch (num)
+        {
+        case 1:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str());
+            break;
+        case 2:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0].c_str(), data[1].c_str());
+            break;
+        case 3:
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_,
+                             data[0].c_str(), "年", data[1].c_str(), "月", data[2].c_str(), "日");
+            break;
+        case 4: /*8月7号  星期三*/
+            ret = snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_,
+                             data[0].c_str(), data[1].c_str(), data[2].c_str());
+            break;
+        default:
+            GRAPHIC_LOGE("Invalid num: %d. Max size is 3.\n", num);
             return;
         }
-    } else if (num == 3) { // 3: wildcard cnt
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_,
-            data[0].c_str(), data[1].c_str(), data[2].c_str()) < 0) { // 2: index
-            GRAPHIC_LOGE("snprintf_s failed.\n");
+
+        if (ret < 0)
+        {
+            GRAPHIC_LOGE("snprintf_s failed with error code: %d\n", ret);
             return;
         }
-    } else {
-        GRAPHIC_LOGE("max size is 3.\n");
-        return;
-    }
-    SetTextWithWildcardInner(tempBuf);
-}
 
-void DialLabelView::HandleFloatData(const float* data, uint16_t num)
-{
-    char tempBuf[MAX_BUF_SIZE] = {0};
-    if (num == 1) {
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0]) < 0) {
-            GRAPHIC_LOGE("snprintf_s failed.\n");
-            return;
+        // printf("Constructed tempBuf: %s\n", tempBuf);
+        SetTextWithWildcardInner(tempBuf);
+    }
+    void DialLabelView::HandleFloatData(const float *data, uint16_t num)
+    {
+        char tempBuf[MAX_BUF_SIZE] = {0};
+        if (num == 1)
+        {
+            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0]) < 0)
+            {
+                GRAPHIC_LOGE("snprintf_s failed.\n");
+                return;
+            }
         }
-    } else if (num == 2) { // 2: wildcard cnt
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0], data[1]) < 0) {
-            GRAPHIC_LOGE("snprintf_s failed.\n");
-            return;
+        else if (num == 2)
+        { // 2: wildcard cnt
+            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0], data[1]) < 0)
+            {
+                GRAPHIC_LOGE("snprintf_s failed.\n");
+                return;
+            }
         }
-    } else if (num == 3) { // 3: wildcard cnt
-        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0], data[1], data[2]) < 0) { // 2: index
-            GRAPHIC_LOGE("snprintf_s failed.\n");
+        else if (num == 3)
+        { // 3: wildcard cnt
+            if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data[0], data[1], data[2]) < 0)
+            { // 2: index
+                GRAPHIC_LOGE("snprintf_s failed.\n");
+                return;
+            }
+        }
+        else
+        {
+            GRAPHIC_LOGE("max size is 3.\n");
             return;
         }
-    } else {
-        GRAPHIC_LOGE("max size is 3.\n");
-        return;
+        SetTextWithWildcardInner(tempBuf);
     }
-    SetTextWithWildcardInner(tempBuf);
-}
 
-void DialLabelView::HandleFloatData(float data)
-{
-    char tempBuf[MAX_BUF_SIZE] = {0};
-    if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data) < 0) {
-        GRAPHIC_LOGE("snprintf_s failed.\n");
-        return;
+    void DialLabelView::HandleFloatData(float data)
+    {
+        char tempBuf[MAX_BUF_SIZE] = {0};
+        if (snprintf_s(tempBuf, MAX_BUF_SIZE, MAX_BUF_SIZE - 1, text_, data) < 0)
+        {
+            GRAPHIC_LOGE("snprintf_s failed.\n");
+            return;
+        }
+        SetTextWithWildcardInner(tempBuf);
     }
-    SetTextWithWildcardInner(tempBuf);
-}
 }
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCalorie.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCalorie.cpp
new file mode 100644 (file)
index 0000000..3d4e2f8
--- /dev/null
@@ -0,0 +1,51 @@
+/***
+ * @Date: 2024-07-31 18:33:13
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-02 18:54:18
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelCalorie.cpp
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-31 18:36:06
+ * @FilePath:
+ * /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelCalorie.cpp
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelCalorie
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelCalorie.h"
+#include "RegisterDialModel.h"
+#include "wearable_log.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_CALORIE,
+                   OHOS::DialModelCalorie::GetInstance());
+
+// #include "cywee_hal.h"
+// extern "C" int get_calories_data();
+
+namespace OHOS {
+bool DialModelCalorie::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+
+  calorie_ = static_cast<float>(GoalModel::GetInstance().show_data_calories_refresh());
+  out = calorie_;
+  // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialModelCalorie %d", calorie_);
+  return true;
+}
+
+void DialModelCalorie::UpdateCalorie(int16_t calorie) {
+  // 更新表盘卡路里数据
+  calorie_ = static_cast<float>(calorie);
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_CALORIE,
+                                             calorie_);
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCharge.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelCharge.cpp
new file mode 100644 (file)
index 0000000..a78dd61
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelCharge
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "RegisterDialModel.h"
+#include "DialModelCharge.h"
+#include "wearable_log.h"
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_CHARGE, OHOS::DialModelCharge::GetInstance());
+
+namespace OHOS
+{
+    bool DialModelCharge::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        out = chargeStatus_;
+        //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialModelCharge %d", chargeStatus_);
+        return true;
+    }
+
+    void DialModelCharge::UpdatechargeStatus(int16_t chargeStatus)
+    {
+        chargeStatus_ = static_cast<float>(chargeStatus);
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_CHARGE, chargeStatus_);
+        }
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateEnStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateEnStr.cpp
new file mode 100644 (file)
index 0000000..2320e63
--- /dev/null
@@ -0,0 +1,48 @@
+#include "DialModelDateEnStr.h"
+#include "RegisterDialModel.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <ctime>
+#include <sstream>
+#include <string>
+#include <time.h>
+#include <vector>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DATE_EN_STR,
+                   OHOS::DialModelDateEnStr::GetInstance());
+
+namespace OHOS {
+
+// 12个月英文缩写
+const std::string CnMonths[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
+                                "JUL", "AUG", "SEP", "OCT", "NON", "DEC"};
+
+// 获取表盘文本数据(日期相关)的函数
+bool DialModelDateEnStr::GetDialTextData(DialDataType &type, std::string *&out,
+                                         int16_t &strNum) {
+  (void)type;
+  struct tm local_time = {0};
+  time_t seconds = time(nullptr);
+
+  // 获取本地时间
+  if (localtime_r(&seconds, &local_time) == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+    return false;
+  }
+
+  // 使用ostringstream构建日期字符串,格式为"日,英文月缩写",例如 "22,APR"
+  std::ostringstream oss;
+  oss << local_time.tm_mday << "," << CnMonths[local_time.tm_mon];
+
+  // 将构建好的字符串赋值给传出参数out指向的内存
+  dialDateEnStr_ = oss.str();
+  out = &dialDateEnStr_;
+  strNum = 1;
+
+  return true;
+}
+
+// 更新日期字符串的函数
+void DialModelDateEnStr::UpDateEnDateEnStr(const std::string *&dialDateEnStr) {}
+
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateStr.cpp
new file mode 100644 (file)
index 0000000..5be656d
--- /dev/null
@@ -0,0 +1,62 @@
+#include "RegisterDialModel.h"
+#include "DialModelDateStr.h"
+#include <string>
+#include <ctime>
+#include <time.h>
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <vector>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DATE_STR, OHOS::DialModelDateStr::GetInstance());
+namespace OHOS
+{
+    //  CnDatedays 是一个包含星期字符串的数组
+    const std::string CnDatedays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+    /*继承的虚函数 不能修改*/
+    bool DialModelDateStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+
+        struct tm local_time = {0};
+        time_t seconds = time(nullptr);
+
+        if (localtime_r(&seconds, &local_time) == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+            return false;
+        }
+
+        datestr.clear();                                          // 清空之前的数据
+        datestr.push_back(std::to_string(local_time.tm_mon + 1)); // 月份
+        datestr.push_back(std::to_string(local_time.tm_mday));    // 日期
+        datestr.push_back(CnDatedays[local_time.tm_wday]);        // 星期
+
+        strNum = 4; // 更新字符串数量类型
+
+        // 打印调试信息
+        for (size_t i = 0; i < datestr.size(); ++i)
+        {
+            WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "dialdateStr[%zu]: %s", i, datestr[i].c_str());
+        }
+        WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Total strings: %d", strNum);
+
+        // 为输出分配内存
+        for (int16_t i = 0; i < datestr.size(); ++i)
+        {
+            out[i] = datestr[i]; // 将每个字符串复制到输出
+        }
+
+        return true;
+    }
+
+    void DialModelDateStr::UpdateDateStr(const std::string *&dialDateStr)
+    {
+        // dialdateStr_.clear();
+        // dialdateStr_ = *dialDateStr; // 更新字符串
+        // if (onChangeListener_ != nullptr)
+        // {
+        //     onChangeListener_->OnDialTextDataUpdate(DialDataType::DialModelMinUnits, &dialdateStr_, dialdateStr_.size());
+        // }
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekMDStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekMDStr.cpp
new file mode 100644 (file)
index 0000000..e9e42c3
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-11-03 16:47:34
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-11-03 17:29:15
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelDateWeekMDStr.cpp
+ */
+#include "main/include/dial/DialModelDateWeekMDStr.h"
+#include "main/include/dial/RegisterDialModel.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <chrono>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <time.h>
+
+namespace OHOS
+{
+    REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DATE_WEEK_MD_STR, OHOS::DialModelDateWeekMDStr::GetInstance());
+
+    // Cnweekdays 是一个包含周字符串的数组
+    constexpr const char *Cnweekdays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+    /*获取当前日期和星期信息 */
+
+    // 获取表盘文本数据(日期和星期信息)
+    bool DialModelDateWeekMDStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+        struct tm local_time = {0};
+        time_t seconds = time(nullptr);
+
+        // 获取本地时间
+        if (localtime_r(&seconds, &local_time) == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+            return false;
+        }
+
+        // 使用ostringstream构建日期字符串
+        std::ostringstream oss;
+        oss << std::setw(2)
+            << std::setfill('0') << (local_time.tm_mon + 1) << "月"
+            << std::setw(2)
+            << std::setfill('0') << local_time.tm_mday << "号";
+
+        // 获取星期
+        dateweekmdstr = oss.str() + " " + Cnweekdays[local_time.tm_wday];
+
+        out = &dateweekmdstr;
+        strNum = 1;
+
+        return true;
+    }
+
+    void DialModelDateWeekMDStr::UpdateDateWeekStr(const std::string *&dialDateWeekMDStr)
+    {
+        dateweekmdstr.clear();
+        dateweekmdstr = *dialDateWeekMDStr; // 更新字符串
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_DATE_WEEK_MD_STR, &dateweekmdstr, dateweekmdstr.size());
+        }
+    }
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDateWeekStr.cpp
new file mode 100644 (file)
index 0000000..d111d67
--- /dev/null
@@ -0,0 +1,59 @@
+#include "DialModelDateWeekStr.h"
+#include "RegisterDialModel.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <chrono>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <time.h>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DATE_WEEK_STR,
+                   OHOS::DialModelDateWeekStr::GetInstance());
+
+namespace OHOS {
+// Cnweekdays 是一个包含周字符串的数组
+constexpr const char *Cnweekdays[] = {"周天", "周一", "周二", "周三",
+                                      "周四", "周五", "周六"};
+
+/*获取当前日期和星期信息 */
+
+// 获取表盘文本数据(日期和星期信息)
+bool DialModelDateWeekStr::GetDialTextData(DialDataType &type,
+                                           std::string *&out, int16_t &strNum) {
+  (void)type;
+  struct tm local_time = {0};
+  time_t seconds = time(nullptr);
+
+  // 获取本地时间
+  if (localtime_r(&seconds, &local_time) == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+    return false;
+  }
+
+  // 使用ostringstream构建日期字符串
+  std::ostringstream oss;
+  oss << (local_time.tm_year + 1900) << "年" << std::setw(2)
+      << std::setfill('0') << (local_time.tm_mon + 1) << "月" << std::setw(2)
+      << std::setfill('0') << local_time.tm_mday << "日";
+
+  // 获取星期
+  dateweekstr = oss.str() + " " + Cnweekdays[local_time.tm_wday];
+
+  out = &dateweekstr;
+  strNum = 1;
+
+  return true;
+}
+
+void DialModelDateWeekStr::UpdateDateWeekStr(const std::string *&dialWeekStr) {
+  dateweekstr.clear();
+  dateweekstr = *dialWeekStr; // 更新字符串
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialTextDataUpdate(
+        DialDataType::DATA_TYPE_DATE_WEEK_STR, &dateweekstr,
+        dateweekstr.size());
+  }
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDistance.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelDistance.cpp
new file mode 100644 (file)
index 0000000..317672c
--- /dev/null
@@ -0,0 +1,30 @@
+
+#include "RegisterDialModel.h"
+#include "DialModelDistance.h"
+#include "wearable_log.h"
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DISTANCE, OHOS::DialModelDistance::GetInstance());
+#include "goal/include/goalmodel.h"
+// #include "cywee_hal.h"
+// extern "C" int get_distance_data();
+
+namespace OHOS
+{
+    bool DialModelDistance::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        distance_ = static_cast<float>( OHOS::GoalModel::GetInstance().show_data_distance_refresh());
+        out = distance_;
+        return true;
+    }
+
+    void DialModelDistance::UpdateDistance(float distance) {
+      // 将距离从米(m)转换为公里(km)并保留一位小数
+      distance_ = static_cast<float>(distance); //  distance 米
+
+      if (onChangeListener_ != nullptr) {
+        // 通知改变监听器更新距离数据
+        onChangeListener_->OnDialFloatDataUpdate(
+            DialDataType::DATA_TYPE_DISTANCE, distance_);
+      }
+    }
+}
index f4a337e..d4c9bc4 100644 (file)
@@ -1,3 +1,15 @@
+/*** 
+ * @Date: 2024-07-03 14:49:52
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-03 15:31:01
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp
+ */
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-01 09:48:06
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHeartRate.cpp
+ */
 /*
  * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
  * Description: DialModelHeartRate
 
 #include "RegisterDialModel.h"
 #include "DialModelHeartRate.h"
+#include "wearable_log.h"
 
 REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_HEART_RATE, OHOS::DialModelHeartRate::GetInstance());
 
-namespace OHOS {
-bool DialModelHeartRate::GetDialFloatData(DialDataType& type, float& out)
+namespace OHOS
 {
-    (void)type;
-    out = heartRate_;
-    return true;
-}
+    bool DialModelHeartRate::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        out = heartRate_;
+        return true;
+    }
 
-void DialModelHeartRate::UpdateHeartRate(int16_t heartRate)
-{
-    heartRate_ = static_cast<float>(heartRate);
-    if (onChangeListener_ != nullptr) {
-        onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_HEART_RATE, heartRate_);
+    void DialModelHeartRate::UpdateHeartRate(int16_t heartRate)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateHeartRate = %d", heartRate);
+        // 筛选表盘心率数据
+        if (heartRate == 0)
+            return;
+        heartRate_ = static_cast<float>(heartRate);
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_HEART_RATE, heartRate_);
+        }
+    }
+
+    int DialModelHeartRate::GetHeartData()
+    {
+        // Assuming SPO2_ is a float member variable
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "heartRate_ %f", heartRate_);
+        return static_cast<int>(heartRate_);
     }
-}
 }
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourMin.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourMin.cpp
new file mode 100644 (file)
index 0000000..4a56525
--- /dev/null
@@ -0,0 +1,49 @@
+/***
+ * @Date: 2024-08-08 16:15:49
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-08 16:28:43
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHourMin.cpp
+ */
+#include "RegisterDialModel.h"
+#include "DialModelHourMin.h"
+#include <string>
+#include <ctime>
+#include <time.h>
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <vector>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_HOUR_MIN, OHOS::DialModelHourMin::GetInstance());
+namespace OHOS
+{
+    /*继承的虚函数 不能修改*/
+    bool DialModelHourMin::GetDialFloatData(DialDataType &type, float *&out, int16_t len)
+    {
+        (void)type;
+
+        struct tm local_time = {0};
+        time_t seconds = time(nullptr);
+
+        if (localtime_r(&seconds, &local_time) == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+            return false;
+        }
+
+        out[0] = static_cast<float>(local_time.tm_hour);
+        out[1] = static_cast<float>(local_time.tm_min);
+        // printf("GetDialFloatData %f %f\r\n", out[0], out[1]);
+        len = 2;
+        return true;
+    }
+
+    void DialModelHourMin::UpdateHourMin(const std::string *&dialHourMin)
+    {
+        // dialdateStr_.clear();
+        // dialdateStr_ = *dialHourMin; // 更新字符串
+        // if (onChangeListener_ != nullptr)
+        // {
+        //     onChangeListener_->OnDialTextDataUpdate(DialDataType::DialModelMinUnits, &dialdateStr_, dialdateStr_.size());
+        // }
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourTens.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourTens.cpp
new file mode 100644 (file)
index 0000000..0a1a2b6
--- /dev/null
@@ -0,0 +1,40 @@
+/*** 
+ * @Date: 2024-08-08 15:01:28
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-08 15:13:46
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelHourTens.cpp
+ */
+
+#include <sys/time.h>
+#include "RegisterDialModel.h"
+#include "DialModelHourTens.h"
+#include "custom_runtime.h"
+
+// 注册模块
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_HOUR_TENS, OHOS::DialModelHourTens::GetInstance());
+
+namespace OHOS
+{
+
+    bool DialModelHourTens::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        struct timeval tv;
+        gettimeofday(&tv, NULL); // 获取当前时间
+        localtime_r(&tv.tv_sec, &tblock_);
+
+        //需要判断显示的格式
+        if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
+        {
+            if (tblock_.tm_hour > 12)
+                tblock_.tm_hour = tblock_.tm_hour - 12 ;
+        }
+
+        hour_tens = tblock_.tm_hour / 10; // 小时十位
+
+        out = static_cast<float>(hour_tens);
+
+        return true;
+    }
+
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourUnits.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelHourUnits.cpp
new file mode 100644 (file)
index 0000000..e63d63f
--- /dev/null
@@ -0,0 +1,33 @@
+
+#include <sys/time.h>
+#include "RegisterDialModel.h"
+#include "DialModelHourUnits.h"
+#include "custom_runtime.h"
+
+// 注册模块
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_HOUR_UNITS, OHOS::DialModelHourUnits::GetInstance());
+
+namespace OHOS
+{
+
+    bool DialModelHourUnits::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        struct timeval tv;
+        gettimeofday(&tv, NULL); // 获取当前时间
+        localtime_r(&tv.tv_sec, &tblock_);
+
+        //需要判断显示的格式
+        if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
+        {
+            if (tblock_.tm_hour > 12)
+                tblock_.tm_hour = tblock_.tm_hour - 12 ;
+        }
+  
+        hour_units = tblock_.tm_hour % 10; // 小时十位
+
+        out = static_cast<float>(hour_units);
+
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoal.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoal.cpp
new file mode 100644 (file)
index 0000000..c7f66d0
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcals
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelKcalgoal.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_CALORIE_GOAL,
+                   OHOS::DialModelKcalgoal::GetInstance());
+
+namespace OHOS {
+bool DialModelKcalgoal::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+  uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
+  uint32_t Kcal_ = GoalModel::GetInstance().show_data_calories_refresh();
+  
+  if (goal > 0) {
+    Kcalgoal_ = (static_cast<float>(Kcal_) / goal) * 100;
+    if (Kcalgoal_ > 100)
+      Kcalgoal_ = 100;
+    Kcalgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+        DialBoxDataType::CALORIE_TARGET, Kcalgoal_);
+  } else {
+    Kcalgoal_ = 0;
+  }
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_CALORIE_GOAL, Kcalgoal_);
+  }
+  out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+      DialBoxDataType::CALORIE_TARGET, Kcalgoal_);
+  return true;
+}
+
+void DialModelKcalgoal::UpdateKcalgoal(uint32_t Kcals) {
+  uint32_t Kcal_ = static_cast<float>(Kcals);
+  uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
+  if (goal > 0) {
+    Kcalgoal_ = (static_cast<float>(Kcal_) / goal) * 100;
+    if (Kcalgoal_ > 100)
+      Kcalgoal_ = 100;
+    Kcalgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+        DialBoxDataType::CALORIE_TARGET, Kcalgoal_);
+  }
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_CALORIE_GOAL, Kcalgoal_);
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalStr.cpp
new file mode 100644 (file)
index 0000000..a5889b3
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcals
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelKcalgoalStr.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_CALORIE_GOAL_STR,
+                   OHOS::DialModelKcalgoalStr::GetInstance());
+
+namespace OHOS {
+bool DialModelKcalgoalStr::GetDialTextData(DialDataType &type,
+                                           std::string *&out, int16_t &strNum) {
+  (void)type;
+  uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
+  uint32_t Kcal_ = GoalModel::GetInstance().show_data_calories_refresh();
+  
+  uint32_t Kcalgoal = 0; //百分比
+  if (goal > 0) {
+    Kcalgoal = (static_cast<float>(Kcal_) / goal) * 100;
+    if (Kcalgoal > 100)
+      Kcalgoal = 100;
+  }
+  KcalgoalStr_.clear();
+  KcalgoalStr_ = std::to_string(Kcalgoal) + "%"; //百分比字符串
+
+  out = &KcalgoalStr_;
+  strNum = 1;
+  return true;
+}
+
+void DialModelKcalgoalStr::UpdateKcalgoalStr(uint32_t Kcals) {
+  uint32_t Kcal_ = static_cast<float>(Kcals);
+  uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
+  uint32_t Kcalgoal = 0; //百分比
+  if (goal > 0) {
+    Kcalgoal = (static_cast<float>(Kcal_) / goal) * 100;
+    if (Kcalgoal > 100)
+      Kcalgoal = 100;
+  }
+  KcalgoalStr_.clear();
+  KcalgoalStr_ = std::to_string(Kcalgoal) + "%"; //百分比字符串
+
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialTextDataUpdate(
+        DialDataType::DATA_TYPE_CALORIE_GOAL_STR, &KcalgoalStr_,
+        KcalgoalStr_.size());
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalValue.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelKcalgoalValue.cpp
new file mode 100644 (file)
index 0000000..359d8a2
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelKcals
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelKcalgoalValue.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_CALORIE_GOAL_INT,
+                   OHOS::DialModelKcalgoalValue::GetInstance());
+
+namespace OHOS {
+bool DialModelKcalgoalValue::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+  uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
+  uint32_t Kcal_ = GoalModel::GetInstance().show_data_calories_refresh();
+  if (goal > 0) {
+    KcalgoalValue_ = (static_cast<float>(Kcal_) / static_cast<float>(goal));
+    if (KcalgoalValue_ > 1.0f) {
+      KcalgoalValue_ = 1.0f;
+    }
+  } else {
+    KcalgoalValue_ = 0;
+  }
+  // printf(" KcalgoalValue_:%f\n", KcalgoalValue_);
+  out = static_cast<float>(KcalgoalValue_);
+  return true;
+}
+
+void DialModelKcalgoalValue::UpdateKcalgoalValue(uint32_t caloriesInput) {
+  uint32_t goalValue = GoalModel::GetInstance().getKcalgoaldata();
+  if (goalValue > 0) {
+    KcalgoalValue_ =
+        (static_cast<float>(caloriesInput) / static_cast<float>(goalValue));
+    if (KcalgoalValue_ > 1.0f) {
+      KcalgoalValue_ = 1.0f;
+    }
+  } else {
+    KcalgoalValue_ = 0;
+  }
+
+  // printf(" KcalgoalValue_:%f\n", KcalgoalValue_);
+
+  if (onChangeListener_) {
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_CALORIE_GOAL_INT, KcalgoalValue_);
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinTens.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinTens.cpp
new file mode 100644 (file)
index 0000000..afff9b2
--- /dev/null
@@ -0,0 +1,37 @@
+/*** 
+ * @Date: 2024-08-08 15:02:25
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-08 15:12:41
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelMinTens.cpp
+ */
+/***
+ * @Date: 2024-08-08 15:01:28
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-08 15:10:38
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelMinTens.cpp
+ */
+
+#include <sys/time.h>
+#include "RegisterDialModel.h"
+#include "DialModelMinTens.h"
+#include "custom_runtime.h"
+
+// 注册模块
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_MINUTE_TENS, OHOS::DialModelMinTens::GetInstance());
+
+namespace OHOS
+{
+
+    bool DialModelMinTens::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        struct timeval tv;
+        gettimeofday(&tv, NULL); // 获取当前时间
+        localtime_r(&tv.tv_sec, &tblock_);
+        min_tens = tblock_.tm_min / 10; // 分钟十位
+
+        out = static_cast<float>(min_tens);
+
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinUnits.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelMinUnits.cpp
new file mode 100644 (file)
index 0000000..f5b289f
--- /dev/null
@@ -0,0 +1,37 @@
+/*** 
+ * @Date: 2024-08-08 15:02:35
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 17:12:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelMinUnits.cpp
+ */
+/***
+ * @Date: 2024-08-08 15:02:35
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-08 15:12:59
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelMinUnits.cpp
+ */
+
+#include <sys/time.h>
+#include "RegisterDialModel.h"
+#include "DialModelMinUnits.h"
+#include "custom_runtime.h"
+
+// 注册模块
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_MINUTE_UNITS, OHOS::DialModelMinUnits::GetInstance());
+
+namespace OHOS
+{
+
+    bool DialModelMinUnits::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        struct timeval tv;
+        gettimeofday(&tv, NULL); // 获取当前时间
+        localtime_r(&tv.tv_sec, &tblock_);
+        min_units = tblock_.tm_min % 10; // 小时十位
+
+        out = static_cast<float>(min_units);
+
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPath.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPath.cpp
new file mode 100644 (file)
index 0000000..f8d70c0
--- /dev/null
@@ -0,0 +1,24 @@
+#include "RegisterDialModel.h"
+#include "DialModelPath.h"
+#include <string>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_DIALPATH, OHOS::DialModelPath::GetInstance());
+
+namespace OHOS
+{
+    bool DialModelPath::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+        out = &DialPath_;
+        return true;
+    }
+
+    void DialModelPath::UpdatePath(const std::string *&DialPath)
+    {
+        DialPath_ = *DialPath;
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_HEART_RATE, &DialPath_, 0);
+        }
+    }
+}
index e0e1877..ae7c2e5 100644 (file)
@@ -1,3 +1,17 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-04-27 10:00:50
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp
+ */
+/***
+ * @Author: Caisking 3449750381@qq.com
+ * @Date: 2024-02-21 10:06:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-03-30 09:25:17
+ * @FilePath: /sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPower.cpp
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE101
+ */
 /*
  * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
  * Description: DialModelPower
 
 #include "RegisterDialModel.h"
 #include "DialModelPower.h"
+#include "DialBoxProgressView.h"
+#include <string>
+#include "wearable_log.h"
+
+// #include "battery_hal.h"
+// extern uint8_t battery_get_voltage(float *voltage);
 
 REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_POWER, OHOS::DialModelPower::GetInstance());
 
-namespace OHOS {
-bool DialModelPower::GetDialFloatData(DialDataType& type, float& out)
+namespace OHOS
 {
-    (void)type;
-    out = power_;
-    return true;
-}
+    bool DialModelPower::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+
+        float voltage = 0.0F;
+        // power_ = battery_get_voltage(&voltage);
+        // out = static_cast<float>(power_);
+        out = 0;
+        return true;
+    }
+
+    void DialModelPower::UpdatePower()
+    {
+        // float voltage = 0.0F;
+        // power_ = battery_get_voltage(&voltage);
+        // if (power_ == 0)
+        // {
+        //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get battery voltage");
+        //     return;
+        // }
+        // powerUpdated_ = true;
+        // NotifyPowerUpdate();
+    }
+
+    void DialModelPower::NotifyPowerUpdate() {
+      if (onChangeListener_ == nullptr) {
+            onChangeListener_ = new OnDialDataUpdateListener(); 
+        }
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_POWER, power_);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UpdatePower!]\r\n");
+        }
+    }
 }
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerMapper.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerMapper.cpp
new file mode 100644 (file)
index 0000000..779f9ef
--- /dev/null
@@ -0,0 +1,50 @@
+
+
+#include "DialBoxProgressView.h"
+#include "DialModelPowerMapper.h"
+#include "RegisterDialModel.h"
+#include "wearable_log.h"
+#include <string>
+
+// #include "battery_hal.h"
+// extern uint8_t battery_get_voltage(float *voltage);
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_POWER_MAPPER,
+                   OHOS::DialModelPowerMapper::GetInstance());
+
+namespace OHOS {
+bool DialModelPowerMapper::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+  float voltage = 0.0F;
+  // powermapper_ = battery_get_voltage(&voltage);
+  powermapper_ = 0;
+  //电量0~100
+  //映射0~1
+  powermapper_ = static_cast<float>(powermapper_) / 100.0f;
+  out = static_cast<float>(powermapper_);
+  return true;
+}
+
+void DialModelPowerMapper::UpdatePowerMapper() {
+  float voltage = 0.0F;
+  // powermapper_ = battery_get_voltage(&voltage);
+  powermapper_ = 0;
+  if (powermapper_ == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get battery voltage");
+    return;
+  }
+  PowerMapperUpdated_ = true;
+  NotifyPowerMapperUpdate();
+}
+
+void DialModelPowerMapper::NotifyPowerMapperUpdate() {
+  if (onChangeListener_ == nullptr) {
+    onChangeListener_ = new OnDialDataUpdateListener();
+  }
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_POWER_MAPPER, powermapper_);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[UpdatePowerMapper!]\r\n");
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStandby.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStandby.cpp
new file mode 100644 (file)
index 0000000..a3a08ba
--- /dev/null
@@ -0,0 +1,78 @@
+
+
+#include "DialModelPowerStandby.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "wearable_log.h"
+#include <string>
+
+
+// #include "battery_hal.h"
+// extern uint8_t battery_get_voltage(float *voltage);
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_POWER_STANDBY,
+                   OHOS::DialModelPowerStanby::GetInstance());
+
+namespace OHOS {
+
+bool DialModelPowerStanby::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+
+  float voltage = 0.0F;
+  // PowerStanby_ = battery_get_voltage(&voltage);
+  PowerStanby_  = 0;
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Battery voltage obtained: %.2f",
+                voltage);
+
+  // 计算映射值
+  //   float minPower = 0;
+  //   float maxPower = 100;
+
+  //   float mappedValue = 0.0F;
+  //   if (maxPower - minPower != 0) {
+  //     mappedValue = (PowerStanby_ - minPower) / (maxPower - minPower);
+  //   } else {
+  //     mappedValue = (PowerStanby_ == maxPower) ? 1.0f : 0.0f; // 边界处理
+  //   }
+  //   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+  //                 "Raw power value: %d, Mapped value: %.2f", PowerStanby_,
+  //                 mappedValue);
+  // 如果需要在 0 到 1 范围映射
+
+  // 需要前4个为类型
+  // 后28位为数据
+
+  out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+      DialBoxDataType::BATTERY_LEVEL, PowerStanby_);
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Mapped value sent to caller: %.2f",
+                out);
+
+  return true;
+}
+
+void DialModelPowerStanby::UpdatePowerStanby() {
+  float voltage = 0.0F;
+  // PowerStanby_ = battery_get_voltage(&voltage);
+  PowerStanby_ = 0;
+
+  if (PowerStanby_ == 0) {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Failed to get battery voltage");
+    return;
+  }
+  PowerStanbyUpdated_ = true;
+  NotifyPowerStanbyUpdate();
+}
+
+void DialModelPowerStanby::NotifyPowerStanbyUpdate() {
+  if (onChangeListener_ == nullptr) {
+    onChangeListener_ = new OnDialDataUpdateListener();
+  }
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_POWER_STANDBY, PowerStanby_);
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[UpdatePowerStanby!]\r\n");
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelPowerStr.cpp
new file mode 100644 (file)
index 0000000..402ea86
--- /dev/null
@@ -0,0 +1,32 @@
+#include "main/include/dial/DialModelPowerStr.h"
+#include "main/include/dial/RegisterDialModel.h"
+#include "wearable_log.h"
+// #include "battery_hal.h"
+// extern uint8_t battery_get_voltage(float *voltage);
+
+namespace OHOS
+{
+    REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_POWER_STR,OHOS::DialModelPowerStr::GetInstance());
+
+    bool DialModelPowerStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+        float voltage = 0.0F;
+        // uint8_t power_ = battery_get_voltage(&voltage);
+        uint8_t power_ =  0;
+        dialPowerStr_ = std::to_string(power_) + "%";
+        out = &dialPowerStr_;
+        strNum = 1;
+        return true;
+    }
+
+    void DialModelPowerStr::UpdateTimeStr(const std::string dialPowerStr)
+    {
+        dialPowerStr_.clear();
+        dialPowerStr_ = dialPowerStr; // 更新字符串
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_POWER_STR, &dialPowerStr_, 1);
+        }
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSPO2.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSPO2.cpp
new file mode 100644 (file)
index 0000000..fbda6a4
--- /dev/null
@@ -0,0 +1,47 @@
+/*** 
+ * @Date: 2024-04-27 18:32:46
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-06 15:37:21
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelSPO2.cpp
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelSPO2
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "RegisterDialModel.h"
+#include "DialModelSPO2.h"
+#include "wearable_log.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_SPO2, OHOS::DialModelSPO2::GetInstance());
+
+namespace OHOS
+{
+    bool DialModelSPO2::GetDialFloatData(DialDataType &type, float &out)
+    {
+        (void)type;
+        out = SPO2_;
+        return true;
+    }
+
+    void DialModelSPO2::UpdateSPO2(uint8_t SPO2)
+    {
+        if (SPO2 == 0)
+            return;
+        SPO2_ = static_cast<float>(SPO2);
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_SPO2, SPO2_);
+        }
+    }
+
+    int DialModelSPO2::GetSPO2Data()
+    {
+        // Assuming SPO2_ is a float member variable
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %f", SPO2_);
+        return static_cast<int>(SPO2_);
+    }
+
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSecondMapper.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelSecondMapper.cpp
new file mode 100644 (file)
index 0000000..24ea853
--- /dev/null
@@ -0,0 +1,50 @@
+#include "DialModelSecondMapper.h"
+#include "RegisterDialModel.h"
+#include "custom_runtime.h"
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+#include <sys/time.h>
+
+// 注册模块
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_SECOND_MAPPER,
+                   OHOS::DialModelSecondMapper::GetInstance());
+
+namespace OHOS {
+
+bool DialModelSecondMapper::GetDialFloatData(DialDataType &type, float &out) {
+
+  // (void)type;
+
+  struct timeval tv;
+  gettimeofday(&tv, NULL);
+  // 获取当前时间并转换为当地时间
+  localtime_r(&tv.tv_sec, &tblock_);
+
+  // 获取当前的分钟
+  // int min = tblock_.tm_min;
+  int sencond = tblock_.tm_sec;
+
+  // 根据分钟奇偶性计算映射值
+  float mappedValue = static_cast<float>(sencond) / 59.0f;
+
+  // 使用stringstream保留两位小数
+  std::stringstream ss;
+  ss << std::fixed << std::setprecision(3) << mappedValue;
+  ss >> out;
+
+  return true;
+}
+
+// 提取计算映射值的逻辑到单独函数,根据奇偶性传入不同参数进行计算
+float DialModelSecondMapper::CalculateMappedValue(int min, int sencond) {
+  if (min % 2 == 0) {
+    // 偶数分钟:1 -> 0
+    return 1.0f - (static_cast<float>(sencond) / 59.0f);
+  } else {
+    // 奇数分钟:0 -> 1
+    return static_cast<float>(sencond) / 59.0f;
+  }
+}
+
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoal.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoal.cpp
new file mode 100644 (file)
index 0000000..12e0ed9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelSteps
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelStepgoal.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS_GOAL,
+                   OHOS::DialModelStepgoal::GetInstance());
+
+namespace OHOS {
+bool DialModelStepgoal::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+
+  uint32_t step_ = GoalModel::GetInstance().show_data_step_refresh();
+  uint32_t goal = GoalModel::GetInstance().getstepgoaldata();
+  if (goal > 0) {
+    stepgoal_ = (static_cast<float>(step_) / goal) * 100;
+    if (stepgoal_ > 100)
+      stepgoal_ = 100;
+    stepgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+        DialBoxDataType::STEP_TARGET, stepgoal_);
+  } else {
+    stepgoal_ = 0;
+  }
+  out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+      DialBoxDataType::STEP_TARGET, stepgoal_);
+  return true;
+}
+
+void DialModelStepgoal::UpdateStepgoal(uint32_t steps) {
+  uint32_t step_ = static_cast<float>(steps);
+  uint32_t goal = GoalModel::GetInstance().getstepgoaldata();
+  if (goal > 0) {
+    stepgoal_ = (static_cast<float>(step_) / goal) * 100;
+    if (stepgoal_ > 100)
+      stepgoal_ = 100;
+    stepgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+        DialBoxDataType::STEP_TARGET, stepgoal_);
+  }
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS_GOAL,
+                                             stepgoal_);
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalStr.cpp
new file mode 100644 (file)
index 0000000..8425232
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelSteps
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelStepgoalStr.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS_GOAL_STR,
+                   OHOS::DialModelStepgoalStr::GetInstance());
+
+namespace OHOS {
+bool DialModelStepgoalStr::GetDialTextData(DialDataType &type,
+                                           std::string *&out, int16_t &strNum) {
+  (void)type;
+  uint32_t step_ = GoalModel::GetInstance().show_data_step_refresh();
+  uint32_t goal = GoalModel::GetInstance().getstepgoaldata();
+  uint32_t stepgoal = 0; //百分比
+  if (goal > 0) {
+    stepgoal = (static_cast<float>(step_) / goal) * 100;
+    if (stepgoal > 100)
+      stepgoal = 100;
+  }
+  StepgoalStr_.clear();
+  StepgoalStr_ = std::to_string(stepgoal) + "%"; //百分比字符串
+  out = &StepgoalStr_;
+  strNum = 1;
+  return true;
+}
+
+void DialModelStepgoalStr::UpdateStepgoalStr(uint32_t steps) {
+  uint32_t step_ = static_cast<float>(steps);
+  uint32_t goal = GoalModel::GetInstance().getstepgoaldata();
+  uint32_t stepgoal = 0; //百分比
+  if (goal > 0) {
+    stepgoal = (static_cast<float>(step_) / goal) * 100;
+    if (stepgoal > 100)
+      stepgoal = 100;
+  }
+  StepgoalStr_.clear();
+  StepgoalStr_ = std::to_string(stepgoal) + "%"; //百分比字符串
+
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialTextDataUpdate(
+        DialDataType::DATA_TYPE_STEPS_GOAL_STR, &StepgoalStr_,
+        StepgoalStr_.size());
+  }
+}
+} // namespace OHOS
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalValue.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelStepgoalValue.cpp
new file mode 100644 (file)
index 0000000..0a3fbe3
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2023. All rights reserved.
+ * Description: DialModelSteps
+ * Author:
+ * Create: 2023-12
+ */
+
+#include "DialModelStepgoalValue.h"
+#include "DialBoxProgressView.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS_GOAL_INT,
+                   OHOS::DialModelStepgoalValue::GetInstance());
+
+namespace OHOS {
+bool DialModelStepgoalValue::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+  //更新步数
+  uint32_t goalValue = GoalModel::GetInstance().getstepgoaldata();
+  uint32_t steps = GoalModel::GetInstance().show_data_step_refresh();
+  if (goalValue > 0) {
+    stepgoalValue_ =
+        (static_cast<float>(steps) / static_cast<float>(goalValue));
+    if (stepgoalValue_ > 1.0f)
+      stepgoalValue_ = 1.0;
+  } else {
+    stepgoalValue_ = 0;
+  }
+
+  // printf("stepgoalValue_ %f\n", stepgoalValue_);
+  out = static_cast<float>(stepgoalValue_);
+  return true;
+}
+
+void DialModelStepgoalValue::UpdateStepgoalValue(uint32_t steps) {
+  uint32_t goalValue = GoalModel::GetInstance().getstepgoaldata();
+  if (goalValue > 0) {
+    stepgoalValue_ =
+        (static_cast<float>(steps) / static_cast<float>(goalValue));
+    if (stepgoalValue_ > 1.0f)
+      stepgoalValue_ = 1.0;
+  } else {
+    stepgoalValue_ = 0;
+  }
+  // printf("steps %d goalValue %d stepgoalValue_ %f\n", steps, goalValue, stepgoalValue_);
+  if (onChangeListener_ != nullptr) {
+    //更新百分比 实际值
+    onChangeListener_->OnDialFloatDataUpdate(
+        DialDataType::DATA_TYPE_STEPS_GOAL_INT, stepgoalValue_);
+  }
+}
+} // namespace OHOS
index 0a9e7ff..c54ebec 100644 (file)
@@ -5,24 +5,27 @@
  * Create: 2023-12
  */
 
-#include "RegisterDialModel.h"
 #include "DialModelSteps.h"
+#include "RegisterDialModel.h"
+#include "goal/include/goalmodel.h"
 
-REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS, OHOS::DialModelSteps::GetInstance());
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS,
+                   OHOS::DialModelSteps::GetInstance());
 
 namespace OHOS {
-bool DialModelSteps::GetDialFloatData(DialDataType& type, float& out)
-{
-    (void)type;
-    out = steps_;
-    return true;
+bool DialModelSteps::GetDialFloatData(DialDataType &type, float &out) {
+  (void)type;
+  //更新步数
+  steps_ = GoalModel::GetInstance().show_data_step_refresh();
+  out = steps_;
+  return true;
 }
 
-void DialModelSteps::UpdateSteps(int16_t steps)
-{
-    steps_ = static_cast<float>(steps);
-    if (onChangeListener_ != nullptr) {
-        onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS, steps_);
-    }
-}
+void DialModelSteps::UpdateSteps(uint32_t steps) {
+  steps_ = static_cast<float>(steps);
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS,
+                                             steps_);
+  }
 }
+} // namespace OHOS
index 2af8cd2..6dd110f 100644 (file)
@@ -8,7 +8,7 @@
 #include "sys/time.h"
 #include "RegisterDialModel.h"
 #include "DialModelTime.h"
-
+#include "custom_runtime.h"
 #define REGIST_DIAL_MODULE_ANGLE_H(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_H)(type, func)
 #define REGIST_DIAL_MODULE_ANGLE_M(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_M)(type, func)
 #define REGIST_DIAL_MODULE_ANGLE_S(type, func) static OHOS::RegisterDialModel(REGIST_ANGLE_S)(type, func)
@@ -37,7 +37,7 @@ REGIST_DIAL_MODULE_YEAR(DialDataType::DATA_TYPE_TIME_YEAR, OHOS::DialModelTime::
 
 namespace OHOS {
 static constexpr int16_t S_MS_US_TRANS = 1000;      // 1000: seconds, milliseconds, microsecond transform value
-static constexpr uint16_t CIRCLE_IN_DEGREE = 360;   // 360: A full rotation: 360 degrees
+static constexpr uint16_t CIRCLE_IN_DEGREE_UI = 360;   // 360: A full rotation: 360 degrees
 static constexpr uint8_t ONE_MINUTE_IN_SECOND = 60; // 60: 60 seconds per minute
 static constexpr uint8_t ONE_HOUR_IN_MINUTE = 60;   // 60: 60 minutes per hour
 static constexpr uint8_t HALF_DAY_IN_HOUR = 12;     // 60: 12 hours every half day
@@ -53,9 +53,9 @@ static uint16_t ConvertHandValueToAngle(int32_t handValue, uint8_t range, int32_
      * angle is [(5 * 60  + 30) / (12 * 60)] * 360
      */
     int32_t degree = (handValue * ratio + secondHandValue);
-    degree = CIRCLE_IN_DEGREE * degree / (static_cast<uint16_t>(range) * ratio);
+    degree = CIRCLE_IN_DEGREE_UI * degree / (static_cast<uint16_t>(range) * ratio);
 
-    return static_cast<uint16_t>(degree % CIRCLE_IN_DEGREE);
+    return static_cast<uint16_t>(degree % CIRCLE_IN_DEGREE_UI);
 }
 
 static float ConvertHandSecondValueToAngle(int32_t handValue, uint16_t range)
@@ -65,28 +65,49 @@ static float ConvertHandSecondValueToAngle(int32_t handValue, uint16_t range)
      * Assume that the time is 5:30:30, then range is 60
      * angle is (30 / 60) * 360
      */
-    return (static_cast<float>(handValue * CIRCLE_IN_DEGREE) / range);
+    return (static_cast<float>(handValue * CIRCLE_IN_DEGREE_UI) / range);
 }
 
 void DialModelTime::UpdateTime()
 {
+#if 0
     struct timeval tv;
-    gettimeofday(&tv, nullptr);
+    gettimeofday(&tv, NULL);
     tblock_ = localtime(&tv.tv_sec);
-    int realMS = tblock_->tm_sec * S_MS_US_TRANS + tv.tv_usec / S_MS_US_TRANS;
+    int realMS = tblock_.tm_sec * S_MS_US_TRANS + tv.tv_usec / S_MS_US_TRANS;
+#else
+    /*优化为更安全的localtime_r()*/
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    struct tm tmp={0};
+    localtime_r(&tv.tv_sec, &tmp);
+    int realMS = tmp.tm_sec * S_MS_US_TRANS + tv.tv_usec / S_MS_US_TRANS;
+    tblock_.tm_year = tmp.tm_year;
+    tblock_.tm_mon = tmp.tm_mon;
+    tblock_.tm_mday = tmp.tm_mday;
+    tblock_.tm_wday = tmp.tm_wday;
+    tblock_.tm_hour = tmp.tm_hour;
+    tblock_.tm_min = tmp.tm_min;
+    tblock_.tm_sec = tmp.tm_sec;
 
-    angleH_ = ConvertHandValueToAngle(tblock_->tm_hour, HALF_DAY_IN_HOUR, tblock_->tm_min, ONE_HOUR_IN_MINUTE);
-    angleM_ = ConvertHandValueToAngle(tblock_->tm_min, ONE_HOUR_IN_MINUTE, tblock_->tm_sec, ONE_MINUTE_IN_SECOND);
-    angleS_ = ConvertHandValueToAngle(tblock_->tm_sec, ONE_MINUTE_IN_SECOND, 0, 1);
+    if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
+    {
+        if (tmp.tm_hour > 12)
+            tblock_.tm_hour = tmp.tm_hour - 12 ;
+    }
+#endif
+
+    angleH_ = ConvertHandValueToAngle(tblock_.tm_hour, HALF_DAY_IN_HOUR, tblock_.tm_min, ONE_HOUR_IN_MINUTE);
+    angleM_ = ConvertHandValueToAngle(tblock_.tm_min, ONE_HOUR_IN_MINUTE, tblock_.tm_sec, ONE_MINUTE_IN_SECOND);
+    angleS_ = ConvertHandValueToAngle(tblock_.tm_sec, ONE_MINUTE_IN_SECOND, 0, 1);
     angleMS_ = ConvertHandSecondValueToAngle(realMS, S_MS_US_TRANS * ONE_MINUTE_IN_SECOND);
 }
 
 bool DialModelTime::GetDialFloatData(DialDataType& type, float& out)
 {
-    if (tblock_ == nullptr) {
-        UpdateTime();
-    }
 
+    UpdateTime();
+    
     switch (type) {
         case DialDataType::DATA_TYPE_CLOCK_ANGLE_H:
             out = static_cast<float>(angleH_);
@@ -101,25 +122,25 @@ bool DialModelTime::GetDialFloatData(DialDataType& type, float& out)
             out = static_cast<float>(angleMS_);
             break;
         case DialDataType::DATA_TYPE_TIME_YEAR:
-            out = static_cast<float>(tblock_->tm_year);
+            out = static_cast<float>((tblock_.tm_year) + 1900);
             break;
         case DialDataType::DATA_TYPE_TIME_MONTH:
-            out = static_cast<float>(tblock_->tm_mon);
+            out = static_cast<float>((tblock_.tm_mon) + 1);
             break;
         case DialDataType::DATA_TYPE_TIME_WEEK:
-            out = static_cast<float>(tblock_->tm_wday);
+            out = static_cast<float>(tblock_.tm_wday);
             break;
         case DialDataType::DATA_TYPE_TIME_DATE:
-            out = static_cast<float>(tblock_->tm_mday);
+            out = static_cast<float>(tblock_.tm_mday);
             break;
         case DialDataType::DATA_TYPE_TIME_HOUR:
-            out = static_cast<float>(tblock_->tm_hour);
+            out = static_cast<float>(tblock_.tm_hour);
             break;
         case DialDataType::DATA_TYPE_TIME_MINUTE:
-            out = static_cast<float>(tblock_->tm_min);
+            out = static_cast<float>(tblock_.tm_min);
             break;
         case DialDataType::DATA_TYPE_TIME_SECOND:
-            out = static_cast<float>(tblock_->tm_sec);
+            out = static_cast<float>(tblock_.tm_sec);
             break;
         default:
             return false;
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTimeStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelTimeStr.cpp
new file mode 100644 (file)
index 0000000..848f721
--- /dev/null
@@ -0,0 +1,58 @@
+#include "DialModelTimeStr.h"
+#include "RegisterDialModel.h"
+#include "custom_runtime.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <time.h>
+#include <vector>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_TIMESTR_STR,
+                   OHOS::DialModelTimeStr::GetInstance());
+
+namespace OHOS {
+
+bool DialModelTimeStr::GetDialTextData(DialDataType &type, std::string *&out,
+                                       int16_t &strNum) {
+  (void)type;
+  /*获取时间*/
+  struct timeval tv;
+  gettimeofday(&tv, NULL); // 获取当前时间
+  localtime_r(&tv.tv_sec, &tblock_);
+
+  // Use ostringstream to format the time with leading zeros
+  std::ostringstream oss;
+
+  //需要判断显示的格式
+  if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
+  {
+      if (tblock_.tm_hour > 12)
+          tblock_.tm_hour = tblock_.tm_hour - 12 ;
+  }
+
+  oss << std::setw(2) << std::setfill('0') << tblock_.tm_hour << ":"
+    << std::setw(2) << std::setfill('0') << tblock_.tm_min;
+
+  std::string timeStr = oss.str(); // Get the formatted time string
+
+  if (!timeStr.empty()) {
+    dialTimeStr_ = timeStr;
+    out = &dialTimeStr_;
+  }
+
+  strNum = 1;
+  return true;
+}
+
+void DialModelTimeStr::UpdateTimeStr(const std::string dialTimeStr) {
+  dialTimeStr_.clear();
+  dialTimeStr_ = dialTimeStr; // 更新字符串
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_TIMESTR_STR,
+                                            &dialTimeStr_, 1);
+  }
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeather.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeather.cpp
new file mode 100644 (file)
index 0000000..d549ea3
--- /dev/null
@@ -0,0 +1,37 @@
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-27 16:00:39
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeather.cpp
+ */
+/*
+ * 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;
+    }
+    /*表盘更新天气Icon*/
+    void DialModelWeather::UpdateWeather(int16_t Weather)
+    {
+        Weather_ = static_cast<float>(Weather - 1);
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_WEATHER, Weather_);
+        }
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeatherStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeatherStr.cpp
new file mode 100644 (file)
index 0000000..d2c82dd
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-08-23 10:50:37
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-08-28 16:57:26
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelWeatherStr.cpp
+ * @Description: 
+ * 
+ * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
+ */
+#include "RegisterDialModel.h"
+#include "DialModelWeatherStr.h"
+#include <string>
+#include <ctime>
+#include <time.h>
+#include "sys/time.h"
+#include "wearable_log.h"
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEATHER_STR, OHOS::DialModelWeatherStr::GetInstance());
+namespace OHOS
+{
+
+    bool DialModelWeatherStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+
+        out = &dialWeatherStr_;
+        strNum = 1;
+        return true;
+    }
+
+    void DialModelWeatherStr::UpdateWeatherStr(const std::string dialWeatherStr)
+    {
+        dialWeatherStr_.clear();
+        dialWeatherStr_ = dialWeatherStr; // 更新字符串
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_WEATHER_STR, &dialWeatherStr_, 1);
+        }
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekEnStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekEnStr.cpp
new file mode 100644 (file)
index 0000000..6f04fb4
--- /dev/null
@@ -0,0 +1,49 @@
+#include "DialModelWeekEnStr.h"
+#include "RegisterDialModel.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <ctime>
+#include <sstream>
+#include <string>
+#include <time.h>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEEK_EN_STR,
+                   OHOS::DialModelWeekEnStr::GetInstance());
+namespace OHOS {
+//  CnWeekEndays 是一个包含星期字符串的数组
+// const std::string CnWeekEndays_EN[] = {"Sunday",    "Monday",   "Tuesday",
+//                                        "Wednesday", "Thursday", "Friday",
+//                                        "Saturday"};
+const std::string CnWeekEndays_EN[] = {"SUNDAY",    "MONDAY",   "TUESDAY",
+                                       "WEDNESDAY", "THURSDAY", "FRIDAY",
+                                       "SATURDAY"};
+
+bool DialModelWeekEnStr::GetDialTextData(DialDataType &type, std::string *&out,
+                                         int16_t &strNum) {
+  (void)type;
+
+  struct tm local_time = {0};
+  time_t seconds = time(nullptr);
+
+  if (localtime_r(&seconds, &local_time) == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+    return false;
+  }
+
+  dialWeekEnStr_.clear();
+  dialWeekEnStr_ = CnWeekEndays_EN[local_time.tm_wday];
+  out = &dialWeekEnStr_;
+  strNum = 1;
+  return true;
+}
+
+void DialModelWeekEnStr::UpdateWeekEnStr(const std::string *&dialWeekEnStr) {
+  dialWeekEnStr_.clear();
+  dialWeekEnStr_ = *dialWeekEnStr; // 更新字符串
+  if (onChangeListener_ != nullptr) {
+    onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_WEEK_EN_STR,
+                                            &dialWeekEnStr_,
+                                            dialWeekEnStr_.size());
+  }
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekNum.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekNum.cpp
new file mode 100644 (file)
index 0000000..e61797e
--- /dev/null
@@ -0,0 +1,33 @@
+#include "DialModelWeekNum.h"
+#include "RegisterDialModel.h"
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <ctime>
+#include <string>
+#include <time.h>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEEK_NUM,
+                   OHOS::DialModelWeekNum::GetInstance());
+
+namespace OHOS {
+
+bool DialModelWeekNum::GetDialFloatData(DialDataType &type, float &out) {
+
+  (void)type;
+
+  struct tm local_time = {0};
+  time_t seconds = time(nullptr);
+
+  if (localtime_r(&seconds, &local_time) == nullptr) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+    return false;
+  }
+
+  // 获取当前星期几,tm_wday 的范围是 0 (周日) 到 6 (周六),
+  // 将其转换为 1 到 7
+  dialWeekNum_ = local_time.tm_wday;  // 1-7
+  out = static_cast<float>(dialWeekNum_); // 将其转换为 float 类型
+  return true;
+}
+
+} // namespace OHOS
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekStr.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialModelWeekStr.cpp
new file mode 100644 (file)
index 0000000..6f14eeb
--- /dev/null
@@ -0,0 +1,47 @@
+#include "RegisterDialModel.h"
+#include "DialModelWeekStr.h"
+#include <string>
+#include <ctime>
+#include <time.h>
+#include "sys/time.h"
+#include "wearable_log.h"
+#include <sstream>
+
+REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_WEEK_STR, OHOS::DialModelWeekStr::GetInstance());
+namespace OHOS
+{
+    //  Cnweekdays 是一个包含星期字符串的数组
+    const std::string Cnweekdays[] = {"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+    bool DialModelWeekStr::GetDialTextData(DialDataType &type, std::string *&out, int16_t &strNum)
+    {
+        (void)type;
+
+        struct tm local_time = {0};
+        time_t seconds = time(nullptr);
+
+        if (localtime_r(&seconds, &local_time) == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "get localtime error!");
+            return false;
+        }
+
+        dialWeekStr_.clear();
+        dialWeekStr_ = Cnweekdays[local_time.tm_wday];
+        // printf("dialWeekStr_:%s\r\n", dialWeekStr_.c_str());
+        out = &dialWeekStr_;
+        strNum = 1;
+        // printf("GetDialTextData %d\r\n",strNum);
+        return true;
+    }
+
+    void DialModelWeekStr::UpdateWeekStr(const std::string *&dialWeekStr)
+    {
+        dialWeekStr_.clear();
+        dialWeekStr_ = *dialWeekStr; // 更新字符串
+        if (onChangeListener_ != nullptr)
+        {
+            onChangeListener_->OnDialTextDataUpdate(DialDataType::DATA_TYPE_WEEK_STR, &dialWeekStr_, dialWeekStr_.size());
+        }
+    }
+}
\ No newline at end of file
index f18e9ea..13113cd 100644 (file)
@@ -23,7 +23,8 @@ DialVideoView::DialVideoView()
 DialVideoView::~DialVideoView()
 {
     if (videoPlayer_ != nullptr) {
-        delete videoPlayer_;
+      delete videoPlayer_;
+      videoPlayer_ = nullptr;
     }
 }
 
index ef1979f..0235d36 100644 (file)
 #include "msg_center.h"
 #include "securec.h"
 #include "DialBinParser.h"
+#include "custom_runtime.h"
+#include "MainModel.h"
 #include "ModelDialDataFactory.h"
 #include "common/low_power_manager.h"
+#include "main/include/PullUpDownView.h"
+// #include "message/include/MessageControlView.h"
+#include "hal_tick.h"
 #include "common/image_cache_manager.h"
+#include "MainViewSample.h"
+#include "alipay_feature.h"
 #ifdef SUPPORT_OHOSFWK
 #include "ui_screennotify.h"
 #endif
-#include "MainPresenterSample.h"
+namespace OHOS
+{
+static DialVideoView *g_video = nullptr;
 
-namespace OHOS {
-static DialVideoView* g_video = nullptr;
+    static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin";
+    static constexpr const char *MESSAGEICON = "user/res/dial_state/unread.bin";
+    static constexpr const char *SLEEPICON = "user/res/dial_state/sleep.bin";
+    static constexpr const char *LOCKICON = "user/res/dial_state/lock.bin";
 
 #ifdef SUPPORT_OHOSFWK
-static void ScreenStatusNotify(ScreenStatus status)
-{
-    if (g_video == nullptr) {
-        return;
-    }
-    if (status == SCREEN_STATUS_OFF) {
-        g_video->PausePlay();
-    } else if (status == SCREEN_STATUS_ON) {
-        if (g_video->IsPaused()) {
-            g_video->ResumePlay();
-        } else if (!g_video->IsPlayed()) {
-            g_video->StartPlay();
+    static void ScreenStatusNotify(ScreenStatus status)
+    {
+        if (g_video == nullptr)
+        {
+            return;
+        }
+        // printf("uapi_dev_runtime_get_transmitting_status() %d\n",uapi_dev_runtime_get_transmitting_status());
+        // printf("ScreenStatusNotify status %d\n", status);
+        // printf("ScreenStatusNotify  g_video->IsPlayed() %d\n", g_video->IsPlayed());
+        if (status == SCREEN_STATUS_OFF)
+        {
+            g_video->PausePlay();
+            // printf("暂停视频\n");
+        }
+        else if (status == SCREEN_STATUS_ON)
+        {
+            if (g_video->IsPaused())
+            {
+              g_video->ResumePlay();
+            //   printf("恢复视频\n");
+            }
+            else if (!g_video->IsPlayed())
+            {
+              g_video->StartPlay();
+            //   printf("开始播放\n");
+            }
         }
     }
-}
 #endif
 
-DialViewGroup::DialViewGroup(void)
-{
-    SetTouchable(true);
-    SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
-    SetCoverable(true);
-}
+    DialViewGroup::DialViewGroup(void)
+    {
+        SetTouchable(true);
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        SetCoverable(true);
+    }
 
-DialViewGroup::~DialViewGroup(void)
-{
-    if (video_ != nullptr) {
+    DialViewGroup::~DialViewGroup(void)
+    {
+        if (video_ != nullptr)
+        {
 #ifdef SUPPORT_OHOSFWK
-        deregisterNotifyScreenStatus(ScreenStatusNotify);
+            deregisterNotifyScreenStatus(ScreenStatusNotify);
 #endif
-        g_video = nullptr;
-    }
-    if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->ClearFocus();
-        kaleidoscope_ = nullptr;
-    }
-    ClearDial();
-}
+            g_video = nullptr;
+        }
+        if (kaleidoscope_ != nullptr)
+        {
+            kaleidoscope_->ClearFocus();
+            kaleidoscope_ = nullptr;
+        }
+        ClearDial();
+    }
+
+    void DialViewGroup::ClearDial()
+    {
+        ImageCacheManager::GetInstance().UnloadAllInMultiRes(filePath_);
+        ListNode<DialDataType> *passiveNode = passiveUpdateTypes_.Head();
+        while (passiveNode != passiveUpdateTypes_.End())
+        {
+            DialDataType type = passiveNode->data_;
+            ModelDialDataFactory::GetInstance().UnRegisterDialDataListener(type);
+            passiveNode = passiveNode->next_;
+        }
+        passiveUpdateTypes_.Clear();
+
+        ListNode<DialClick> *clickNode = dialClicks_.Head();
+        while (clickNode != dialClicks_.End())
+        {
+            DialClick click = clickNode->data_;
+            if (!click.isSliceType)
+            {
+                UIFree(click.bundleName);
+            }
+            clickNode = clickNode->next_;
+        }
+        dialClicks_.Clear();
 
-void DialViewGroup::ClearDial()
-{
-    ImageCacheManager::GetInstance().UnloadAllInMultiRes(filePath_);
-    ListNode<DialDataType>* passiveNode = passiveUpdateTypes_.Head();
-    while (passiveNode != passiveUpdateTypes_.End()) {
-        DialDataType type = passiveNode->data_;
-        ModelDialDataFactory::GetInstance().UnRegisterDialDataListener(type);
-        passiveNode = passiveNode->next_;
-    }
-    passiveUpdateTypes_.Clear();
+        periodicUpdateTypes_.Clear();
+
+        dataTypeMap_.clear();
 
-    ListNode<DialClick>* clickNode = dialClicks_.Head();
-    while (clickNode != dialClicks_.End()) {
-        DialClick click = clickNode->data_;
-        if (!click.isSliceType) {
-            UIFree(click.bundleName);
+        ListNode<UIView *> *viewNode = dialViews_.Head();
+        while (viewNode != dialViews_.End())
+        {
+            UIViewGroup::Remove(viewNode->data_);
+            delete (viewNode->data_);
+            viewNode = viewNode->next_;
         }
-        clickNode = clickNode->next_;
-    }
-    dialClicks_.Clear();
+        dialViews_.Clear();
+
+        period_ = DEFAULT_TASK_PERIOD;
 
-    periodicUpdateTypes_.Clear();
+        video_ = nullptr;
 
-    dataTypeMap_.clear();
+        if (dialstateicon_ != nullptr) {
+          delete dialstateicon_;
+          dialstateicon_ = nullptr;
+        }
 
-    ListNode<UIView*>* viewNode = dialViews_.Head();
-    while (viewNode != dialViews_.End()) {
-        UIViewGroup::Remove(viewNode->data_);
-        delete(viewNode->data_);
-        viewNode = viewNode->next_;
+        if (messageicon_ != nullptr) {
+          delete messageicon_;
+          messageicon_ = nullptr;
+        }
+        
+        if (fp_ != nullptr)
+        {
+            fclose(fp_);
+            fp_ = nullptr;
+        }
     }
-    dialViews_.Clear();
 
-    period_ = DEFAULT_TASK_PERIOD;
+    void DialViewGroup::SetDial(std::string filePath, DisplayState state)
+    {
+        ClearDial();
+        resPreloaded_ = false;
+        filePath_ = filePath;
+        state_ = state;
+    }
 
-    video_ = nullptr;
+    void DialViewGroup::UpdateStateShow()
+    {
+        if (messageicon_ == nullptr || dialstateicon_ == nullptr)
+            return;
 
-    if (fp_ != nullptr) {
-        fclose(fp_);
-        fp_ = nullptr;
+        /*配置未读状态*/
+        messageicon_->SetVisible(MainModel::GetInstance().getMessageActiveState());
+        /*配置表盘状态*/
+        dialstateicon_->SetVisible(true);
+        switch (MainModel::GetInstance().getHighestPriorityActiveState())
+        {
+        case DialState::DO_NOT_DISTURB:
+            dialstateicon_->SetSrc(DISTURBICON);
+            break;
+        case DialState::SLEEP:
+            dialstateicon_->SetSrc(SLEEPICON);
+            break;
+        case DialState::LOCK:
+            dialstateicon_->SetSrc(LOCKICON);
+            break;
+        default:
+            dialstateicon_->SetVisible(false);
+            break;
+        }
     }
-}
+    void DialViewGroup::PreLoad(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialViewGroup::PreLoad");
+        uint32_t startTime_ = HALTick::GetInstance().GetTime();
+        if (!resPreloaded_)
+        {
+            fp_ = fopen(filePath_.c_str(), "rb");
+            if (fp_ == nullptr)
+            {
+                GRAPHIC_LOGE("cannot open file: %s\n", filePath_.c_str());
+                return;
+            }
+            DialBinParserManager::GetInstance()->UpdateDial(filePath_, fp_, this,state_); // 添加主表盘卡片内容
+            // 添加自定义logo,例如勿扰模式
 
-void DialViewGroup::SetDial(std::string filePath, DisplayState state)
-{
-    ClearDial();
-    resPreloaded_ = false;
-    filePath_ = filePath;
-    state_ = state;
-}
+            /*增加手表状态图标*/
+            InitImageView(dialstateicon_, 213, 2, 40, 40, "disturbicon", DISTURBICON);
+            // dialstateicon_->SetVisible(false);
 
-void DialViewGroup::PreLoad(void)
-{
-    if (!resPreloaded_) {
-        fp_ = fopen(filePath_.c_str(), "rb");
-        if (fp_ == nullptr) {
-            GRAPHIC_LOGE("cannot open file: %s\n", filePath_.c_str());
-            return;
+            /*增加未读图标*/
+            InitImageView(messageicon_, 223, 444, 20, 20, "messageicon_", MESSAGEICON);
+
+            UpdateStateShow();
+
+            Add(dialstateicon_);
+            Add(messageicon_);
+
+            resPreloaded_ = true;
         }
-        DialBinParserManager::GetInstance()->UpdateDial(filePath_, fp_, this, state_);
-        resPreloaded_ = true;
-    }
-}
 
-void DialViewGroup::ProcessData(DialDataType type, DialView* view)
-{
-    int16_t value = static_cast<int16_t>(type) >> 13; // 13: bit shift
-    if (value == 0) { // 0: float
-        float floatData = 0;
-        ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatData);
-        view->HandleFloatData(floatData);
-    } else if (value == 1) { // 1: text
-        std::string* textData = nullptr;
-        int16_t num = 0;
-        ModelDialDataFactory::GetInstance().GetDialTextData(type, textData, num);
-        view->HandleTextData(textData, num);
-    } else if (value == 2) { // 2: multifloat
-        float* floatsData = nullptr;
-        int16_t num = 0;
-        ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatsData, num);
-        view->HandleFloatData(floatsData, num);
+        if (!resLoadStatus)
+        {
+            /*打印已经注册的表盘model类型*/
+            // ModelDialDataFactory::GetInstance().DumpModules();
+            resLoadStatus = true;
+        }
+        uint32_t elapseTime = HALTick::GetInstance().GetElapseTime(startTime_);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialViewGroup::GetElapseTime %d", elapseTime);
     }
-}
 
-void DialViewGroup::AddView(UIView* view, bool isDialVideoView)
-{
-    if (view == nullptr) {
-        GRAPHIC_LOGE("Parameter is nullptr.\n");
-        return;
-    }
-    dialViews_.PushBack(view);
-    Add(view);
 
-    if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW) {
-        kaleidoscope_ = dynamic_cast<UIKaleidoscopeView*>(view);
+    void DialViewGroup::ProcessData(DialDataType type, DialView *view)
+    {
+        int16_t value = static_cast<int16_t>(type) >> 13; // 14: bit shift
+        if (value == 0)
+        { // 0: float
+            float floatData = 0;
+            ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatData);
+            view->HandleFloatData(floatData);
+        }
+        else if (value == 1)
+        { // 1: text
+            std::string *textData = nullptr;
+            int16_t num = 0;
+            bool ret = ModelDialDataFactory::GetInstance().GetDialTextData(type, textData, num);
+            // printf("ModelDialDataFactory type %d  num %d ret %d \r\n", type, num, ret);
+            view->HandleTextData(textData, num);
+        }
+        else if (value == 2)
+        { // 2: multifloat
+            float *floatsData = nullptr;
+            int16_t num = 0;
+            ModelDialDataFactory::GetInstance().GetDialFloatData(type, floatsData, num);
+            view->HandleFloatData(floatsData, num);
+        }
     }
 
-    if (isDialVideoView) {
-        if (video_ != nullptr) {
-            GRAPHIC_LOGE("Already added a video view.\n");
+    void DialViewGroup::AddView(UIView *view, bool isDialVideoView)
+    {
+        if (view == nullptr)
+        {
+            GRAPHIC_LOGE("Parameter is nullptr.\n");
             return;
         }
-        video_ = reinterpret_cast<DialVideoView*>(view);
-        g_video = video_;
+        dialViews_.PushBack(view);
+        Add(view);
+
+        if (view->GetViewType() == UI_KALEIDOSCOPE_VIEW)
+        {
+            kaleidoscope_ = dynamic_cast<UIKaleidoscopeView *>(view);
+        }
+
+        if (isDialVideoView)
+        {
+            if (video_ != nullptr)
+            {
+                GRAPHIC_LOGE("Already added a video view.\n");
+                return;
+            }
+            video_ = reinterpret_cast<DialVideoView *>(view);
+            g_video = video_;
 #ifdef SUPPORT_OHOSFWK
-        registerNotifyScreenStatus(ScreenStatusNotify);
+            registerNotifyScreenStatus(ScreenStatusNotify);
 #endif
+        }
     }
-}
 
-void DialViewGroup::AddView(DialDataType type, DialView* view, bool isPeriodic)
-{
-    if (view == nullptr) {
-        GRAPHIC_LOGE("Parameter is nullptr.\n");
-        return;
+    void DialViewGroup::AddView(DialDataType type, DialView *view, bool isPeriodic)
+    {
+        if (view == nullptr)
+        {
+            GRAPHIC_LOGE("Parameter is nullptr.\n");
+            return;
+        }
+
+        dataTypeMap_.insert(std::make_pair(static_cast<int16_t>(type), view));
+        if (isPeriodic)
+        {
+            periodicUpdateTypes_.PushBack(type);
+        }
+        else
+        {
+            ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this);
+            passiveUpdateTypes_.PushBack(type);
+        }
+        dialViews_.PushBack(dynamic_cast<UIView *>(view));
+        Add(dynamic_cast<UIView *>(view));
+               ProcessData(type, view);
     }
 
-    dataTypeMap_.insert(std::make_pair(static_cast<int16_t>(type), view));
-    if (isPeriodic) {
-        periodicUpdateTypes_.PushBack(type);
-    } else {
-        ModelDialDataFactory::GetInstance().RegisterDialDataListener(type, this);
-        passiveUpdateTypes_.PushBack(type);
+    void DialViewGroup::SetPeriod(uint32_t period)
+    {
+        if (period_ < DEFAULT_TASK_PERIOD)
+        {
+            period_ = DEFAULT_TASK_PERIOD;
+        }
+        else
+        {
+            period_ = period;
+        }
     }
-    dialViews_.PushBack(dynamic_cast<UIView*>(view));
-    Add(dynamic_cast<UIView*>(view));
-    ProcessData(type, view);
-}
 
-void DialViewGroup::SetPeriod(uint32_t period)
-{
-    if (period_ < DEFAULT_TASK_PERIOD) {
-        period_ = DEFAULT_TASK_PERIOD;
-    } else {
-        period_ = period;
+    uint32_t DialViewGroup::GetPeriod()
+    {
+        return period_;
     }
-}
 
-uint32_t DialViewGroup::GetPeriod()
-{
-    return period_;
-}
 
-void DialViewGroup::UpdateViewsByPeriodicUpdateData()
-{
-    ListNode<DialDataType>* node = periodicUpdateTypes_.Head();
-    while (node != periodicUpdateTypes_.End()) {
-        DialDataType type = node->data_;
+    void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data)
+    {
         auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-        if (iter != dataTypeMap_.end()) {
-            ProcessData(type, iter->second);
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleFloatData(data);
         }
-        node = node->next_;
     }
-    if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) {
-        Invalidate();
-    }
-}
 
-void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, float data)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleFloatData(data);
-    }
-}
-
-void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, const float* data, uint16_t num)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleFloatData(data, num);
-    }
-}
-
-void DialViewGroup::OnDialTextDataUpdate(DialDataType type, const std::string* data, uint16_t num)
-{
-    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
-    if (iter != dataTypeMap_.end()) {
-        DialView* view = iter->second;
-        view->HandleTextData(data, num);
+    void DialViewGroup::OnDialFloatDataUpdate(DialDataType type, const float *data, uint16_t num)
+    {
+        auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleFloatData(data, num);
+        }
     }
-}
 
-void DialViewGroup::AddDialClick(Rect& rect, const char* bundleName)
-{
-    if (bundleName == nullptr) {
-        return;
-    }
-    uint32_t len = static_cast<uint32_t>(strlen(bundleName));
-    char* name = static_cast<char*>(UIMalloc(++len));
-    if (name == nullptr) {
-        return;
-    }
-    if (memcpy_s(name, len, bundleName, len) != EOK) {
-        UIFree(name);
-        name = nullptr;
-        return;
+    void DialViewGroup::OnDialTextDataUpdate(DialDataType type, const std::string *data, uint16_t num)
+    {
+        auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+        if (iter != dataTypeMap_.end())
+        {
+            DialView *view = iter->second;
+            view->HandleTextData(data, num);
+        }
     }
-    name[len] = '\0';
-    DialClick click = {rect, false, {.bundleName = name}};
-    dialClicks_.PushBack(click);
-}
 
-void DialViewGroup::AddDialClick(Rect& rect, uint32_t sliceId)
-{
-    if (sliceId == 0) {
-        return;
+    void DialViewGroup::AddDialClick(Rect &rect, const char *bundleName)
+    {
+        if (bundleName == nullptr)
+        {
+            return;
+        }
+        uint32_t len = static_cast<uint32_t>(strlen(bundleName));
+        char *name = static_cast<char *>(UIMalloc(++len));
+        if (name == nullptr)
+        {
+            return;
+        }
+        if (memcpy_s(name, len, bundleName, len) != EOK)
+        {
+            UIFree(name);
+            name = nullptr;
+            return;
+        }
+        name[len] = '\0';
+        DialClick click = {rect, false, {.bundleName = name}};
+        dialClicks_.PushBack(click);
     }
 
-    DialClick click = {rect, true, {.sliceId = sliceId}};
-    dialClicks_.PushBack(click);
-}
+    void DialViewGroup::AddDialClick(Rect &rect, uint32_t sliceId)
+    {
+        if (sliceId == 0)
+        {
+            return;
+        }
 
-bool DialViewGroup::OnClickEvent(const ClickEvent& event)
-{
-    Point point = event.GetCurrentPos();
-    ListNode<DialClick>* node = dialClicks_.Head();
-    while (node != dialClicks_.End()) {
-        DialClick dialClick = node->data_;
-        if (dialClick.area.IsContains(point)) {
-            if (dialClick.isSliceType) {
+        DialClick click = {rect, true, {.sliceId = sliceId}};
+        dialClicks_.PushBack(click);
+    }
+
+    bool DialViewGroup::OnClickEvent(const ClickEvent &event)
+    {
+        Point point = event.GetCurrentPos();
+        ListNode<DialClick> *node = dialClicks_.Head();
+        while (node != dialClicks_.End())
+        {
+            DialClick dialClick = node->data_;
+            if (dialClick.area.IsContains(point))
+            {
+              if (dialClick.isSliceType) {
+                //支付宝需要先判断
+#ifdef SUPPORT_ALIPAY_SEC
+                // if(dialClick.sliceId == VIEW_MAIN_ALIPAY && Alipay_is_init()==false)
+                // {
+                //     return false;
+                // }
+#endif       
                 NativeAbility::GetInstance().ChangeSlice(dialClick.sliceId);
-            } else {
+                }
+                else
+                {
 #ifdef JS_ENABLE
-                StartJsApp(dialClick.bundleName);
+                    StartJsApp(dialClick.bundleName);
 #endif
+                }
+                return true;
             }
-            return true;
+            node = node->next_;
         }
-        node = node->next_;
+        return false;
     }
-    return false;
-}
 
-void DialViewGroup::ScrollBegin(bool isActive)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (isActive) {
-            kaleidoscope_->ClearFocus();
-            kaleidoscope_->StopRotateAnimator();
+    void DialViewGroup::ScrollBegin(bool isActive)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (isActive)
+            {
+                kaleidoscope_->ClearFocus();
+                kaleidoscope_->StopRotateAnimator();
+            }
+            return;
         }
-        return;
-    }
-
-    if (video_ == nullptr) {
-        return;
-    }
-    video_->PausePlay();
-}
 
-void DialViewGroup::ScrollEnd(bool isActive)
-{
-    MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance();
-    if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) {
-        return;
+        if (video_ == nullptr)
+        {
+            return;
+        }
+        if (video_->IsPlayed())
+        {
+            video_->PausePlay();
+        }
     }
 
-    if (kaleidoscope_ != nullptr) {
-        if (isActive) {
-            kaleidoscope_->StartRotateAnimator();
-            kaleidoscope_->RequestFocus();
+    void DialViewGroup::ScrollEnd(bool isActive)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (isActive)
+            {
+                kaleidoscope_->StartRotateAnimator();
+                kaleidoscope_->RequestFocus();
+            }
+            return;
         }
-        return;
-    }
 
-    if (video_ == nullptr) {
-        return;
-    }
+        if (video_ == nullptr)
+        {
+            return;
+        }
 
-    if (isActive) {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
+        if (isActive)
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
         }
-        g_video = video_;
-    } else {
-        if (!video_->IsStopped()) {
-            video_->StopPlay();
+        else
+        {
+            if (video_->IsPaused() || video_->IsPlayed())
+            {
+                video_->StopPlay();
+            }
+            ClearCache();
+            g_video = nullptr;
         }
-        ClearCache();
-        g_video = nullptr;
     }
-}
 
-void DialViewGroup::CoverBegin(bool isCovered)
-{
-    if (kaleidoscope_ != nullptr) {
-        if (!isCovered) {
-            kaleidoscope_->StopRotateAnimator();
-            kaleidoscope_->ClearFocus();
+    void DialViewGroup::CoverBegin(bool isCovered)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (!isCovered)
+            {
+                kaleidoscope_->StopRotateAnimator();
+                kaleidoscope_->ClearFocus();
+            }
+            return;
         }
-        return;
-    }
 
-    if (video_ == nullptr) {
-        return;
-    }
+        if (video_ == nullptr)
+        {
+            return;
+        }
 
-    video_->PausePlay();
-}
+        if (video_->IsPlayed())
+        {
+            video_->PausePlay();
+        }
+    }
 
-void DialViewGroup::CoverEnd(bool isCovered)
-{
-    MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance();
-    if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) {
-        return;
+    void DialViewGroup::CoverEnd(bool isCovered)
+    {
+        if (kaleidoscope_ != nullptr)
+        {
+            if (!isCovered)
+            {
+                kaleidoscope_->RequestFocus();
+                kaleidoscope_->StartRotateAnimator();
+            }
+            return;
+        }
+        if (video_ == nullptr)
+        {
+            return;
+        }
+        if (isCovered)
+        {
+            g_video = nullptr;
+        }
+        else
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
+        }
     }
 
-    if (kaleidoscope_ != nullptr) {
-        if (!isCovered) {
+    void DialViewGroup::OnActive(void)
+    {
+        if (video_ != nullptr)
+        {
+            if (video_->IsPaused())
+            {
+                video_->ResumePlay();
+            }
+            else if (!video_->IsPlayed())
+            {
+                video_->StartPlay();
+            }
+            g_video = video_;
+        }
+        else if (kaleidoscope_ != nullptr)
+        {
             kaleidoscope_->RequestFocus();
             kaleidoscope_->StartRotateAnimator();
         }
-        return;
-    }
-    if (video_ == nullptr) {
-        return;
-    }
-    if (isCovered) {
-        g_video = nullptr;
-    } else {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
-        }
-        g_video = video_;
-    }
-}
-
-void DialViewGroup::OnActive(void)
-{
-    MainPresenterSample* mainPresenter = MainPresenterSample::GetInstance();
-    if ((mainPresenter == nullptr) || (mainPresenter->GetMainPresenterState() != MainPresenterState::RESUME)) {
-        return;
-    }
-
-    if (video_ != nullptr) {
-        if (video_->IsPaused()) {
-            video_->ResumePlay();
-        } else if (!video_->IsPlayed()) {
-            video_->StartPlay();
-        }
-        g_video = video_;
-    } else if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->RequestFocus();
-        kaleidoscope_->StartRotateAnimator();
     }
-}
 
-void DialViewGroup::OnInactive(void)
-{
-    if (video_ != nullptr) {
-        if (!video_->IsStopped()) {
-            video_->StopPlay();
+    void DialViewGroup::OnInactive(void)
+    {
+        if (video_ != nullptr)
+        {
+            if (!video_->IsStopped())
+            {
+                video_->StopPlay();
+            }
+            g_video = nullptr;
+        }
+        else if (kaleidoscope_ != nullptr)
+        {
+            kaleidoscope_->StopRotateAnimator();
+            kaleidoscope_->ClearFocus();
         }
-        g_video = nullptr;
-    } else if (kaleidoscope_ != nullptr) {
-        kaleidoscope_->StopRotateAnimator();
-        kaleidoscope_->ClearFocus();
     }
+void DialViewGroup::StopDial() {
+  if (MainModel::GetInstance().getVideostate() != false) {
+    return;
+  }
+  MainModel::GetInstance().setVideostate(true);
+  if (video_ != nullptr) {
+    if (!video_->IsStopped()) {
+      video_->StopPlay();
+    }
+    g_video = nullptr;
+  } else if (kaleidoscope_ != nullptr) {
+    kaleidoscope_->StopRotateAnimator();
+    kaleidoscope_->ClearFocus();
+  }
+}
+void DialViewGroup::StartDial() {
+  if (MainModel::GetInstance().getVideostate() != true) {
+    return;
+  }
+  MainModel::GetInstance().setVideostate(false);
+  if (video_ != nullptr) {
+    if (video_->IsPaused()) {
+      video_->ResumePlay();
+    } else if (!video_->IsPlayed()) {
+      video_->StartPlay();
+    }
+    g_video = video_;
+  } else if (kaleidoscope_ != nullptr) {
+    kaleidoscope_->RequestFocus();
+    kaleidoscope_->StartRotateAnimator();
+  }
 }
-
 MediaVideoPlay* DialViewGroup::GetVideoPlay()
 {
     if (video_ != nullptr) {
@@ -430,4 +601,27 @@ MediaVideoPlay* DialViewGroup::GetVideoPlay()
     }
     return nullptr;
 }
+//更新数据
+void DialViewGroup::UpdateViewsByPeriodicUpdateData() {
+  ListNode<DialDataType> *node = periodicUpdateTypes_.Head();
+  while (node != periodicUpdateTypes_.End()) {
+    DialDataType type = node->data_;
+    auto iter = dataTypeMap_.find(static_cast<int16_t>(type));
+    if (iter != dataTypeMap_.end()) {
+      ProcessData(type, iter->second);
+    }
+    node = node->next_;
+  }
+  if (LowPowerManager::GetInstance()->IsLiteSurfaceInRootView()) {
+    Invalidate();
+  }
+  // ota进行视频暂停
+  if (uapi_dev_runtime_get_transmitting_status() == 1 || uapi_dev_runtime_get_restore_factory_status() == 1 ) {
+    //暂停视频
+    StopDial();
+  } else {
+    //获取视频
+    StartDial();
+  }
+}
 }
\ No newline at end of file
index d17de5b..88ce467 100644 (file)
@@ -13,6 +13,7 @@ bool ModelDialDataFactory::GetDialTextData(DialDataType& type, std::string*& out
     if (model == nullptr) {
         return false;
     }
+    // printf("type %d strNum %d\r\n",type,strNum);
     return model->GetDialTextData(type, out, strNum);
 }