Browse Source

E3V2 DWIN Advanced Settings (#21534)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Miguel Risco-Castillo 3 years ago
parent
commit
13f3ccb85d
No account linked to committer's email address

+ 357
- 29
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

@@ -154,18 +154,20 @@ typedef struct {
154 154
 
155 155
 select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
156 156
          , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
157
-         , select_PLA{0}, select_ABS{0}
157
+         , select_advset{0}, select_PLA{0}, select_ABS{0}
158 158
          , select_speed{0}
159 159
          , select_acc{0}
160 160
          , select_jerk{0}
161 161
          , select_step{0}
162
+         , select_item{0}
162 163
          ;
163 164
 
164 165
 uint8_t index_file     = MROWS,
165 166
         index_prepare  = MROWS,
166 167
         index_control  = MROWS,
167 168
         index_leveling = MROWS,
168
-        index_tune     = MROWS;
169
+        index_tune     = MROWS,
170
+        index_advset   = MROWS;
169 171
 
170 172
 bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home
171 173
 
@@ -462,12 +464,21 @@ void Erase_Menu_Text(const uint8_t line) {
462 464
   DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28);
463 465
 }
464 466
 
465
-void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr) {
467
+void Draw_Menu_Item(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) {
466 468
   if (label) DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, LBLX, MBASE(line) - 1, (char*)label);
467 469
   if (icon) Draw_Menu_Icon(line, icon);
470
+  if (more) Draw_More_Icon(line);
471
+}
472
+
473
+void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) {
474
+  Draw_Menu_Item(line, icon, label, more);
468 475
   DWIN_Draw_Line(Line_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 34);
469 476
 }
470 477
 
478
+void Draw_Chkb_Line(const uint8_t line, const bool mode) {
479
+  DWIN_Draw_Checkbox(Color_White, Color_Bg_Black, 225, MBASE(line) - 1, mode);
480
+}
481
+
471 482
 // The "Back" label is always on the first line
472 483
 void Draw_Back_Label() {
473 484
   if (HMI_IsChinese())
@@ -516,7 +527,8 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr
516 527
 #define CONTROL_CASE_SAVE  (CONTROL_CASE_MOVE + ENABLED(EEPROM_SETTINGS))
517 528
 #define CONTROL_CASE_LOAD  (CONTROL_CASE_SAVE + ENABLED(EEPROM_SETTINGS))
518 529
 #define CONTROL_CASE_RESET (CONTROL_CASE_LOAD + ENABLED(EEPROM_SETTINGS))
519
-#define CONTROL_CASE_INFO  (CONTROL_CASE_RESET + 1)
530
+#define CONTROL_CASE_ADVSET (CONTROL_CASE_RESET + 1)
531
+#define CONTROL_CASE_INFO  (CONTROL_CASE_ADVSET + 1)
520 532
 #define CONTROL_CASE_TOTAL CONTROL_CASE_INFO
521 533
 
522 534
 #define TUNE_CASE_SPEED 1
@@ -539,6 +551,13 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr
539 551
 #define PREHEAT_CASE_SAVE (PREHEAT_CASE_FAN + ENABLED(EEPROM_SETTINGS))
540 552
 #define PREHEAT_CASE_TOTAL PREHEAT_CASE_SAVE
541 553
 
554
+#define ADVSET_CASE_HOMEOFF   1
555
+#define ADVSET_CASE_PROBEOFF  (ADVSET_CASE_HOMEOFF + ENABLED(HAS_ONESTEP_LEVELING))
556
+#define ADVSET_CASE_HEPID     (ADVSET_CASE_PROBEOFF + ENABLED(HAS_HOTEND))
557
+#define ADVSET_CASE_BEDPID    (ADVSET_CASE_HEPID + ENABLED(HAS_HEATED_BED))
558
+#define ADVSET_CASE_PWRLOSSR  (ADVSET_CASE_BEDPID + ENABLED(POWER_LOSS_RECOVERY))
559
+#define ADVSET_CASE_TOTAL     ADVSET_CASE_PWRLOSSR
560
+
542 561
 //
543 562
 // Draw Menus
544 563
 //
@@ -770,26 +789,36 @@ void Draw_Control_Menu() {
770 789
       DWIN_Frame_TitleCopy(1, 128, 2, 176, 12);                                         // "Control"
771 790
     #endif
772 791
     #ifdef USE_STRING_TITLES
773
-      DWIN_Draw_Label(CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE));
774
-      DWIN_Draw_Label(CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION));
792
+      if (CVISI(CONTROL_CASE_TEMP)) DWIN_Draw_Label(CLINE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE));
793
+      if (CVISI(CONTROL_CASE_MOVE)) DWIN_Draw_Label(CLINE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION));
775 794
       #if ENABLED(EEPROM_SETTINGS)
