Browse Source

✨ Ender-3 V2 CrealityUI Enhanced (#21942)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Miguel Risco-Castillo 2 years ago
parent
commit
0f61d9e4dd
No account linked to committer's email address
44 changed files with 6408 additions and 84 deletions
  1. 5
    0
      Marlin/Configuration.h
  2. 8
    5
      Marlin/src/MarlinCore.cpp
  3. 12
    1
      Marlin/src/feature/pause.cpp
  4. 1
    1
      Marlin/src/feature/powerloss.cpp
  5. 1
    1
      Marlin/src/feature/powerloss.h
  6. 3
    0
      Marlin/src/feature/runout.cpp
  7. 7
    10
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  8. 3
    0
      Marlin/src/gcode/bedlevel/mbl/G29.cpp
  9. 3
    0
      Marlin/src/gcode/bedlevel/ubl/M421.cpp
  10. 6
    5
      Marlin/src/gcode/calibrate/G28.cpp
  11. 6
    0
      Marlin/src/gcode/control/M997.cpp
  12. 6
    1
      Marlin/src/gcode/feature/powerloss/M1000.cpp
  13. 4
    0
      Marlin/src/gcode/lcd/M0_M1.cpp
  14. 21
    7
      Marlin/src/gcode/lcd/M73.cpp
  15. 3
    0
      Marlin/src/gcode/sd/M1001.cpp
  16. 16
    7
      Marlin/src/gcode/stats/M75-M78.cpp
  17. 3
    0
      Marlin/src/gcode/temp/M303.cpp
  18. 4
    1
      Marlin/src/inc/Conditionals_LCD.h
  19. 15
    3
      Marlin/src/inc/SanityCheck.h
  20. 0
    0
      Marlin/src/lcd/e3v2/README.md
  21. 6
    6
      Marlin/src/lcd/e3v2/creality/rotary_encoder.h
  22. 3529
    0
      Marlin/src/lcd/e3v2/enhanced/dwin.cpp
  23. 268
    0
      Marlin/src/lcd/e3v2/enhanced/dwin.h
  24. 564
    0
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp
  25. 282
    0
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h
  26. 452
    0
      Marlin/src/lcd/e3v2/enhanced/dwinui.cpp
  27. 623
    0
      Marlin/src/lcd/e3v2/enhanced/dwinui.h
  28. 69
    0
      Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp
  29. 35
    0
      Marlin/src/lcd/e3v2/enhanced/lockscreen.h
  30. 261
    0
      Marlin/src/lcd/e3v2/enhanced/rotary_encoder.cpp
  31. 93
    0
      Marlin/src/lcd/e3v2/enhanced/rotary_encoder.h
  32. 0
    3
      Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h
  33. 16
    1
      Marlin/src/lcd/language/language_en.h
  34. 4
    1
      Marlin/src/lcd/marlinui.cpp
  35. 16
    5
      Marlin/src/lcd/marlinui.h
  36. 1
    1
      Marlin/src/lcd/tft/ui_common.h
  37. 3
    1
      Marlin/src/module/probe.cpp
  38. 29
    11
      Marlin/src/module/settings.cpp
  39. 19
    10
      Marlin/src/module/temperature.cpp
  40. 1
    1
      Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h
  41. 3
    1
      Marlin/src/sd/cardreader.cpp
  42. 5
    0
      buildroot/tests/STM32F103RET6_creality
  43. 1
    0
      ini/features.ini
  44. 1
    1
      platformio.ini

+ 5
- 0
Marlin/Configuration.h View File

@@ -2757,6 +2757,11 @@
2757 2757
 //#define DWIN_CREALITY_LCD
2758 2758
 
2759 2759
 //
2760
+// Ender-3 v2 OEM display, enhanced.
2761
+//
2762
+//#define DWIN_CREALITY_LCD_ENHANCED
2763
+
2764
+//
2760 2765
 // Ender-3 v2 OEM display with enhancements by Jacob Myers
2761 2766
 //
2762 2767
 //#define DWIN_CREALITY_LCD_JYERSUI

+ 8
- 5
Marlin/src/MarlinCore.cpp View File

@@ -77,6 +77,9 @@
77 77
 #if ENABLED(DWIN_CREALITY_LCD)
78 78
   #include "lcd/e3v2/creality/dwin.h"
79 79
   #include "lcd/e3v2/creality/rotary_encoder.h"
80
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
81
+  #include "lcd/e3v2/enhanced/dwin.h"
82
+  #include "lcd/e3v2/enhanced/rotary_encoder.h"
80 83
 #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
81 84
   #include "lcd/e3v2/jyersui/dwin.h"
82 85
   #include "lcd/e3v2/jyersui/rotary_encoder.h"
@@ -849,7 +852,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
849 852
   TERN_(USE_BEEPER, buzzer.tick());
850 853
 
851 854
   // Handle UI input / draw events
852
-  TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
855
+  TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
853 856
 
854 857
   // Run i2c Position Encoders
855 858
   #if ENABLED(I2C_POSITION_ENCODERS)
@@ -904,7 +907,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
904 907
   // Echo the LCD message to serial for extra context
905 908
   if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
906 909
 
907
-  #if HAS_DISPLAY
910
+  #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
908 911
     ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
909 912
   #else
910 913
     UNUSED(lcd_error); UNUSED(lcd_component);
@@ -1315,7 +1318,7 @@ void setup() {
1315 1318
   // UI must be initialized before EEPROM
1316 1319
   // (because EEPROM code calls the UI).
1317 1320
 
1318
-  #if ENABLED(DWIN_CREALITY_LCD)
1321
+  #if HAS_DWIN_E3V2_BASIC
1319 1322
     SETUP_RUN(DWIN_Startup());
1320 1323
   #else
1321 1324
     SETUP_RUN(ui.init());
@@ -1590,7 +1593,7 @@ void setup() {
1590 1593
     SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n");
1591 1594
   #endif
1592 1595
 
1593
-  #if ENABLED(DWIN_CREALITY_LCD)
1596
+  #if HAS_DWIN_E3V2_BASIC
1594 1597
     Encoder_Configuration();
1595 1598
     HMI_Init();
1596 1599
     HMI_SetLanguageCache();
@@ -1598,7 +1601,7 @@ void setup() {
1598 1601
     DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG));
1599 1602
   #endif
1600 1603
 
1601
-  #if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD)
1604
+  #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
1602 1605
     ui.reset_status(true);  // Show service messages or keep current status
1603 1606
   #endif
1604 1607
 

+ 12
- 1
Marlin/src/feature/pause.cpp View File

@@ -53,6 +53,8 @@
53 53
 
54 54
 #if ENABLED(EXTENSIBLE_UI)
55 55
   #include "../lcd/extui/ui_api.h"
56
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
57
+  #include "../lcd/e3v2/enhanced/dwin.h"
56 58
 #endif
57 59
 
58 60
 #include "../lcd/marlinui.h"
@@ -242,6 +244,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
242 244
 
243 245
     TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE)));
244 246
     TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR));
247
+    TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT(MSG_FILAMENT_CHANGE_PURGE), CONTINUE_STR));
245 248
     wait_for_user = true; // A click or M108 breaks the purge_length loop
246 249
     for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
247 250
       unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
@@ -265,7 +268,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
265 268
           // Show "Purge More" / "Resume" menu and wait for reply
266 269
           KEEPALIVE_STATE(PAUSED_FOR_USER);
267 270
           wait_for_user = false;
268
-          #if HAS_LCD_MENU
271
+          #if EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD_ENHANCED)
269 272
             ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR
270 273
           #else
271 274
             pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
@@ -525,6 +528,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
525 528
 
526 529
       TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
527 530
 
531
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATING)));
532
+
528 533
       // Re-enable the heaters if they timed out
529 534
       HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);
530 535
 
@@ -538,8 +543,13 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
538 543
       const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);
539 544
 
540 545
       HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout);
546
+
541 547
       TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_REHEATDONE), CONTINUE_STR));
548
+
542 549
       TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_REHEATDONE)));
550
+
551
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status_P(GET_TEXT(MSG_REHEATDONE)));
552
+
543 553
       wait_for_user = true;
544 554
       nozzle_timed_out = false;
545 555
 
@@ -675,6 +685,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
675 685
 
676 686
   TERN_(HAS_STATUS_MESSAGE, ui.reset_status());
677 687
   TERN_(HAS_LCD_MENU, ui.return_to_status());
688
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, HMI_ReturnScreen());
678 689
 }
679 690
 
680 691
 #endif // ADVANCED_PAUSE_FEATURE

+ 1
- 1
Marlin/src/feature/powerloss.cpp View File

@@ -40,7 +40,7 @@ uint8_t PrintJobRecovery::queue_index_r;
40 40
 uint32_t PrintJobRecovery::cmd_sdpos, // = 0
41 41
          PrintJobRecovery::sdpos[BUFSIZE];
42 42
 
43
-#if ENABLED(DWIN_CREALITY_LCD)
43
+#if HAS_DWIN_E3V2_BASIC
44 44
   bool PrintJobRecovery::dwin_flag; // = false
45 45
 #endif
46 46
 

+ 1
- 1
Marlin/src/feature/powerloss.h View File

@@ -145,7 +145,7 @@ class PrintJobRecovery {
145 145
     static uint32_t cmd_sdpos,        //!< SD position of the next command
146 146
                     sdpos[BUFSIZE];   //!< SD positions of queued commands
147 147
 
148
-    #if ENABLED(DWIN_CREALITY_LCD)
148
+    #if HAS_DWIN_E3V2_BASIC
149 149
       static bool dwin_flag;
150 150
     #endif
151 151
 

+ 3
- 0
Marlin/src/feature/runout.cpp View File

@@ -68,6 +68,8 @@ bool FilamentMonitorBase::enabled = true,
68 68
 
69 69
 #if ENABLED(EXTENSIBLE_UI)
70 70
   #include "../lcd/extui/ui_api.h"
71
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
72
+  #include "../lcd/e3v2/enhanced/dwin.h"
71 73
 #endif
72 74
 
73 75
 void event_filament_runout(const uint8_t extruder) {
@@ -86,6 +88,7 @@ void event_filament_runout(const uint8_t extruder) {
86 88
   #endif
87 89
 
88 90
   TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder)));
91
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_FilamentRunout(extruder));
89 92
 
90 93
   #if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR)
91 94
     const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder);

+ 7
- 10
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -58,10 +58,10 @@
58 58
 
59 59
 #if ENABLED(EXTENSIBLE_UI)
60 60
   #include "../../../lcd/extui/ui_api.h"
61
-#endif
62
-
63
-#if ENABLED(DWIN_CREALITY_LCD)
61
+#elif ENABLED(DWIN_CREALITY_LCD)
64 62
   #include "../../../lcd/e3v2/creality/dwin.h"
63
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
64
+  #include "../../../lcd/e3v2/enhanced/dwin.h"
65 65
 #endif
66 66
 
67 67
 #if HAS_MULTI_HOTEND
@@ -403,10 +403,9 @@ G29_TYPE GcodeSuite::G29() {
403 403
     #if ENABLED(AUTO_BED_LEVELING_3POINT)
404 404
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
405 405
       points[0].z = points[1].z = points[2].z = 0;  // Probe at 3 arbitrary points
406
-    #endif
407
-
408
-    #if BOTH(AUTO_BED_LEVELING_BILINEAR, EXTENSIBLE_UI)
409
-      ExtUI::onMeshLevelingStart();
406
+    #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
407
+      TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
408
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshLevelingStart());
410 409
     #endif
411 410
 
412 411
     if (!faux) {
@@ -886,9 +885,7 @@ G29_TYPE GcodeSuite::G29() {
886 885
     process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
887 886
   #endif
888 887
 
889
-  #if ENABLED(DWIN_CREALITY_LCD)
890
-    DWIN_CompletedLeveling();
891
-  #endif
888
+  TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling());
892 889
 
893 890
   report_current_position();
894 891
 

+ 3
- 0
Marlin/src/gcode/bedlevel/mbl/G29.cpp View File

@@ -40,6 +40,8 @@
40 40
 
41 41
 #if ENABLED(EXTENSIBLE_UI)
42 42
   #include "../../../lcd/extui/ui_api.h"
43
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
44
+  #include "../../../lcd/e3v2/enhanced/dwin.h"
43 45
 #endif
44 46
 
45 47
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
@@ -191,6 +193,7 @@ void GcodeSuite::G29() {
191 193
       if (parser.seenval('Z')) {
192 194
         mbl.z_values[ix][iy] = parser.value_linear_units();
193 195
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]));
196
+        TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy]));
194 197
       }
195 198
       else
196 199
         return echo_not_entered('Z');

+ 3
- 0
Marlin/src/gcode/bedlevel/ubl/M421.cpp View File

@@ -33,6 +33,8 @@
33 33
 
34 34
 #if ENABLED(EXTENSIBLE_UI)
35 35
   #include "../../../lcd/extui/ui_api.h"
36
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
37
+  #include "../../../lcd/e3v2/enhanced/dwin.h"
36 38
 #endif
37 39
 
38 40
 /**
@@ -67,6 +69,7 @@ void GcodeSuite::M421() {
67 69
     float &zval = ubl.z_values[ij.x][ij.y];                               // Altering this Mesh Point
68 70
     zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);  // N=NAN, Z=NEWVAL, or Q=ADDVAL
69 71
     TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));          // Ping ExtUI in case it's showing the mesh
72
+    TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ij.x, ij.y, zval));
70 73
   }
71 74
 }
72 75
 

+ 6
- 5
Marlin/src/gcode/calibrate/G28.cpp View File

@@ -46,12 +46,13 @@
46 46
 #endif
47 47
 
48 48
 #include "../../lcd/marlinui.h"
49
-#if ENABLED(DWIN_CREALITY_LCD)
50
-  #include "../../lcd/e3v2/creality/dwin.h"
51
-#endif
52 49
 
53 50
 #if ENABLED(EXTENSIBLE_UI)
54 51
   #include "../../lcd/extui/ui_api.h"
52
+#elif ENABLED(DWIN_CREALITY_LCD)
53
+  #include "../../lcd/e3v2/creality/dwin.h"
54
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
55
+  #include "../../lcd/e3v2/enhanced/dwin.h"
55 56
 #endif
56 57
 
57 58
 #if HAS_L64XX                         // set L6470 absolute position registers to counts
@@ -238,7 +239,7 @@ void GcodeSuite::G28() {
238 239
     return;
239 240
   }
240 241
 
241
-  TERN_(DWIN_CREALITY_LCD, DWIN_StartHoming());
242
+  TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming());
242 243
   TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart());
243 244
 
244 245
   planner.synchronize();          // Wait for planner moves to finish!
@@ -522,7 +523,7 @@ void GcodeSuite::G28() {
522 523
 
523 524
   ui.refresh();
524 525
 
525
-  TERN_(DWIN_CREALITY_LCD, DWIN_CompletedHoming());
526
+  TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming());
526 527
   TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete());
527 528
 
528 529
   report_current_position();

+ 6
- 0
Marlin/src/gcode/control/M997.cpp View File

@@ -24,11 +24,17 @@
24 24
 
25 25
 #if ENABLED(PLATFORM_M997_SUPPORT)
26 26
 
27
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
28
+  #include "../../lcd/e3v2/enhanced/dwin.h"
29
+#endif
30
+
27 31
 /**
28 32
  * M997: Perform in-application firmware update
29 33
  */
30 34
 void GcodeSuite::M997() {
31 35
 
36
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen());
37
+
32 38
   flashFirmware(parser.intval('S'));
33 39
 
34 40
 }

+ 6
- 1
Marlin/src/gcode/feature/powerloss/M1000.cpp View File

@@ -27,9 +27,14 @@
27 27
 #include "../../gcode.h"
28 28
 #include "../../../feature/powerloss.h"
29 29
 #include "../../../module/motion.h"
30
+
30 31
 #include "../../../lcd/marlinui.h"
31 32
 #if ENABLED(EXTENSIBLE_UI)
32 33
   #include "../../../lcd/extui/ui_api.h"
34
+#elif ENABLED(DWIN_CREALITY_LCD)
35
+  #include "../../../lcd/e3v2/creality/dwin.h"
36
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
37
+  #include "../../../lcd/e3v2/enhanced/dwin.h"
33 38
 #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
34 39
   #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented
35 40
 #endif
