增加充电中UI 583/1 583/head
authorhcj <1224667075@qq.com>
Thu, 25 Jul 2024 01:31:21 +0000 (09:31 +0800)
committerhcj <1224667075@qq.com>
Thu, 25 Jul 2024 01:31:21 +0000 (09:31 +0800)
code/sdk/application/wearable/fd230app/nativeui/goal/src/goalview.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/application/wearable/service/msg_center/include/notify/charge_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp
code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Ellipse 37.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/solar-energy 1.bin [new file with mode: 0644]

index e6d64cb..bb8ec16 100644 (file)
@@ -240,6 +240,7 @@ namespace OHOS
         circleProgress1_->SetEndAngle(320);
         circleProgress1_->SetValue(GoalModel::GetInstance().getstepvalue());
         circleProgress1_->SetBackgroundImagePosition(36, 26);
+        circleProgress1_->SetCapType(CAP_ROUND);
 
          /*----------------------------------------------------------------------------- */
          goalPathsArray = CreateImagePathsArray(stepPaths, "bin", 20);
index c9a6aaf..4e0ea4f 100644 (file)
@@ -419,9 +419,9 @@ static void srv_ble_add_chart_decr_battery(uint8_t server_id,uint16_t srv_handle
     uint8_t power = 0;\r
     power = battery_get_voltage(&voltage);\r
     battery_point_val[0] = power;//电量90\r
-    uint16_t dial = 1;\r
-    battery_point_val[1] = 0;//当前表盘几\r
-    battery_point_val[2] = 1;\r
+\r
+    uint16_t dial = ble_get_dial_id();\r
+    memcpy_s(&battery_point_val[1],2,&dial,2);\r
 \r
     uint8_t _major,_mid,_minor;\r
     uapi_get_fw_version(&_major,&_mid,&_minor);\r
index ea77f4b..58073b2 100644 (file)
@@ -6,8 +6,11 @@ namespace OHOS
 {
     // UIViewGroup *ChargingStatuShow(void);
     // UIView *view_ = nullptr;
+    void FreeChargePower(void);
+    UIViewGroup * ShowChargeingView(void);
 
     UIViewGroup* lowPowerShow(void);
+    
     void set_lowpower_falg(uint8_t falg);
     void FreelowPower(void);
     void low_power_play();
index cb1a804..62cb6a4 100644 (file)
@@ -238,6 +238,12 @@ static OHOS::UIViewGroup* showlowpowerNotify(void)
     return OHOS::lowPowerShow();
 }
 
+static OHOS::UIViewGroup* ShowChargeingNotify(void)
+{
+    return OHOS::ShowChargeingView();
+}
+
+
 static OHOS::UIViewGroup* showFindWatchNotify(void)
 {
     return OHOS::CreateFindWatchView();
@@ -343,11 +349,17 @@ void MsgCenterNotifyChargePlugProc(const Topic topic, Request* req)
     DialModelCharge::GetInstance()->UpdateChargeStuaut(1);
     SaveEleModel::GetInstance()->SetChargeStuaut(1);
 
+   
+
     testCHANINGView *t=testCHANINGView::GetInstance();
     if(t!=NULL)
     {
          t->ChangeViewcolor(true);
     }
+    else
+    {
+        NotificationManager::GetInstance()->ShowNotify(ShowChargeingNotify, (uint16_t)topic, true);
+    }
    
 }
 
@@ -359,12 +371,18 @@ void MsgCenterNotifyChargeUnPlugProc(const Topic topic, Request* req)
     WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyProc:: CHarger UnPlug !");
     DialModelCharge::GetInstance()->UpdateChargeStuaut(0);
     SaveEleModel::GetInstance()->SetChargeStuaut(0);
-    
+
+   
+
     testCHANINGView *t=testCHANINGView::GetInstance();
     if(t!=NULL)
     {
         t->ChangeViewcolor(false);
     }
+    else
+    {
+        NotificationManager::GetInstance()->StopNotify();
+    }
 }
 
 /*低电量提醒*/
index 5bb1d33..b1c05c0 100644 (file)
@@ -11,6 +11,8 @@
 #include "custom_utils.h"
 #include "cmsis_os2.h"
 #include "linux/delay.h"
