#include "components/ui_circle_progress.h"
#include "uicomponents/UIComponents.h"
#include "charge_notification.h"
+#include <service/graphic_service.h>
//#include "ui_resource_string.h"
osTimerId_t Chargeing_timer= NULL;
- // 刷新回调
- void Chargeing_Timer_CallBack(int data) {
- if (UIViewGroup_charge == nullptr || UILabel_Chargeing == nullptr ||
- UILabel_power == nullptr || UILabel_time == nullptr ||
- batteryprogress== nullptr) {
+ // 实际的UI更新逻辑(在图形线程中执行)
+ static void Chargeing_Timer_CallBackProc(int data) {
+ // 检查必要的UI组件是否存在(batteryprogress可能为nullptr,不影响更新)
+ if (UIViewGroup_charge == nullptr ||
+ UILabel_power == nullptr ||
+ UILabel_time == nullptr) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Chargeing_Timer_CallBackProc: UI组件为空,跳过更新");
return;
}
UILabel_power->Invalidate();
}
+ // 如果batteryprogress存在,也更新它的值
+ if (batteryprogress != nullptr) {
+ batteryprogress->SetValue(power);
+ batteryprogress->Invalidate();
+ }
+
+ }
+
+ // 定时器回调函数(通过PostGraphicEvent投递到图形线程)
+ void Chargeing_Timer_CallBack(int data) {
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(Chargeing_Timer_CallBackProc, data));
}
bool is_UIViewGroup_charge(void)