@@ -64,7 +69,7 @@ void GcodeSuite::M1000() {
64 69
     if (parser.seen_test('S')) {
65 70
       #if HAS_LCD_MENU
66 71
         ui.goto_screen(menu_job_recovery);
67
-      #elif ENABLED(DWIN_CREALITY_LCD)
72
+      #elif HAS_DWIN_E3V2_BASIC
68 73
         recovery.dwin_flag = true;
69 74
       #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) // Temporary fix until it can be better implemented
70 75
         CrealityDWIN.Popup_Handler(Resume);

+ 4
- 0
Marlin/src/gcode/lcd/M0_M1.cpp View File

@@ -35,6 +35,8 @@
35 35
   #include "../../lcd/marlinui.h"
36 36
 #elif ENABLED(EXTENSIBLE_UI)
37 37
   #include "../../lcd/extui/ui_api.h"
38
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
39
+  #include "../../lcd/e3v2/enhanced/dwin.h"
38 40
 #endif
39 41
 
40 42
 #if ENABLED(HOST_PROMPT_SUPPORT)
@@ -68,6 +70,8 @@ void GcodeSuite::M0_M1() {
68 70
       ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
69 71
     else
70 72
       ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
73
+  #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
74
+    DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg ?: GET_TEXT(MSG_STOPPED), GET_TEXT(MSG_USERWAIT));
71 75
   #else
72 76
 
73 77
     if (parser.string_arg) {

+ 21
- 7
Marlin/src/gcode/lcd/M73.cpp View File

@@ -28,6 +28,10 @@
28 28
 #include "../../lcd/marlinui.h"
29 29
 #include "../../sd/cardreader.h"
30 30
 
31
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
32
+  #include "../../lcd/e3v2/enhanced/dwin.h"
33
+#endif
34
+
31 35
 /**
32 36
  * M73: Set percentage complete (for display on LCD)
33 37
  *
@@ -35,13 +39,23 @@
35 39
  *   M73 P25 ; Set progress to 25%
36 40
  */
37 41
 void GcodeSuite::M73() {
38
-  if (parser.seenval('P'))
39
-    ui.set_progress((PROGRESS_SCALE) > 1
40
-      ? parser.value_float() * (PROGRESS_SCALE)
41
-      : parser.value_byte()
42
-    );
43
-  #if ENABLED(USE_M73_REMAINING_TIME)
44
-    if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
42
+
43
+  #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
44
+
45
+    DWIN_Progress_Update();
46
+
47
+  #else
48
+
49
+    if (parser.seenval('P'))
50
+      ui.set_progress((PROGRESS_SCALE) > 1
51
+        ? parser.value_float() * (PROGRESS_SCALE)
52
+        : parser.value_byte()
53
+      );
54
+
55
+    #if ENABLED(USE_M73_REMAINING_TIME)
56
+      if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
57
+    #endif
58
+
45 59
   #endif
46 60
 }
47 61
 

+ 3
- 0
Marlin/src/gcode/sd/M1001.cpp View File

@@ -48,6 +48,8 @@
48 48
 
49 49
 #if ENABLED(EXTENSIBLE_UI)
50 50
   #include "../../lcd/extui/ui_api.h"
51
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
52
+  #include "../../lcd/e3v2/enhanced/dwin.h"
51 53
 #endif
52 54
 
53 55
 #if ENABLED(HOST_ACTION_COMMANDS)
@@ -106,6 +108,7 @@ void GcodeSuite::M1001() {
106 108
   #endif
107 109
 
108 110
   TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
111
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished());
109 112
 
110 113
   // Re-select the last printed file in the UI
111 114
   TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());

+ 16
- 7
Marlin/src/gcode/stats/M75-M78.cpp View File

@@ -29,11 +29,19 @@
29 29
 
30 30
 #include "../../MarlinCore.h" // for startOrResumeJob
31 31
 
32
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
33
+  #include "../../lcd/e3v2/enhanced/dwin.h"
34
+#endif
35
+
32 36
 /**
33 37
  * M75: Start print timer
34 38
  */
35 39
 void GcodeSuite::M75() {
36 40
   startOrResumeJob();
41
+  #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
42
+    DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
43
+    DWIN_Print_Started(false);
44
+  #endif
37 45
 }
38 46
 
39 47
 /**
@@ -49,29 +57,30 @@ void GcodeSuite::M76() {
49 57
  */
50 58
 void GcodeSuite::M77() {
51 59
   print_job_timer.stop();
60
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished());
52 61
 }
53 62
 
54 63
 #if ENABLED(PRINTCOUNTER)
55 64
 
56
-/**
65
+  /**
57 66
    * M78: Show print statistics
58 67
    */
59
-void GcodeSuite::M78() {
60
-  if (parser.intval('S') == 78) {  // "M78 S78" will reset the statistics
68
+  void GcodeSuite::M78() {
69
+    if (parser.intval('S') == 78) {  // "M78 S78" will reset the statistics
61 70
       print_job_timer.initStats();
62 71
       ui.reset_status();
63
-    return;
72
+      return;
64 73
     }
65 74
 
66 75
     #if HAS_SERVICE_INTERVALS
67
-    if (parser.seenval('R')) {
76
+      if (parser.seenval('R')) {
68 77
         print_job_timer.resetServiceInterval(parser.value_int());
69 78
         ui.reset_status();
70
-      return;
79
+        return;
71 80
       }
72 81
     #endif
73 82
 
74 83
     print_job_timer.showStats();
75
-}
84
+  }
76 85
 
77 86
 #endif // PRINTCOUNTER

+ 3
- 0
Marlin/src/gcode/temp/M303.cpp View File

@@ -30,6 +30,8 @@
30 30
 
31 31
 #if ENABLED(EXTENSIBLE_UI)
32 32
   #include "../../lcd/extui/ui_api.h"
33
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
34
+  #include "../../lcd/e3v2/enhanced/dwin.h"
33 35
 #endif
34 36
 
35 37
 /**
@@ -71,6 +73,7 @@ void GcodeSuite::M303() {
71 73
     default:
72 74
       SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
73 75
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
76
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
74 77
       return;
75 78
   }
76 79
 

+ 4
- 1
Marlin/src/inc/Conditionals_LCD.h View File

@@ -493,7 +493,10 @@
493 493
 #endif
494 494
 
495 495
 // Aliases for LCD features
496
-#if ANY(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_JYERSUI)
496
+#if EITHER(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED)
497
+  #define HAS_DWIN_E3V2_BASIC 1
498
+#endif
499
+#if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI)
497 500
   #define HAS_DWIN_E3V2 1
498 501
 #endif
499 502
 

+ 15
- 3
Marlin/src/inc/SanityCheck.h View File

@@ -808,7 +808,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
808 808
     #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0."
809 809
   #endif
810 810
 #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
811
-  #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, or EXTENSIBLE_UI."
811
+  #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI."
812 812
 #endif
813 813
 
814 814
 #if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY)
@@ -1748,7 +1748,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1748 1748
  * LCD_BED_LEVELING requirements
1749 1749
  */
1750 1750
 #if ENABLED(LCD_BED_LEVELING)
1751
-  #if NONE(HAS_LCD_MENU, DWIN_CREALITY_LCD)
1751
+  #if NONE(HAS_LCD_MENU, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED)
1752 1752
     #error "LCD_BED_LEVELING is not supported by the selected LCD controller."
1753 1753
   #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL)
1754 1754
     #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING."
@@ -2655,7 +2655,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2655 2655
   + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
2656 2656
   + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \
2657 2657
   + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
2658
-  + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
2658
+  + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
2659 2659
   + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
2660 2660
   + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
2661 2661
   + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \
@@ -2763,6 +2763,18 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
2763 2763
   #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)
2764 2764
     #error "DWIN_CREALITY_LCD does not support LCD_BED_LEVELING with PROBE_MANUALLY."
2765 2765
   #endif
2766
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
2767
+  #if DISABLED(SDSUPPORT)
2768
+    #error "DWIN_CREALITY_LCD_ENHANCED requires SDSUPPORT to be enabled."
2769
+  #elif ENABLED(PID_EDIT_MENU)
2770
+    #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_EDIT_MENU."
2771
+  #elif ENABLED(PID_AUTOTUNE_MENU)
2772
+    #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_AUTOTUNE_MENU."
2773
+  #elif ENABLED(LEVEL_BED_CORNERS)
2774
+    #error "DWIN_CREALITY_LCD_ENHANCED does not support LEVEL_BED_CORNERS."
2775
+  #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY)
2776
+    #error "DWIN_CREALITY_LCD_ENHANCED does not support LCD_BED_LEVELING with PROBE_MANUALLY."
2777
+  #endif
2766 2778
 #endif
2767 2779
 
2768 2780
 /**

Marlin/src/lcd/e3v2/creality/README.md → Marlin/src/lcd/e3v2/README.md View File


+ 6
- 6
Marlin/src/lcd/e3v2/creality/rotary_encoder.h View File

@@ -22,12 +22,12 @@
22 22
 #pragma once
23 23
 
24 24
 /*****************************************************************************
25
-  * @file     lcd/e3v2/creality/rotary_encoder.h
26
-  * @author   LEO / Creality3D
27
-  * @date     2019/07/06
28
-  * @version  2.0.1
29
-  * @brief    Rotary encoder functions
30
-  ****************************************************************************/
25
+ * @file     lcd/e3v2/creality/rotary_encoder.h
26
+ * @author   LEO / Creality3D
27
+ * @date     2019/07/06
28
+ * @version  2.0.1
29
+ * @brief    Rotary encoder functions
30
+ ****************************************************************************/
31 31
 
32 32
 #include "../../../inc/MarlinConfig.h"
33 33
 

+ 3529
- 0
Marlin/src/lcd/e3v2/enhanced/dwin.cpp
File diff suppressed because it is too large
View File


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

@@ -0,0 +1,268 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+#pragma once
22
+
23
+/**
24
+ * DWIN by Creality3D
25
+ * Enhanced implementation by Miguel A. Risco-Castillo
26
+ */
27
+
28
+#include "../../../inc/MarlinConfigPre.h"
29
+#include "dwinui.h"
30
+#include "rotary_encoder.h"
31
+#include "../../../libs/BL24CXX.h"
32
+
33
+#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
34
+  #define HAS_PREHEAT 1
35
+  #if PREHEAT_COUNT < 2
36
+    #error "Creality DWIN requires two material preheat presets."
37
+  #endif
38
+#endif
39
+
40
+#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY)
41
+  #define HAS_ONESTEP_LEVELING 1
42
+#endif
43
+
44
+#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING)
45
+  #define JUST_BABYSTEP 1
46
+#endif
47
+
48
+#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET)
49
+  #define HAS_ZOFFSET_ITEM 1
50
+#endif
51
+
52
+static constexpr size_t eeprom_data_size = 64;
53
+
54
+enum processID : uint8_t {
55
+  // Process ID
56
+  MainMenu,
57
+  Menu,
58
+  SetInt,
59
+  SetPInt,
60
+  SetIntNoDraw,
61
+  SetFloat,
62
+  SetPFloat,
63
+  SelectFile,
64
+  PrintProcess,
65
+  PrintDone,
66
+  Info,
67
+
68
+  // Popup Windows
69
+  Homing,
70
+  Leveling,
71
+  PauseOrStop,
72
+  FilamentPurge,
73
+  WaitResponse,
74
+  Locked,
75
+  NothingToDo,
76
+};
77
+
78
+enum pidresult_t : uint8_t {
79
+  PID_BAD_EXTRUDER_NUM,
80
+  PID_TEMP_TOO_HIGH,
81
+  PID_TUNING_TIMEOUT,
82
+  PID_EXTR_START,
83
+  PID_BED_START,
84
+  PID_DONE
85
+};
86
+
87
+// Picture ID
88
+#define Start_Process       0
89
+#define Language_English    1
90
+#define Language_Chinese    2
91
+
92
+#define DWIN_CHINESE 123
93
+#define DWIN_ENGLISH 0
94
+
95
+typedef struct {
96
+  int8_t Color[3];                    // Color components
97
+  int8_t Preheat          = 0;        // Material Select 0: PLA, 1: ABS, 2: Custom
98
+  AxisEnum axis           = X_AXIS;   // Axis Select
99
+  int32_t MaxValue        = 0;        // Auxiliar max integer/scaled float value
100
+  int32_t MinValue        = 0;        // Auxiliar min integer/scaled float value
101
+  int8_t dp               = 0;        // Auxiliar decimal places
102
+  int32_t Value           = 0;        // Auxiliar integer / scaled float value
103
+  int16_t *P_Int          = nullptr;  // Auxiliar pointer to 16 bit integer variable
104
+  float *P_Float          = nullptr;  // Auxiliar pointer to float variable
105
+  void (*Apply)()         = nullptr;  // Auxiliar apply function
106
+  void (*LiveUpdate)()    = nullptr;  // Auxiliar live update function
107
+} HMI_value_t;
108
+
109
+typedef struct {
110
+  uint16_t Background_Color = Def_Background_Color;
111
+  uint16_t Cursor_color     = Def_Cursor_color;
112
+  uint16_t TitleBg_color    = Def_TitleBg_color;
113
+  uint16_t TitleTxt_color   = Def_TitleTxt_color;
114
+  uint16_t Text_Color       = Def_Text_Color;
115
+  uint16_t Selected_Color   = Def_Selected_Color;
116
+  uint16_t SplitLine_Color  = Def_SplitLine_Color;
117
+  uint16_t Highlight_Color  = Def_Highlight_Color;
118
+  uint16_t StatusBg_Color   = Def_StatusBg_Color;
119
+  uint16_t StatusTxt_Color  = Def_StatusTxt_Color;
120
+  uint16_t PopupBg_color    = Def_PopupBg_color;
121
+  uint16_t PopupTxt_Color   = Def_PopupTxt_Color;
122
+  uint16_t AlertBg_Color    = Def_AlertBg_Color;
123
+  uint16_t AlertTxt_Color   = Def_AlertTxt_Color;
124
+  uint16_t PercentTxt_Color = Def_PercentTxt_Color;
125
+  uint16_t Barfill_Color    = Def_Barfill_Color;
126
+  uint16_t Indicator_Color  = Def_Indicator_Color;
127
+  uint16_t Coordinate_Color = Def_Coordinate_Color;
128
+  TERN_(HAS_HOTEND, int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND);
129
+  TERN_(HAS_HOTEND, int16_t PidCycles = 10);
130
+  #ifdef PREHEAT_1_TEMP_BED
131
+    int16_t BedPidT = PREHEAT_1_TEMP_BED;
132
+  #endif
133
+  TERN_(PREVENT_COLD_EXTRUSION, uint16_t ExtMinT = EXTRUDE_MINTEMP);
134
+} HMI_data_t;
135
+
136
+typedef struct {
137
+  uint8_t language;
138
+  bool pause_flag:1;    // printing is paused
139
+  bool pause_action:1;  // flag a pause action
140
+  bool print_finish:1;  // print was finished
141
+  bool select_flag:1;   // Popup button selected
142
+  bool home_flag:1;     // homing in course
143
+  bool heat_flag:1;     // 0: heating done  1: during heating
144
+  bool lock_flag:1;     // 0: lock called from AdvSet  1: lock called from Tune
145
+} HMI_flag_t;
146
+
147
+extern HMI_value_t HMI_value;
148
+extern HMI_flag_t HMI_flag;
149
+extern HMI_data_t HMI_data;
150
+extern uint8_t checkkey;
151
+extern millis_t dwin_heat_time;
152
+
153
+// Popup windows
154
+void DWIN_Popup_Confirm(uint8_t icon, const char * const msg1, const char * const msg2);
155
+#if HAS_HOTEND || HAS_HEATED_BED
156
+  void DWIN_Popup_Temperature(const bool toohigh);
157
+#endif
158
+TERN_(HAS_HOTEND, void Popup_Window_ETempTooLow());
159
+void Popup_Window_Resume();
160
+
161
+// SD Card
162
+void HMI_SDCardInit();
163
+void HMI_SDCardUpdate();
164
+
165
+// Main Process
166
+//void Icon_print();
167
+//void Icon_control();
168
+//void Icon_leveling(bool value);
169
+
170
+// Other
171
+void Goto_PrintProcess();
172
+void Goto_Main_Menu();
173
+void update_variable();
174
+void Draw_Select_Highlight(const bool sel);
175
+void Draw_Status_Area(const bool with_update); // Status Area
176
+void Draw_Main_Area();      // Redraw main area;
177
+void DWIN_Redraw_screen();  // Redraw all screen elements
178
+void HMI_StartFrame(const bool with_update);   // Prepare the menu view
179
+void HMI_MainMenu();        // Main process screen
180
+void HMI_SelectFile();      // File page
181
+void HMI_Printing();        // Print page
182
+void HMI_ReturnScreen();    // Return to previous screen before popups
183
+void ApplyExtMinT();
184
+void HMI_SetLanguageCache(); // Set the languaje image cache
185
+
186
+//void HMI_Leveling();    // Level the page
187
+//void HMI_LevBedCorners();   // Tramming menu
188
+//void HMI_Info();          // Information menu
189
+
190
+
191
+void HMI_Init();
192
+void HMI_Popup();
193
+void HMI_SaveProcessID(const uint8_t id);
194
+void HMI_AudioFeedback(const bool success=true);
195
+void DWIN_Startup();
196
+void DWIN_Update();
197
+void EachMomentUpdate();
198
+void DWIN_HandleScreen();
199
+void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
200
+void DWIN_StatusChanged(const char * const text);
201
+void DWIN_StatusChanged_P(PGM_P const text);
202
+void DWIN_StartHoming();
203
+void DWIN_CompletedHoming();
204
+TERN_(MESH_BED_LEVELING, void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval));
205
+void DWIN_MeshLevelingStart();
206
+void DWIN_CompletedLeveling();
207
+void DWIN_PidTuning(pidresult_t result);
208
+void DWIN_Print_Started(const bool sd = false);
209
+void DWIN_Print_Finished();
210
+#if HAS_FILAMENT_SENSOR
211
+  void DWIN_FilamentRunout(const uint8_t extruder);
212
+#endif
213
+void DWIN_Progress_Update();
214
+void DWIN_Print_Header(const char *text);
215
+void DWIN_SetColorDefaults();
216
+void DWIN_StoreSettings(char *buff);
217
+void DWIN_LoadSettings(const char *buff);
218
+void DWIN_SetDataDefaults();
219
+void DWIN_RebootScreen();
220
+
221
+#if ENABLED(ADVANCED_PAUSE_FEATURE)
222
+  void Draw_Popup_FilamentPurge();
223
+  void DWIN_Popup_FilamentPurge();
224
+  void HMI_FilamentPurge();
225
+#endif
226
+
227
+// Utility and extensions
228
+void HMI_LockScreen();
229
+void DWIN_LockScreen(const bool flag = true);
230
+
231
+// HMI user control functions
232
+void HMI_Menu();
233
+void HMI_SetInt();
234
+void HMI_SetPInt();
235
+void HMI_SetIntNoDraw();
236
+void HMI_SetFloat();
237
+void HMI_SetPFloat();
238
+
239
+// Menu drawing functions
240
+void Draw_Control_Menu();
241
+void Draw_AdvancedSettings_Menu();
242
+void Draw_Prepare_Menu();
243
+void Draw_Move_Menu();
244
+void Draw_LevBedCorners_Menu();
245
+TERN_(HAS_HOME_OFFSET, void Draw_HomeOffset_Menu());
246
+TERN_(HAS_BED_PROBE, void Draw_ProbeSet_Menu());
247
+TERN_(HAS_FILAMENT_SENSOR, void Draw_FilSet_Menu());
248
+void Draw_SelectColors_Menu();
249
+void Draw_GetColor_Menu();
250
+void Draw_Tune_Menu();
251
+void Draw_Motion_Menu();
252
+TERN_(ADVANCED_PAUSE_FEATURE, void Draw_FilamentMan_Menu());
253
+TERN_(MESH_BED_LEVELING, void Draw_ManualMesh_Menu());
254
+#if HAS_HOTEND
255
+  void Draw_Preheat1_Menu();
256
+  void Draw_Preheat2_Menu();
257
+  void Draw_Preheat3_Menu();
258
+#endif
259
+void Draw_Temperature_Menu();
260
+void Draw_MaxSpeed_Menu();
261
+void Draw_MaxAccel_Menu();
262
+TERN_(HAS_CLASSIC_JERK, void Draw_MaxJerk_Menu());
263
+void Draw_Steps_Menu();
264
+TERN_(HAS_HOTEND, void Draw_HotendPID_Menu());
265
+TERN_(HAS_HEATED_BED, void Draw_BedPID_Menu());
266
+#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
267
+  void Draw_ZOffsetWiz_Menu();
268
+#endif

+ 564
- 0
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp View File

@@ -0,0 +1,564 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+/********************************************************************************
23
+ * @file     lcd/e3v2/enhanced/dwin_lcd.cpp
24
+ * @author   LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
25
+ * @date     2021/08/29
26
+ * @version  2.1.1
27
+ * @brief    DWIN screen control functions
28
+ ********************************************************************************/
29
+
30
+#include "../../../inc/MarlinConfigPre.h"
31
+
32
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
33
+
34
+#include "../../../inc/MarlinConfig.h"
35
+
36
+#include "dwin_lcd.h"
37
+#include <string.h> // for memset
38
+
39
+//#define DEBUG_OUT 1
40
+#include "../../../core/debug_out.h"
41
+
42
+// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
43
+// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
44
+uint8_t DWIN_SendBuf[11 + DWIN_DataLength] = { 0xAA };
45
+uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
46
+uint8_t databuf[26] = { 0 };
47
+uint8_t receivedType;
48
+
49
+int recnum = 0;
50
+
51
+inline void DWIN_Byte(size_t &i, const uint16_t bval) {
52
+  DWIN_SendBuf[++i] = bval;
53
+}
54
+
55
+inline void DWIN_Word(size_t &i, const uint16_t wval) {
56
+  DWIN_SendBuf[++i] = wval >> 8;
57
+  DWIN_SendBuf[++i] = wval & 0xFF;
58
+}
59
+
60
+inline void DWIN_Long(size_t &i, const uint32_t lval) {
61
+  DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
62
+  DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
63
+  DWIN_SendBuf[++i] = (lval >>  8) & 0xFF;
64
+  DWIN_SendBuf[++i] = lval & 0xFF;
65
+}
66
+
67
+inline void DWIN_String(size_t &i, const char * const string, uint16_t rlimit = 0xFFFF) {
68
+  if (!string) return;
69
+  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit));
70
+  if (len == 0) return;
71
+  memcpy(&DWIN_SendBuf[i+1], string, len);
72
+  i += len;
73
+}
74
+
75
+inline void DWIN_String(size_t &i, const __FlashStringHelper * string, uint16_t rlimit = 0xFFFF) {
76
+  if (!string) return;
77
+  const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P((PGM_P)string))); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
78
+  if (len == 0) return;
79
+  memcpy(&DWIN_SendBuf[i+1], string, len);
80
+  i += len;
81
+}
82
+
83
+// Send the data in the buffer and the packet end
84
+inline void DWIN_Send(size_t &i) {
85
+  ++i;
86
+  LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
87
+  LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
88
+}
89
+
90
+/*-------------------------------------- System variable function --------------------------------------*/
91
+
92
+// Handshake (1: Success, 0: Fail)
93
+bool DWIN_Handshake(void) {
94
+  #ifndef LCD_BAUDRATE
95
+    #define LCD_BAUDRATE 115200
96
+  #endif
97
+  LCD_SERIAL.begin(LCD_BAUDRATE);
98
+  const millis_t serial_connect_timeout = millis() + 1000UL;
99
+  while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
100
+
101
+  size_t i = 0;
102
+  DWIN_Byte(i, 0x00);
103
+  DWIN_Send(i);
104
+
105
+  while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
106
+    databuf[recnum] = LCD_SERIAL.read();
107
+    // ignore the invalid data
108
+    if (databuf[0] != FHONE) { // prevent the program from running.
109
+      if (recnum > 0) {
110
+        recnum = 0;
111
+        ZERO(databuf);
112
+      }
113
+      continue;
114
+    }
115
+    delay(10);
116
+    recnum++;
117
+  }
118
+
119
+  return ( recnum >= 3
120
+        && databuf[0] == FHONE
121
+        && databuf[1] == '\0'
122
+        && databuf[2] == 'O'
123
+        && databuf[3] == 'K' );
124
+}
125
+
126
+// Set screen display direction
127
+//  dir: 0=0°, 1=90°, 2=180°, 3=270°
128
+void DWIN_Frame_SetDir(uint8_t dir) {
129
+  size_t i = 0;
130
+  DWIN_Byte(i, 0x34);
131
+  DWIN_Byte(i, 0x5A);
132
+  DWIN_Byte(i, 0xA5);
133
+  DWIN_Byte(i, dir);
134
+  DWIN_Send(i);
135
+}
136
+
137
+// Update display
138
+void DWIN_UpdateLCD(void) {
139
+  size_t i = 0;
140
+  DWIN_Byte(i, 0x3D);
141
+  DWIN_Send(i);
142
+}
143
+
144
+/*---------------------------------------- Drawing functions ----------------------------------------*/
145
+
146
+// Clear screen
147
+//  color: Clear screen color
148
+void DWIN_Frame_Clear(const uint16_t color) {
149
+  size_t i = 0;
150
+  DWIN_Byte(i, 0x01);
151
+  DWIN_Word(i, color);
152
+  DWIN_Send(i);
153
+}
154
+
155
+// Draw a point
156
+//  color: point color
157
+//  width: point width   0x01-0x0F
158
+//  height: point height 0x01-0x0F
159
+//  x,y: upper left point
160
+void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
161
+  size_t i = 0;
162
+  DWIN_Byte(i, 0x02);
163
+  DWIN_Word(i, color);
164
+  DWIN_Byte(i, width);
165
+  DWIN_Byte(i, height);
166
+  DWIN_Word(i, x);
167
+  DWIN_Word(i, y);
168
+  DWIN_Send(i);
169
+}
170
+
171
+// Draw a line
172
+//  color: Line segment color
173
+//  xStart/yStart: Start point
174
+//  xEnd/yEnd: End point
175
+void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
176
+  size_t i = 0;
177
+  DWIN_Byte(i, 0x03);
178
+  DWIN_Word(i, color);
179
+  DWIN_Word(i, xStart);
180
+  DWIN_Word(i, yStart);
181
+  DWIN_Word(i, xEnd);
182
+  DWIN_Word(i, yEnd);
183
+  DWIN_Send(i);
184
+}
185
+
186
+// Draw a rectangle
187
+//  mode: 0=frame, 1=fill, 2=XOR fill
188
+//  color: Rectangle color
189
+//  xStart/yStart: upper left point
190
+//  xEnd/yEnd: lower right point
191
+void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
192
+                         uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
193
+  size_t i = 0;
194
+  DWIN_Byte(i, 0x05);
195
+  DWIN_Byte(i, mode);
196
+  DWIN_Word(i, color);
197
+  DWIN_Word(i, xStart);
198
+  DWIN_Word(i, yStart);
199
+  DWIN_Word(i, xEnd);
200
+  DWIN_Word(i, yEnd);
201
+  DWIN_Send(i);
202
+}
203
+
204
+// Move a screen area
205
+//  mode: 0, circle shift; 1, translation
206
+//  dir: 0=left, 1=right, 2=up, 3=down
207
+//  dis: Distance
208
+//  color: Fill color
209
+//  xStart/yStart: upper left point
210
+//  xEnd/yEnd: bottom right point
211
+void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
212
+                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
213
+  size_t i = 0;
214
+  DWIN_Byte(i, 0x09);
215
+  DWIN_Byte(i, (mode << 7) | dir);
216
+  DWIN_Word(i, dis);
217
+  DWIN_Word(i, color);
218
+  DWIN_Word(i, xStart);
219
+  DWIN_Word(i, yStart);
220
+  DWIN_Word(i, xEnd);
221
+  DWIN_Word(i, yEnd);
222
+  DWIN_Send(i);
223
+}
224
+
225
+/*---------------------------------------- Text related functions ----------------------------------------*/
226
+
227
+// Draw a string
228
+//  widthAdjust: true=self-adjust character width; false=no adjustment
229
+//  bShow: true=display background color; false=don't display background color
230
+//  size: Font size
231
+//  color: Character color
232
+//  bColor: Background color
233
+//  x/y: Upper-left coordinate of the string
234
+//  *string: The string
235
+//  rlimit: For draw less chars than string length use rlimit
236
+void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit) {
237
+  size_t i = 0;
238
+  DWIN_Byte(i, 0x11);
239
+  // Bit 7: widthAdjust
240
+  // Bit 6: bShow
241
+  // Bit 5-4: Unused (0)
242
+  // Bit 3-0: size
243
+  DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
244
+  DWIN_Word(i, color);
245
+  DWIN_Word(i, bColor);
246
+  DWIN_Word(i, x);
247
+  DWIN_Word(i, y);
248
+  DWIN_String(i, string, rlimit);
249
+  DWIN_Send(i);
250
+}
251
+
252
+// Draw a positive integer
253
+//  bShow: true=display background color; false=don't display background color
254
+//  zeroFill: true=zero fill; false=no zero fill
255
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
256
+//  size: Font size
257
+//  color: Character color
258
+//  bColor: Background color
259
+//  iNum: Number of digits
260
+//  x/y: Upper-left coordinate
261
+//  value: Integer value
262
+void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
263
+                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
264
+  size_t i = 0;
265
+  DWIN_Byte(i, 0x14);
266
+  // Bit 7: bshow
267
+  // Bit 6: 1 = signed; 0 = unsigned number;
268
+  // Bit 5: zeroFill
269
+  // Bit 4: zeroMode
270
+  // Bit 3-0: size
271
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
272
+  DWIN_Word(i, color);
273
+  DWIN_Word(i, bColor);
274
+  DWIN_Byte(i, iNum);
275
+  DWIN_Byte(i, 0); // fNum
276
+  DWIN_Word(i, x);
277
+  DWIN_Word(i, y);
278
+  #if 0
279
+    for (char count = 0; count < 8; count++) {
280
+      DWIN_Byte(i, value);
281
+      value >>= 8;
282
+      if (!(value & 0xFF)) break;
283
+    }
284
+  #else
285
+    // Write a big-endian 64 bit integer
286
+    const size_t p = i + 1;
287
+    for (char count = 8; count--;) { // 7..0
288
+      ++i;
289
+      DWIN_SendBuf[p + count] = value;
290
+      value >>= 8;
291
+    }
292
+  #endif
293
+
294
+  DWIN_Send(i);
295
+}
296
+
297
+// Draw a positive floating point number
298
+//  bShow: true=display background color; false=don't display background color
299
+//  zeroFill: true=zero fill; false=no zero fill
300
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
301
+//  size: Font size
302
+//  color: Character color
303
+//  bColor: Background color
304
+//  iNum: Number of whole digits
305
+//  fNum: Number of decimal digits
306
+//  x/y: Upper-left point
307
+//  value: Scaled positive float value
308
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
309
+                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
310
+  size_t i = 0;
311
+  DWIN_Byte(i, 0x14);
312
+  DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
313
+  DWIN_Word(i, color);
314
+  DWIN_Word(i, bColor);
315
+  DWIN_Byte(i, iNum);
316
+  DWIN_Byte(i, fNum);
317
+  DWIN_Word(i, x);
318
+  DWIN_Word(i, y);
319
+  DWIN_Long(i, value);
320
+  DWIN_Send(i);
321
+}
322
+
323
+/*---------------------------------------- Picture related functions ----------------------------------------*/
324
+
325
+// Display QR code
326
+//  The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
327
+//  QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
328
+//  (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
329
+//  str: multi-bit data
330
+void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string) {
331
+  size_t i = 0;
332
+  DWIN_Byte(i, 0x21);
333
+  DWIN_Word(i, x);
334
+  DWIN_Word(i, y);
335
+  DWIN_Byte(i, QR_Pixel);
336
+  DWIN_String(i, string);
337
+  DWIN_Send(i);
338
+}
339
+
340
+// Draw JPG and cached in #0 virtual display area
341
+// id: Picture ID
342
+void DWIN_JPG_ShowAndCache(const uint8_t id) {
343
+  size_t i = 0;
344
+  DWIN_Word(i, 0x2200);
345
+  DWIN_Byte(i, id);
346
+  DWIN_Send(i);
347
+}
348
+
349
+// Draw an Icon
350
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
351
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
352
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
353
+//  libID: Icon library ID
354
+//  picID: Icon ID
355
+//  x/y: Upper-left point
356
+void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
357
+  NOMORE(x, DWIN_WIDTH - 1);
358
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
359
+  size_t i = 0;
360
+  DWIN_Byte(i, 0x23);
361
+  DWIN_Word(i, x);
362
+  DWIN_Word(i, y);
363
+  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | libID);
364
+  DWIN_Byte(i, picID);
365
+  DWIN_Send(i);
366
+}
367
+
368
+// Draw an Icon from SRAM
369
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
370
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
371
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
372
+//  x/y: Upper-left point
373
+//  addr: SRAM address
374
+void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr) {
375
+  NOMORE(x, DWIN_WIDTH - 1);
376
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
377
+  size_t i = 0;
378
+  DWIN_Byte(i, 0x24);
379
+  DWIN_Word(i, x);
380
+  DWIN_Word(i, y);
381
+  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | 0x00);
382
+  DWIN_Word(i, addr);
383
+  DWIN_Send(i);
384
+}
385
+
386
+// Unzip the JPG picture to a virtual display area
387
+//  n: Cache index
388
+//  id: Picture ID
389
+void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
390
+  size_t i = 0;
391
+  DWIN_Byte(i, 0x25);
392
+  DWIN_Byte(i, n);
393
+  DWIN_Byte(i, id);
394
+  DWIN_Send(i);
395
+}
396
+
397
+// Copy area from current virtual display area to current screen
398
+//  xStart/yStart: Upper-left of virtual area
399
+//  xEnd/yEnd: Lower-right of virtual area
400
+//  x/y: Screen paste point
401
+void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
402
+                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
403
+  size_t i = 0;
404
+  DWIN_Byte(i, 0x26);
405
+  DWIN_Word(i, xStart);
406
+  DWIN_Word(i, yStart);
407
+  DWIN_Word(i, xEnd);
408
+  DWIN_Word(i, yEnd);
409
+  DWIN_Word(i, x);
410
+  DWIN_Word(i, y);
411
+  DWIN_Send(i);
412
+}
413
+
414
+// Copy area from virtual display area to current screen
415
+//  IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
416
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
417
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
418
+//  cacheID: virtual area number
419
+//  xStart/yStart: Upper-left of virtual area
420
+//  xEnd/yEnd: Lower-right of virtual area
421
+//  x/y: Screen paste point
422
+void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
423
+                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
424
+  size_t i = 0;
425
+  DWIN_Byte(i, 0x27);
426
+  DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | cacheID);
427
+  DWIN_Word(i, xStart);
428
+  DWIN_Word(i, yStart);
429
+  DWIN_Word(i, xEnd);
430
+  DWIN_Word(i, yEnd);
431
+  DWIN_Word(i, x);
432
+  DWIN_Word(i, y);
433
+  DWIN_Send(i);
434
+}
435
+
436
+// Animate a series of icons
437
+//  animID: Animation ID; 0x00-0x0F
438
+//  animate: true on; false off;
439
+//  libID: Icon library ID
440
+//  picIDs: Icon starting ID
441
+//  picIDe: Icon ending ID
442
+//  x/y: Upper-left point
443
+//  interval: Display time interval, unit 10mS
444
+void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
445
+  NOMORE(x, DWIN_WIDTH - 1);
446
+  NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
447
+  size_t i = 0;
448
+  DWIN_Byte(i, 0x28);
449
+  DWIN_Word(i, x);
450
+  DWIN_Word(i, y);
451
+  // Bit 7: animation on or off
452
+  // Bit 6: start from begin or end
453
+  // Bit 5-4: unused (0)
454
+  // Bit 3-0: animID
455
+  DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
456
+  DWIN_Byte(i, libID);
457
+  DWIN_Byte(i, picIDs);
458
+  DWIN_Byte(i, picIDe);
459
+  DWIN_Byte(i, interval);
460
+  DWIN_Send(i);
461
+}
462
+
463
+// Animation Control
464
+//  state: 16 bits, each bit is the state of an animation id
465
+void DWIN_ICON_AnimationControl(uint16_t state) {
466
+  size_t i = 0;
467
+  DWIN_Byte(i, 0x29);
468
+  DWIN_Word(i, state);
469
+  DWIN_Send(i);
470
+}
471
+
472
+// Set LCD Brightness 0x00-0xFF
473
+void DWIN_LCD_Brightness(const uint8_t brightness) {
474
+  size_t i = 0;
475
+  DWIN_Byte(i, 0x30);
476
+  DWIN_Byte(i, brightness);
477
+  DWIN_Send(i);
478
+}
479
+
480
+// Write buffer data to the SRAM or Flash
481
+//  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
482
+//  addr: start address
483
+//  length: Bytes to write
484
+//  data: address of the buffer with data
485
+void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
486
+  const uint8_t max_size = 128;
487
+  uint16_t pending = length;
488
+  uint16_t to_send;
489
+  uint16_t indx;
490
+  uint8_t block = 0;
491
+
492
+  while (pending > 0) {
493
+    indx = block * max_size;
494
+    to_send = _MIN(pending, max_size);
495
+    size_t i = 0;
496
+    DWIN_Byte(i, 0x31);
497
+    DWIN_Byte(i, mem);
498
+    DWIN_Word(i, addr + indx); // start address of the data block
499
+    ++i;
500
+    LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); }  // Buf header
501
+    for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1);  // write block of data
502
+    LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); }
503
+    block++;
504
+    pending -= to_send;
505
+  }
506
+}
507
+
508
+// Write the contents of the 32KB SRAM data memory into the designated image memory space.
509
+//  picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes
510
+void DWIN_SRAMToPic(uint8_t picID) {
511
+  size_t i = 0;
512
+  DWIN_Byte(i, 0x33);
513
+  DWIN_Byte(i, 0x5A);
514
+  DWIN_Byte(i, 0xA5);
515
+  DWIN_Byte(i, picID);
516
+  DWIN_Send(i);
517
+}
518
+
519
+//--------------------------Test area -------------------------
520
+
521
+// void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
522
+//   size_t i = 0;
523
+//   DWIN_Byte(i, 0x32);
524
+//   DWIN_Byte(i, 0x5A);  // 0x5A Read from SRAM - 0xA5 Read from Flash
525
+//   DWIN_Word(i, addr);  // 0x0000 to 0x7FFF
526
+//   const size_t len = _MIN(0xF0, length);
527
+//   DWIN_Byte(i, len);
528
+//   DWIN_Send(i);
529
+// }
530
+
531
+/*---------------------------------------- Memory functions ----------------------------------------*/
532
+// The LCD has an additional 32KB SRAM and 16KB Flash
533
+
534
+// Data can be written to the sram and save to one of the jpeg page files
535
+
536
+// Write Data Memory
537
+//  command 0x31
538
+//  Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
539
+//  Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
540
+//  Data: data
541
+//
542
+//  Flash writing returns 0xA5 0x4F 0x4B
543
+
544
+// Read Data Memory
545
+//  command 0x32
546
+//  Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
547
+//  Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
548
+//  Length: leangth of data to read; 0x01-0xF0
549
+//
550
+//  Response:
551
+//    Type, Address, Length, Data
552
+
553
+// Write Picture Memory
554
+//  Write the contents of the 32KB SRAM data memory into the designated image memory space
555
+//  Issued: 0x5A, 0xA5, PIC_ID
556
+//  Response: 0xA5 0x4F 0x4B
557
+//
558
+//  command 0x33
559
+//  0x5A, 0xA5
560
+//  PicId: Picture Memory location, 0x00-0x0F
561
+//
562
+//  Flash writing returns 0xA5 0x4F 0x4B
563
+
564
+#endif // DWIN_CREALITY_LCD_ENHANCED

