#define LOW_POWER_BUTTON "LOW_POWER_BUTTON"
#define CHARGE_GROUP "UIViewGroup_charge"
+
+ //增加充电动画
+ UIImageAnimatorView *chargeAnimatorView = nullptr;
+ static constexpr char *ChargeAnimationPaths = "/user/res/charge/"; //充电动画路径
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_NUM_FRAMES = 24; //充电动画帧数
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_TIME = 150; //充电动画更新间隔
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_X = 142; //充电动画位置x
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_Y = 134; //充电动画位置y
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_W = 182; //充电动画宽度
+ static constexpr int16_t CHARGE_ANIMATION_VIEW_H = 202; //充电动画高度
+ const ImageInfo **ChargeAnimationInfoArray{nullptr}; //充电动画图片路径数组
+ ImageAnimatorInfo ChargeAnimationInfo[CHARGE_ANIMATION_VIEW_NUM_FRAMES]; //充电动画图像的信息
+
+
// GILROY_BOLD_FONT
//充电中 UI
UIViewGroup *UIViewGroup_charge =nullptr;
(pTM.tm_hour < 10 ? "0" : "") + std::to_string(pTM.tm_hour) + ":" +
(pTM.tm_min < 10 ? "0" : "") + std::to_string(pTM.tm_min);
- // 更新充电状态标签
- if (UILabel_Chargeing) {
- if (power == 100) {
- UILabel_Chargeing->SetTextId(STR_CHARG_DOWN); // TODO: 增加多国语言
- } else {
- UILabel_Chargeing->SetTextId(STR_CHAEGING);
- // UILabel_Chargeing->SetTextId(STR_CHARGE);
- }
- UILabel_Chargeing->Invalidate();
- }
-
// 刷新时间标签
if (UILabel_time) {
UILabel_time->SetText(stringtime.c_str());
UILabel_power->Invalidate();
}
- // 刷新进度条
- if (batteryprogress) {
- batteryprogress->SetValue(power);
- batteryprogress->Invalidate();
- }
}
bool is_UIViewGroup_charge(void)
UIViewGroup_charge->RemoveAll();
- if (batteryprogress) {
- delete batteryprogress;
- batteryprogress = nullptr;
- }
+ // if (batteryprogress) {
+ // delete batteryprogress;
+ // batteryprogress = nullptr;
+ // }
+
if(image_lightning)
{
delete image_lightning;
UILabel_power = nullptr;
}
- if(UILabel_Chargeing)
- {
- delete UILabel_Chargeing;
- UILabel_Chargeing = nullptr;
+ if (chargeAnimatorView)
+ {
+ chargeAnimatorView->Stop();
+ delete chargeAnimatorView;
+ chargeAnimatorView = nullptr;
}
+ if (ChargeAnimationInfoArray)
+ {
+ FreeImageInfoArray(ChargeAnimationInfoArray, ChargeAnimationPaths,
+ CHARGE_ANIMATION_VIEW_NUM_FRAMES);
+ ChargeAnimationInfoArray = nullptr;
+ }
+
+ // if(UILabel_Chargeing)
+ // {
+ // delete UILabel_Chargeing;
+ // UILabel_Chargeing = nullptr;
+
+ // }
RootView::GetInstance()->Remove(UIViewGroup_charge);
char time_buf[16]={0};
sprintf_s(time_buf,16,"%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
- if (batteryprogress == nullptr) {
- batteryprogress = new UICircleProgress();
- }
- batteryprogress->SetPosition(
- 123, 123); // widget's left position and top position
- batteryprogress->Resize(224, 222); // widget's width and height
- batteryprogress->SetViewId("circleProgress1"); // Set style
- batteryprogress->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
-
- // Set additional property
- // Set BackgroundStyle
- batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- batteryprogress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x05);
- batteryprogress->SetBackgroundStyle(STYLE_BORDER_OPA, 0x07);
- batteryprogress->SetBackgroundStyle(STYLE_LINE_OPA, 0x07);
- batteryprogress->SetBackgroundStyle(STYLE_LINE_WIDTH, 22);
- // Set ForegroundStyle
- batteryprogress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6);
- batteryprogress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000);
- batteryprogress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4FC34C);
- batteryprogress->SetForegroundStyle(STYLE_LINE_WIDTH, 22);
- batteryprogress->SetCenterPosition(111, 109);
- batteryprogress->SetRadius(108);
- batteryprogress->SetEndAngle(359);
- batteryprogress->SetValue(power);
- batteryprogress->SetVisible(true);
- // batteryprogress->SetCapType(CAP_ROUND); 不使用圆形边缘
-
- if (image_lightning == nullptr) {
- image_lightning = new UIImageView();
- }
- image_lightning->SetPosition(207, 176); // widget's left position and top position
- image_lightning->Resize(70, 60); // widget's width and height
- image_lightning->SetViewId("image2");// Set style
- image_lightning->SetStyle(STYLE_BORDER_COLOR, 0xff191919);
- char* image2imagesPath = "/user/res/solar-energy_1.bin";
- image_lightning->SetSrc(image2imagesPath);
- image_lightning->SetVisible(true);
-
-
- if (image_circle == nullptr) {
- image_circle = new UIImageView();
- }
- image_circle->SetPosition(126, 125); // widget's left position and top position
- image_circle->Resize(194, 194); // widget's width and height
- image_circle->SetViewId("image1");// Set style
- char* image1imagesPath = "/user/res/Ellipse_37.bin";
- image_circle->SetSrc(image1imagesPath);
- image_circle->SetVisible(true);
-
+
+
if (UILabel_power == nullptr) {
UILabel_power = new UILabelExt();
}
- UILabel_power->SetPosition(133, 252); // widget's left position and top position
+ UILabel_power->SetPosition(133, 202); // widget's left position and top position
UILabel_power->Resize(200, 60); // widget's width and height
UILabel_power->SetViewId("label5");// Set style
UILabel_power->SetStyle(STYLE_TEXT_FONT, 40);
UILabel_power->SetVisible(true);
- if (UILabel_Chargeing == nullptr) {
- UILabel_Chargeing = new UILabelExt();
- }
- UILabel_Chargeing->SetPosition(133, 356); // widget's left position and top position
- UILabel_Chargeing->Resize(200, 60); // widget's width and height
- UILabel_Chargeing->SetViewId("label4");// Set style
- UILabel_Chargeing->SetStyle(STYLE_TEXT_FONT, 30);
- // UILabel_Chargeing->SetText("正在充电");
- // UILabel_Chargeing->SetTextId(STR_CHARGE);
- UILabel_Chargeing->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
- UILabel_Chargeing->SetTextColor(Color::GetColorFromRGBA(0x4F, 0xC3, 0x4C, 0xff));
- UILabel_Chargeing->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
- UILabel_Chargeing->SetRollSpeed(0);
- UILabel_Chargeing->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
- UILabel_Chargeing->SetVisible(true);
+
if (UILabel_time == nullptr) {
- UIViewGroup_charge->Add(image_lightning);
- UIViewGroup_charge->Add(image_circle);
- UIViewGroup_charge->Add(batteryprogress);
+ // 充电动画初始化与添加
+ if (chargeAnimatorView == nullptr) {
+ chargeAnimatorView = new UIImageAnimatorView();
+ }
+ if (ChargeAnimationInfoArray == nullptr) {
+ // 加载 /user/res/charge/ 目录中的帧序列:1.bin ... N.bin
+ ChargeAnimationInfoArray = CreateImageInfoArray(ChargeAnimationPaths, CHARGE_ANIMATION_VIEW_NUM_FRAMES);
+ }
+ if (ChargeAnimationInfoArray != nullptr && chargeAnimatorView != nullptr) {
+ for (uint8_t i = 0; i < CHARGE_ANIMATION_VIEW_NUM_FRAMES; i++) {
+ ChargeAnimationInfo[i].imageInfo = (ChargeAnimationInfoArray[i]);
+ ChargeAnimationInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+ ChargeAnimationInfo[i].pos.x = CHARGE_ANIMATION_VIEW_X;
+ ChargeAnimationInfo[i].pos.y = CHARGE_ANIMATION_VIEW_Y;
+ ChargeAnimationInfo[i].width = CHARGE_ANIMATION_VIEW_W;
+ ChargeAnimationInfo[i].height = CHARGE_ANIMATION_VIEW_H;
+ }
+ chargeAnimatorView->SetPosition(CHARGE_ANIMATION_VIEW_X, CHARGE_ANIMATION_VIEW_Y,
+ CHARGE_ANIMATION_VIEW_W, CHARGE_ANIMATION_VIEW_H);
+ chargeAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ chargeAnimatorView->SetImageAnimatorSrc(ChargeAnimationInfo,
+ CHARGE_ANIMATION_VIEW_NUM_FRAMES,
+ CHARGE_ANIMATION_VIEW_TIME);
+ chargeAnimatorView->SetRepeat(true);
+ chargeAnimatorView->SetRepeatTimes(0); // 无限循环
+ chargeAnimatorView->SetResizeMode(UIImageView::COVER);
+ chargeAnimatorView->Start();
+ UIViewGroup_charge->Add(chargeAnimatorView);
+ }
UIViewGroup_charge->Add(UILabel_time);
UIViewGroup_charge->Add(UILabel_power);
- UIViewGroup_charge->Add(UILabel_Chargeing);
NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeChargePower);
return UIViewGroup_charge;
}
-
+///////////////////////////////////////////////////////////////////////////////////
+//低电量弹窗
void ShowUpShutDownAnimatorView()
{
group = new UIViewGroup();