evb下拉菜单和表盘电池电量更新
authorSnickerSun <snickersun@163.com>
Thu, 9 Jan 2025 06:52:15 +0000 (14:52 +0800)
committerSnickerSun <snickersun@163.com>
Thu, 9 Jan 2025 06:52:15 +0000 (14:52 +0800)
code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp
code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelPower.cpp
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/MainClockView.cpp
code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/PullUpDownView.cpp

index f197f04..a6b2cb8 100644 (file)
@@ -155,7 +155,7 @@ bool MainClockView::InitLabelView(void)
     uint8_t power=90;
     battery_getvolpower(&power);
     char tmp[16]={0};
-    sprintf(tmp,"%d%",power);
+    sprintf(tmp,"%d%c",power,'%');
     batteryLabel->SetText(tmp);
     batteryLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
     batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
index edcccbf..1a6ed80 100644 (file)
@@ -264,7 +264,7 @@ void PullUpDownView::InitViewInfo(void)
     uint8_t power=90;
     battery_getvolpower(&power);
     char tmp[16]={0};
-    sprintf(tmp,"%d%",power);
+    sprintf(tmp,"%d%c",power,'%');
     batteryLable->SetText(tmp);
     batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
     batteryLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);
index e0e1877..f26446d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "RegisterDialModel.h"
 #include "DialModelPower.h"
+#include "battery_hal.h"
 
 REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_POWER, OHOS::DialModelPower::GetInstance());
 
@@ -14,7 +15,11 @@ namespace OHOS {
 bool DialModelPower::GetDialFloatData(DialDataType& type, float& out)
 {
     (void)type;
-    out = power_;
+    // out = power_;
+
+    float voltage = 0.0F;
+    power_ = battery_get_voltage(&voltage);
+    out = static_cast<float>(power_);
     return true;
 }
 }
index 1bf73f9..9280d63 100644 (file)
@@ -156,7 +156,7 @@ bool MainClockView::InitLabelView(void)
     uint8_t power=90;\r
     battery_getvolpower(&power);\r
     char tmp[16]={0};\r
-    sprintf(tmp,"%d%",power);\r
+    sprintf(tmp,"%d%c",power,'%');\r
     batteryLabel->SetText(tmp);\r
     batteryLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
     batteryLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);\r
index 2f3f227..be9e101 100644 (file)
@@ -212,7 +212,7 @@ void PullUpDownView::InitViewInfo(void)
     uint8_t power=90;\r
     battery_getvolpower(&power);\r
     char tmp[16]={0};\r
-    sprintf(tmp,"%d%",power);\r
+    sprintf(tmp,"%d%c",power,'%');\r
     batteryLable->SetText(tmp);\r
     batteryLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);\r
     batteryLable->SetStyle(STYLE_BACKGROUND_COLOR, OPA_TRANSPARENT);\r