+ 282
- 0
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h View File

@@ -0,0 +1,282 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+/********************************************************************************
23
+ * @file     lcd/e3v2/enhanced/dwin_lcd.h
24
+ * @author   LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
25
+ * @date     2021/08/29
26
+ * @version  2.1.1
27
+ * @brief    DWIN screen control functions
28
+ ********************************************************************************/
29
+
30
+#pragma once
31
+
32
+#include <stdint.h>
33
+
34
+#define RECEIVED_NO_DATA         0x00
35
+#define RECEIVED_SHAKE_HAND_ACK  0x01
36
+
37
+#define FHONE                    0xAA
38
+
39
+#define DWIN_SCROLL_UP   2
40
+#define DWIN_SCROLL_DOWN 3
41
+
42
+#define DWIN_WIDTH  272
43
+#define DWIN_HEIGHT 480
44
+
45
+#define DWIN_DataLength (DWIN_WIDTH / 6 * 2)
46
+
47
+/*-------------------------------------- System variable function --------------------------------------*/
48
+
49
+// Handshake (1: Success, 0: Fail)
50
+bool DWIN_Handshake(void);
51
+
52
+// Set the backlight luminance
53
+//  luminance: (0x00-0xFF)
54
+void DWIN_Backlight_SetLuminance(const uint8_t luminance);
55
+
56
+// Set screen display direction
57
+//  dir: 0=0°, 1=90°, 2=180°, 3=270°
58
+void DWIN_Frame_SetDir(uint8_t dir);
59
+
60
+// Update display
61
+void DWIN_UpdateLCD(void);
62
+
63
+/*---------------------------------------- Drawing functions ----------------------------------------*/
64
+
65
+// Clear screen
66
+//  color: Clear screen color
67
+void DWIN_Frame_Clear(const uint16_t color);
68
+
69
+// Draw a point
70
+//  color: point color
71
+//  width: point width   0x01-0x0F
72
+//  height: point height 0x01-0x0F
73
+//  x,y: upper left point
74
+void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
75
+
76
+// Draw a line
77
+//  color: Line segment color
78
+//  xStart/yStart: Start point
79
+//  xEnd/yEnd: End point
80
+void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
81
+
82
+// Draw a Horizontal line
83
+//  color: Line segment color
84
+//  xStart/yStart: Start point
85
+//  xLength: Line Length
86
+inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
87
+  DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
88
+}
89
+
90
+// Draw a Vertical line
91
+//  color: Line segment color
92
+//  xStart/yStart: Start point
93
+//  yLength: Line Length
94
+inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
95
+  DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
96
+}
97
+
98
+// Draw a rectangle
99
+//  mode: 0=frame, 1=fill, 2=XOR fill
100
+//  color: Rectangle color
101
+//  xStart/yStart: upper left point
102
+//  xEnd/yEnd: lower right point
103
+void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,  uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
104
+
105
+// Draw a box
106
+//  mode: 0=frame, 1=fill, 2=XOR fill
107
+//  color: Rectangle color
108
+//  xStart/yStart: upper left point
109
+//  xSize/ySize: box size
110
+inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
111
+  DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
112
+}
113
+
114
+// Move a screen area
115
+//  mode: 0, circle shift; 1, translation
116
+//  dir: 0=left, 1=right, 2=up, 3=down
117
+//  dis: Distance
118
+//  color: Fill color
119
+//  xStart/yStart: upper left point
120
+//  xEnd/yEnd: bottom right point
121
+void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
122
+                         uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
123
+
124
+/*---------------------------------------- Text related functions ----------------------------------------*/
125
+
126
+// Draw a string
127
+//  widthAdjust: true=self-adjust character width; false=no adjustment
128
+//  bShow: true=display background color; false=don't display background color
129
+//  size: Font size
130
+//  color: Character color
131
+//  bColor: Background color
132
+//  x/y: Upper-left coordinate of the string
133
+//  *string: The string
134
+//  rlimit: For draw less chars than string length use rlimit
135
+void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit = 0xFFFF);
136
+inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit = 0xFFFF) {
137
+  DWIN_Draw_String(0, bShow, size, color, bColor, x, y, string, rlimit);
138
+}
139
+
140
+class __FlashStringHelper;
141
+
142
+inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
143
+  DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, (char *)title);
144
+}
145
+inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
146
+  DWIN_Draw_String(0, bShow, size, color, bColor, x, y, (char *)title);
147
+}
148
+
149
+// Draw a positive integer
150
+//  bShow: true=display background color; false=don't display background color
151
+//  zeroFill: true=zero fill; false=no zero fill
152
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
153
+//  size: Font size
154
+//  color: Character color
155
+//  bColor: Background color
156
+//  iNum: Number of digits
157
+//  x/y: Upper-left coordinate
158
+//  value: Integer value
159
+void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
160
+                          uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value);
161
+
162
+// Draw a positive floating point number
163
+//  bShow: true=display background color; false=don't display background color
164
+//  zeroFill: true=zero fill; false=no zero fill
165
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
166
+//  size: Font size
167
+//  color: Character color
168
+//  bColor: Background color
169
+//  iNum: Number of whole digits
170
+//  fNum: Number of decimal digits
171
+//  x/y: Upper-left point
172
+//  value: Scaled positive float value
173
+void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
174
+                            uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
175
+
176
+/*---------------------------------------- Picture related functions ----------------------------------------*/
177
+
178
+// Display QR code
179
+//  The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
180
+//  QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
181
+//  (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
182
+//  str: multi-bit data
183
+void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string);
184
+
185
+inline void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
186
+  DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
187
+}
188
+
189
+// Draw JPG and cached in #0 virtual display area
190
+// id: Picture ID
191
+void DWIN_JPG_ShowAndCache(const uint8_t id);
192
+
193
+// Draw an Icon
194
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
195
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
196
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
197
+//  libID: Icon library ID
198
+//  picID: Icon ID
199
+//  x/y: Upper-left point
200
+void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
201
+
202
+// Draw an Icon with transparent background
203
+//  libID: Icon library ID
204
+//  picID: Icon ID
205
+//  x/y: Upper-left point
206
+inline void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
207
+  DWIN_ICON_Show(0, 0, 1, libID, picID, x, y);
208
+}
209
+
210
+// Draw an Icon from SRAM
211
+//  IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
212
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
213
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
214
+//  x/y: Upper-left point
215
+//  addr: SRAM address
216
+void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr);
217
+
218
+// Unzip the JPG picture to a virtual display area
219
+//  n: Cache index
220
+//  id: Picture ID
221
+void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
222
+
223
+// Unzip the JPG picture to virtual display area #1
224
+//  id: Picture ID
225
+inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
226
+
227
+// Copy area from current virtual display area to current screen
228
+//  xStart/yStart: Upper-left of virtual area
229
+//  xEnd/yEnd: Lower-right of virtual area
230
+//  x/y: Screen paste point
231
+void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
232
+                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
233
+
234
+// Copy area from virtual display area to current screen
235
+//  IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
236
+//  BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
237
+//  BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
238
+//  cacheID: virtual area number
239
+//  xStart/yStart: Upper-left of virtual area
240
+//  xEnd/yEnd: Lower-right of virtual area
241
+//  x/y: Screen paste point
242
+void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
243
+                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
244
+
245
+// Copy area from virtual display area to current screen with transparent background
246
+//  cacheID: virtual area number
247
+//  xStart/yStart: Upper-left of virtual area
248
+//  xEnd/yEnd: Lower-right of virtual area
249
+//  x/y: Screen paste point
250
+inline void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
251
+                         uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
252
+  DWIN_Frame_AreaCopy(0, 0, 1, cacheID, xStart, yStart, xEnd, yEnd, x, y);
253
+}
254
+
255
+// Animate a series of icons
256
+//  animID: Animation ID  up to 16
257
+//  animate: animation on or off
258
+//  libID: Icon library ID
259
+//  picIDs: Icon starting ID
260
+//  picIDe: Icon ending ID
261
+//  x/y: Upper-left point
262
+//  interval: Display time interval, unit 10mS
263
+void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
264
+                         uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
265
+
266
+// Animation Control
267
+//  state: 16 bits, each bit is the state of an animation id
268
+void DWIN_ICON_AnimationControl(uint16_t state);
269
+
270
+// Set LCD Brightness 0x00-0x0F
271
+void DWIN_LCD_Brightness(const uint8_t brightness);
272
+
273
+// Write buffer data to the SRAM or Flash
274
+//  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
275
+//  addr: start address
276
+//  length: Bytes to write
277
+//  data: address of the buffer with data
278
+void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data);
279
+
280
+// Write the contents of the 32KB SRAM data memory into the designated image memory space.
281
+//  picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes
282
+void DWIN_SRAMToPic(uint8_t picID);