776
-        DWIN_Draw_Label(CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM));
777
-        DWIN_Draw_Label(CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM));
778
-        DWIN_Draw_Label(CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS));
795
+        if (CVISI(CONTROL_CASE_SAVE)) DWIN_Draw_Label(CLINE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM));
796
+        if (CVISI(CONTROL_CASE_LOAD)) DWIN_Draw_Label(CLINE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM));
797
+        if (CVISI(CONTROL_CASE_RESET)) DWIN_Draw_Label(CLINE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS));
779 798
       #endif
780 799
     #else
781
-      DWIN_Frame_AreaCopy(1,  1, 89,  83, 101, LBLX, CLINE(CONTROL_CASE_TEMP));           // Temperature >
782
-      DWIN_Frame_AreaCopy(1, 84, 89, 128,  99, LBLX, CLINE(CONTROL_CASE_MOVE));           // Motion >
800
+      if (CVISI(CONTROL_CASE_TEMP)) DWIN_Frame_AreaCopy(1,  1, 89,  83, 101, LBLX, CLINE(CONTROL_CASE_TEMP));           // Temperature >
801
+      if (CVISI(CONTROL_CASE_MOVE)) DWIN_Frame_AreaCopy(1, 84, 89, 128,  99, LBLX, CLINE(CONTROL_CASE_MOVE));           // Motion >
783 802
       #if ENABLED(EEPROM_SETTINGS)
784
-        DWIN_Frame_AreaCopy(1, 148,  89, 268, 101, LBLX     , CLINE(CONTROL_CASE_SAVE));  // "Store Configuration"
785
-        DWIN_Frame_AreaCopy(1,  26, 104,  57, 114, LBLX     , CLINE(CONTROL_CASE_LOAD));  // "Read"
786
-        DWIN_Frame_AreaCopy(1, 182,  89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD));  // "Configuration"
787
-        DWIN_Frame_AreaCopy(1,  59, 104,  93, 114, LBLX     , CLINE(CONTROL_CASE_RESET)); // "Reset"
788
-        DWIN_Frame_AreaCopy(1, 182,  89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration"
803
+        if (CVISI(CONTROL_CASE_SAVE)) DWIN_Frame_AreaCopy(1, 148,  89, 268, 101, LBLX     , CLINE(CONTROL_CASE_SAVE));  // "Store Configuration"
804
+        if (CVISI(CONTROL_CASE_LOAD)) {
805
+          DWIN_Frame_AreaCopy(1,  26, 104,  57, 114, LBLX     , CLINE(CONTROL_CASE_LOAD));  // "Read"
806
+          DWIN_Frame_AreaCopy(1, 182,  89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD));  // "Configuration"
807
+        }
808
+        if (CVISI(CONTROL_CASE_RESET)) {
809
+          DWIN_Frame_AreaCopy(1,  59, 104,  93, 114, LBLX     , CLINE(CONTROL_CASE_RESET)); // "Reset"
810
+          DWIN_Frame_AreaCopy(1, 182,  89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration"
811
+        }
789 812
       #endif
790 813
     #endif
791 814
   }
792 815
 
816
+  if (CVISI(CONTROL_CASE_ADVSET)) {
817
+    DWIN_Draw_Label(CLINE(CONTROL_CASE_ADVSET), GET_TEXT_F(MSG_ADVANCED_SETTINGS));  // Advanced Settings
818
+    Draw_More_Icon(CSCROL(CONTROL_CASE_ADVSET));
819
+    Draw_Menu_Line(CSCROL(CONTROL_CASE_ADVSET), ICON_AdvSet);
820
+  }
821
+
793 822
   if (CVISI(CONTROL_CASE_INFO)) Item_Control_Info(CLINE(CONTROL_CASE_INFO));
794 823
 
795 824
   if (select_control.now && CVISI(select_control.now))
