Browse Source

Fix up E3 DWIN Power Panic

Scott Lahteine 3 years ago
parent
commit
169ec65e72
1 changed files with 22 additions and 37 deletions
  1. 22
    37
      Marlin/src/lcd/dwin/e3v2/dwin.cpp

+ 22
- 37
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

991
   if (HMI_IsChinese()) {
991
   if (HMI_IsChinese()) {
992
     DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135);
992
     DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135);
993
     DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192);
993
     DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192);
994
-    DWIN_ICON_Show(ICON, ICON_Continue_C, 26, 307);
995
-    DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307);
994
+    DWIN_ICON_Show(ICON, ICON_Cancel_C,    26, 307);
995
+    DWIN_ICON_Show(ICON, ICON_Continue_C, 146, 307);
996
   }
996
   }
997
   else {
997
   else {
998
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print"));
998
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 14) / 2, 115, F("Continue Print"));
999
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last"));
999
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 192, F("It looks like the last"));
1000
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted."));
1000
     DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, (272 - 8 * 22) / 2, 212, F("file was interrupted."));
1001
-    DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307);
1002
-    DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307);
1001
+    DWIN_ICON_Show(ICON, ICON_Cancel_E,    26, 307);
1002
+    DWIN_ICON_Show(ICON, ICON_Continue_E, 146, 307);
1003
   }
1003
   }
1004
 }
1004
 }
1005
 
1005
 
3597
   #if ENABLED(POWER_LOSS_RECOVERY)
3597
   #if ENABLED(POWER_LOSS_RECOVERY)
3598
     else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
3598
     else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
3599
       static bool recovery_flag = false;
3599
       static bool recovery_flag = false;
3600
-      recovery.dwin_flag = false;
3601
 
3600
 
3602
-      recovery.load();
3603
-      if (!recovery.valid()) return recovery.purge();
3601
+      recovery.dwin_flag = false;
3602
+      recovery_flag = true;
3604
 
3603
 
3605
-      auto draw_first_option = [](const bool sel) {
3604
+      auto update_selection = [&](const bool sel) {
3605
+        HMI_flag.select_flag = sel;
3606
         const uint16_t c1 = sel ? Color_Bg_Window : Select_Color;
3606
         const uint16_t c1 = sel ? Color_Bg_Window : Select_Color;
3607
         DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345);
3607
         DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345);
3608
         DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346);
3608
         DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346);
3609
-      };
3610
-
3611
-      auto update_selection = [&](const bool sel) {
3612
-        HMI_flag.select_flag = sel;
3613
-        draw_first_option(sel);
3614
         const uint16_t c2 = sel ? Select_Color : Color_Bg_Window;
3609
         const uint16_t c2 = sel ? Select_Color : Color_Bg_Window;
3615
         DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345);
3610
         DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345);
3616
         DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346);
3611
         DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346);
3617
       };
3612
       };
3618
 
3613
 
3619
-      const uint16_t fileCnt = card.get_num_Files();
3620
-      for (uint16_t i = 0; i < fileCnt; i++) {
3621
-        // TODO: Resume print via M1000 then update the UI
3622
-        // with the active filename which can come from CardReader.
3623
-        card.getfilename_sorted(SD_ORDER(i, fileCnt));
3624
-        if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file
3625
-          recovery_flag = true;
3626
-          HMI_flag.select_flag = true;
3627
-          Popup_Window_Resume();
3628
-          draw_first_option(false);
3629
-          char * const name = card.longest_filename();
3630
-          const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
3631
-          DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name);
3632
-          DWIN_UpdateLCD();
3633
-          break;
3634
-        }
3635
-      }
3614
+      Popup_Window_Resume();
3615
+      update_selection(true);
3636
 
3616
 
3637
-      // if hasn't resumable G-code file
3638
-      if (!recovery_flag) return;
3617
+      // TODO: Get the name of the current file from someplace
3618
+      //
3619
+      //(void)recovery.interrupted_file_exists();
3620
+      char * const name = card.longest_filename();
3621
+      const int8_t npos = _MAX(0U, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
3622
+      DWIN_Draw_String(false, true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name);
3623
+      DWIN_UpdateLCD();
3639
 
3624
 
3640
       while (recovery_flag) {
3625
       while (recovery_flag) {
3641
         ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3626
         ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3643
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
3628
           if (encoder_diffState == ENCODER_DIFF_ENTER) {
3644
             recovery_flag = false;
3629
             recovery_flag = false;
3645
             if (HMI_flag.select_flag) break;
3630
             if (HMI_flag.select_flag) break;
3646
-            TERN_(POWER_LOSS_RECOVERY, recovery.cancel());
3631
+            TERN_(POWER_LOSS_RECOVERY, queue.inject_P(PSTR("M1000C")));
3647
             HMI_StartFrame(true);
3632
             HMI_StartFrame(true);
3648
             return;
3633
             return;
3649
           }
3634
           }
3650
           else
3635
           else
3651
-            update_selection(encoder_diffState == ENCODER_DIFF_CCW);
3636
+            update_selection(encoder_diffState == ENCODER_DIFF_CW);
3652
 
3637
 
3653
           DWIN_UpdateLCD();
3638
           DWIN_UpdateLCD();
3654
         }
3639
         }
3656
 
3641
 
3657
       select_print.set(0);
3642
       select_print.set(0);
3658
       HMI_ValueStruct.show_mode = 0;
3643
       HMI_ValueStruct.show_mode = 0;
3659
-      HMI_StartFrame(false);
3660
-      recovery.resume();
3661
-      return;
3644
+      queue.inject_P(PSTR("M1000"));
3645
+      Goto_PrintProcess();
3646
+      Draw_Status_Area(true);
3662
     }
3647
     }
3663
   #endif
3648
   #endif
3664
   DWIN_UpdateLCD();
3649
   DWIN_UpdateLCD();

Loading…
Cancel
Save