+ 452
- 0
Marlin/src/lcd/e3v2/enhanced/dwinui.cpp View File

@@ -0,0 +1,452 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+#include "../../../inc/MarlinConfigPre.h"
23
+
24
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
25
+
26
+#include "../../../inc/MarlinConfig.h"
27
+#include "../../../core/macros.h"
28
+#include "dwin_lcd.h"
29
+#include "dwinui.h"
30
+
31
+//#define DEBUG_OUT 1
32
+#include "../../../core/debug_out.h"
33
+
34
+uint8_t MenuItemTotal = 0;
35
+uint8_t MenuItemCount = 0;
36
+MenuItemClass** MenuItems = nullptr;
37
+MenuClass *CurrentMenu = nullptr;
38
+MenuClass *PreviousMenu = nullptr;
39
+
40
+xy_int_t DWINUI::cursor = { 0 };
41
+uint16_t DWINUI::pencolor = Color_White;
42
+uint16_t DWINUI::textcolor = Def_Text_Color;
43
+uint16_t DWINUI::backcolor = Def_Background_Color;
44
+uint8_t  DWINUI::font = font8x16;
45
+
46
+void (*DWINUI::onCursorErase)(uint8_t line)=nullptr;
47
+void (*DWINUI::onCursorDraw)(uint8_t line)=nullptr;
48
+void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
49
+void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
50
+
51
+void DWINUI::Init(void) {
52
+  DEBUG_ECHOPGM("\r\nDWIN handshake ");
53
+  delay(750);   // Delay here or init later in the boot process
54
+  const bool success = DWIN_Handshake();
55
+  if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
56
+  DWIN_Frame_SetDir(1);
57
+  TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black));
58
+  DWIN_UpdateLCD();
59
+  cursor.x = 0;
60
+  cursor.y = 0;
61
+  pencolor = Color_White;
62
+  textcolor = Def_Text_Color;
63
+  backcolor = Def_Background_Color;
64
+  font = font8x16;
65
+}
66
+
67
+// Set text/number font
68
+void DWINUI::SetFont(uint8_t cfont) {
69
+  font = cfont;
70
+}
71
+
72
+// Get font character width
73
+uint8_t DWINUI::Get_font_width(uint8_t cfont) {
74
+  switch (cfont) {
75
+    case font6x12 : return 6;
76
+    case font8x16 : return 8;
77
+    case font10x20: return 10;
78
+    case font12x24: return 12;
79
+    case font14x28: return 14;
80
+    case font16x32: return 16;
81
+    case font20x40: return 20;
82
+    case font24x48: return 24;
83
+    case font28x56: return 28;
84
+    case font32x64: return 32;
85
+    default: return 0;
86
+  }
87
+}
88
+
89
+// Get font character heigh
90
+uint8_t DWINUI::Get_font_height(uint8_t cfont) {
91
+  switch (cfont) {
92
+    case font6x12 : return 12;
93
+    case font8x16 : return 16;
94
+    case font10x20: return 20;
95
+    case font12x24: return 24;
96
+    case font14x28: return 28;
97
+    case font16x32: return 32;
98
+    case font20x40: return 40;
99
+    case font24x48: return 48;
100
+    case font28x56: return 56;
101
+    case font32x64: return 64;
102
+    default: return 0;
103
+  }
104
+}
105
+
106
+// Get screen x coodinates from text column
107
+uint16_t DWINUI::ColToX(uint8_t col) {
108
+  return col * Get_font_width(font);
109
+}
110
+
111
+// Get screen y coodinates from text row
112
+uint16_t DWINUI::RowToY(uint8_t row) {
113
+  return row * Get_font_height(font);
114
+}
115
+
116
+// Set text/number color
117
+void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor) {
118
+  textcolor = fgcolor;
119
+  backcolor = bgcolor;
120
+}
121
+void DWINUI::SetTextColor(uint16_t fgcolor) {
122
+  textcolor = fgcolor;
123
+}
124
+void DWINUI::SetBackgroundColor(uint16_t bgcolor) {
125
+  backcolor = bgcolor;
126
+}
127
+
128
+// Moves cursor to point
129
+//  x: abscissa of the display
130
+//  y: ordinate of the display
131
+//  point: xy coordinate
132
+void DWINUI::MoveTo(int16_t x, int16_t y) {
133
+  cursor.x = x;
134
+  cursor.y = y;
135
+}
136
+void DWINUI::MoveTo(xy_int_t point) {
137
+  cursor = point;
138
+}
139
+
140
+// Moves cursor relative to the actual position
141
+//  x: abscissa of the display
142
+//  y: ordinate of the display
143
+//  point: xy coordinate
144
+void DWINUI::MoveBy(int16_t x, int16_t y) {
145
+  cursor.x += x;
146
+  cursor.y += y;
147
+}
148
+void DWINUI::MoveBy(xy_int_t point) {
149
+  cursor += point;
150
+}
151
+
152
+// Draw a Centered string using DWIN_WIDTH
153
+void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
154
+  const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * Get_font_width(size)) / 2 - 1;
155
+  DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
156
+}
157
+
158
+// Draw a char at cursor position
159
+void DWINUI::Draw_Char(const char c) {
160
+  const char string[2] = { c, 0};
161
+  DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
162
+  MoveBy(Get_font_width(font), 0);
163
+}
164
+
165
+// Draw a string at cursor position
166
+//  color: Character color
167
+//  *string: The string
168
+//  rlimit: For draw less chars than string length use rlimit
169
+void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
170
+  DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
171
+  MoveBy(strlen(string) * Get_font_width(font), 0);
172
+}
173
+void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
174
+  DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
175
+  MoveBy(strlen(string) * Get_font_width(font), 0);
176
+}
177
+
178
+// Draw a signed floating point number
179
+//  bShow: true=display background color; false=don't display background color
180
+//  zeroFill: true=zero fill; false=no zero fill
181
+//  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
182
+//  size: Font size
183
+//  bColor: Background color
184
+//  iNum: Number of whole digits
185
+//  fNum: Number of decimal digits
186
+//  x/y: Upper-left point
187
+//  value: Float value
188
+void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
189
+  if (value < 0) {
190
+    DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, -value);
191
+    DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F("-"));
192
+  }
193
+  else {
194
+    DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F(" "));
195
+    DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
196
+  }
197
+}
198
+
199
+// Draw a circle
200
+//  color: circle color
201
+//  x: the abscissa of the center of the circle
202
+//  y: ordinate of the center of the circle
203
+//  r: circle radius
204
+void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
205
+  int a = 0, b = 0;
206
+  while (a <= b) {
207
+    b = SQRT(sq(r) - sq(a));
208
+    if (a == 0) b--;
209
+    DWIN_Draw_Point(color, 1, 1, x + a, y + b);   // Draw some sector 1
210
+    DWIN_Draw_Point(color, 1, 1, x + b, y + a);   // Draw some sector 2
211
+    DWIN_Draw_Point(color, 1, 1, x + b, y - a);   // Draw some sector 3
212
+    DWIN_Draw_Point(color, 1, 1, x + a, y - b);   // Draw some sector 4
213
+    DWIN_Draw_Point(color, 1, 1, x - a, y - b);   // Draw some sector 5
214
+    DWIN_Draw_Point(color, 1, 1, x - b, y - a);   // Draw some sector 6
215
+    DWIN_Draw_Point(color, 1, 1, x - b, y + a);   // Draw some sector 7
216
+    DWIN_Draw_Point(color, 1, 1, x - a, y + b);   // Draw some sector 8
217
+    a++;
218
+  }
219
+}
220
+
221
+// Draw a circle filled with color
222
+//  bcolor: fill color
223
+//  x: the abscissa of the center of the circle
224
+//  y: ordinate of the center of the circle
225
+//  r: circle radius
226
+void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
227
+  int a = 0, b = 0;
228
+  while (a <= b) {
229
+    b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a);
230
+    if (a == 0) b--;
231
+    DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a);
232
+    DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b);
233
+    DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a);
234
+    DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b);
235
+    a++;
236
+  }
237
+}
238
+
239
+// Color Interpolator
240
+//  val : Interpolator minv..maxv
241
+//  minv : Minimum value
242
+//  maxv : Maximun value
243
+//  color1 : Start color
244
+//  color2 : End color
245
+uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
246
+  uint8_t B,G,R;
247
+  float n;
248
+  n = (float)(val-minv)/(maxv-minv);
249
+  R = (1-n)*GetRColor(color1) + n*GetRColor(color2);
250
+  G = (1-n)*GetGColor(color1) + n*GetGColor(color2);
251
+  B = (1-n)*GetBColor(color1) + n*GetBColor(color2);
252
+  return RGB(R,G,B);
253
+}
254
+
255
+// Color Interpolator through Red->Yellow->Green->Blue
256
+//  val : Interpolator minv..maxv
257
+//  minv : Minimum value
258
+//  maxv : Maximun value
259
+uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
260
+  uint8_t B,G,R;
261
+  const uint8_t maxB = 28;
262
+  const uint8_t maxR = 28;
263
+  const uint8_t maxG = 38;
264
+  const int16_t limv = _MAX(abs(minv), abs(maxv));
265
+  float n;
266
+  if (minv>=0) {
267
+    n = (float)(val-minv)/(maxv-minv);
268
+  } else {
269
+    n = (float)val/limv;
270
+  }
271
+  n = _MIN(1, n);
272
+  n = _MAX(-1, n);
273
+  if (n < 0) {
274
+    R = 0;
275
+    G = (1+n)*maxG;
276
+    B = (-n)*maxB;
277
+  } else if (n < 0.5) {
278
+    R = maxR*n*2;
279
+    G = maxG;
280
+    B = 0;
281
+  } else {
282
+    R = maxR;
283
+    G = maxG*(1-n);
284
+    B = 0;
285
+  }
286
+  return RGB(R,G,B);
287
+}
288
+
289
+// Draw a checkbox
290
+//  Color: frame color
291
+//  bColor: Background color
292
+//  x/y: Upper-left point
293
+//  mode : 0 : unchecked, 1 : checked
294
+void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
295
+  DWIN_Draw_String(false, true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
296
+  DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
297
+}
298
+
299
+// Clear Menu by filling the menu area with background color
300
+void DWINUI::ClearMenuArea() {
301
+  DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
302
+}
303
+
304
+void DWINUI::MenuItemsClear() {
305
+  if (MenuItems == nullptr) return;
306
+  for (uint8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i];
307
+  delete[] MenuItems;
308
+  MenuItems = nullptr;
309
+  MenuItemCount = 0;
310
+  MenuItemTotal = 0;
311
+}
312
+
313
+void DWINUI::MenuItemsPrepare(uint8_t totalitems) {
314
+  MenuItemsClear();
315
+  MenuItemTotal = totalitems;
316
+  MenuItems = new MenuItemClass*[totalitems];
317
+}
318
+
319
+MenuItemClass* DWINUI::MenuItemsAdd(MenuItemClass* menuitem) {
320
+  if (MenuItemCount < MenuItemTotal) {
321
+    MenuItems[MenuItemCount] = menuitem;
322
+    menuitem->pos = MenuItemCount++;
323
+    return menuitem;
324
+  }
325
+  else {
326
+    delete menuitem;
327
+    return nullptr;
328
+  }
329
+}
330
+
331
+/* Title Class ==============================================================*/
332
+
333
+TitleClass Title;
334
+
335
+void TitleClass::Draw() {
336
+  if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
337
+}
338
+
339
+void TitleClass::SetCaption(const char * const title) {
340
+  frameid = 0;
341
+  if ( caption == title ) return;
342
+  const uint8_t len = _MIN(sizeof(caption) - 1, strlen(title));
343
+  memcpy(&caption[0], title, len);
344
+  caption[len] = '\0';
345
+}
346
+
347
+void TitleClass::ShowCaption(const char * const title) {
348
+  SetCaption(title);
349
+  Draw();
350
+}
351
+
352
+void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
353
+  caption[0] = '\0';
354
+  frameid = id;
355
+  frame = { x1, y1, x2, y2 };
356
+}
357
+
358
+void TitleClass::SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
359
+  SetFrame(1, x, y, x + w - 1, y + h - 1);
360
+}
361
+
362
+void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
363
+  SetFrame(id, x1, y1, x2, y2);
364
+  Draw();
365
+}
366
+
367
+void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
368
+  FrameCopy(1, x, y, x + w - 1, y + h - 1);
369
+}
370
+
371
+/* Menu Class ===============================================================*/
372
+
373
+MenuClass::MenuClass() {
374
+  selected = 0;
375
+  topline = 0;
376
+}
377
+
378
+void MenuClass::Draw() {
379
+  MenuTitle.Draw();
380
+  if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
381
+  for (uint8_t i = 0; i < MenuItemCount; i++)
382
+    MenuItems[i]->Draw(i - topline);
383
+  if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
384
+  DWIN_UpdateLCD();
385
+}
386
+
387
+void MenuClass::onScroll(bool dir) {
388
+  int8_t sel = selected;
389
+  if (dir) sel++; else sel--;
390
+  LIMIT(sel, 0, MenuItemCount - 1);
391
+  if (sel != selected) {
392
+    if (DWINUI::onCursorErase != nullptr) DWINUI::onCursorErase(line());
393
+    if ((sel - topline) == TROWS) {
394
+      DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
395
+      topline++;
396
+      MenuItems[sel]->Draw(TROWS - 1);
397
+    }
398
+    if ((sel < topline)) {
399
+      DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
400
+      topline--;
401
+      MenuItems[sel]->Draw(0);
402
+    }
403
+    selected = sel;
404
+    if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
405
+    DWIN_UpdateLCD();
406
+  }
407
+}
408
+
409
+void MenuClass::onClick() {
410
+  if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)();
411
+}
412
+
413
+MenuItemClass *MenuClass::SelectedItem() {
414
+  return MenuItems[selected];
415
+}
416
+
417
+/* MenuItem Class ===========================================================*/
418
+
419
+MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) {
420
+  icon = cicon;
421
+  onClick = onclick;
422
+  onDraw = ondraw;
423
+  const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text));
424
+  memcpy(&caption[0], text, len);
425
+  caption[len] = '\0';
426
+}
427
+
428
+MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) {
429
+  icon = cicon;
430
+  onClick = onclick;
431
+  onDraw = ondraw;
432
+  caption[0] = '\0';
433
+  frameid = id;
434
+  frame = { x1, y1, x2, y2 };
435
+}
436
+
437
+void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
438
+  caption[0] = '\0';
439
+  frameid = id;
440
+  frame = { x1, y1, x2, y2 };
441
+}
442
+
443
+void MenuItemClass::Draw(int8_t line) {
444
+  if (line < 0 || line >= TROWS) return;
445
+  if (onDraw != nullptr) (*onDraw)(this, line);
446
+};
447
+
448
+MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemClass(cicon, text, ondraw, onclick) {
449
+  value = val;
450
+};
451
+
452
+#endif // DWIN_CREALITY_LCD_ENHANCED