@@ -1785,7 +1814,7 @@ void Draw_SDItem(const uint16_t item, int16_t row=-1) {
1785 1814
 
1786 1815
 #if ENABLED(SCROLL_LONG_FILENAMES)
1787 1816
 
1788
-  void Draw_SDItem_Shifted(int8_t &shift) {
1817
+  void Draw_SDItem_Shifted(uint8_t &shift) {
1789 1818
     // Limit to the number of chars past the cutoff
1790 1819
     const size_t len = strlen(shift_name);
1791 1820
     NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U));
@@ -2060,7 +2089,7 @@ void HMI_SelectFile() {
2060 2089
         if (ELAPSED(ms, shift_ms)) {
2061 2090
           const bool was_reset = shift_amt < 0;
2062 2091
           shift_ms = ms + 375UL + was_reset * 250UL;  // ms per character
2063
-          int8_t shift_new = shift_amt + 1;           // Try to shift by...
2092
+          uint8_t shift_new = shift_amt + 1;           // Try to shift by...
2064 2093
           Draw_SDItem_Shifted(shift_new);             // Draw the item
2065 2094
           if (!was_reset && shift_new == 0)           // Was it limited to 0?
2066 2095
             shift_ms = 0;                             // No scrolling needed
@@ -2331,6 +2360,60 @@ void Draw_Move_Menu() {
2331 2360
   LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MoveX + i);
2332 2361
 }
2333 2362
 
2363
+void Draw_AdvSet_Menu() {
2364
+  Clear_Main_Window();
2365
+
2366
+  #if ADVSET_CASE_TOTAL >= 6
2367
+    const int16_t scroll = MROWS - index_advset; // Scrolled-up lines
2368
+    #define ASCROL(L) (scroll + (L))
2369
+  #else
2370
+    #define ASCROL(L) (L)
2371
+  #endif
2372
+
2373
+  #define AVISI(L)  WITHIN(ASCROL(L), 0, MROWS)
2374
+
2375
+  Draw_Title(GET_TEXT_F(MSG_ADVANCED_SETTINGS));
2376
+
2377
+  if (AVISI(0)) Draw_Back_First(select_advset.now == 0);
2378
+  if (AVISI(ADVSET_CASE_HOMEOFF)) Draw_Menu_Line(ASCROL(ADVSET_CASE_HOMEOFF), ICON_HomeOff, GET_TEXT(MSG_SET_HOME_OFFSETS),true);  // Home Offset >
2379
+  #if HAS_ONESTEP_LEVELING
2380
+    if (AVISI(ADVSET_CASE_PROBEOFF)) Draw_Menu_Line(ASCROL(ADVSET_CASE_PROBEOFF), ICON_ProbeOff, GET_TEXT(MSG_ZPROBE_OFFSETS),true);  // Probe Offset >
2381
+  #endif
2382
+  if (AVISI(ADVSET_CASE_HEPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_HEPID), ICON_PIDNozzle, "Hotend PID", false);  // Nozzle PID
2383
+  if (AVISI(ADVSET_CASE_BEDPID)) Draw_Menu_Line(ASCROL(ADVSET_CASE_BEDPID), ICON_PIDbed, "Bed PID", false);  // Bed PID
2384
+  if (AVISI(ADVSET_CASE_PWRLOSSR)) {
2385
+    Draw_Menu_Line(ASCROL(ADVSET_CASE_PWRLOSSR), ICON_Motion, "Power-loss recovery", false);  // Power-loss recovery
2386
+    Draw_Chkb_Line(ASCROL(ADVSET_CASE_PWRLOSSR), recovery.enabled);
2387
+  }
2388
+  if (select_advset.now) Draw_Menu_Cursor(ASCROL(select_advset.now));
2389
+}
2390
+
2391
+void Draw_HomeOff_Menu() {
2392
+  Clear_Main_Window();
2393
+  Draw_Title(GET_TEXT_F(MSG_SET_HOME_OFFSETS));                 // Home Offsets
2394
+  Draw_Back_First(select_item.now == 0);
2395
+  Draw_Menu_Line(1, ICON_HomeOffX, GET_TEXT(MSG_HOME_OFFSET_X));  // Home X Offset
2396
+  DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Home_OffX_scaled);
2397
+  Draw_Menu_Line(2, ICON_HomeOffY, GET_TEXT(MSG_HOME_OFFSET_Y));  // Home Y Offset
2398
+  DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Home_OffY_scaled);
2399
+  Draw_Menu_Line(3, ICON_HomeOffZ, GET_TEXT(MSG_HOME_OFFSET_Z));  // Home Y Offset
2400
+  DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Home_OffZ_scaled);
2401
+  if (select_item.now) Draw_Menu_Cursor(select_item.now);
2402
+}
2403
+
2404
+#if HAS_ONESTEP_LEVELING
2405
+  void Draw_ProbeOff_Menu() {
2406
+    Clear_Main_Window();
2407
+    Draw_Title(GET_TEXT_F(MSG_ZPROBE_OFFSETS));                 // Probe Offsets
2408
+    Draw_Back_First(select_item.now == 0);
2409
+    Draw_Menu_Line(1, ICON_ProbeOffX, GET_TEXT(MSG_ZPROBE_XOFFSET));  // Probe X Offset
2410
+    DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Probe_OffX_scaled);
2411
+    Draw_Menu_Line(2, ICON_ProbeOffY, GET_TEXT(MSG_ZPROBE_YOFFSET));  // Probe Y Offset
2412
+    DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Probe_OffY_scaled);
2413
+    if (select_item.now) Draw_Menu_Cursor(select_item.now);
2414
+  }
2415
+#endif
2416
+
2334 2417
 #include "../../../libs/buzzer.h"
