From: SnickerSun Date: Thu, 9 Jan 2025 06:52:15 +0000 (+0800) Subject: evb下拉菜单和表盘电池电量更新 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=6f96f8336dca4e49f997517629034d7c29fc9f44;p=mirrors%2FFD230.git evb下拉菜单和表盘电池电量更新 --- diff --git a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp index f197f0440..a6b2cb8e5 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/clock/src/MainClockView.cpp @@ -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); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp index edcccbfea..1a6ed80ce 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/PullUpDownView.cpp @@ -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); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelPower.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelPower.cpp index e0e1877d8..f26446d2c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelPower.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/dial/DialModelPower.cpp @@ -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(power_); return true; } } diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/MainClockView.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/MainClockView.cpp index 1bf73f96b..9280d63ea 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/MainClockView.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/MainClockView.cpp @@ -156,7 +156,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); diff --git a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/PullUpDownView.cpp b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/PullUpDownView.cpp index 2f3f22708..be9e10145 100644 --- a/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/PullUpDownView.cpp +++ b/code/sdk/middleware/services/gui/uikit/sample/uitest/components/ui_test_clock_dial/PullUpDownView.cpp @@ -212,7 +212,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);