+ 623
- 0
Marlin/src/lcd/e3v2/enhanced/dwinui.h View File

@@ -0,0 +1,623 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+#pragma once
22
+
23
+#include "../../../core/types.h"
24
+#include "dwin_lcd.h"
25
+
26
+// ICON ID
27
+#define ICON                7 // Icon set file 7.ICO
28
+
29
+#define ICON_LOGO                  0
30
+#define ICON_Print_0               1
31
+#define ICON_Print_1               2
32
+#define ICON_Prepare_0             3
33
+#define ICON_Prepare_1             4
34
+#define ICON_Control_0             5
35
+#define ICON_Control_1             6
36
+#define ICON_Leveling_0            7
37
+#define ICON_Leveling_1            8
38
+#define ICON_HotendTemp            9
39
+#define ICON_BedTemp              10
40
+#define ICON_Speed                11
41
+#define ICON_Zoffset              12
42
+#define ICON_Back                 13
43
+#define ICON_File                 14
44
+#define ICON_PrintTime            15
45
+#define ICON_RemainTime           16
46
+#define ICON_Setup_0              17
47
+#define ICON_Setup_1              18
48
+#define ICON_Pause_0              19
49
+#define ICON_Pause_1              20
50
+#define ICON_Continue_0           21
51
+#define ICON_Continue_1           22
52
+#define ICON_Stop_0               23
53
+#define ICON_Stop_1               24
54
+#define ICON_Bar                  25
55
+#define ICON_More                 26
56
+
57
+#define ICON_Axis                 27
58
+#define ICON_CloseMotor           28
59
+#define ICON_Homing               29
60
+#define ICON_SetHome              30
61
+#define ICON_PLAPreheat           31
62
+#define ICON_ABSPreheat           32
63
+#define ICON_Cool                 33
64
+#define ICON_Language             34
65
+
66
+#define ICON_MoveX                35
67
+#define ICON_MoveY                36
68
+#define ICON_MoveZ                37
69
+#define ICON_Extruder             38
70
+
71
+#define ICON_Temperature          40
72
+#define ICON_Motion               41
73
+#define ICON_WriteEEPROM          42
74
+#define ICON_ReadEEPROM           43
75
+#define ICON_ResumeEEPROM         44
76
+#define ICON_Info                 45
77
+
78
+#define ICON_SetEndTemp           46
79
+#define ICON_SetBedTemp           47
80
+#define ICON_FanSpeed             48
81
+#define ICON_SetPLAPreheat        49
82
+#define ICON_SetABSPreheat        50
83
+
84
+#define ICON_MaxSpeed             51
85
+#define ICON_MaxAccelerated       52
86
+#define ICON_MaxJerk              53
87
+#define ICON_Step                 54
88
+#define ICON_PrintSize            55
89
+#define ICON_Version              56
90
+#define ICON_Contact              57
91
+#define ICON_StockConfiguration   58
92
+#define ICON_MaxSpeedX            59
93
+#define ICON_MaxSpeedY            60
94
+#define ICON_MaxSpeedZ            61
95
+#define ICON_MaxSpeedE            62
96
+#define ICON_MaxAccX              63
97
+#define ICON_MaxAccY              64
98
+#define ICON_MaxAccZ              65
99
+#define ICON_MaxAccE              66
100
+#define ICON_MaxSpeedJerkX        67
101
+#define ICON_MaxSpeedJerkY        68
102
+#define ICON_MaxSpeedJerkZ        69
103
+#define ICON_MaxSpeedJerkE        70
104
+#define ICON_StepX                71
105
+#define ICON_StepY                72
106
+#define ICON_StepZ                73
107
+#define ICON_StepE                74
108
+#define ICON_Setspeed             75
109
+#define ICON_SetZOffset           76
110
+#define ICON_Rectangle            77
111
+#define ICON_BLTouch              78
112
+#define ICON_TempTooLow           79
113
+#define ICON_AutoLeveling         80
114
+#define ICON_TempTooHigh          81
115
+#define ICON_NoTips_C             82
116
+#define ICON_NoTips_E             83
117
+#define ICON_Continue_C           84
118
+#define ICON_Continue_E           85
119
+#define ICON_Cancel_C             86
120
+#define ICON_Cancel_E             87
121
+#define ICON_Confirm_C            88
122
+#define ICON_Confirm_E            89
123
+#define ICON_Info_0               90
124
+#define ICON_Info_1               91
125
+
126
+// Extra Icons
127
+#define ICON_AdvSet               ICON_Language
128
+#define ICON_Brightness           ICON_Motion
129
+#define ICON_Cancel               ICON_StockConfiguration
130
+#define ICON_CustomPreheat        ICON_SetEndTemp
131
+#define ICON_Error                ICON_TempTooHigh
132
+#define ICON_ExtrudeMinT          ICON_HotendTemp
133
+#define ICON_FilLoad              ICON_WriteEEPROM
134
+#define ICON_FilMan               ICON_ResumeEEPROM
135
+#define ICON_FilSet               ICON_ResumeEEPROM
136
+#define ICON_FilUnload            ICON_ReadEEPROM
137
+#define ICON_Flow                 ICON_StepE
138
+#define ICON_HomeOffset           ICON_AdvSet
139
+#define ICON_HomeOffsetX          ICON_StepX
140
+#define ICON_HomeOffsetY          ICON_StepY
141
+#define ICON_HomeOffsetZ          ICON_StepZ
142
+#define ICON_LevBed               ICON_SetEndTemp
143
+#define ICON_Lock                 ICON_Cool
144
+#define ICON_ManualMesh           ICON_HotendTemp
145
+#define ICON_MeshNext             ICON_Axis
146
+#define ICON_MeshSave             ICON_WriteEEPROM
147
+#define ICON_MoveZ0               ICON_HotendTemp
148
+#define ICON_Park                 ICON_Motion
149
+#define ICON_PIDbed               ICON_SetBedTemp
150
+#define ICON_PIDcycles            ICON_ResumeEEPROM
151
+#define ICON_PIDNozzle            ICON_SetEndTemp
152
+#define ICON_PIDValue             ICON_Contact
153
+#define ICON_ProbeOffsetX         ICON_StepX
154
+#define ICON_ProbeOffsetY         ICON_StepY
155
+#define ICON_ProbeSet             ICON_SetEndTemp
156
+#define ICON_ProbeTest            ICON_SetEndTemp
157
+#define ICON_Pwrlossr             ICON_Motion
158
+#define ICON_Reboot               ICON_ResumeEEPROM
159
+#define ICON_Runout               ICON_MaxAccE
160
+#define ICON_Scolor               ICON_MaxSpeed
161
+#define ICON_SetCustomPreheat     ICON_SetEndTemp
162
+#define ICON_Sound                ICON_Cool
163
+
164
+/**
165
+ * 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
166
+ * 0x00=6*12   0x01=8*16   0x02=10*20  0x03=12*24  0x04=14*28
167
+ * 0x05=16*32  0x06=20*40  0x07=24*48  0x08=28*56  0x09=32*64
168
+ */
169
+#define font6x12  0x00
170
+#define font8x16  0x01
171
+#define font10x20 0x02
172
+#define font12x24 0x03
173
+#define font14x28 0x04
174
+#define font16x32 0x05
175
+#define font20x40 0x06
176
+#define font24x48 0x07
177
+#define font28x56 0x08
178
+#define font32x64 0x09
179
+
180
+// Extended and default UI Colors
181
+#define RGB(R,G,B)  (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
182
+#define GetRColor(color) ((color >> 11) & 0x1F)
183
+#define GetGColor(color) ((color >>  5) & 0x3F)
184
+#define GetBColor(color) ((color >>  0) & 0x1F)
185
+
186
+#define Color_White       0xFFFF
187
+#define Color_Bg_Window   0x31E8  // Popup background color
188
+#define Color_Bg_Blue     0x1125  // Dark blue background color
189
+#define Color_Bg_Black    0x0841  // Black background color
190
+#define Color_Bg_Red      0xF00F  // Red background color
191
+#define Popup_Text_Color  0xD6BA  // Popup font background color
192
+#define Line_Color        0x3A6A  // Split line color
193
+#define Rectangle_Color   0xEE2F  // Blue square cursor color
194
+#define Percent_Color     0xFE29  // Percentage color
195
+#define BarFill_Color     0x10E4  // Fill color of progress bar
196
+#define Select_Color      0x33BB  // Selected color
197
+
198
+#define Color_Black           0
199
+#define Color_Red             RGB(31,0,0)
200
+#define Color_Yellow          RGB(31,63,0)
201
+#define Color_Green           RGB(0,63,0)
202
+#define Color_Aqua            RGB(0,63,31)
203
+#define Color_Blue            RGB(0,0,31)
204
+
205
+// Default UI Colors
206
+#define Def_Background_Color  Color_Bg_Black
207
+#define Def_Cursor_color      Rectangle_Color
208
+#define Def_TitleBg_color     Color_Bg_Blue
209
+#define Def_TitleTxt_color    Color_White
210
+#define Def_Text_Color        Color_White
211
+#define Def_Selected_Color    Select_Color
212
+#define Def_SplitLine_Color   Line_Color
213
+#define Def_Highlight_Color   Color_White
214
+#define Def_StatusBg_Color    RGB(0,20,20)
215
+#define Def_StatusTxt_Color   Color_Yellow
216
+#define Def_PopupBg_color     Color_Bg_Window
217
+#define Def_PopupTxt_Color    Popup_Text_Color
218
+#define Def_AlertBg_Color     Color_Bg_Red
219
+#define Def_AlertTxt_Color    Color_Yellow
220
+#define Def_PercentTxt_Color  Percent_Color
221
+#define Def_Barfill_Color     BarFill_Color
222
+#define Def_Indicator_Color   Color_White
223
+#define Def_Coordinate_Color   Color_White
224
+
225
+//UI elements defines and constants
226
+#define DWIN_FONT_MENU font8x16
227
+#define DWIN_FONT_STAT font10x20
228
+#define DWIN_FONT_HEAD font10x20
229
+#define DWIN_FONT_ALERT font10x20
230
+#define STATUS_Y 354
231
+#define LCD_WIDTH (DWIN_WIDTH / 8)
232
+
233
+constexpr uint16_t TITLE_HEIGHT = 30,                          // Title bar height
234
+                   MLINE = 53,                                 // Menu line height
235
+                   TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE,  // Total rows
236
+                   MROWS = TROWS - 1,                          // Other-than-Back
237
+                   ICOX = 26,                                  // Menu item icon X position
238
+                   LBLX = 60,                                  // Menu item label X position
239
+                   VALX = 210,                                 // Menu item value X position
240
+                   MENU_CHR_W = 8, MENU_CHR_H = 16,            // Menu font 8x16
241
+                   STAT_CHR_W = 10;
242
+
243
+// Menuitem Y position
244
+#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L))
245
+
246
+// Menuitem caption Offset
247
+#define CAPOFF ((MLINE - MENU_CHR_H) / 2)
248
+
249
+// Menuitem caption Y position
250
+#define MBASE(L) (MYPOS(L) + CAPOFF)
251
+
252
+// Create and add a MenuItem object to the menu array
253
+#define ADDMENUITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V))
254
+#define ADDMENUITEM_P(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V))
255
+
256
+typedef struct { uint16_t left, top, right, bottom; } rect_t;
257
+typedef struct { uint16_t x, y, w, h; } frame_rect_t;
258
+
259
+class TitleClass {
260
+public:
261
+  char caption[32] = "";
262
+  uint8_t frameid = 0;
263
+  rect_t frame = {0};
264
+  void Draw();
265
+  void SetCaption(const char * const title);
266
+  inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
267
+  void ShowCaption(const char * const title);
268
+  inline void ShowCaption(const __FlashStringHelper * title) { ShowCaption((char *)title); }
269
+  void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
270
+  void SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
271
+  void FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
272
+  void FrameCopy(uint16_t x, uint16_t y, uint16_t h, uint16_t v);
273
+};
274
+extern TitleClass Title;
275
+
276
+class MenuItemClass {
277
+protected:
278
+public:
279
+  uint8_t pos = 0;
280
+  uint8_t icon = 0;
281
+  char caption[32] = "";
282
+  uint8_t frameid = 0;
283
+  rect_t frame = {0};
284
+  void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr;
285
+  void (*onClick)() = nullptr;
286
+  MenuItemClass() {};
287
+  MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
288
+  MenuItemClass(uint8_t cicon, const __FlashStringHelper * text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, (char*)text, ondraw, onclick){}
289
+  MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
290
+  void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
291
+  virtual ~MenuItemClass(){};
292
+  virtual void Draw(int8_t line);
293
+};
294
+
295
+class MenuItemPtrClass: public MenuItemClass {
296
+public:
297
+  void *value = nullptr;
298
+  using MenuItemClass::MenuItemClass;
299
+  MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val);
300
+  MenuItemPtrClass(uint8_t cicon, const __FlashStringHelper * text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, (char*)text, ondraw, onclick, val){}
301
+};
302
+
303
+class MenuClass {
304
+public:
305
+  int8_t topline = 0;
306
+  int8_t selected = 0;
307
+  TitleClass MenuTitle;
308
+  MenuClass();
309
+  virtual ~MenuClass(){};
310
+  inline int8_t line() { return selected - topline; };
311
+  inline int8_t line(uint8_t pos) {return pos - topline; };
312
+  void Draw();
313
+  void onScroll(bool dir);
314
+  void onClick();
315
+  MenuItemClass* SelectedItem();
316
+};
317
+extern MenuClass *CurrentMenu;
318
+
319
+namespace DWINUI {
320
+  extern xy_int_t cursor;
321
+  extern uint16_t pencolor;
322
+  extern uint16_t textcolor;
323
+  extern uint16_t backcolor;
324
+  extern uint8_t  font;
325
+
326
+  extern void (*onCursorErase)(uint8_t line);
327
+  extern void (*onCursorDraw)(uint8_t line);
328
+  extern void (*onTitleDraw)(TitleClass* title);
329
+  extern void (*onMenuDraw)(MenuClass* menu);
330
+
331
+  // DWIN LCD Initialization
332
+  void Init(void);
333
+
334
+  // Set text/number font
335
+  void SetFont(uint8_t cfont);
336
+
337
+  // Get font character width
338
+  uint8_t Get_font_width(uint8_t cfont);
339
+
340
+  // Get font character heigh
341
+  uint8_t Get_font_height(uint8_t cfont);
342
+
343
+  // Get screen x coodinates from text column
344
+  uint16_t ColToX(uint8_t col);
345
+
346
+  // Get screen y coodinates from text row
347
+  uint16_t RowToY(uint8_t row);
348
+
349
+  // Set text/number color
350
+  void SetColors(uint16_t fgcolor, uint16_t bgcolor);
351
+  void SetTextColor(uint16_t fgcolor);
352
+  void SetBackgroundColor(uint16_t bgcolor);
353
+
354
+  // Moves cursor to point
355
+  //  x: abscissa of the display
356
+  //  y: ordinate of the display
357
+  //  point: xy coordinate
358
+  void MoveTo(int16_t x, int16_t y);
359
+  void MoveTo(xy_int_t point);
360
+
361
+  // Moves cursor relative to the actual position
362
+  //  x: abscissa of the display
363
+  //  y: ordinate of the display
364
+  //  point: xy coordinate
365
+  void MoveBy(int16_t x, int16_t y);
366
+  void MoveBy(xy_int_t point);
367
+
368
+  // Draw a line from the cursor to xy position
369
+  //  color: Line segment color
370
+  //  x/y: End point
371
+  inline void LineTo(uint16_t color, uint16_t x, uint16_t y) {
372
+    DWIN_Draw_Line(color, cursor.x, cursor.y, x, y);
373
+  }
374
+  inline void LineTo(uint16_t x, uint16_t y) {
375
+    DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y);
376
+  }
377
+
378
+  // Draw an Icon with transparent background from the library ICON
379
+  //  icon: Icon ID
380
+  //  x/y: Upper-left point
381
+  inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) {
382
+    DWIN_ICON_Show(ICON, icon, x, y);
383
+  }
384
+
385
+  // Draw a positive integer
386
+  //  bShow: true=display background color; false=don't display background color
387
+  //  zeroFill: true=zero fill; false=no zero fill
388
+  //  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
389
+  //  size: Font size
390
+  //  color: Character color
391
+  //  bColor: Background color
392
+  //  iNum: Number of digits
393
+  //  x/y: Upper-left coordinate
394
+  //  value: Integer value
395
+  inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
396
+    DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value);
397
+  }
398
+  inline void Draw_Int(uint8_t iNum, uint16_t value) {
399
+    DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
400
+    MoveBy(iNum * Get_font_width(font), 0);
401
+  }
402
+  inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
403
+    DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
404
+  }
405
+  inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
406
+    DWIN_Draw_IntValue(false, true, 0, font, color, backcolor, iNum, x, y, value);
407
+  }
408
+  inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
409
+    DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value);
410
+  }
411
+  inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
412
+    DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value);
413
+  }
414
+
415
+  // Draw a floating point number
416
+  //  bShow: true=display background color; false=don't display background color
417
+  //  zeroFill: true=zero fill; false=no zero fill
418
+  //  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
419
+  //  size: Font size
420
+  //  color: Character color
421
+  //  bColor: Background color
422
+  //  iNum: Number of whole digits
423
+  //  fNum: Number of decimal digits
424
+  //  x/y: Upper-left point
425
+  //  value: Float value
426
+  inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
427
+    DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
428
+  }
429
+  inline void Draw_Float(uint8_t iNum, uint8_t fNum, long value) {
430
+    DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum,  cursor.x, cursor.y, value);
431
+    MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
432
+  }
433
+  inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
434
+    DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
435
+  }
436
+  inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
437
+    DWIN_Draw_FloatValue(false, true, 0, font, color, backcolor, iNum, fNum, x, y, value);
438
+  }
439
+  inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
440
+    DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
441
+  }
442
+  inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
443
+    DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
444
+  }
445
+
446
+  // Draw a signed floating point number
447
+  //  bShow: true=display background color; false=don't display background color
448
+  //  zeroFill: true=zero fill; false=no zero fill
449
+  //  zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
450
+  //  size: Font size
451
+  //  bColor: Background color
452
+  //  iNum: Number of whole digits
453
+  //  fNum: Number of decimal digits
454
+  //  x/y: Upper-left point
455
+  //  value: Float value
456
+  void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
457
+  inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, long value) {
458
+    Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
459
+    MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
460
+  }
461
+  inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
462
+    Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
463
+  }
464
+  inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
465
+    Draw_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
466
+  }
467
+  inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
468
+    Draw_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
469
+  }
470
+  inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
471
+    Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
472
+  }
473
+
474
+  // Draw a char at cursor position
475
+  void Draw_Char(const char c);
476
+
477
+  // Draw a string at cursor position
478
+  //  color: Character color
479
+  //  *string: The string
480
+  //  rlimit: For draw less chars than string length use rlimit
481
+  void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
482
+  void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
483
+
484
+  // Draw a string
485
+  //  size: Font size
486
+  //  color: Character color
487
+  //  bColor: Background color
488
+  //  x/y: Upper-left coordinate of the string
489
+  //  *string: The string
490
+  inline void Draw_String(uint16_t x, uint16_t y, const char * const string) {
491
+    DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
492
+  }
493
+  inline void Draw_String(uint16_t x, uint16_t y, const __FlashStringHelper *title) {
494
+    DWIN_Draw_String(false, font, textcolor, backcolor, x, y, (char *)title);
495
+  }
496
+  inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
497
+    DWIN_Draw_String(false, font, color, backcolor, x, y, string);
498
+  }
499
+  inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
500
+    DWIN_Draw_String(false, font, color, backcolor, x, y, (char *)title);
501
+  }
502
+  inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
503
+    DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
504
+  }
505
+  inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
506
+    DWIN_Draw_String(true, font, color, bgcolor, x, y, (char *)title);
507
+  }
508
+  inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
509
+    DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
510
+  }
511
+  inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
512
+    DWIN_Draw_String(true, size, color, bgcolor, x, y, (char *)title);
513
+  }
514
+
515
+  // Draw a centered string using DWIN_WIDTH
516
+  //  bShow: true=display background color; false=don't display background color
517
+  //  size: Font size
518
+  //  color: Character color
519
+  //  bColor: Background color
520
+  //  y: Upper coordinate of the string
521
+  //  *string: The string
522
+  void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string);
523
+  inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const __FlashStringHelper *title) {
524
+    Draw_CenteredString(bShow, size, color, bColor, y, (char *)title);
525
+  }
526
+  inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
527
+    Draw_CenteredString(true, font, color, bcolor, y, string);
528
+  }
529
+  inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) {
530
+    Draw_CenteredString(false, size, color, backcolor, y, string);
531
+  }
532
+  inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const __FlashStringHelper *title) {
533
+    Draw_CenteredString(false, size, color, backcolor, y, (char *)title);
534
+  }
535
+  inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
536
+    Draw_CenteredString(false, font, color, backcolor, y, string);
537
+  }
538
+  inline void Draw_CenteredString(uint16_t color, uint16_t y, const __FlashStringHelper *title) {
539
+    Draw_CenteredString(false, font, color, backcolor, y, (char *)title);
540
+  }
541
+  inline void Draw_CenteredString(uint16_t y, const char * const string) {
542
+    Draw_CenteredString(false, font, textcolor, backcolor, y, string);
543
+  }
544
+  inline void Draw_CenteredString(uint16_t y, const __FlashStringHelper *title) {
545
+    Draw_CenteredString(false, font, textcolor, backcolor, y, (char *)title);
546
+  }
547
+
548
+  // Draw a circle
549
+  //  Color: circle color
550
+  //  x: the abscissa of the center of the circle
551
+  //  y: ordinate of the center of the circle
552
+  //  r: circle radius
553
+  void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
554
+  inline void Draw_Circle(uint16_t color, uint8_t r) {
555
+    Draw_Circle(color, cursor.x, cursor.y, r);
556
+  }
557
+
558
+  // Draw a checkbox
559
+  //  Color: frame color
560
+  //  bColor: Background color
561
+  //  x/y: Upper-left point
562
+  //  checked : 0 : unchecked, 1 : checked
563
+  void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
564
+  inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) {
565
+    Draw_Checkbox(textcolor, backcolor, x, y, checked);
566
+  }
567
+
568
+  // Color Interpolator
569
+  //  val : Interpolator minv..maxv
570
+  //  minv : Minimum value
571
+  //  maxv : Maximun value
572
+  //  color1 : Start color
573
+  //  color2 : End color
574
+  uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
575
+
576
+  // -------------------------- Extra -------------------------------//
577
+
578
+  // Draw a circle filled with color
579
+  //  bcolor: fill color
580
+  //  x: the abscissa of the center of the circle
581
+  //  y: ordinate of the center of the circle
582
+  //  r: circle radius
583
+  void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
584
+  inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
585
+    Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
586
+  }
587
+
588
+  // Color Interpolator through Red->Yellow->Green->Blue
589
+  //  val : Interpolator minv..maxv
590
+  //  minv : Minimum value
591
+  //  maxv : Maximun value
592
+  uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
593
+
594
+  // Write buffer data to the SRAM
595
+  //  addr: SRAM start address 0x0000-0x7FFF
596
+  //  length: Bytes to write
597
+  //  data: address of the buffer with data
598
+  inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
599
+    DWIN_WriteToMem(0x5A, addr, length, data);
600
+  }
601
+
602
+  // Write buffer data to the Flash
603
+  //  addr: Flash start address 0x0000-0x3FFF
604
+  //  length: Bytes to write
605
+  //  data: address of the buffer with data
606
+  inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
607
+    DWIN_WriteToMem(0xA5, addr, length, data);
608
+  }
609
+
610
+  // Clear Menu by filling the area with background color
611
+  // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
612
+  void ClearMenuArea();
613
+
614
+  // Clear MenuItems array and free MenuItems elements
615
+  void MenuItemsClear();
616
+
617
+  // Prepare MenuItems array
618
+  void MenuItemsPrepare(uint8_t totalitems);
619
+
620
+  // Add elements to the MenuItems array
621
+  MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem);
622
+
623
+};

