--- /dev/null
+#ifndef DIAL_BOX_PROGRESS_MODEL_H
+#define DIAL_BOX_PROGRESS_MODEL_H
+
+#include <cstdint>
+#include "View.h"
+
+enum DialBoxDataType {
+ // 剩余电量百分比
+ BATTERY_LEVEL = 1,
+ // 步数目标
+ STEP_TARGET = 2,
+ // 卡路里
+ CALORIE_TARGET = 3,
+};
+
+namespace OHOS {
+class DialBoxProgressModel {
+public:
+ DialBoxProgressModel();
+ ~DialBoxProgressModel();
+ static DialBoxProgressModel *GetInstance() {
+ static DialBoxProgressModel instance;
+ return &instance;
+ }
+
+ void UpdateBatteryColor( float value_);
+ void SetViewColor(int64_t color);
+ int64_t GetViewColor();
+
+
+ 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;
+ int64_t color_ = Color::White().full;
+ DialBoxDataType datatype_ = BATTERY_LEVEL;
+};
+} // namespace OHOS
+#endif
+/*
+ * Copyright (c) @CompanyNameMagicTag. 2023. All rights reserved.
+ */
#ifndef DIAL_BOX_PROGRESS_VIEW_H
#define DIAL_BOX_PROGRESS_VIEW_H
#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;
- 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);
-
+ DialBoxProgressView();
+ ~DialBoxProgressView() override;
+ void HandleFloatData(float data) override;
private:
- int32_t value_ = -1;
- int64_t color_ = Color::White().full;
- DialBoxDataType datatype_ = BATTERY_LEVEL;
+ int32_t value_ = -1;
};
-} // namespace OHOS
+}
#endif
\ No newline at end of file
--- /dev/null
+#include "DialBoxProgressModel.h"
+#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 {
+DialBoxProgressModel::DialBoxProgressModel(void)
+ : value_(0), color_(Color::White().full) // 初始化 color_
+{}
+
+DialBoxProgressModel::~DialBoxProgressModel(void) {}
+
+/* --------------------------------- 编码解码函数
+ * --------------------------------- */
+
+// 定义用于位操作的掩码和位移值,可根据实际需求调整
+constexpr uint32_t TYPE_MASK = 0xFF000000;
+constexpr uint32_t TYPE_SHIFT = 24;
+constexpr uint32_t VALUE_MASK = 0x00FFFFFF;
+
+uint32_t
+DialBoxProgressModel::DialBoxDataTypeToBitPattern(DialBoxDataType type) {
+ return static_cast<uint32_t>(type) << TYPE_SHIFT;
+}
+//增加box不同值颜色绘制
+uint32_t DialBoxProgressModel::ConvertToRequiredFormat(DialBoxDataType type,
+ float data) {
+
+ uint32_t typeBitPattern = DialBoxDataTypeToBitPattern(type);
+ uint32_t dataAsInt = static_cast<uint32_t>(data);
+
+ return (typeBitPattern | dataAsInt);
+}
+
+DialBoxDataType DialBoxProgressModel::ExtractDataType(uint32_t rawData) {
+
+ uint32_t typeValue = (rawData & TYPE_MASK) >> TYPE_SHIFT;
+ return static_cast<DialBoxDataType>(typeValue);
+}
+
+uint32_t DialBoxProgressModel::ExtractValue(uint32_t rawData) {
+
+ return rawData & VALUE_MASK;
+}
+
+
+void DialBoxProgressModel::UpdateBatteryColor( float value_) {
+ bool isCharging = get_charge_stat(); // 获取充电状态
+
+ 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 DialBoxProgressModel::SetViewColor(int64_t color) {
+ // 仅在颜色变化时设置
+ if (color != color_) {
+ color_ = color;
+ }
+}
+
+//增加返回颜色
+int64_t DialBoxProgressModel::GetViewColor() { return color_; }
+} // namespace OHOS
\ No newline at end of file
#include "DialBoxProgressView.h"
+#include "DialBoxProgressModel.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) {}
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) {
-
- uint32_t typeValue = (rawData & TYPE_MASK) >> TYPE_SHIFT;
- return static_cast<DialBoxDataType>(typeValue);
-}
-
-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_LOGE("DialBoxProgressView", "HandleFloatData: %d %f", datatype_,
+ DialBoxDataType datatype_ =
+ DialBoxProgressModel::GetInstance()->ExtractDataType(data); //类型为前4位
+ float value =
+ DialBoxProgressModel::GetInstance()->ExtractValue(data); //数值为后28位
+ WEARABLE_LOGD("DialBoxProgressView", "HandleFloatData: %d %f", datatype_,
value);
-
- if (datatype_ == BATTERY_LEVEL) {
- UpdateBatteryColor(); // 在值变化或充电状态变化时更新颜色
- } else if (datatype_ == STEP_TARGET) {
- SetViewColor(0xFFf0c440);
+ int64_t color;
+ switch (datatype_) {
+ //电池颜色
+ case BATTERY_LEVEL:
+ DialBoxProgressModel::GetInstance()->UpdateBatteryColor(value);
+ color = DialBoxProgressModel::GetInstance()->GetViewColor();
+ SetForegroundStyle(STYLE_BACKGROUND_COLOR, color);
+ break;
+ //步数目标
+ case STEP_TARGET:
+ color = 0xFFf0c440; //黄色
+ SetForegroundStyle(STYLE_BACKGROUND_COLOR, color);
+ break;
+ default:
+ WEARABLE_LOGE("DialBoxProgressView", "HandleFloatData: datatype error");
+ break;
}
if (value != value_) {
value_ = value;
}
}
-void DialBoxProgressView::UpdateBatteryColor() {
- bool isCharging = get_charge_stat(); // 获取充电状态
-
- 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_);
- }
-}
} // namespace OHOS
\ No newline at end of file
#include "DialModelKcalgoal.h"
#include "DialBoxProgressView.h"
+#include "DialBoxProgressModel.h"
#include "RegisterDialModel.h"
#include "goal/include/goalmodel.h"
namespace OHOS {
bool DialModelKcalgoal::GetDialFloatData(DialDataType &type, float &out) {
(void)type;
+#if 1
uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
uint32_t Kcal_ = GoalModel::GetInstance().show_data_calories_refresh();
Kcalgoal_ = (static_cast<float>(Kcal_) / goal) * 100;
if (Kcalgoal_ > 100)
Kcalgoal_ = 100;
- Kcalgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+ Kcalgoal_ = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::CALORIE_TARGET, Kcalgoal_);
} else {
Kcalgoal_ = 0;
onChangeListener_->OnDialFloatDataUpdate(
OHOS::DialDataType::CALORIE_GOAL_BOXPROGRESS, Kcalgoal_);
}
- out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+ out = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::CALORIE_TARGET, Kcalgoal_);
+#else
+ out = 0;
+#endif
return true;
}
void DialModelKcalgoal::UpdateKcalgoal(uint32_t Kcals) {
+#if 0
uint32_t Kcal_ = static_cast<float>(Kcals);
uint32_t goal = GoalModel::GetInstance().getKcalgoaldata();
if (goal > 0) {
onChangeListener_->OnDialFloatDataUpdate(
OHOS::DialDataType::CALORIE_GOAL_BOXPROGRESS, Kcalgoal_);
}
+#endif
}
} // namespace OHOS
#include "DialModelPowerStandby.h"
#include "DialBoxProgressView.h"
+#include "DialBoxProgressModel.h"
+
#include "RegisterDialModel.h"
#include "wearable_log.h"
#include <string>
namespace OHOS {
bool DialModelPowerStanby::GetDialFloatData(DialDataType &type, float &out) {
+#if 1
(void)type;
-
float voltage = 0.0F;
PowerStanby_ = battery_get_voltage(&voltage);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Battery voltage obtained: %.2f",
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Battery voltage obtained: %.2f",
voltage);
// 计算映射值
} else {
mappedValue = (PowerStanby_ == maxPower) ? 1.0f : 0.0f; // 边界处理
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
"Raw power value: %d, Mapped value: %.2f", PowerStanby_,
mappedValue);
// 如果需要在 0 到 1 范围映射
// 需要前4个为类型
// 后28位为数据
- out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+ out = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::BATTERY_LEVEL, PowerStanby_);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Mapped value sent to caller: %.2f",
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Mapped value sent to caller: %.2f",
out);
+#else
+ (void)type;
+ float voltage = 0.0F;
+ power_ = battery_get_voltage(&voltage);
+ out = static_cast<float>(power_);
+#endif
return true;
}
#include "DialModelStepgoal.h"
#include "DialBoxProgressView.h"
+#include "DialBoxProgressModel.h"
#include "RegisterDialModel.h"
#include "goal/include/goalmodel.h"
namespace OHOS {
bool DialModelStepgoal::GetDialFloatData(DialDataType &type, float &out) {
(void)type;
-
+#if 1
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(
+ stepgoal_ = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::STEP_TARGET, stepgoal_);
} else {
stepgoal_ = 0;
}
- out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat(
+ out = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::STEP_TARGET, stepgoal_);
+#else
+ out = 0;
+#endif
return true;
}
void DialModelStepgoal::UpdateStepgoal(uint32_t steps) {
+#if 1
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(
+ stepgoal_ = DialBoxProgressModel::GetInstance()->ConvertToRequiredFormat(
DialBoxDataType::STEP_TARGET, stepgoal_);
}
if (onChangeListener_ != nullptr) {
- onChangeListener_->OnDialFloatDataUpdate(OHOS::DialDataType::STEPS_GOAL_BOXPROGRESS,
- stepgoal_);
+ onChangeListener_->OnDialFloatDataUpdate(
+ OHOS::DialDataType::STEPS_GOAL_BOXPROGRESS, stepgoal_);
}
+#endif
}
} // namespace OHOS
${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/key/include
${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include
${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/main/include/dial
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/saveele/include
${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include
${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits
${ROOT_DIR}/middleware/services/gui/uikit/ui/interfaces/innerkits
${ROOT_DIR}/middleware/services/gui/uikit/utils/interfaces/kits/gfx_utils
${ROOT_DIR}/middleware/services/gui/uikit/surface/interfaces/kits
${ROOT_DIR}/middleware/services/gui/uikit/ui/frameworks
- ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components_ext
+ ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include/components
+ ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/ui/frameworks/components/
${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audio_player/interfaces/kits
${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiomanager
${ROOT_DIR}/open_source/openharmony/foundation/multimedia/audiomanager/interfaces/kits/audiocommon
${ROOT_DIR}/application/wearable/nativeapp/nativeui/player/include
${ROOT_DIR}/application/wearable/nativeapp/nativeui/applist/include
${ROOT_DIR}/open_source/openharmony/foundation/multimedia/player/interfaces/kits
+
${ROOT_DIR}/application/wearable/fd230/nativeapp/nativeui/
)
#include "VolumeSettingPresenter.h"
#include "VolumeSettingView.h"
#include "pairing_notification.h"
+// #include "saveele/include/SaveEleModel.h"
+// #include "DialModelCharge.h"
+
+#define DIALDATASET 1
+
#ifdef SUPPORT_BLE_SERVICE
#include "bleInstruct.h"
#endif
{
GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
}
-
#if 0
#if DIALDATASET
DialModelCharge::GetInstance()->UpdatechargeStatus(1);
#endif
SaveEleModel::GetInstance()->SetChargeStatus(true);
+
if (uapi_dev_runtime_get_train_status())
{
WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger Plug ! but train status is true");
NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
}
}
- #endif
-
+ #endif
}
/*充电器已拔掉*/
{
GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PullUpDownView::UpdateBatteryProcess, OHOS::PullUpDownView::GetInstance() ));
}
-
- #if 0
+#if 0
#if DIALDATASET
DialModelCharge::GetInstance()->UpdatechargeStatus(0);
#endif
SaveEleModel::GetInstance()->SetChargeStatus(false);
-
+
+
testCHANINGView *t = testCHANINGView::GetInstance();
if(t != nullptr)
{
NotificationManager::GetInstance()->StopNotify();
}
}
- #endif
+ #endif
}
/*低电量提醒*/