From: Caisking <3449750381@qq.com> Date: Sat, 26 Oct 2024 07:26:36 +0000 (+0800) Subject: 表盘:修复晨曦表盘电量映射 X-Git-Tag: fd230_release_V1.3.102~179^2~7 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=da17bfbc2367c3f72d07ed4d3be1ddffde733fa8;p=mirrors%2FFD230.git 表盘:修复晨曦表盘电量映射 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h index f69ca2fc0..c15165f2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialDataBase.h @@ -38,6 +38,8 @@ enum class DialDataType { DATA_TYPE_MINUTE_UNITS, // 分钟(单位) DATA_TYPE_WEEK_NUM, // 星期(数字) DATA_TYPE_STEPS_GOAL, // 运动步数目标 + DATA_TYPE_SECOND_MAPPER, // 秒映射 + DATA_TYPE_POWER_MAPPER, // 电量映射 DATA_TYPE_MULTI_FLOAT_BASE = 0x2fff, // 多个浮点数据类型基值 DATA_TYPE_HOUR_MIN, // 时分 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelPowerMapper.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelPowerMapper.h new file mode 100644 index 000000000..fb7659bb8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelPowerMapper.h @@ -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/fd230app/nativeui/main/src/dial/DialModelPowerMapper.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPowerMapper.cpp new file mode 100644 index 000000000..8e5ce049d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelPowerMapper.cpp @@ -0,0 +1,47 @@ + + +#include "DialBoxProgressView.h" +#include "DialModelPowerMapper.h" +#include "RegisterDialModel.h" +#include "battery_hal.h" +#include "wearable_log.h" +#include +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); + //电量0~100 + //映射0~1 + powermapper_ = static_cast(powermapper_) / 100.0f; + out = static_cast(powermapper_); + return true; +} + +void DialModelPowerMapper::UpdatePowerMapper() { + float voltage = 0.0F; + powermapper_ = battery_get_voltage(&voltage); + 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/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/res_dial/dawninsight.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/res_dial/dawninsight.bin index cfb3698d0..91b7786bd 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/res_dial/dawninsight.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/dial/res_dial/dawninsight.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59d4044131b8101acc4537c70d02d19fc99241863bc22a2c66de1e06fafb817a +oid sha256:22d4aaf5fcfa158662d264ebc3957834718b0c5f9bb093debc5a440555cc0806 size 330175 diff --git a/tools/dial_converter_tool/dial_lzma/113/dawninsight.lzma b/tools/dial_converter_tool/dial_lzma/113/dawninsight.lzma index 6f1ddd9c4..f7a4c62ae 100644 Binary files a/tools/dial_converter_tool/dial_lzma/113/dawninsight.lzma and b/tools/dial_converter_tool/dial_lzma/113/dawninsight.lzma differ diff --git a/tools/dial_converter_tool/instance/113/dawninsight.xml b/tools/dial_converter_tool/instance/113/dawninsight.xml index 56be3a949..cdea9d33b 100644 --- a/tools/dial_converter_tool/instance/113/dawninsight.xml +++ b/tools/dial_converter_tool/instance/113/dawninsight.xml @@ -28,7 +28,7 @@ - +