+ 69
- 0
Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp View File

@@ -0,0 +1,69 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+#include "../../../inc/MarlinConfigPre.h"
23
+
24
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
25
+
26
+#include "../../../core/types.h"
27
+#include "dwin_lcd.h"
28
+#include "dwinui.h"
29
+#include "dwin.h"
30
+#include "lockscreen.h"
31
+
32
+LockScreenClass LockScreen;
33
+
34
+void LockScreenClass::Init() {
35
+  Lock_Pos = 0;
36
+  unlocked = false;
37
+  Draw();
38
+}
39
+
40
+void LockScreenClass::Draw() {
41
+  Title.SetCaption(PSTR("Lock Screen"));
42
+  DWINUI::ClearMenuArea();
43
+  DWINUI::Draw_Icon(ICON_LOGO, 71, 120);  // CREALITY logo
44
+  DWINUI::Draw_CenteredString(Color_White, 180, F("Printer is Locked,"));
45
+  DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
46
+  DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
47
+  DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
48
+  DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
49
+  DWIN_UpdateLCD();
50
+}
51
+
52
+void LockScreenClass::onEncoderState(ENCODER_DiffState encoder_diffState) {
53
+  if (encoder_diffState == ENCODER_DIFF_CW) {
54
+    Lock_Pos += 8;
55
+  }
56
+  else if (encoder_diffState == ENCODER_DIFF_CCW) {
57
+    Lock_Pos -= 8;
58
+  }
59
+  else if (encoder_diffState == ENCODER_DIFF_ENTER) {
60
+    unlocked = (Lock_Pos == 128);
61
+  }
62
+  DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
63
+  DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
64
+  DWIN_UpdateLCD();
65
+}
66
+
67
+bool LockScreenClass::isUnlocked() { return unlocked; }
68
+
69
+#endif // DWIN_CREALITY_LCD_ENHANCED