+#include "components/ui_circle_progress.h"
+#include "battery_hal.h"
 namespace OHOS
 {
     UIImageView *imageCharge = nullptr;
@@ -31,29 +33,251 @@ namespace OHOS
     const char **ShutDownPathsArray{nullptr};                                     // 关机图片路径数组
     ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
     #define LOW_POWER_BUTTON "LOW_POWER_BUTTON"
-    // UIViewGroup *ChargingStatuShow()
-    // {
-    //     // Add ImageView to App
-    //     if (imageCharge == nullptr)
-    //     {
-    //         imageCharge = new UIImageView();
-    //     }
-    //     imageCharge->SetPosition(186, 55); // widget's left position and top position
-    //     imageCharge->Resize(100, 100);     // widget's width and height
-    //     imageCharge->SetViewId("image1");  // Set style
-
-    //     // Set additional property
-    //     char *image1imagesPath = "/user/res/Battery/Charge_Icon.bin";
-    //     imageCharge->SetSrc(image1imagesPath);
-
-    //     // Add to rootView
-    //     RootView::GetInstance()->Add(imageCharge);
-
-    //     if (view_->GetHorCurrentPage() == WATCH_FACE)
-    //     {
-    //         imageCharge->SetVisible(true);
-    //     }
-    // }
+    #define CHARGE_GROUP "UIViewGroup_charge"
+
+   // GILROY_BOLD_FONT
+    //充电中 UI 
+    UIViewGroup *UIViewGroup_charge =nullptr;
+
+    UICircleProgress *circleProgress1_=nullptr;
+
+    UIImageView *image_circle = nullptr;
+    UIImageView *image_lightning=nullptr;
+  
+    UILabelExt *UILabel_time=nullptr;
+    UILabelExt *UILabel_power=nullptr;
+    UILabelExt *UILabel_Chargeing=nullptr;
+
+    osTimerId_t Chargeing_timer= NULL;
+
+    void Chargeing_Timer_CallBack(int data)
+    {
+        float voltage = 0.0F;
+        uint8_t power = 0;
+        power = battery_get_voltage(&voltage);
+      
+        char buf[16]={0};
+        sprintf(buf,"%d%c",power,'%');
+        //printf("power:%s\r\n",buf);
+        time_t currtime;
+        struct tm *timeinfo;
+        time(&currtime);
+        timeinfo = localtime(&currtime);
+
+        char time_buf[16]={0};
+        sprintf_s(time_buf,16,"%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
+
+        if(UILabel_time)
+        UILabel_time->SetText(time_buf);
+        if(UILabel_power)
+        UILabel_power->SetText(buf);
+
+        RootView::GetInstance()->Invalidate();
+       
+        
+    }
+
+    void FreeChargePower(void)
+    {
+       if (UIViewGroup_charge != nullptr) 
+       {
+        UIViewGroup_charge->RemoveAll();
+        if(circleProgress1_)
+        {
+            delete circleProgress1_;
+            circleProgress1_ = nullptr;
+        }
+        if(image_lightning)
+        {
+            delete image_lightning;
+            image_lightning = nullptr;
+        }
+
+        if(UILabel_time)
+        {
+            delete UILabel_time;
+            UILabel_time = nullptr;
+        }
+
+        if(UILabel_power)
+        {
+            delete UILabel_power;
+            UILabel_power = nullptr;
+
+        }
+         if(UILabel_Chargeing)
+        {
+            delete UILabel_Chargeing;
+            UILabel_Chargeing = nullptr;
+
+        }
+        if(Chargeing_timer)
+        {
+            osTimerStop(Chargeing_timer);
+            osTimerDelete(Chargeing_timer);
+            Chargeing_timer = NULL;
+        }
+      
+        RootView::GetInstance()->Remove(UIViewGroup_charge);
+        delete UIViewGroup_charge;
+        UIViewGroup_charge = nullptr;
+        }
+    }
+
+    UIViewGroup * ShowChargeingView(void)
+    {
+      
+        if (UIViewGroup_charge == nullptr) 
+        {
+            UIViewGroup_charge = new UIViewGroup();
+            UIViewGroup_charge->SetPosition(0, 0, 466, 466);
+            //UIViewGroup_charge->SetStyle(STYLE_BACKGROUND_OPA, 0);
+        }
+        UIViewGroup_charge->SetViewId(CHARGE_GROUP);
+        UIViewGroup_charge->SetTouchable(true);
+        UIView::OnClickListener *UIViewGroup_charge_Click = static_cast<UIView::OnClickListener *>(lowppowrViewEventListener::GetInstance());
+        UIViewGroup_charge->SetOnClickListener(UIViewGroup_charge_Click);
+
+        
+        float voltage = 0.0F;
+        uint8_t power = 0;
+        power = battery_get_voltage(&voltage);
+      
+        char buf[16]={0};
+        sprintf(buf,"%d%c",power,'%');
+        //printf("power:%s\r\n",buf);
+
+        time_t currtime;
+        struct tm *timeinfo;
+        time(&currtime);
+        timeinfo = localtime(&currtime);
+
+        char time_buf[16]={0};
+        sprintf_s(time_buf,16,"%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
+
+        if (circleProgress1_ == nullptr) {
+            circleProgress1_ = new UICircleProgress();
+        }
+        circleProgress1_->SetPosition(123, 123);         // widget's left position and top position
+        circleProgress1_->Resize(224, 222);          // widget's width and height
+        circleProgress1_->SetViewId("circleProgress1");// Set style
+        circleProgress1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+        // Set additional property
+        // Set BackgroundStyle
+        circleProgress1_->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+        circleProgress1_->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x05);
+        circleProgress1_->SetBackgroundStyle(STYLE_BORDER_OPA, 0x07);
+        circleProgress1_->SetBackgroundStyle(STYLE_LINE_OPA, 0x07);
+        circleProgress1_->SetBackgroundStyle(STYLE_LINE_WIDTH, 22);
+        // Set ForegroundStyle
+        circleProgress1_->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6);
+        circleProgress1_->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000);
+        circleProgress1_->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4FC34C);
+        circleProgress1_->SetForegroundStyle(STYLE_LINE_WIDTH, 22);
+        circleProgress1_->SetCenterPosition(111, 109);
+        circleProgress1_->SetRadius(108);
+        circleProgress1_->SetEndAngle(359);
+        circleProgress1_->SetValue(power);
+        circleProgress1_->SetVisible(true);
+        circleProgress1_->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->Resize(200, 60);          // widget's width and height
+        UILabel_power->SetViewId("label5");// Set style
+        UILabel_power->SetStyle(STYLE_TEXT_FONT, 40);
+
+        UILabel_power->SetText(buf);
+        UILabel_power->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        UILabel_power->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        UILabel_power->SetRollSpeed(0);
+        UILabel_power->SetFont(GILROY_BOLD_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->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, 30);
+        UILabel_Chargeing->SetVisible(true);
+
+
+        if (UILabel_time == nullptr) {
+            UILabel_time = new UILabelExt();
+        }
+        UILabel_time->SetPosition(173, 65);         // widget's left position and top position
+        UILabel_time->Resize(120, 48);          // widget's width and height
+        UILabel_time->SetViewId("label3");// Set style
+        UILabel_time->SetStyle(STYLE_TEXT_FONT, 40);
+        // Set additional property
+        UILabel_time->SetText(time_buf);
+        UILabel_time->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+        UILabel_time->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        UILabel_time->SetRollSpeed(0);
+        UILabel_time->SetFont(GILROY_BOLD_FONT, 40);
+        UILabel_time->SetVisible(true);
+
+        osStatus_t retTimer;
+        Chargeing_timer = osTimerNew((osTimerFunc_t)Chargeing_Timer_CallBack, osTimerPeriodic, NULL, NULL);
+        retTimer = osTimerStart(Chargeing_timer, 1000*1);
+        if (retTimer != osOK && Chargeing_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "StartCallTimer osTimerStart failed,  ret = %lx!!", retTimer);
+            osTimerDelete(Chargeing_timer);
+            Chargeing_timer = NULL;
+        }
+        
+       
+
+        UIViewGroup_charge->Add(image_lightning);
+        UIViewGroup_charge->Add(image_circle);
+
+       
+
+        UIViewGroup_charge->Add(circleProgress1_);
+
+        UIViewGroup_charge->Add(UILabel_time);
+        UIViewGroup_charge->Add(UILabel_power);
+        UIViewGroup_charge->Add(UILabel_Chargeing);
+
+        return UIViewGroup_charge;
+    }
+
 
     static void FreeImagePathsArray(const char **imagePaths, const int numImages)
     {
@@ -214,6 +438,9 @@ namespace OHOS
             return ;
         }
         ShutDownImageAnimatorView->Start();