2335 2418
 
2336 2419
 void HMI_AudioFeedback(const bool success=true) {
@@ -2566,14 +2649,20 @@ void HMI_Control() {
2566 2649
     if (select_control.inc(1 + CONTROL_CASE_TOTAL)) {
2567 2650
       if (select_control.now > MROWS && select_control.now > index_control) {
2568 2651
         index_control = select_control.now;
2652
+
2653
+        // Scroll up and draw a blank bottom line
2569 2654
         Scroll_Menu(DWIN_SCROLL_UP);
2570
-        Draw_Menu_Icon(MROWS, ICON_Temperature + index_control - 1);
2571
-        Draw_More_Icon(CONTROL_CASE_TEMP + MROWS - index_control); // Temperature >
2572
-        Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion >
2573
-        if (index_control > MROWS) {
2574
-          Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info >
2575
-          Item_Control_Info(MBASE(CONTROL_CASE_INFO - 1));
2655
+
2656
+        switch (index_control) {  // Last menu items
2657
+          case CONTROL_CASE_ADVSET:  // Advance Settings >
2658
+            Draw_Menu_Item(MROWS, ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), true);
2659
+            break;
2660
+          case CONTROL_CASE_INFO:    // Info >
2661
+            Draw_Menu_Item(MROWS, ICON_Info, GET_TEXT(MSG_INFO_SCREEN), true);
2662
+            break;
2663
+          default: break;
2576 2664
         }
2665
+
2577 2666
       }
2578 2667
       else {
2579 2668
         Move_Highlight(1, select_control.now + MROWS - index_control);
@@ -2585,12 +2674,17 @@ void HMI_Control() {
2585 2674
       if (select_control.now < index_control - MROWS) {
2586 2675
         index_control--;
2587 2676
         Scroll_Menu(DWIN_SCROLL_DOWN);
2588
-        if (index_control == MROWS)
2677
+        switch (index_control) {  // First menu items
2678
+          case MROWS :
2589 2679
           Draw_Back_First();
2590
-        else
2591
-          Draw_Menu_Line(0, ICON_Temperature + select_control.now - 1);
2592
-        Draw_More_Icon(0 + MROWS - index_control + 1); // Temperature >
2593
-        Draw_More_Icon(1 + MROWS - index_control + 1); // Motion >
2680
+            break;
2681
+          case MROWS + 1: // Temperature >
2682
+            Draw_Menu_Line(0, ICON_Temperature, GET_TEXT(MSG_TEMPERATURE), true);
2683
+            break;
2684
+          case MROWS + 2: // Move >
2685
+            Draw_Menu_Line(0, ICON_Motion, GET_TEXT(MSG_MOTION), true);
2686
+          default: break;
2687
+        }
2594 2688
       }
2595 2689
       else {
2596 2690
         Move_Highlight(-1, select_control.now + MROWS - index_control);
@@ -2628,6 +2722,11 @@ void HMI_Control() {
2628 2722
           HMI_AudioFeedback();
2629 2723
           break;
2630 2724
       #endif
2725
+      case CONTROL_CASE_ADVSET: // Advance Settings
2726
+        checkkey = AdvSet;
2727
+        select_advset.reset();
2728
+        Draw_AdvSet_Menu();
2729
+        break;
2631 2730
       case CONTROL_CASE_INFO: // Info
2632 2731
         checkkey = Info;
2633 2732
         Draw_Info_Menu();
@@ -3227,6 +3326,217 @@ void HMI_Motion() {
3227 3326
   DWIN_UpdateLCD();
3228 3327
 }
3229 3328
 
3329
+/* Advanced Settings */
3330
+void HMI_AdvSet() {
3331
+  ENCODER_DiffState encoder_diffState = get_encoder_state();
3332
+  if (encoder_diffState == ENCODER_DIFF_NO) return;
3333
+
3334
+  // Avoid flicker by updating only the previous menu
3335
+  if (encoder_diffState == ENCODER_DIFF_CW) {
3336
+    if (select_advset.inc(1 + ADVSET_CASE_TOTAL)) {
3337
+      if (select_advset.now > MROWS && select_advset.now > index_advset) {
3338
+        index_advset = select_advset.now;
3339
+
3340
+        // Scroll up and draw a blank bottom line
3341
+        Scroll_Menu(DWIN_SCROLL_UP);
3342
+
3343
+        //switch (index_advset) {  // Redraw last menu items
3344
+        //  default: break;
3345
+        //}
3346
+
3347
+      }
3348
+      else {
3349
+        Move_Highlight(1, select_advset.now + MROWS - index_advset);
3350
+      }
3351
+    }
3352
+  }
3353
+  else if (encoder_diffState == ENCODER_DIFF_CCW) {
3354
+    if (select_advset.dec()) {
3355
+      if (select_advset.now < index_advset - MROWS) {
3356
+        index_advset--;
3357
+        Scroll_Menu(DWIN_SCROLL_DOWN);
3358
+
3359
+        //switch (index_advset) {  // Redraw first menu items
3360
+        //  default: break;
3361
+        //}
3362
+      }
3363
+      else {
3364
+        Move_Highlight(-1, select_advset.now + MROWS - index_advset);
3365
+      }
3366
+    }
3367
+  }
3368
+  else if (encoder_diffState == ENCODER_DIFF_ENTER) {
3369
+    switch (select_advset.now) {
3370
+      case 0: // Back
3371
+        checkkey = Control;
3372
+        select_control.set(CONTROL_CASE_ADVSET);
3373
+        index_control = CONTROL_CASE_ADVSET;
3374
+        Draw_Control_Menu();
3375
+        break;
3376
+
3377
+      #if HAS_HOME_OFFSET
3378
+        case ADVSET_CASE_HOMEOFF:   // Home Offsets
3379
+          checkkey = HomeOff;
3380
+          select_item.reset();
3381
+          HMI_ValueStruct.Home_OffX_scaled = home_offset[X_AXIS] * 10;
3382
+          HMI_ValueStruct.Home_OffY_scaled = home_offset[Y_AXIS] * 10;
3383
+          HMI_ValueStruct.Home_OffZ_scaled = home_offset[Z_AXIS] * 10;
3384
+          Draw_HomeOff_Menu();
3385
+          break;
3386
+      #endif
3387
+
3388
+      #if HAS_ONESTEP_LEVELING
3389
+        case ADVSET_CASE_PROBEOFF:   // Probe Offsets
3390
+          checkkey = ProbeOff;
3391
+          select_item.reset();
3392
+          HMI_ValueStruct.Probe_OffX_scaled = probe.offset.x * 10;
3393
+          HMI_ValueStruct.Probe_OffY_scaled = probe.offset.y * 10;
3394
+          Draw_ProbeOff_Menu();
3395
+          break;
3396
+      #endif
3397
+
3398
+      #if HAS_HOTEND
3399
+        case ADVSET_CASE_HEPID:   // Nozzle PID Autotune
3400
+          thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
3401
+          thermalManager.PID_autotune(ui.material_preset[0].hotend_temp, H_E0, 10, true);
3402
+          break;
3403
+      #endif
3404
+
3405
+      #if HAS_HEATED_BED
3406
+        case ADVSET_CASE_BEDPID:  // Bed PID Autotune
3407
+          thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
3408
+          thermalManager.PID_autotune(ui.material_preset[0].bed_temp, H_BED, 10, true);
3409
+          break;
3410
+      #endif
3411
+
3412
+      case ADVSET_CASE_PWRLOSSR:  // Power-loss recovery
3413
+        recovery.enable(!recovery.enabled);
3414
+        Draw_Chkb_Line(ADVSET_CASE_PWRLOSSR + MROWS - index_advset, recovery.enabled);
3415
+        break;
3416
+      default: break;
3417
+    }
3418
+  }
3419
+  DWIN_UpdateLCD();
3420
+}
3421
+
3422
+#if HAS_HOME_OFFSET
3423
+
3424
+  /* Home Offset */
3425
+  void HMI_HomeOff() {
3426
+    ENCODER_DiffState encoder_diffState = get_encoder_state();
3427
+    if (encoder_diffState == ENCODER_DIFF_NO) return;
3428
+
3429
+    // Avoid flicker by updating only the previous menu
3430
+    if (encoder_diffState == ENCODER_DIFF_CW) {
3431
+      if (select_item.inc(1 + 3)) Move_Highlight(1, select_item.now);
3432
+    }
3433
+    else if (encoder_diffState == ENCODER_DIFF_CCW) {
3434
+      if (select_item.dec()) Move_Highlight(-1, select_item.now);
3435
+    }
3436
+    else if (encoder_diffState == ENCODER_DIFF_ENTER) {
3437
+      switch (select_item.now) {
3438
+        case 0: // Back
3439
+          checkkey = AdvSet;
3440
+          select_advset.set(ADVSET_CASE_HOMEOFF);
3441
+          Draw_AdvSet_Menu();
3442
+          break;
3443
+        case 1: // Home Offset X
3444
+          checkkey = HomeOffX;
3445
+          DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Home_OffX_scaled);
3446
+          EncoderRate.enabled = true;
3447
+          break;
3448
+        case 2: // Home Offset Y
3449
+          checkkey = HomeOffY;
3450
+          DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Home_OffY_scaled);
3451
+          EncoderRate.enabled = true;
3452
+          break;
3453
+        case 3: // Home Offset Z
3454
+          checkkey = HomeOffZ;
3455
+          DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Home_OffZ_scaled);
3456
+          EncoderRate.enabled = true;
3457
+          break;
3458
+        default: break;
3459
+      }
3460
+    }
3461
+    DWIN_UpdateLCD();
3462
+  }
3463
+
3464
+  void HMI_HomeOffN(float &posScaled, const_float_t lo, const_float_t hi) {
3465
+    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3466
+    if (encoder_diffState != ENCODER_DIFF_NO) {
3467
+      if (Apply_Encoder(encoder_diffState, posScaled)) {
3468
+        checkkey = HomeOff;
3469
+        EncoderRate.enabled = false;
3470
+        set_home_offset(X_AXIS, posScaled / 10);
3471
+        DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(select_item.now), posScaled);
3472
+        return;
3473
+      }
3474
+      LIMIT(posScaled, lo, hi);
3475
+      DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(select_item.now), posScaled);
3476
+    }
3477
+  }
3478
+
3479
+  void HMI_HomeOffX() { HMI_HomeOffN(HMI_ValueStruct.Home_OffX_scaled, -500, 500); }
3480
+  void HMI_HomeOffY() { HMI_HomeOffN(HMI_ValueStruct.Home_OffY_scaled, -500, 500); }
3481
+  void HMI_HomeOffZ() { HMI_HomeOffN(HMI_ValueStruct.Home_OffZ_scaled,  -20,  20); }
3482
+
3483
+#endif // HAS_HOME_OFFSET
3484
+
3485
+#if HAS_ONESTEP_LEVELING
3486
+  /*Probe Offset */
3487
+  void HMI_ProbeOff() {
3488
+    ENCODER_DiffState encoder_diffState = get_encoder_state();
3489
+    if (encoder_diffState == ENCODER_DIFF_NO) return;
3490
+
3491
+    // Avoid flicker by updating only the previous menu
3492
+    if (encoder_diffState == ENCODER_DIFF_CW) {
3493
+      if (select_item.inc(1 + 2)) Move_Highlight(1, select_item.now);
3494
+    }
3495
+    else if (encoder_diffState == ENCODER_DIFF_CCW) {
3496
+      if (select_item.dec()) Move_Highlight(-1, select_item.now);
3497
+    }
3498
+    else if (encoder_diffState == ENCODER_DIFF_ENTER) {
3499
+      switch (select_item.now) {
3500
+        case 0: // Back
3501
+          checkkey = AdvSet;
3502
+          select_advset.set(ADVSET_CASE_PROBEOFF);
3503
+          Draw_AdvSet_Menu();
3504
+          break;
3505
+        case 1: // Probe Offset X
3506
+          checkkey = ProbeOffX;
3507
+          DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Probe_OffX_scaled);
3508
+          EncoderRate.enabled = true;
3509
+          break;
3510
+        case 2: // Probe Offset X
3511
+          checkkey = ProbeOffY;
3512
+          DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Probe_OffY_scaled);
3513
+          EncoderRate.enabled = true;
3514
+          break;
3515
+      }
3516
+    }
3517
+    DWIN_UpdateLCD();
3518
+  }
3519
+
3520
+  void HMI_ProbeOffN(float &posScaled, float &offset_ref) {
3521
+    ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
3522
+    if (encoder_diffState != ENCODER_DIFF_NO) {
3523
+      if (Apply_Encoder(encoder_diffState, posScaled)) {
3524
+        checkkey = ProbeOff;
3525
+        EncoderRate.enabled = false;
3526
+        offset_ref = posScaled / 10;
3527
+        DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(select_item.now), posScaled);
3528
+        return;
3529
+      }
3530
+      LIMIT(posScaled, -500, 500);
3531
+      DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, UNITFDIGITS, 216, MBASE(select_item.now), posScaled);
3532
+    }
3533
+  }
3534
+
3535
+  void HMI_ProbeOffX() { HMI_ProbeOffN(HMI_ValueStruct.Probe_OffX_scaled, probe.offset.x); }
3536
+  void HMI_ProbeOffY() { HMI_ProbeOffN(HMI_ValueStruct.Probe_OffY_scaled, probe.offset.y); }
3537
+
3538
+#endif // HAS_ONESTEP_LEVELING
3539
+
3230 3540
 /* Info */