+ 35
- 0
Marlin/src/lcd/e3v2/enhanced/lockscreen.h View File

@@ -0,0 +1,35 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+#pragma once
22
+
23
+#include "../../../core/types.h"
24
+
25
+class LockScreenClass {
26
+private:
27
+  uint8_t Lock_Pos = 0;
28
+  bool unlocked = false;
29
+public:
30
+  void Init();
31
+  void onEncoderState(ENCODER_DiffState encoder_diffState);
32
+  void Draw();
33
+  bool isUnlocked();
34
+};
35
+extern LockScreenClass LockScreen;

+ 261
- 0
Marlin/src/lcd/e3v2/enhanced/rotary_encoder.cpp View File

@@ -0,0 +1,261 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+
22
+/*****************************************************************************
23
+ * @file     lcd/e3v2/enhanced/rotary_encoder.cpp
24
+ * @author   LEO / Creality3D
25
+ * @date     2019/07/06
26
+ * @version  2.0.1
27
+ * @brief    Rotary encoder functions
28
+ *****************************************************************************/
29
+
30
+#include "../../../inc/MarlinConfigPre.h"
31
+
32
+#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
33
+
34
+#include "rotary_encoder.h"
35
+#include "../../buttons.h"
36
+
37
+#include "../../../MarlinCore.h"
38
+#include "../../../HAL/shared/Delay.h"
39
+
40
+#if HAS_BUZZER
41
+  #include "../../../libs/buzzer.h"
42
+#endif
43
+
44
+#include <stdlib.h>
45
+
46
+#ifndef ENCODER_PULSES_PER_STEP
47
+  #define ENCODER_PULSES_PER_STEP 4
48
+#endif
49
+
50
+#if ENABLED(SOUND_MENU_ITEM)
51
+  #include "../../marlinui.h"
52
+#endif
53
+
54
+ENCODER_Rate EncoderRate;
55
+
56
+// Buzzer
57
+void Encoder_tick() {
58
+  #if PIN_EXISTS(BEEPER)
59
+    if (TERN1(SOUND_MENU_ITEM, ui.buzzer_enabled)) {
60
+      WRITE(BEEPER_PIN, HIGH);
61
+      delay(10);
62
+      WRITE(BEEPER_PIN, LOW);
63
+    }
64
+  #endif
65
+}
66
+
67
+// Encoder initialization
68
+void Encoder_Configuration() {
69
+  #if BUTTON_EXISTS(EN1)
70
+    SET_INPUT_PULLUP(BTN_EN1);
71
+  #endif
72
+  #if BUTTON_EXISTS(EN2)
73
+    SET_INPUT_PULLUP(BTN_EN2);
74
+  #endif
75
+  #if BUTTON_EXISTS(ENC)
76
+    SET_INPUT_PULLUP(BTN_ENC);
77
+  #endif
78
+  #if PIN_EXISTS(BEEPER)
79
+    SET_OUTPUT(BEEPER_PIN);
80
+  #endif
81
+}
82
+
83
+// Analyze encoder value and return state
84
+ENCODER_DiffState Encoder_ReceiveAnalyze() {
85
+  const millis_t now = millis();
86
+  static uint8_t lastEncoderBits;
87
+  uint8_t newbutton = 0;
88
+  static signed char temp_diff = 0;
89
+
90
+  ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
91
+  if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
92
+  if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
93
+  if (BUTTON_PRESSED(ENC)) {
94
+    static millis_t next_click_update_ms;
95
+    if (ELAPSED(now, next_click_update_ms)) {
96
+      next_click_update_ms = millis() + 300;
97
+      Encoder_tick();
98
+      #if PIN_EXISTS(LCD_LED)
99
+        //LED_Action();
100
+      #endif
101
+      const bool was_waiting = wait_for_user;
102
+      wait_for_user = false;
103
+      return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
104
+    }
105
+    else return ENCODER_DIFF_NO;
106
+  }
107
+  if (newbutton != lastEncoderBits) {
108
+    switch (newbutton) {
109
+      case ENCODER_PHASE_0:
110
+             if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
111
+        else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
112
+        break;
113
+      case ENCODER_PHASE_1:
114
+             if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
115
+        else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
116
+        break;
117
+      case ENCODER_PHASE_2:
118
+             if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
119
+        else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
120
+        break;
121
+      case ENCODER_PHASE_3:
122
+             if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
123
+        else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
124
+        break;
125
+    }
126
+    lastEncoderBits = newbutton;
127
+  }
128
+
129
+  if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
130
+    if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
131
+    else temp_diffState = ENCODER_DIFF_CCW;
132
+
133
+    #if ENABLED(ENCODER_RATE_MULTIPLIER)
134
+
135
+      millis_t ms = millis();
136
+      int32_t encoderMultiplier = 1;
137
+
138
+      // if must encoder rati multiplier
139
+      if (EncoderRate.enabled) {
140
+        const float abs_diff = ABS(temp_diff),
141
+                    encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
142
+        if (EncoderRate.lastEncoderTime) {
143
+          // Note that the rate is always calculated between two passes through the
144
+          // loop and that the abs of the temp_diff value is tracked.
145
+          const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
146
+               if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
147
+          else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)  encoderMultiplier = 10;
148
+          else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC)   encoderMultiplier = 5;
149
+        }
150
+        EncoderRate.lastEncoderTime = ms;
151
+      }
152
+
153
+    #else
154
+
155
+      constexpr int32_t encoderMultiplier = 1;
156
+
157
+    #endif
158
+
159
+    // EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
160
+    EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
161
+    if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
162
+
163
+    temp_diff = 0;
164
+  }
165
+  return temp_diffState;
166
+}
167
+
168
+#if PIN_EXISTS(LCD_LED)
169
+
170
+  // Take the low 24 valid bits  24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
171
+  uint16_t LED_DataArray[LED_NUM];
172
+
173
+  // LED light operation
174
+  void LED_Action() {
175
+    LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
176
+    delay(30);
177
+    LED_Control(RGB_SCALE_WARM_WHITE,0x00);
178
+  }
179
+
180
+  // LED initialization
181
+  void LED_Configuration() {
182
+    SET_OUTPUT(LCD_LED_PIN);
183
+  }
184
+
185
+  // LED write data
186
+  void LED_WriteData() {
187
+    uint8_t tempCounter_LED, tempCounter_Bit;
188
+    for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
189
+      for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
190
+        if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
191
+          LED_DATA_HIGH;
192
+          DELAY_NS(300);
193
+          LED_DATA_LOW;
194
+          DELAY_NS(200);
195
+        }
196
+        else {
197
+          LED_DATA_HIGH;
198
+          LED_DATA_LOW;
199
+          DELAY_NS(200);
200
+        }
201
+      }
202
+    }
203
+  }
204
+
205
+  // LED control
206
+  //  RGB_Scale: RGB color ratio
207
+  //  luminance: brightness (0~0xFF)
208
+  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
209
+    for (uint8_t i = 0; i < LED_NUM; i++) {
210
+      LED_DataArray[i] = 0;
211
+      switch (RGB_Scale) {
212
+        case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
213
+        case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
214
+        case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
215
+      }
216
+    }
217
+    LED_WriteData();
218
+  }
219
+
220
+  // LED gradient control
221
+  //  RGB_Scale: RGB color ratio
222
+  //  luminance: brightness (0~0xFF)
223
+  //  change_Time: gradient time (ms)
224
+  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
225
+    struct { uint8_t g, r, b; } led_data[LED_NUM];
226
+    for (uint8_t i = 0; i < LED_NUM; i++) {
227
+      switch (RGB_Scale) {
228
+        case RGB_SCALE_R10_G7_B5:
229
+          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
230
+          break;
231
+        case RGB_SCALE_R10_G7_B4:
232
+          led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
233
+          break;
234
+        case RGB_SCALE_R10_G8_B7:
235
+          led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
236
+          break;
237
+      }
238
+    }
239
+
240
+    struct { bool g, r, b; } led_flag = { false, false, false };
241
+    for (uint8_t i = 0; i < LED_NUM; i++) {
242
+      while (1) {
243
+        const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
244
+                      r = uint8_t(LED_DataArray[i] >> 8),
245
+                      b = uint8_t(LED_DataArray[i]);
246
+        if (g == led_data[i].g) led_flag.g = true;
247
+        else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
248
+        if (r == led_data[i].r) led_flag.r = true;
249
+        else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
250
+        if (b == led_data[i].b) led_flag.b = true;
251
+        else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
252
+        LED_WriteData();
253
+        if (led_flag.r && led_flag.g && led_flag.b) break;
254
+        delay(change_Interval);
255
+      }
256
+    }
257
+  }
258
+
259
+#endif // LCD_LED
260
+
261
+#endif // DWIN_CREALITY_LCD_ENHANCED

+ 93
- 0
Marlin/src/lcd/e3v2/enhanced/rotary_encoder.h View File

@@ -0,0 +1,93 @@
1
+/**
2
+ * DWIN UI Enhanced implementation
3
+ * Author: Miguel A. Risco-Castillo
4
+ * Version: 3.6.1
5
+ * Date: 2021/08/29
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ */
21
+#pragma once
22
+
23
+/*****************************************************************************
24
+ * @file     lcd/e3v2/enhanced/rotary_encoder.h
25
+ * @author   LEO / Creality3D
26
+ * @date     2019/07/06
27
+ * @version  2.0.1
28
+ * @brief    Rotary encoder functions
29
+ ****************************************************************************/
30
+
31
+#include "../../../inc/MarlinConfig.h"
32
+
33
+/*********************** Encoder Set ***********************/
34
+
35
+typedef struct {
36
+  bool enabled = false;
37
+  int encoderMoveValue = 0;
38
+  millis_t lastEncoderTime = 0;
39
+} ENCODER_Rate;
40
+
41
+extern ENCODER_Rate EncoderRate;
42
+
43
+typedef enum {
44
+  ENCODER_DIFF_NO    = 0,  // no state
45
+  ENCODER_DIFF_CW    = 1,  // clockwise rotation
46
+  ENCODER_DIFF_CCW   = 2,  // counterclockwise rotation
47
+  ENCODER_DIFF_ENTER = 3   // click
48
+} ENCODER_DiffState;
49
+
50
+// Encoder initialization
51
+void Encoder_Configuration();
52
+
53
+// Analyze encoder value and return state
54
+ENCODER_DiffState Encoder_ReceiveAnalyze();
55
+
56
+/*********************** Encoder LED ***********************/
57
+
58
+#if PIN_EXISTS(LCD_LED)
59
+
60
+  #define LED_NUM  4
61
+  #define LED_DATA_HIGH  WRITE(LCD_LED_PIN, 1)
62
+  #define LED_DATA_LOW   WRITE(LCD_LED_PIN, 0)
63
+
64
+  #define RGB_SCALE_R10_G7_B5  1
65
+  #define RGB_SCALE_R10_G7_B4  2
66
+  #define RGB_SCALE_R10_G8_B7  3
67
+  #define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
68
+  #define RGB_SCALE_WARM_WHITE    RGB_SCALE_R10_G7_B4
69
+  #define RGB_SCALE_COOL_WHITE    RGB_SCALE_R10_G8_B7
70
+
71
+  extern unsigned int LED_DataArray[LED_NUM];
72
+
73
+  // LED light operation
74
+  void LED_Action();
75
+
76
+  // LED initialization
77
+  void LED_Configuration();
78
+
79
+  // LED write data
80
+  void LED_WriteData();
81
+
82
+  // LED control
83
+  //  RGB_Scale: RGB color ratio
84
+  //  luminance: brightness (0~0xFF)
85
+  void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
86
+
87
+  // LED gradient control
88
+  //  RGB_Scale: RGB color ratio
89
+  //  luminance: brightness (0~0xFF)
90
+  //  change_Time: gradient time (ms)
91
+  void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
92
+
93
+#endif // LCD_LED

+ 0
- 3
Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h View File

@@ -44,9 +44,6 @@
44 44
 // Handshake (1: Success, 0: Fail)
45 45
 bool DWIN_Handshake(void);
46 46
 
47
-// Common DWIN startup
48
-void DWIN_Startup(void);
49
-
50 47
 // Set the backlight luminance
51 48
 //  luminance: (0x00-0xFF)
52 49
 void DWIN_Backlight_SetLuminance(const uint8_t luminance);

+ 16
- 1
Marlin/src/lcd/language/language_en.h View File

@@ -78,6 +78,14 @@ namespace Language_en {
78 78
   PROGMEM Language_Str MSG_AUTO_HOME_I                     = _UxGT("Home ") LCD_STR_I;
79 79
   PROGMEM Language_Str MSG_AUTO_HOME_J                     = _UxGT("Home ") LCD_STR_J;
80 80
   PROGMEM Language_Str MSG_AUTO_HOME_K                     = _UxGT("Home ") LCD_STR_K;
81
+  PROGMEM Language_Str MSG_FILAMENT_SET                    = _UxGT("Filament Settings");
82
+  PROGMEM Language_Str MSG_FILAMENT_MAN                    = _UxGT("Filament Management");
83
+  PROGMEM Language_Str MSG_LEVBED_FL                       = _UxGT("Front Left");
84
+  PROGMEM Language_Str MSG_LEVBED_FR                       = _UxGT("Front Right");
85
+  PROGMEM Language_Str MSG_LEVBED_C                        = _UxGT("Center");
86
+  PROGMEM Language_Str MSG_LEVBED_BL                       = _UxGT("Back Left");
87
+  PROGMEM Language_Str MSG_LEVBED_BR                       = _UxGT("Back Right");
88
+  PROGMEM Language_Str MSG_MANUAL_MESH                     = _UxGT("Manual Mesh");
81 89
   PROGMEM Language_Str MSG_AUTO_Z_ALIGN                    = _UxGT("Auto Z-Align");
82 90
   PROGMEM Language_Str MSG_ITERATION                       = _UxGT("G34 Iteration: %i");
83 91
   PROGMEM Language_Str MSG_DECREASING_ACCURACY             = _UxGT("Accuracy Decreasing!");
@@ -289,6 +297,11 @@ namespace Language_en {
289 297
   PROGMEM Language_Str MSG_MOVE_01IN                       = _UxGT("Move 0.1in");
290 298
   PROGMEM Language_Str MSG_MOVE_1IN                        = _UxGT("Move 1.0in");
291 299
   PROGMEM Language_Str MSG_SPEED                           = _UxGT("Speed");
300
+  PROGMEM Language_Str MSG_MAXSPEED                        = _UxGT("Max Speed (mm/s)");
301
+  PROGMEM Language_Str MSG_MAXSPEED_X                      = _UxGT("Max ") LCD_STR_A _UxGT(" Speed");
302
+  PROGMEM Language_Str MSG_MAXSPEED_Y                      = _UxGT("Max ") LCD_STR_B _UxGT(" Speed");
303
+  PROGMEM Language_Str MSG_MAXSPEED_Z                      = _UxGT("Max ") LCD_STR_C _UxGT(" Speed");
304
+  PROGMEM Language_Str MSG_MAXSPEED_E                      = _UxGT("Max ") LCD_STR_E _UxGT(" Speed");
292 305
   PROGMEM Language_Str MSG_BED_Z                           = _UxGT("Bed Z");
293 306
   PROGMEM Language_Str MSG_NOZZLE                          = _UxGT("Nozzle");
294 307
   PROGMEM Language_Str MSG_NOZZLE_N                        = _UxGT("Nozzle ~");
@@ -321,7 +334,7 @@ namespace Language_en {
321 334
   PROGMEM Language_Str MSG_LCD_OFF                         = _UxGT("Off");
322 335
   PROGMEM Language_Str MSG_PID_AUTOTUNE                    = _UxGT("PID Autotune");
323 336
   PROGMEM Language_Str MSG_PID_AUTOTUNE_E                  = _UxGT("PID Autotune *");
324
-  PROGMEM Language_Str MSG_PID_CYCLE                       = _UxGT("PID Cycle");
337
+  PROGMEM Language_Str MSG_PID_CYCLE                       = _UxGT("PID Cycles");
325 338
   PROGMEM Language_Str MSG_PID_AUTOTUNE_DONE               = _UxGT("PID tuning done");
326 339
   PROGMEM Language_Str MSG_PID_BAD_EXTRUDER_NUM            = _UxGT("Autotune failed. Bad extruder.");
327 340
   PROGMEM Language_Str MSG_PID_TEMP_TOO_HIGH               = _UxGT("Autotune failed. Temperature too high.");
@@ -504,6 +517,7 @@ namespace Language_en {
504 517
   PROGMEM Language_Str MSG_MANUAL_DEPLOY                   = _UxGT("Deploy Z-Probe");
505 518
   PROGMEM Language_Str MSG_MANUAL_STOW                     = _UxGT("Stow Z-Probe");
506 519
   PROGMEM Language_Str MSG_HOME_FIRST                      = _UxGT("Home %s%s%s First");
520
+  PROGMEM Language_Str MSG_ZPROBE_SETTINGS                 = _UxGT("Probe Settings");
507 521
   PROGMEM Language_Str MSG_ZPROBE_OFFSETS                  = _UxGT("Probe Offsets");
508 522
   PROGMEM Language_Str MSG_ZPROBE_XOFFSET                  = _UxGT("Probe X Offset");
509 523
   PROGMEM Language_Str MSG_ZPROBE_YOFFSET                  = _UxGT("Probe Y Offset");
@@ -611,6 +625,7 @@ namespace Language_en {
611 625
   PROGMEM Language_Str MSG_FILAMENT_CHANGE_NOZZLE          = _UxGT("  Nozzle: ");
612 626
   PROGMEM Language_Str MSG_RUNOUT_SENSOR                   = _UxGT("Runout Sensor");
613 627
   PROGMEM Language_Str MSG_RUNOUT_DISTANCE_MM              = _UxGT("Runout Dist mm");
628
+  PROGMEM Language_Str MSG_RUNOUT_ENABLE                   = _UxGT("Enable Runout");
614 629
   PROGMEM Language_Str MSG_KILL_HOMING_FAILED              = _UxGT("Homing Failed");
615 630
   PROGMEM Language_Str MSG_LCD_PROBING_FAILED              = _UxGT("Probing Failed");
616 631
 

+ 4
- 1
Marlin/src/lcd/marlinui.cpp View File

@@ -48,6 +48,8 @@ MarlinUI ui;
48 48
 
49 49
 #if ENABLED(DWIN_CREALITY_LCD)
50 50
   #include "e3v2/creality/dwin.h"
51
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
52
+  #include "e3v2/enhanced/dwin.h"
51 53
 #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
52 54
   #include "e3v2/jyersui/dwin.h"
53 55
 #endif
@@ -101,6 +103,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
101 103
     backlight = !!value;
102 104
     if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
103 105
     // Set brightness on enabled LCD here
106
+    TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
104 107
     TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_Backlight_SetLuminance(backlight ? brightness : 0));
105 108
   }
106 109
 #endif
@@ -1474,7 +1477,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
1474 1477
     #endif
1475 1478
 
1476 1479
     TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message));
1477
-    TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message));
1480
+    TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StatusChanged(status_message));
1478 1481
     TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message));