+
+        start_shutdown_or_reboot();
+        shutdown_reboot_prejobs();
         
     }
 
@@ -317,6 +544,8 @@ namespace OHOS
         {
             group->SetVisible(true);
             ShutDownImageAnimatorView->Start();
+            start_shutdown_or_reboot();
+            shutdown_reboot_prejobs();
         }
         return UIViewGroup_lowpower;
     }
@@ -354,6 +583,10 @@ namespace OHOS
             }
            
         }
+        if(strcmp(view.GetViewId(),CHARGE_GROUP)==0)
+        {
+            NotificationManager::GetInstance()->StopNotify();
+        }
         return true;
         UNUSED(event);
     }
index c912dd3..4f1ab43 100755 (executable)
@@ -47,6 +47,7 @@ void NotificationManager::FreeNotifyViews()
     
     FreeFindWatchView();
     FreelowPower();
+    FreeChargePower();
     FreeDrinkReminderView();
     FreeSedentaryReminderView();
     FreeMessageView();
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Ellipse 37.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Ellipse 37.bin
new file mode 100644 (file)
index 0000000..95dbe8b
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6a204fd28436ee8ec2e7cc05f33bb242018a20bd4f7f384d1c86a6e5e9475895
+size 31128
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/solar-energy 1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/solar-energy 1.bin
new file mode 100644 (file)
index 0000000..40bdda9
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:056331d571d3c726b2fb4230b2139614c5a8583eb830de9daa03caf1948bc721
+size 2424