public:
DialBoxProgressView();
virtual ~DialBoxProgressView();
+ static DialBoxProgressView* GetInstance()
+ {
+ static DialBoxProgressView instance;
+ return &instance;
+ }
void HandleFloatData(float data) override;
private:
- int32_t value_ = 50;
+ int32_t value_ = -1;
};
}
#endif
\ No newline at end of file
#include "ModelDialDataFactory.h"
#include "PresenterTask.h"
#include "DialModelTime.h"
+#include "DialModelPower.h"
#if USE_OFFLINE_DIAL
#include "DialViewGroup.h"
#endif
{
map<string, AppViewId> g_jumpView = {
- {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置
+ {DROPDOWN_CLICK_SETTING, VIEW_SETTING}, // 设置
{DROPDOWN_CLICK_BLUETOOTH, VIEW_CLASSIC_BLUETOOTH}, // 蓝牙
};
SendMsgToUIService(SCREEN_OFF_ENABLE_TO_UI, 0, &enable, sizeof(int32_t));
}
}
- #endif
+#endif
if (g_jumpView.count(curViewId) != 0)
{
NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]);
{
#if USE_OFFLINE_DIAL
DialModelTime::GetInstance()->UpdateTime();
+ DialModelPower::GetInstance()->UpdatePower();
dynamic_cast<DialViewGroup *>(view_->GetViewById(WATCH_FACE))->UpdateViewsByPeriodicUpdateData();
#else
dynamic_cast<MainClockView *>(view_->GetViewById(WATCH_FACE))->UpdateTime();
*/
#include "DialBoxProgressView.h"
+#include "wearable_log.h"
+#include "battery_hal.h"
+extern uint8_t battery_get_voltage(float *voltage);
-namespace OHOS {
-DialBoxProgressView::DialBoxProgressView(void)
+namespace OHOS
{
-}
-
-DialBoxProgressView::~DialBoxProgressView(void)
-{
-}
+ DialBoxProgressView::DialBoxProgressView(void)
+ {
+ }
-void DialBoxProgressView::HandleFloatData(float data)
-{
- float ratio = data;
- if (ratio > 1.0f) {
- ratio = 1.0f;
- } else if (ratio < 0.0f) {
- ratio = 0.0f;
+ DialBoxProgressView::~DialBoxProgressView(void)
+ {
}
- int32_t value = ratio * (GetRangeMax() - GetRangeMin());
- if (value_ == value) {
- return;
+
+ 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;
+ }
+ // 获取电池电压值
+ float voltage = 0.0F;
+ value = battery_get_voltage(&voltage);
+ value_ = value;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"battery_get_value:%d", value_);
+ SetValue(value_);
}
- value_ = value;
- SetValue(value_);
}
-}
\ No newline at end of file
#include "RegisterDialModel.h"
#include "DialModelPower.h"
+#include "DialBoxProgressView.h"
#include <string>
#include "battery_hal.h"
extern uint8_t battery_get_voltage(float *voltage);
{
bool DialModelPower::GetDialFloatData(DialDataType &type, float &out)
{
- if (power_ == 0)
- {
- UpdatePower();
- }
(void)type;
- out = power_;
+ // 获取电池电压值
+ float voltage = 0.0F;
+ power_ = battery_get_voltage(&voltage);
+ out = static_cast<float>(power_);
return true;
}
void DialModelPower::UpdatePower()
// 获取电池电压值
float voltage = 0.0F;
power_ = battery_get_voltage(&voltage);
+#if 1
if (onChangeListener_ != nullptr)
{
onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_POWER, power_);
}
+#endif
}
+
}
--- /dev/null
+#ifndef CHARGE_NOTIFICATION_H
+#define CHARGE_NOTIFICATION_H
+
+namespace OHOS
+{
+ UIViewGroup *ChargingStatuShow(void);
+ UIView *view_ = nullptr;
+};
+#endif /* CHARGE_NOTIFICATION_H */
\ No newline at end of file
--- /dev/null
+#include "notification_manager.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "AlarmPopUpPresenter.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+namespace OHOS
+{
+ UIImageView *imageCharge = nullptr;
+
+ // 展示充电图标
+ UIViewGroup *ChargingStatuShow()
+ {
+ // Add ImageView to App
+ if (imageCharge == nullptr)
+ {
+ imageCharge = new UIImageView();
+ }
+ imageCharge->SetPosition(186, 55); // widget's left position and top position
+ imageCharge->Resize(100, 100); // widget's width and height
+ imageCharge->SetViewId("image1"); // Set style
+
+ // Set additional property
+ char *image1imagesPath = "/user/res/Battery/Charge_Icon.bin";
+ imageCharge->SetSrc(image1imagesPath);
+
+ // Add to rootView
+ RootView::GetInstance()->Add(imageCharge);
+
+ if (view_->GetHorCurrentPage() == WATCH_FACE)
+ {
+ imageCharge->SetVisible(true);
+ }
+ }
+}