1479 1482
   }
1480 1483
 

+ 16
- 5
Marlin/src/lcd/marlinui.h View File

@@ -55,11 +55,17 @@
55 55
   #include "../module/printcounter.h"
56 56
 #endif
57 57
 
58
-#if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI)
58
+#if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2)
59 59
   #include "../feature/pause.h"
60 60
   #include "../module/motion.h" // for active_extruder
61 61
 #endif
62 62
 
63
+#if ENABLED(DWIN_CREALITY_LCD)
64
+  #include "e3v2/creality/dwin.h"
65
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
66
+  #include "e3v2/enhanced/dwin.h"
67
+#endif
68
+
63 69
 #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U)
64 70
 
65 71
 #if HAS_WIRED_LCD
@@ -257,7 +263,7 @@ public:
257 263
     FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
258 264
   #endif
259 265
 
260
-  #if ENABLED(DWIN_CREALITY_LCD)
266
+  #if HAS_DWIN_E3V2_BASIC
261 267
     static void refresh();
262 268
   #else
263 269
     FORCE_INLINE static void refresh() {
@@ -315,7 +321,7 @@ public:
315 321
 
316 322
   #if HAS_STATUS_MESSAGE
317 323
 
318
-    #if HAS_WIRED_LCD
324
+    #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED)
319 325
       #if ENABLED(STATUS_MESSAGE_SCROLLING)
320 326
         #define MAX_MESSAGE_LENGTH _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH))
321 327
       #else
@@ -351,6 +357,12 @@ public:
351 357
     static inline void reset_alert_level() {}
352 358
   #endif
353 359
 
360
+  #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
361
+    static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
362
+  #else
363
+    static inline void kill_screen(PGM_P const, PGM_P const) {}
364
+  #endif
365
+
354 366
   #if HAS_DISPLAY
355 367
 
356 368
     static void init();
@@ -457,7 +469,6 @@ public:
457 469
       static bool did_first_redraw;
458 470
     #endif
459 471
 
460
-    static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
461 472
     static void draw_kill_screen();
462 473
 
463 474
   #else // No LCD
@@ -585,7 +596,7 @@ public:
585 596
     static inline bool use_click() { return false; }
586 597
   #endif
587 598
 
588
-  #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI)
599
+  #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2)
589 600
     static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder);
590 601
   #else
591 602
     static inline void _pause_show_message() {}

+ 1
- 1
Marlin/src/lcd/tft/ui_common.h View File

@@ -23,7 +23,7 @@
23 23
 
24 24
 #include "../../inc/MarlinConfigPre.h"
25 25
 
26
-#if !HAS_LCD_MENU
26
+#if ENABLED(NO_LCD_MENUS)
27 27
   #error "Seriously? High resolution TFT screen without menu?"
28 28
 #endif
29 29
 

+ 3
- 1
Marlin/src/module/probe.cpp View File

@@ -79,6 +79,8 @@
79 79
 
80 80
 #if ENABLED(EXTENSIBLE_UI)
81 81
   #include "../lcd/extui/ui_api.h"
82
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
83
+  #include "../lcd/e3v2/enhanced/dwin.h"
82 84
 #endif
83 85
 
84 86
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
@@ -295,7 +297,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
295 297
 
296 298
       TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Stow Probe"), CONTINUE_STR));
297 299
       TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Stow Probe")));
298
-
300
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, PSTR("Stow Probe"), CONTINUE_STR));
299 301
       wait_for_user_response();
300 302
       ui.reset_status();
301 303
 

+ 29
- 11
Marlin/src/module/settings.cpp View File

@@ -71,9 +71,9 @@
71 71
 
72 72
 #if ENABLED(EXTENSIBLE_UI)
73 73
   #include "../lcd/extui/ui_api.h"
74
-#endif
75
-
76
-#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
74
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
75
+  #include "../lcd/e3v2/enhanced/dwin.h"
76
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
77 77
   #include "../lcd/e3v2/jyersui/dwin.h"
78 78
 #endif
79 79
 
@@ -441,14 +441,15 @@ typedef struct SettingsDataStruct {
441 441
   // EXTENSIBLE_UI
442 442
   //
443 443
   #if ENABLED(EXTENSIBLE_UI)
444
-    // This is a significant hardware change; don't reserve space when not present
445 444
     uint8_t extui_data[ExtUI::eeprom_data_size];
446 445
   #endif
447 446
 
448 447
   //
449
-  // DWIN_CREALITY_LCD_JYERSUI
448
+  // Ender-3 V2 DWIN
450 449
   //
451
-  #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
450
+  #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
451
+    uint8_t dwin_data[eeprom_data_size];
452
+  #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
452 453
     uint8_t dwin_settings[CrealityDWIN.eeprom_data_size];
453 454
   #endif
454 455
 
@@ -1358,9 +1359,16 @@ void MarlinSettings::postprocess() {
1358 1359
     #endif
1359 1360
 
1360 1361
     //
1361
-    // Creality UI Settings
1362
+    // Creality DWIN User Data
1362 1363
     //
1363
-    #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
1364
+    #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
1365
+    {
1366
+      char dwin_data[eeprom_data_size] = { 0 };
1367
+      DWIN_StoreSettings(dwin_data);
1368
+      _FIELD_TEST(dwin_data);
1369
+      EEPROM_WRITE(dwin_data);
1370
+    }
1371
+    #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
1364 1372
     {
1365 1373
       char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
1366 1374
       CrealityDWIN.Save_Settings(dwin_settings);
@@ -1488,6 +1496,8 @@ void MarlinSettings::postprocess() {
1488 1496
         stored_ver[1] = '\0';
1489 1497
       }
1490 1498
       DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1499
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status(GET_TEXT(MSG_ERR_EEPROM_VERSION)));
1500
+
1491 1501
       IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version());
1492 1502
       eeprom_error = true;
1493 1503
     }
@@ -2249,9 +2259,16 @@ void MarlinSettings::postprocess() {
2249 2259
       #endif
2250 2260
 
2251 2261
       //
2252
-      // Creality UI Settings
2262
+      // Creality DWIN User Data
2253 2263
       //
2254
-      #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
2264
+      #if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
2265
+      {
2266
+        const char dwin_data[eeprom_data_size] = { 0 };
2267
+        _FIELD_TEST(dwin_data);
2268
+        EEPROM_READ(dwin_data);
2269
+        if (!validating) DWIN_LoadSettings(dwin_data);
2270
+      }
2271
+      #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
2255 2272
       {
2256 2273
         const char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
2257 2274
         _FIELD_TEST(dwin_settings);
@@ -2340,6 +2357,7 @@ void MarlinSettings::postprocess() {
2340 2357
       else if (working_crc != stored_crc) {
2341 2358
         eeprom_error = true;
2342 2359
         DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
2360
+        TERN_(DWIN_CREALITY_LCD_ENHANCED, ui.set_status(GET_TEXT(MSG_ERR_EEPROM_CRC)));
2343 2361
         IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc());
2344 2362
       }
2345 2363
       else if (!validating) {
@@ -2656,7 +2674,7 @@ void MarlinSettings::reset() {
2656 2674
   #endif
2657 2675
 
2658 2676
   TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset());
2659
-
2677
+  TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_SetDataDefaults());
2660 2678
   TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings());
2661 2679
 
2662 2680
   //

+ 19
- 10
Marlin/src/module/temperature.cpp View File

@@ -47,6 +47,8 @@
47 47
 
48 48
 #if ENABLED(DWIN_CREALITY_LCD)
49 49
   #include "../lcd/e3v2/creality/dwin.h"
50
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
51
+  #include "../lcd/e3v2/enhanced/dwin.h"
50 52
 #endif
51 53
 
52 54
 #if ENABLED(EXTENSIBLE_UI)
@@ -603,10 +605,12 @@ volatile bool Temperature::raw_temps_ready = false;
603 605
     TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL);
604 606
 
605 607
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED));
608
+    TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
606 609
 
607 610
     if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
608 611
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
609 612
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
613
+      TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
610 614
       return;
611 615
     }
612 616
 
@@ -627,6 +631,7 @@ volatile bool Temperature::raw_temps_ready = false;
627 631
 
628 632
     // PID Tuning loop
629 633
     wait_for_heatup = true; // Can be interrupted with M108
634
+    TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT), "Wait for heat up..."));
630 635
     while (wait_for_heatup) {
631 636
 
632 637
       const millis_t ms = millis();
@@ -687,6 +692,7 @@ volatile bool Temperature::raw_temps_ready = false;
687 692
             }
688 693
           }
689 694
           SHV((bias + d) >> 1);
695
+          TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PID_CYCLE), cycles, ncycles));
690 696
           cycles++;
691 697
           minT = target;
692 698
         }
@@ -699,6 +705,7 @@ volatile bool Temperature::raw_temps_ready = false;
699 705
       if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
700 706
         SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
701 707
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
708
+        TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
702 709
         break;
703 710
       }
704 711
 
@@ -734,6 +741,7 @@ volatile bool Temperature::raw_temps_ready = false;
734 741
       #endif
735 742
       if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) {
736 743
         TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
744
+        TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TUNING_TIMEOUT));
737 745
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
738 746
         SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
739 747
         break;
@@ -787,6 +795,7 @@ volatile bool Temperature::raw_temps_ready = false;
787 795
         TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
788 796
 
789 797
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
798
+        TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE));
790 799
 
791 800
         goto EXIT_M303;
792 801
       }
@@ -795,7 +804,7 @@ volatile bool Temperature::raw_temps_ready = false;
795 804
       TERN_(HAL_IDLETASK, HAL_idletask());
796 805
 
797 806
       // Run UI update
798
-      TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
807
+      TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
799 808
     }
800 809
     wait_for_heatup = false;
801 810
 
@@ -804,6 +813,7 @@ volatile bool Temperature::raw_temps_ready = false;
804 813
     TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color));
805 814
 
806 815
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
816
+    TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE));
807 817
 
808 818
     EXIT_M303:
809 819
       TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);
@@ -1014,14 +1024,14 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms
1014 1024
 }
1015 1025
 
1016 1026
 void Temperature::max_temp_error(const heater_id_t heater_id) {
1017
-  #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED)
1027
+  #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED)
1018 1028
     DWIN_Popup_Temperature(1);
1019 1029
   #endif
1020 1030
   _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP));
1021 1031
 }
1022 1032
 
1023 1033
 void Temperature::min_temp_error(const heater_id_t heater_id) {
1024
-  #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED)
1034
+  #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED)
1025 1035
     DWIN_Popup_Temperature(0);
1026 1036
   #endif
1027 1037
   _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP));
@@ -1329,7 +1339,7 @@ void Temperature::manage_heater() {
1329 1339
           if (watch_hotend[e].check(degHotend(e)))  // Increased enough?
1330 1340
             start_watching_hotend(e);               // If temp reached, turn off elapsed check
1331 1341
           else {
1332
-            TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
1342
+            TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0));
1333 1343
             _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1334 1344
           }
1335 1345
         }
@@ -1372,7 +1382,7 @@ void Temperature::manage_heater() {
1372 1382
         if (watch_bed.check(degBed()))          // Increased enough?
1373 1383
           start_watching_bed();                 // If temp reached, turn off elapsed check
1374 1384
         else {
1375
-          TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
1385
+          TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0));
1376 1386
           _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD));
1377 1387
         }
1378 1388
       }
@@ -2586,7 +2596,7 @@ void Temperature::init() {
2586 2596
         state = TRRunaway;
2587 2597
 
2588 2598
       case TRRunaway:
2589
-        TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
2599
+        TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0));
2590 2600
         _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY));
2591 2601
     }
2592 2602
   }
@@ -3600,7 +3610,7 @@ void Temperature::isr() {
3600 3610
         #if HAS_MULTI_HOTEND
3601 3611
           PSTR("E%c " S_FMT), '1' + e
3602 3612
         #else
3603
-          PSTR("E " S_FMT)
3613
+          PSTR("E1 " S_FMT)
3604 3614
         #endif
3605 3615
         , heating ? GET_TEXT(MSG_HEATING) : GET_TEXT(MSG_COOLING)
3606 3616
       );
@@ -3720,13 +3730,12 @@ void Temperature::isr() {
3720 3730
 
3721 3731
       if (wait_for_heatup) {
3722 3732
         wait_for_heatup = false;
3723
-        #if ENABLED(DWIN_CREALITY_LCD)
3733
+        #if HAS_DWIN_E3V2_BASIC
3724 3734
           HMI_flag.heat_flag = 0;
3725 3735
           duration_t elapsed = print_job_timer.duration();  // print timer
3726 3736
           dwin_heat_time = elapsed.value;
3727
-        #else
3728
-          ui.reset_status();
3729 3737
         #endif
3738
+        ui.reset_status();
3730 3739
         TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onHeatingDone());
3731 3740
         return true;
3732 3741
       }

+ 1
- 1
Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h View File

@@ -148,7 +148,7 @@
148 148
    * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on.
149 149
    */
150 150
 
151
-  #error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue."
151
+  #error "Ender-3 V2 display requires a custom cable, see diagram above this line. Comment out this line to continue."
152 152
 
153 153
   #define BEEPER_PIN                      EXP1_9
154 154
   #define BTN_EN1                         EXP1_3

+ 3
- 1
Marlin/src/sd/cardreader.cpp View File

@@ -33,6 +33,8 @@
33 33
 
34 34
 #if ENABLED(DWIN_CREALITY_LCD)
35 35
   #include "../lcd/e3v2/creality/dwin.h"
36
+#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
37
+  #include "../lcd/e3v2/enhanced/dwin.h"
36 38
 #endif
37 39
 
38 40
 #include "../module/planner.h"        // for synchronize
@@ -564,7 +566,7 @@ void CardReader::startOrResumeFilePrinting() {
564 566
 //
565 567
 void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) {
566 568
   TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0);
567
-  TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting);
569
+  TERN_(HAS_DWIN_E3V2_BASIC, HMI_flag.print_finish = flag.sdprinting);
568 570
   flag.abort_sd_printing = false;
569 571
   if (isFileOpen()) file.close();
570 572
   TERN_(SD_RESORT, if (re_sort) presort());

+ 5
- 0
buildroot/tests/STM32F103RET6_creality View File

@@ -15,6 +15,11 @@ exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
15 15
 
16 16
 use_example_configs "Creality/Ender-3 V2/CrealityUI"
17 17
 opt_disable DWIN_CREALITY_LCD
18
+opt_enable DWIN_CREALITY_LCD_ENHANCED
19
+exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3"
20
+
21
+use_example_configs "Creality/Ender-3 V2/CrealityUI"
22
+opt_disable DWIN_CREALITY_LCD
18 23
 opt_enable DWIN_CREALITY_LCD_JYERSUI
19 24
 exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
20 25
 

+ 1
- 0
ini/features.ini View File

@@ -45,6 +45,7 @@ I2C_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_i
45 45
 SOFT_I2C_EEPROM                        = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
46 46
 SPI_EEPROM                             = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
47 47
 DWIN_CREALITY_LCD                      = src_filter=+<src/lcd/e3v2/creality>
48
+DWIN_CREALITY_LCD_ENHANCED             = src_filter=+<src/lcd/e3v2/enhanced>
48 49
 DWIN_CREALITY_LCD_JYERSUI              = src_filter=+<src/lcd/e3v2/jyersui>
49 50
 DWIN_MARLINUI_.+                       = src_filter=+<src/lcd/e3v2/marlinui>
50 51
 HAS_GRAPHICAL_TFT                      = src_filter=+<src/lcd/tft>

+ 1
- 1
platformio.ini View File

@@ -50,7 +50,7 @@ lib_deps           =
50 50
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
51 51
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
52 52
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
53
-  -<src/lcd/e3v2/creality> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
53
+  -<src/lcd/e3v2/creality> -<src/lcd/e3v2/enhanced> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
54 54
   -<src/lcd/menu>
55 55
   -<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
56 56
   -<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>

Loading…
Cancel
Save