3231 3541
 void HMI_Info() {
3232 3542
   ENCODER_DiffState encoder_diffState = get_encoder_state();
@@ -3735,6 +4045,18 @@ void DWIN_HandleScreen() {
3735 4045
     case AxisMove:        HMI_AxisMove(); break;
3736 4046
     case TemperatureID:   HMI_Temperature(); break;
3737 4047
     case Motion:          HMI_Motion(); break;
4048
+    case AdvSet:          HMI_AdvSet(); break;
4049
+    #if HAS_HOME_OFFSET
4050
+      case HomeOff:       HMI_HomeOff(); break;
4051
+      case HomeOffX:      HMI_HomeOffX(); break;
4052
+      case HomeOffY:      HMI_HomeOffY(); break;
4053
+      case HomeOffZ:      HMI_HomeOffZ(); break;
4054
+    #endif
4055
+    #if HAS_ONESTEP_LEVELING
4056
+      case ProbeOff:      HMI_ProbeOff(); break;
4057
+      case ProbeOffX:     HMI_ProbeOffX(); break;
4058
+      case ProbeOffY:     HMI_ProbeOffY(); break;
4059
+    #endif
3738 4060
     case Info:            HMI_Info(); break;
3739 4061
     case Tune:            HMI_Tune(); break;
3740 4062
     #if HAS_PREHEAT
@@ -3801,4 +4123,10 @@ void DWIN_StatusChanged(const char *text) {
3801 4123
   DWIN_UpdateLCD();
3802 4124
 }
3803 4125
 
4126
+// GUI extension
4127
+void DWIN_Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool mode=false) {
4128
+  DWIN_Draw_String(false,true,font8x16,Select_Color,bcolor,x+4,y,F(mode ? "x" : " "));
4129
+  DWIN_Draw_Rectangle(0,color,x+2,y+2,x+17,y+17);
4130
+}
4131
+
3804 4132
 #endif // DWIN_CREALITY_LCD

+ 27
- 0
Marlin/src/lcd/dwin/e3v2/dwin.h View File

@@ -63,10 +63,20 @@ enum processID : uint8_t {
63 63
   MaxJerk_value,
64 64
   Step,
65 65
   Step_value,
66
+  HomeOff,
67
+  HomeOffX,
68
+  HomeOffY,
69
+  HomeOffZ,
66 70
 
67 71
   // Last Process ID
68 72
   Last_Prepare,
69 73
 
74
+  // Advance Settings
75
+  AdvSet,
76
+  ProbeOff,
77
+  ProbeOffX,
78
+  ProbeOffY,
79
+
70 80
   // Back Process ID
71 81
   Back_Main,
72 82
   Back_Print,
@@ -197,6 +207,17 @@ enum processID : uint8_t {
197 207
 #define ICON_Info_0               90
198 208
 #define ICON_Info_1               91
199 209
 
210
+#define ICON_AdvSet               ICON_Language
211
+#define ICON_HomeOff              ICON_AdvSet
212
+#define ICON_HomeOffX             ICON_StepX
213
+#define ICON_HomeOffY             ICON_StepY
214
+#define ICON_HomeOffZ             ICON_StepZ
215
+#define ICON_ProbeOff             ICON_AdvSet
216
+#define ICON_ProbeOffX            ICON_StepX
217
+#define ICON_ProbeOffY            ICON_StepY
218
+#define ICON_PIDNozzle            ICON_SetEndTemp
219
+#define ICON_PIDbed               ICON_SetBedTemp
220
+
200 221
 /**
201 222
  * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
202 223
  * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
@@ -256,6 +277,11 @@ typedef struct {
256 277
   #endif
257 278
   float offset_value      = 0;
258 279
   int8_t show_mode        = 0; // -1: Temperature control    0: Printing temperature
280
+  float Home_OffX_scaled  = 0;
281
+  float Home_OffY_scaled  = 0;
282
+  float Home_OffZ_scaled  = 0;
283
+  float Probe_OffX_scaled = 0;
284
+  float Probe_OffY_scaled = 0;
259 285
 } HMI_value_t;
260 286
 
261 287
 #define DWIN_CHINESE 123
@@ -378,6 +404,7 @@ void DWIN_Update();
378 404
 void EachMomentUpdate();
379 405
 void DWIN_HandleScreen();
380 406
 void DWIN_StatusChanged(const char *text);
407
+void DWIN_Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool mode /* = false*/);
381 408
 
382 409
 inline void DWIN_StartHoming() { HMI_flag.home_flag = true; }
383 410
 

+ 3
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -82,6 +82,9 @@ namespace Language_en {
82 82
   PROGMEM Language_Str MSG_LEVEL_BED_DONE                  = _UxGT("Leveling Done!");
83 83
   PROGMEM Language_Str MSG_Z_FADE_HEIGHT                   = _UxGT("Fade Height");
84 84
   PROGMEM Language_Str MSG_SET_HOME_OFFSETS                = _UxGT("Set Home Offsets");
85
+  PROGMEM Language_Str MSG_HOME_OFFSET_X                   = _UxGT("Home Offset X");
86
+  PROGMEM Language_Str MSG_HOME_OFFSET_Y                   = _UxGT("Home Offset Y");
87
+  PROGMEM Language_Str MSG_HOME_OFFSET_Z                   = _UxGT("Home Offset Z");
85 88
   PROGMEM Language_Str MSG_HOME_OFFSETS_APPLIED            = _UxGT("Offsets Applied");
86 89
   PROGMEM Language_Str MSG_SET_ORIGIN                      = _UxGT("Set Origin");
87 90
   PROGMEM Language_Str MSG_ASSISTED_TRAMMING               = _UxGT("Assisted Tramming");

+ 2
- 1
buildroot/tests/STM32F103RET6_creality View File

@@ -16,7 +16,8 @@ exec_test $1 $2 "Ender 3 v2" "$3"
16 16
 use_example_configs "Creality/Ender-3 V2"
17 17
 opt_disable CLASSIC_JERK
18 18
 opt_add SDCARD_EEPROM_EMULATION
19
-exec_test $1 $2 "Ender 3 v2, SD EEPROM, w/o CLASSIC_JERK" "$3"
19
+opt_set TEMP_SENSOR_BED 0
20
+exec_test $1 $2 "Ender 3 v2, SD EEPROM, no CLASSIC_JERK, no Bed" "$3"
20 21
 
21 22
 restore_configs
22 23
 opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1

Loading…
Cancel
Save