Browse Source

🚸 JyersUI updates (#24451)

Meilleur Gars 1 year ago
parent
commit
509dfe92d0
32 changed files with 4352 additions and 1000 deletions
  1. 2
    0
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  2. 8
    1
      Marlin/src/gcode/config/M575.cpp
  3. 3
    0
      Marlin/src/gcode/control/M997.cpp
  4. 4
    0
      Marlin/src/gcode/lcd/M0_M1.cpp
  5. 6
    4
      Marlin/src/gcode/probe/G30.cpp
  6. 12
    4
      Marlin/src/gcode/stats/M75-M78.cpp
  7. 3
    0
      Marlin/src/gcode/temp/M303.cpp
  8. 4
    5
      Marlin/src/inc/Conditionals_LCD.h
  9. 1
    1
      Marlin/src/inc/Conditionals_post.h
  10. 1
    1
      Marlin/src/inc/SanityCheck.h
  11. 7
    3
      Marlin/src/lcd/e3v2/common/dwin_api.cpp
  12. 208
    0
      Marlin/src/lcd/e3v2/jyersui/base64.hpp
  13. 2218
    872
      Marlin/src/lcd/e3v2/jyersui/dwin.cpp
  14. 134
    96
      Marlin/src/lcd/e3v2/jyersui/dwin.h
  15. 131
    0
      Marlin/src/lcd/e3v2/jyersui/dwin_defines.h
  16. 31
    2
      Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp
  17. 8
    0
      Marlin/src/lcd/e3v2/jyersui/dwin_lcd.h
  18. 340
    0
      Marlin/src/lcd/e3v2/jyersui/dwinui.cpp
  19. 527
    0
      Marlin/src/lcd/e3v2/jyersui/dwinui.h
  20. 111
    0
      Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp
  21. 39
    0
      Marlin/src/lcd/e3v2/jyersui/endstop_diag.h
  22. 244
    0
      Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp
  23. 34
    0
      Marlin/src/lcd/e3v2/jyersui/gcode_preview.h
  24. 83
    0
      Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp
  25. 49
    0
      Marlin/src/lcd/e3v2/jyersui/lockscreen.h
  26. 86
    0
      Marlin/src/lcd/e3v2/jyersui/plot.cpp
  27. 41
    0
      Marlin/src/lcd/e3v2/jyersui/plot.h
  28. 3
    3
      Marlin/src/lcd/e3v2/proui/base64.hpp
  29. 2
    4
      Marlin/src/lcd/e3v2/proui/gcode_preview.cpp
  30. 1
    1
      Marlin/src/lcd/e3v2/proui/gcode_preview.h
  31. 3
    3
      Marlin/src/module/settings.cpp
  32. 8
    0
      Marlin/src/module/temperature.cpp

+ 2
- 0
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -51,6 +51,8 @@
51 51
   #include "../../../lcd/e3v2/creality/dwin.h"
52 52
 #elif ENABLED(DWIN_LCD_PROUI)
53 53
   #include "../../../lcd/e3v2/proui/dwin.h"
54
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
55
+  #include "../../../lcd/e3v2/jyersui/dwin.h"
54 56
 #endif
55 57
 
56 58
 #if HAS_MULTI_HOTEND

+ 8
- 1
Marlin/src/gcode/config/M575.cpp View File

@@ -26,6 +26,10 @@
26 26
 
27 27
 #include "../gcode.h"
28 28
 
29
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
30
+  #include "../../lcd/e3v2/jyersui/dwin.h"
31
+#endif
32
+
29 33
 /**
30 34
  * M575 - Change serial baud rate
31 35
  *
@@ -65,7 +69,10 @@ void GcodeSuite::M575() {
65 69
 
66 70
       SERIAL_FLUSH();
67 71
 
68
-      if (set1) { MYSERIAL1.end(); MYSERIAL1.begin(baud); }
72
+      if (set1) {
73
+        MYSERIAL1.end(); MYSERIAL1.begin(baud);
74
+        TERN_(DWIN_CREALITY_LCD_JYERSUI, eeprom_settings.Baud115k = (baud == 115200));
75
+      }
69 76
       #if HAS_MULTI_SERIAL
70 77
         if (set2) { MYSERIAL2.end(); MYSERIAL2.begin(baud); }
71 78
         #ifdef SERIAL_PORT_3

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

@@ -26,6 +26,8 @@
26 26
 
27 27
 #if ENABLED(DWIN_LCD_PROUI)
28 28
   #include "../../lcd/e3v2/proui/dwin.h"
29
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
30
+  #include "../../lcd/e3v2/jyersui/dwin.h"
29 31
 #endif
30 32
 
31 33
 /**
@@ -34,6 +36,7 @@
34 36
 void GcodeSuite::M997() {
35 37
 
36 38
   TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen());
39
+  TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.DWIN_RebootScreen());
37 40
 
38 41
   flashFirmware(parser.intval('S'));
39 42
 

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

@@ -38,6 +38,8 @@
38 38
 #elif ENABLED(DWIN_LCD_PROUI)
39 39
   #include "../../lcd/e3v2/proui/dwin_popup.h"
40 40
   #include "../../lcd/e3v2/proui/dwin.h"
41
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
42
+  #include "../../lcd/e3v2/jyersui/dwin.h"
41 43
 #endif
42 44
 
43 45
 #if ENABLED(HOST_PROMPT_SUPPORT)
@@ -76,6 +78,8 @@ void GcodeSuite::M0_M1() {
76 78
       DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT));
77 79
     else
78 80
       DWIN_Popup_Confirm(ICON_BLTouch, GET_TEXT_F(MSG_STOPPED), GET_TEXT_F(MSG_USERWAIT));
81
+  #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
82
+    CrealityDWIN.Confirm_Handler(UserInput, parser.string_arg == nullptr);
79 83
   #else
80 84
 
81 85
     if (parser.string_arg) {

+ 6
- 4
Marlin/src/gcode/probe/G30.cpp View File

@@ -33,7 +33,7 @@
33 33
   #include "../../feature/probe_temp_comp.h"
34 34
 #endif
35 35
 
36
-#if ENABLED(DWIN_LCD_PROUI)
36
+#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
37 37
   #include "../../lcd/marlinui.h"
38 38
 #endif
39 39
 
@@ -53,7 +53,7 @@ void GcodeSuite::G30() {
53 53
                          parser.linearval('Y', current_position.y + probe.offset_xy.y) };
54 54
 
55 55
   if (!probe.can_reach(pos)) {
56
-    #if ENABLED(DWIN_LCD_PROUI)
56
+    #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
57 57
       SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
58 58
       LCD_MESSAGE(MSG_ZPROBE_OUT);
59 59
     #endif
@@ -65,7 +65,9 @@ void GcodeSuite::G30() {
65 65
 
66 66
   remember_feedrate_scaling_off();
67 67
 
68
-  TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O")));
68
+  #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
69
+    process_subcommands_now(F("G28O"));
70
+  #endif
69 71
 
70 72
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
71 73
 
@@ -74,7 +76,7 @@ void GcodeSuite::G30() {
74 76
   TERN_(HAS_PTC, ptc.set_enabled(true));
75 77
   if (!isnan(measured_z)) {
76 78
     SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
77
-    #if ENABLED(DWIN_LCD_PROUI)
79
+    #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
78 80
       char msg[31], str_1[6], str_2[6], str_3[6];
79 81
       sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
80 82
         dtostrf(pos.x, 1, 1, str_1),

+ 12
- 4
Marlin/src/gcode/stats/M75-M78.cpp View File

@@ -33,15 +33,23 @@
33 33
   #include "../../lcd/e3v2/proui/dwin.h"
34 34
 #endif
35 35
 
36
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
37
+  #include "../../lcd/e3v2/jyersui/dwin.h"
38
+#endif
39
+
36 40
 /**
37 41
  * M75: Start print timer
38 42
  */
39 43
 void GcodeSuite::M75() {
40 44
   startOrResumeJob();
41
-  #if ENABLED(DWIN_LCD_PROUI)
42
-    DWIN_Print_Started(false);
43
-    if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
44
-  #endif
45
+  TERN_(DWIN_LCD_PROUI, DWIN_Print_Started(false));
46
+  if (!IS_SD_PRINTING()) {
47
+    #if ENABLED(DWIN_LCD_PROUI)
48
+      DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
49
+    #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
50
+      CrealityDWIN.Update_Print_Filename(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
51
+    #endif
52
+  }
45 53
 }
46 54
 
47 55
 /**

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

@@ -32,6 +32,8 @@
32 32
   #include "../../lcd/extui/ui_api.h"
33 33
 #elif ENABLED(DWIN_LCD_PROUI)
34 34
   #include "../../lcd/e3v2/proui/dwin.h"
35
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
36
+  #include "../../lcd/e3v2/jyersui/dwin.h"
35 37
 #endif
36 38
 
37 39
 /**
@@ -75,6 +77,7 @@ void GcodeSuite::M303() {
75 77
       SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID);
76 78
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
77 79
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
80
+      TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_BAD_EXTRUDER_NUM));
78 81
       return;
79 82
   }
80 83
 

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

@@ -1256,6 +1256,8 @@
1256 1256
 #endif
1257 1257
 #if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
1258 1258
   #define HAS_ABL_NOT_UBL 1
1259
+#else
1260
+  #undef PROBE_MANUALLY
1259 1261
 #endif
1260 1262
 #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
1261 1263
   #define HAS_MESH 1
@@ -1274,14 +1276,11 @@
1274 1276
   #if DISABLED(AUTO_BED_LEVELING_UBL)
1275 1277
     #define PLANNER_LEVELING 1
1276 1278
   #endif
1277
-#endif
1278
-#if !HAS_LEVELING
1279
+#else
1279 1280
   #undef RESTORE_LEVELING_AFTER_G28
1280 1281
   #undef ENABLE_LEVELING_AFTER_G28
1281 1282
   #undef G29_RETRY_AND_RECOVER
1282
-#endif
1283
-#if !HAS_LEVELING || EITHER(MESH_BED_LEVELING, AUTO_BED_LEVELING_UBL)
1284
-  #undef PROBE_MANUALLY
1283
+  #undef PREHEAT_BEFORE_LEVELING
1285 1284
 #endif
1286 1285
 #if ANY(HAS_BED_PROBE, PROBE_MANUALLY, MESH_BED_LEVELING)
1287 1286
   #define PROBE_SELECTED 1

+ 1
- 1
Marlin/src/inc/Conditionals_post.h View File

@@ -3541,7 +3541,7 @@
3541 3541
   #ifndef MESH_MAX_Y
3542 3542
     #define MESH_MAX_Y _MESH_MAX_Y
3543 3543
   #endif
3544
-#else
3544
+#elif DISABLED(DWIN_CREALITY_LCD_JYERSUI)
3545 3545
   #undef MESH_MIN_X
3546 3546
   #undef MESH_MIN_Y
3547 3547
   #undef MESH_MAX_X

+ 1
- 1
Marlin/src/inc/SanityCheck.h View File

@@ -3671,7 +3671,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
3671 3671
   #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel."
3672 3672
 #endif
3673 3673
 
3674
-#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
3674
+#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
3675 3675
   #error "LED_CONTROL_MENU requires an LCD controller that implements the menu."
3676 3676
 #endif
3677 3677
 

+ 7
- 3
Marlin/src/lcd/e3v2/common/dwin_api.cpp View File

@@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
234 234
 //  *string: The string
235 235
 //  rlimit: To limit the drawn string length
236 236
 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*/) {
237
-  #if DISABLED(DWIN_LCD_PROUI)
237
+  #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
238 238
     DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size));
239 239
   #endif
240 240
   constexpr uint8_t widthAdjust = 0;
@@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
266 266
 void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
267 267
                           uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
268 268
   size_t i = 0;
269
-  DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
269
+  #if DISABLED(DWIN_CREALITY_LCD_JYERSUI)
270
+    DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
271
+  #endif
270 272
   DWIN_Byte(i, 0x14);
271 273
   // Bit 7: bshow
272 274
   // Bit 6: 1 = signed; 0 = unsigned number;
@@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
314 316
                           uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
315 317
   //uint8_t *fvalue = (uint8_t*)&value;
316 318
   size_t i = 0;
317
-  DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
319
+  #if DISABLED(DWIN_CREALITY_LCD_JYERSUI)
320
+    DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
321
+  #endif
318 322
   DWIN_Byte(i, 0x14);
319 323
   DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
320 324
   DWIN_Word(i, color);

+ 208
- 0
Marlin/src/lcd/e3v2/jyersui/base64.hpp View File

@@ -0,0 +1,208 @@
1
+/**
2
+ * Base64 encoder/decoder for arduino repo
3
+ * Uses common web conventions - '+' for 62, '/' for 63, '=' for padding.
4
+ * Note that invalid base64 characters are interpreted as padding.
5
+ * Author: Densaugeo
6
+ * Maintainer: Densaugeo
7
+ * Version: 1.2.1.1
8
+ * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware
9
+ * Url: https://www.arduino.cc/reference/en/libraries/base64/
10
+ */
11
+
12
+#ifndef BASE64_H_INCLUDED
13
+#define BASE64_H_INCLUDED
14
+
15
+/* binary_to_base64:
16
+ *   Description:
17
+ *     Converts a single byte from a binary value to the corresponding base64 character
18
+ *   Parameters:
19
+ *     v - Byte to convert
20
+ *   Returns:
21
+ *     ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character
22
+ *     and 255 is returned
23
+ */
24
+unsigned char binary_to_base64(unsigned char v);
25
+
26
+/* base64_to_binary:
27
+ *   Description:
28
+ *     Converts a single byte from a base64 character to the corresponding binary value
29
+ *   Parameters:
30
+ *     c - Base64 character (as ascii code)
31
+ *   Returns:
32
+ *     6-bit binary value
33
+ */
34
+unsigned char base64_to_binary(unsigned char c);
35
+
36
+/* encode_base64_length:
37
+ *   Description:
38
+ *     Calculates length of base64 string needed for a given number of binary bytes
39
+ *   Parameters:
40
+ *     input_length - Amount of binary data in bytes
41
+ *   Returns:
42
+ *     Number of base64 characters needed to encode input_length bytes of binary data
43
+ */
44
+uint16_t encode_base64_length(uint16_t input_length);
45
+
46
+/* decode_base64_length:
47
+ *   Description:
48
+ *     Calculates number of bytes of binary data in a base64 string
49
+ *     Variant that does not use input_length no longer used within library, retained for API compatibility
50
+ *   Parameters:
51
+ *     input - Base64-encoded null-terminated string
52
+ *     input_length (optional) - Number of bytes to read from input pointer
53
+ *   Returns:
54
+ *     Number of bytes of binary data in input
55
+ */
56
+uint16_t decode_base64_length(unsigned char input[]);
57
+uint16_t decode_base64_length(unsigned char input[], uint16_t input_length);
58
+
59
+/* encode_base64:
60
+ *   Description:
61
+ *     Converts an array of bytes to a base64 null-terminated string
62
+ *   Parameters:
63
+ *     input - Pointer to input data
64
+ *     input_length - Number of bytes to read from input pointer
65
+ *     output - Pointer to output string. Null terminator will be added automatically
66
+ *   Returns:
67
+ *     Length of encoded string in bytes (not including null terminator)
68
+ */
69
+uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]);
70
+
71
+/* decode_base64:
72
+ *   Description:
73
+ *     Converts a base64 null-terminated string to an array of bytes
74
+ *   Parameters:
75
+ *     input - Pointer to input string
76
+ *     input_length (optional) - Number of bytes to read from input pointer
77
+ *     output - Pointer to output array
78
+ *   Returns:
79
+ *     Number of bytes in the decoded binary
80
+ */
81
+uint16_t decode_base64(unsigned char input[], unsigned char output[]);
82
+uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]);
83
+
84
+unsigned char binary_to_base64(unsigned char v) {
85
+  // Capital letters - 'A' is ascii 65 and base64 0
86
+  if (v < 26) return v + 'A';
87
+
88
+  // Lowercase letters - 'a' is ascii 97 and base64 26
89
+  if (v < 52) return v + 71;
90
+
91
+  // Digits - '0' is ascii 48 and base64 52
92
+  if (v < 62) return v - 4;
93
+
94
+  // '+' is ascii 43 and base64 62
95
+  if (v == 62) return '+';
96
+
97
+  // '/' is ascii 47 and base64 63
98
+  if (v == 63) return '/';
99
+
100
+  return 64;
101
+}
102
+
103
+unsigned char base64_to_binary(unsigned char c) {
104
+  // Capital letters - 'A' is ascii 65 and base64 0
105
+  if ('A' <= c && c <= 'Z') return c - 'A';
106
+
107
+  // Lowercase letters - 'a' is ascii 97 and base64 26
108
+  if ('a' <= c && c <= 'z') return c - 71;
109
+
110
+  // Digits - '0' is ascii 48 and base64 52
111
+  if ('0' <= c && c <= '9') return c + 4;
112
+
113
+  // '+' is ascii 43 and base64 62
114
+  if (c == '+') return 62;
115
+
116
+  // '/' is ascii 47 and base64 63
117
+  if (c == '/') return 63;
118
+
119
+  return 255;
120
+}
121
+
122
+uint16_t encode_base64_length(uint16_t input_length) {
123
+  return (input_length + 2)/3*4;
124
+}
125
+
126
+uint16_t decode_base64_length(unsigned char input[]) {
127
+  return decode_base64_length(input, -1);
128
+}
129
+
130
+uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) {
131
+  unsigned char *start = input;
132
+
133
+  while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) {
134
+    ++input;
135
+  }
136
+
137
+  input_length = input - start;
138
+  return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0);
139
+}
140
+
141
+uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) {
142
+  uint16_t full_sets = input_length/3;
143
+
144
+  // While there are still full sets of 24 bits...
145
+  for (uint16_t i = 0; i < full_sets; ++i) {
146
+    output[0] = binary_to_base64(                         input[0] >> 2);
147
+    output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
148
+    output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6);
149
+    output[3] = binary_to_base64( input[2] & 0x3F);
150
+
151
+    input += 3;
152
+    output += 4;
153
+  }
154
+
155
+  switch (input_length % 3) {
156
+    case 0:
157
+      output[0] = '\0';
158
+      break;
159
+    case 1:
160
+      output[0] = binary_to_base64(                         input[0] >> 2);
161
+      output[1] = binary_to_base64((input[0] & 0x03) << 4);
162
+      output[2] = '=';
163
+      output[3] = '=';
164
+      output[4] = '\0';
165
+      break;
166
+    case 2:
167
+      output[0] = binary_to_base64(                         input[0] >> 2);
168
+      output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
169
+      output[2] = binary_to_base64((input[1] & 0x0F) << 2);
170
+      output[3] = '=';
171
+      output[4] = '\0';
172
+      break;
173
+  }
174
+
175
+  return encode_base64_length(input_length);
176
+}
177
+
178
+uint16_t decode_base64(unsigned char input[], unsigned char output[]) {
179
+  return decode_base64(input, -1, output);
180
+}
181
+
182
+uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) {
183
+  uint16_t output_length = decode_base64_length(input, input_length);
184
+
185
+  // While there are still full sets of 24 bits...
186
+  for (uint16_t i = 2; i < output_length; i += 3) {
187
+    output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
188
+    output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
189
+    output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]);
190
+
191
+    input += 4;
192
+    output += 3;
193
+  }
194
+
195
+  switch (output_length % 3) {
196
+    case 1:
197
+      output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
198
+      break;
199
+    case 2:
200
+      output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
201
+      output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
202
+      break;
203
+  }
204
+
205
+  return output_length;
206
+}
207
+
208
+#endif // BASE64_H_INCLUDED

+ 2218
- 872
Marlin/src/lcd/e3v2/jyersui/dwin.cpp
File diff suppressed because it is too large
View File


+ 134
- 96
Marlin/src/lcd/e3v2/jyersui/dwin.h View File

@@ -23,27 +23,26 @@
23 23
 
24 24
 /**
25 25
  * lcd/e3v2/jyersui/dwin.h
26
+ * JYERSUI Author: Jacob Myers
27
+ *
28
+ * JYERSUI Enhanced by LCH-77
29
+ * Version: 1.9
30
+ * Date: Jun 16, 2022
26 31
  */
27 32
 
28
-#include "dwin_lcd.h"
29
-#include "../common/dwin_set.h"
30
-#include "../common/dwin_font.h"
31
-#include "../common/dwin_color.h"
32
-#include "../common/encoder.h"
33
-#include "../../../libs/BL24CXX.h"
34
-
35
-#include "../../../inc/MarlinConfigPre.h"
33
+#include "dwin_defines.h"
36 34
 
37
-//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
35
+#include "../../../inc/MarlinConfig.h"
38 36
 
39 37
 enum processID : uint8_t {
40
-  Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
38
+  Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait, Locked, Cancel, Keyboard
41 39
 };
42 40
 
43 41
 enum PopupID : uint8_t {
44 42
   Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
45
-  Level, Home, MoveWait, Heating,  FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing,
46
-  FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom
43
+  Level, Home, MoveWait, Heating,  FilLoad, FilChange, TempWarn, Runout, Resuming, ManualProbing,
44
+  FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom, ESDiagPopup, PrintConfirm,
45
+  PIDWait, PIDWaitH, PIDWaitB, BadextruderNumber, TempTooHigh, PIDTimeout, PIDDone
47 46
 };
48 47
 
49 48
 enum menuID : uint8_t {
@@ -55,6 +54,7 @@ enum menuID : uint8_t {
55 54
       ZOffset,
56 55
       Preheat,
57 56
       ChangeFilament,
57
+      HostActions,
58 58
       MenuCustom,
59 59
     Control,
60 60
       TempMenu,
@@ -69,105 +69,108 @@ enum menuID : uint8_t {
69 69
         HomeOffsets,
70 70
         MaxSpeed,
71 71
         MaxAcceleration,
72
-        MaxJerk,
72
+        #if HAS_CLASSIC_JERK
73
+          MaxJerk,
74
+        #endif
75
+        #if HAS_JUNCTION_DEVIATION
76
+          JDmenu,
77
+        #endif
73 78
         Steps,
79
+      #if ENABLED(FWRETRACT)
80
+        FwRetraction,
81
+      #endif
74 82
       Visual,
75 83
         ColorSettings,
84
+      HostSettings,
85
+        ActionCommands,
76 86
       Advanced,
77
-        ProbeMenu,
87
+        #if HAS_BED_PROBE
88
+          ProbeMenu,
89
+        #endif
78 90
       Info,
79
-    Leveling,
80
-      LevelManual,
81
-      LevelView,
82
-      MeshViewer,
83
-      LevelSettings,
84
-      ManualMesh,
85
-      UBLMesh,
91
+    #if HAS_MESH
92
+      Leveling,
93
+        LevelManual,
94
+        LevelView,
95
+        MeshViewer,
96
+        LevelSettings,
97
+        #if ENABLED(PROBE_MANUALLY)
98
+          ManualMesh,
99
+        #endif
100
+        #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE
101
+          UBLMesh,
102
+        #endif
103
+    #endif
86 104
     InfoMain,
87 105
   Tune,
88
-  PreheatHotend
106
+  PreheatHotend,
107
+  #if ANY(CASE_LIGHT_MENU, LED_CONTROL_MENU)
108
+    Ledsmenu,
109
+    #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
110
+      CaseLightmenu,
111
+    #endif
112
+    #if ENABLED(LED_CONTROL_MENU)
113
+      LedControlmenu,
114
+      #if HAS_COLOR_LEDS
115
+        #if ENABLED(LED_COLOR_PRESETS)
116
+          LedControlpresets,
117
+        #else
118
+          LedControlcustom,
119
+        #endif
120
+      #endif
121
+    #endif
122
+  #endif
89 123
 };
90 124
 
91
-// Custom icons
92
-#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
93
-  // index of every custom icon should be >= CUSTOM_ICON_START
94
-  #define CUSTOM_ICON_START         ICON_Checkbox_F
95
-  #define ICON_Checkbox_F           200
96
-  #define ICON_Checkbox_T           201
97
-  #define ICON_Fade                 202
98
-  #define ICON_Mesh                 203
99
-  #define ICON_Tilt                 204
100
-  #define ICON_Brightness           205
101
-  #define ICON_AxisD                249
102
-  #define ICON_AxisBR               250
103
-  #define ICON_AxisTR               251
104
-  #define ICON_AxisBL               252
105
-  #define ICON_AxisTL               253
106
-  #define ICON_AxisC                254
107
-#else
108
-  #define ICON_Fade                 ICON_Version
109
-  #define ICON_Mesh                 ICON_Version
110
-  #define ICON_Tilt                 ICON_Version
111
-  #define ICON_Brightness           ICON_Version
112
-  #define ICON_AxisD                ICON_Axis
113
-  #define ICON_AxisBR               ICON_Axis
114
-  #define ICON_AxisTR               ICON_Axis
115
-  #define ICON_AxisBL               ICON_Axis
116
-  #define ICON_AxisTL               ICON_Axis
117
-  #define ICON_AxisC                ICON_Axis
118
-#endif
125
+typedef struct {
126
+  // Flags
127
+  bool flag_tune = false;
128
+  bool auto_fw_retract = false;
129
+  bool printing = false;
130
+  bool paused = false;
131
+  bool sdprint = false;
132
+  bool livemove = false;
133
+  bool liveadjust = false;
134
+  bool probe_deployed = false;
135
+  // Auxiliary values
136
+  AxisEnum axis = X_AXIS;    // Axis Select
137
+  int16_t pausetemp = 0;
138
+  int16_t pausebed = 0;
139
+  int16_t pausefan = 0;
140
+  uint8_t preheatmode = 0;
141
+  uint8_t zoffsetmode = 0;
142
+  float zoffsetvalue = 0;
143
+  uint8_t gridpoint;
144
+  float corner_avg;
145
+  float corner_pos;
146
+  float zval;
147
+  #if ENABLED(PREHEAT_BEFORE_LEVELING)
148
+    uint8_t LevelingTempmode = 0;
149
+  #endif
150
+  #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
151
+    uint32_t LED_Color = Def_Leds_Color;
152
+  #endif
153
+  #if HAS_PID_HEATING
154
+    uint16_t PID_e_temp = 180;
155
+    uint16_t PID_bed_temp = 60;
156
+  #endif
157
+} temp_val_t;
158
+extern temp_val_t temp_val;
119 159
 
160
+#define Custom_Colors 10
120 161
 enum colorID : uint8_t {
121 162
   Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
122 163
 };
123
-
124
-#define Custom_Colors       10
125
-#define Color_Aqua          RGB(0x00,0x3F,0x1F)
126
-#define Color_Light_White   0xBDD7
127
-#define Color_Green         RGB(0x00,0x3F,0x00)
128
-#define Color_Light_Green   0x3460
129
-#define Color_Cyan          0x07FF
130
-#define Color_Light_Cyan    0x04F3
131
-#define Color_Blue          0x015F
132
-#define Color_Light_Blue    0x3A6A
133
-#define Color_Magenta       0xF81F
134
-#define Color_Light_Magenta 0x9813
135
-#define Color_Light_Red     0x8800
136
-#define Color_Orange        0xFA20
137
-#define Color_Light_Orange  0xFBC0
138
-#define Color_Light_Yellow  0x8BE0
139
-#define Color_Brown         0xCC27
140
-#define Color_Light_Brown   0x6204
141
-#define Color_Black         0x0000
142
-#define Color_Grey          0x18E3
143
-#define Check_Color         0x4E5C  // Check-box check color
144
-#define Confirm_Color       0x34B9
145
-#define Cancel_Color        0x3186
164
+enum pidresult_t : uint8_t { PID_STARTED, PID_EXTR_START, PID_BED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE };
146 165
 
147 166
 class CrealityDWINClass {
148 167
 public:
149
-  static constexpr size_t eeprom_data_size = 48;
150
-  static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
151
-    bool time_format_textual : 1;
152
-    #if ENABLED(AUTO_BED_LEVELING_UBL)
153
-      uint8_t tilt_grid_size : 3;
154
-    #endif
155
-    uint16_t corner_pos : 10;
156
-    uint8_t cursor_color : 4;
157
-    uint8_t menu_split_line : 4;
158
-    uint8_t menu_top_bg : 4;
159
-    uint8_t menu_top_txt : 4;
160
-    uint8_t highlight_box : 4;
161
-    uint8_t progress_percent : 4;
162
-    uint8_t progress_time : 4;
163
-    uint8_t status_bar_text : 4;
164
-    uint8_t status_area_text : 4;
165
-    uint8_t coordinates_text : 4;
166
-    uint8_t coordinates_split_line : 4;
167
-  } eeprom_settings;
168
-
169 168
   static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
170 169
   static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
170
+  static constexpr const char * const zoffset_modes[3] = { "No Live" , "OnClick", "   Live" };
171
+  #if ENABLED(PREHEAT_BEFORE_LEVELING)
172
+    static constexpr const char * const preheat_levmodes[4] = { "   Both", " Hotend", "    Bed", "   None" };
173
+  #endif
171 174
 
172 175
   static void Clear_Screen(uint8_t e=3);
173 176
   static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
@@ -192,7 +195,7 @@ public:
192 195
     static void Draw_Print_ProgressRemain();
193 196
   #endif
194 197
   static void Draw_Print_ProgressElapsed();
195
-  static void Draw_Print_confirm();
198
+  static void Draw_PrintDone_confirm();
196 199
   static void Draw_SD_Item(uint8_t item, uint8_t row);
197 200
   static void Draw_SD_List(bool removed=false);
198 201
   static void Draw_Status_Area(bool icons=false);
@@ -209,8 +212,8 @@ public:
209 212
   static uint8_t Get_Menu_Size(uint8_t menu);
210 213
   static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
211 214
 
212
-  static void Popup_Handler(PopupID popupid, bool option = false);
213
-  static void Confirm_Handler(PopupID popupid);
215
+  static void Popup_Handler(PopupID popupid, bool option=false);
216
+  static void Confirm_Handler(PopupID popupid, bool option=false);
214 217
 
215 218
   static void Main_Menu_Control();
216 219
   static void Menu_Control();
@@ -231,6 +234,7 @@ public:
231 234
   static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
232 235
 
233 236
   static void Update_Status(const char * const text);
237
+  static void Update_Status(FSTR_P text);
234 238
   static void Start_Print(bool sd);
235 239
   static void Stop_Print();
236 240
   static void Update();
@@ -240,6 +244,40 @@ public:
240 244
   static void Save_Settings(char *buff);
241 245
   static void Load_Settings(const char *buff);
242 246
   static void Reset_Settings();
247
+  static void PreheatBefore();
248
+
249
+  #if HAS_ESDIAG
250
+    static void DWIN_EndstopsDiag();
251
+  #endif
252
+  #if HAS_LOCKSCREEN
253
+    static void DWIN_LockScreen();
254
+    static void DWIN_UnLockScreen();
255
+    static void HMI_LockScreen();
256
+  #endif
257
+  static void DWIN_RebootScreen();
258
+  static void RebootPrinter();
259
+  static void Update_Print_Filename(const char * const text);
260
+  #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
261
+    static void ApplyLEDColor();
262
+  #endif
263
+
264
+  #if HAS_HOSTACTION_MENUS
265
+    static void Draw_String(char * string, uint8_t row, bool selected=false, bool below=false);
266
+    static const uint64_t Encode_String(const char * string);
267
+    static void Decode_String(uint64_t num, char * string);
268
+    static void Draw_Keyboard(bool restrict, bool numeric, uint8_t selected=0, bool uppercase=false, bool lock=false);
269
+    static void Draw_Keys(uint8_t index, bool selected, bool uppercase=false, bool lock=false);
270
+    static void Modify_String(char * string, uint8_t maxlength, bool restrict);
271
+    static void Keyboard_Control();
272
+  #endif
273
+
274
+  #if HAS_PIDPLOT
275
+    static void DWIN_Draw_PIDPopup(const pidresult_t pidresult);
276
+  #endif
277
+
278
+  #if HAS_PID_HEATING
279
+    static void DWIN_PidTuning(const pidresult_t pidresult);
280
+  #endif
243 281
 };
244 282
 
245 283
 extern CrealityDWINClass CrealityDWIN;

+ 131
- 0
Marlin/src/lcd/e3v2/jyersui/dwin_defines.h View File

@@ -0,0 +1,131 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * DWIN general defines and data structs for PRO UI
26
+ * Author: Miguel A. Risco-Castillo (MRISCOC)
27
+ * Version: 3.11.2
28
+ * Date: 2022/02/28
29
+ *
30
+ * Modded for JYERSUI by LCH-77
31
+ * Version: 1.9
32
+ * Date: Jun 16, 2022
33
+ */
34
+
35
+#include "../../../inc/MarlinConfigPre.h"
36
+
37
+#define HAS_ESDIAG 1
38
+#define HAS_LOCKSCREEN 1
39
+#define HAS_PIDPLOT 1
40
+#define HAS_GCODE_PREVIEW 1
41
+//#define DEBUG_DWIN 1
42
+//#define NEED_HEX_PRINT 1
43
+
44
+#if ENABLED(HOST_ACTION_COMMANDS)
45
+  #define HAS_HOSTACTION_MENUS 1
46
+#endif
47
+
48
+#include "../../../core/types.h"
49
+#include "../common/dwin_color.h"
50
+
51
+// Default UI Colors
52
+#define Def_Background_Color  RGB(4,4,0)
53
+#define Def_Cursor_color      RGB(24,24,0)
54
+#define Def_TitleBg_color     RGB(12,12,0)
55
+#define Def_TitleTxt_color    Color_White
56
+#define Def_Text_Color        Color_White
57
+#define Def_Selected_Color    RGB(24,24,0)
58
+#define Def_SplitLine_Color   RGB(24,24,0)
59
+#define Def_Highlight_Color   RGB(31,40,0)
60
+#define Def_StatusBg_Color    RGB(12,12,0)
61
+#define Def_StatusTxt_Color   Color_White
62
+#define Def_PopupBg_color     Color_Bg_Window
63
+#define Def_PopupTxt_Color    Popup_Text_Color
64
+#define Def_AlertBg_Color     Color_Bg_Red
65
+#define Def_AlertTxt_Color    Color_Yellow
66
+#define Def_PercentTxt_Color  RGB(31,48,8)
67
+#define Def_Barfill_Color     RGB(12,12,0)
68
+#define Def_Indicator_Color   RGB(31,48,8)
69
+#define Def_Coordinate_Color  Color_White
70
+#define Def_Button_Color      RGB(12,12,0)
71
+
72
+#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
73
+  #define Def_Leds_Color      0xFFFFFFFF
74
+#endif
75
+#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
76
+  #define Def_CaseLight_Brightness 255
77
+#endif
78
+
79
+#if HAS_MESH
80
+  #ifndef MESH_INSET
81
+    #define MESH_INSET 25
82
+  #endif
83
+  #ifndef MESH_MIN_X
84
+    #define MESH_MIN_X MESH_INSET
85
+  #endif
86
+  #ifndef MESH_MIN_Y
87
+    #define MESH_MIN_Y MESH_INSET
88
+  #endif
89
+  #ifndef MESH_MAX_X
90
+    #define MESH_MAX_X  X_BED_SIZE - (MESH_INSET)
91
+  #endif
92
+  #ifndef MESH_MAX_Y
93
+    #define MESH_MAX_Y  X_BED_SIZE - (MESH_INSET)
94
+  #endif
95
+#endif
96
+
97
+typedef struct {
98
+  bool time_format_textual : 1;
99
+  #if ENABLED(AUTO_BED_LEVELING_UBL)
100
+    uint8_t tilt_grid_size : 3;
101
+  #endif
102
+  uint16_t corner_pos : 10;
103
+  uint8_t cursor_color : 4;
104
+  uint8_t menu_split_line : 4;
105
+  uint8_t menu_top_bg : 4;
106
+  uint8_t menu_top_txt : 4;
107
+  uint8_t highlight_box : 4;
108
+  uint8_t progress_percent : 4;
109
+  uint8_t progress_time : 4;
110
+  uint8_t status_bar_text : 4;
111
+  uint8_t status_area_text : 4;
112
+  uint8_t coordinates_text : 4;
113
+  uint8_t coordinates_split_line : 4;
114
+  #if ENABLED(BAUD_RATE_GCODE)
115
+    bool Baud115k : 1;
116
+  #endif
117
+  #if ENABLED(PREHEAT_BEFORE_LEVELING)
118
+    bool ena_hotend_levtemp : 1;
119
+    bool ena_bed_levtemp : 1;
120
+    celsius_t hotend_levtemp = LEVELING_NOZZLE_TEMP;
121
+    celsius_t bed_levtemp = LEVELING_BED_TEMP;
122
+  #endif
123
+  #if HAS_HOSTACTION_MENUS
124
+    uint64_t host_action_label_1 : 48;
125
+    uint64_t host_action_label_2 : 48;
126
+    uint64_t host_action_label_3 : 48;
127
+  #endif
128
+} eeprom_settings_t;
129
+
130
+static constexpr size_t eeprom_data_size = 48;
131
+extern eeprom_settings_t eeprom_settings;

+ 31
- 2
Marlin/src/lcd/e3v2/jyersui/dwin_lcd.cpp View File

@@ -53,12 +53,41 @@ void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
53 53
 
54 54
 /*---------------------------------------- Picture related functions ----------------------------------------*/
55 55
 
56
-// Draw an Icon
56
+// Draw an Icon with transparent background
57 57
 //  libID: Icon library ID
58 58
 //  picID: Icon ID
59 59
 //  x/y: Upper-left point
60 60
 void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
61
-  DWIN_ICON_Show(true, false, false, libID, picID, x, y);
61
+  DWIN_ICON_Show(false, false, true, libID, picID, x, y);
62
+}
63
+
64
+// From DWIN Enhanced implementation for PRO UI v3.10.1
65
+// Write buffer data to the SRAM or Flash
66
+//  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
67
+//  addr: start address
68
+//  length: Bytes to write
69
+//  data: address of the buffer with data
70
+void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
71
+  const uint8_t max_size = 128;
72
+  uint16_t pending = length;
73
+  uint16_t to_send;
74
+  uint16_t indx;
75
+  uint8_t block = 0;
76
+
77
+  while (pending > 0) {
78
+    indx = block * max_size;
79
+    to_send = _MIN(pending, max_size);
80
+    size_t i = 0;
81
+    DWIN_Byte(i, 0x31);
82
+    DWIN_Byte(i, mem);
83
+    DWIN_Word(i, addr + indx); // start address of the data block
84
+    ++i;
85
+    LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); }  // Buf header
86
+    for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1);  // write block of data
87
+    LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); }
88
+    block++;
89
+    pending -= to_send;
90
+  }
62 91
 }
63 92
 
64 93
 #endif // DWIN_CREALITY_LCD_JYERSUI

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

@@ -32,3 +32,11 @@
32 32
 // Color: color
33 33
 //  x/y: Upper-left coordinate of the first pixel
34 34
 void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
35
+
36
+// From DWIN Enhanced implementation for PRO UI v3.10.1
37
+// Write buffer data to the SRAM or Flash
38
+//  mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
39
+//  addr: start address
40
+//  length: Bytes to write
41
+//  data: address of the buffer with data
42
+void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data);

+ 340
- 0
Marlin/src/lcd/e3v2/jyersui/dwinui.cpp View File

@@ -0,0 +1,340 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * DWIN Enhanced implementation for PRO UI
25
+ * Author: Miguel A. Risco-Castillo (MRISCOC)
26
+ * Version: 3.17.1
27
+ * Date: 2022/04/12
28
+ *
29
+ * Modded for JYERSUI by LCH-77
30
+ * Version: 1.9
31
+ * Date: Jun 16, 2022
32
+ */
33
+
34
+#include "../../../inc/MarlinConfigPre.h"
35
+
36
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
37
+
38
+#include "../../../inc/MarlinConfig.h"
39
+#include "dwin_lcd.h"
40
+#include "dwinui.h"
41
+#include "dwin_defines.h"
42
+
43
+//#define DEBUG_OUT 1
44
+#include "../../../core/debug_out.h"
45
+
46
+xy_int_t DWINUI::cursor = { 0 };
47
+uint16_t DWINUI::pencolor = Color_White;
48
+uint16_t DWINUI::textcolor = Def_Text_Color;
49
+uint16_t DWINUI::backcolor = Def_Background_Color;
50
+uint16_t DWINUI::buttoncolor = Def_Button_Color;
51
+uint8_t  DWINUI::font = font8x16;
52
+FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR);
53
+
54
+void DWINUI::init() {
55
+  delay(750);   // Delay for wait to wakeup screen
56
+  const bool hs = DWIN_Handshake(); UNUSED(hs);
57
+  #if ENABLED(DEBUG_DWIN)
58
+    SERIAL_ECHOPGM("DWIN_Handshake ");
59
+    SERIAL_ECHOLNF(hs ? F("ok.") : F("error."));
60
+  #endif
61
+  DWIN_Frame_SetDir(1);
62
+  cursor.reset();
63
+  pencolor = Color_White;
64
+  textcolor = Def_Text_Color;
65
+  backcolor = Def_Background_Color;
66
+  buttoncolor = Def_Button_Color;
67
+  font = font8x16;
68
+}
69
+
70
+// Set text/number font
71
+void DWINUI::setFont(uint8_t cfont) {
72
+  font = cfont;
73
+}
74
+
75
+// Get font character width
76
+uint8_t DWINUI::fontWidth(uint8_t cfont) {
77
+  switch (cfont) {
78
+    case font6x12 : return 6;
79
+    case font8x16 : return 8;
80
+    case font10x20: return 10;
81
+    case font12x24: return 12;
82
+    case font14x28: return 14;
83
+    case font16x32: return 16;
84
+    case font20x40: return 20;
85
+    case font24x48: return 24;
86
+    case font28x56: return 28;
87
+    case font32x64: return 32;
88
+    default: return 0;
89
+  }
90
+}
91
+
92
+// Get font character height
93
+uint8_t DWINUI::fontHeight(uint8_t cfont) {
94
+  switch (cfont) {
95
+    case font6x12 : return 12;
96
+    case font8x16 : return 16;
97
+    case font10x20: return 20;
98
+    case font12x24: return 24;
99
+    case font14x28: return 28;
100
+    case font16x32: return 32;
101
+    case font20x40: return 40;
102
+    case font24x48: return 48;
103
+    case font28x56: return 56;
104
+    case font32x64: return 64;
105
+    default: return 0;
106
+  }
107
+}
108
+
109
+// Get screen x coordinates from text column
110
+uint16_t DWINUI::ColToX(uint8_t col) {
111
+  return col * fontWidth(font);
112
+}
113
+
114
+// Get screen y coordinates from text row
115
+uint16_t DWINUI::RowToY(uint8_t row) {
116
+  return row * fontHeight(font);
117
+}
118
+
119
+// Set text/number color
120
+void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) {
121
+  textcolor = fgcolor;
122
+  backcolor = bgcolor;
123
+  buttoncolor = alcolor;
124
+}
125
+void DWINUI::SetTextColor(uint16_t fgcolor) {
126
+  textcolor = fgcolor;
127
+}
128
+void DWINUI::SetBackgroundColor(uint16_t bgcolor) {
129
+  backcolor = bgcolor;
130
+}
131
+
132
+// Moves cursor to point
133
+//  x: abscissa of the display
134
+//  y: ordinate of the display
135
+//  point: xy coordinate
136
+void DWINUI::MoveTo(int16_t x, int16_t y) {
137
+  cursor.x = x;
138
+  cursor.y = y;
139
+}
140
+void DWINUI::MoveTo(xy_int_t point) {
141
+  cursor = point;
142
+}
143
+
144
+// Moves cursor relative to the actual position
145
+//  x: abscissa of the display
146
+//  y: ordinate of the display
147
+//  point: xy coordinate
148
+void DWINUI::MoveBy(int16_t x, int16_t y) {
149
+  cursor.x += x;
150
+  cursor.y += y;
151
+}
152
+void DWINUI::MoveBy(xy_int_t point) {
153
+  cursor += point;
154
+}
155
+
156
+// Draw a Centered string using arbitrary x1 and x2 margins
157
+void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) {
158
+  const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1;
159
+  DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
160
+}
161
+
162
+// Draw a char
163
+//  color: Character color
164
+//  x: abscissa of the display
165
+//  y: ordinate of the display
166
+//  c: ASCII code of char
167
+void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) {
168
+  const char string[2] = { c, 0};
169
+  DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1);
170
+}
171
+
172
+// Draw a char at cursor position and increment cursor
173
+void DWINUI::Draw_Char(uint16_t color, const char c) {
174
+  Draw_Char(color, cursor.x, cursor.y, c);
175
+  MoveBy(fontWidth(font), 0);
176
+}
177
+
178
+// Draw a string at cursor position
179
+//  color: Character color
180
+//  *string: The string
181
+//  rlimit: For draw less chars than string length use rlimit
182
+void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
183
+  DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
184
+  MoveBy(strlen(string) * fontWidth(font), 0);
185
+}
186
+void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
187
+  DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
188
+  MoveBy(strlen(string) * fontWidth(font), 0);
189
+}
190
+
191
+// Draw a numeric integer value
192
+//  bShow: true=display background color; false=don't display background color
193
+//  signedMode: 1=signed; 0=unsigned
194
+//  size: Font size
195
+//  color: Character color
196
+//  bColor: Background color
197
+//  iNum: Number of digits
198
+//  x/y: Upper-left coordinate
199
+//  value: Integer value
200
+void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) {
201
+  char nstr[10];
202
+  sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value);
203
+  DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr);
204
+}
205
+
206
+// Draw a numeric float value
207
+//  bShow: true=display background color; false=don't display background color
208
+//  signedMode: 1=signed; 0=unsigned
209
+//  size: Font size
210
+//  color: Character color
211
+//  bColor: Background color
212
+//  iNum: Number of digits
213
+//  fNum: Number of decimal digits
214
+//  x/y: Upper-left coordinate
215
+//  value: float value
216
+void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
217
+  char nstr[10];
218
+  DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr));
219
+}
220
+
221
+// ------------------------- Buttons ------------------------------//
222
+
223
+void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) {
224
+  DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2);
225
+  Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption);
226
+}
227
+
228
+void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {
229
+  switch (id) {
230
+    case BTN_Cancel  : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break;
231
+    case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break;
232
+    case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break;
233
+    case BTN_Print   : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break;
234
+    case BTN_Save    : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break;
235
+    case BTN_Purge   : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break;
236
+    default: break;
237
+  }
238
+}
239
+
240
+// -------------------------- Extra -------------------------------//
241
+
242
+// Draw a circle
243
+//  color: circle color
244
+//  x: the abscissa of the center of the circle
245
+//  y: ordinate of the center of the circle
246
+//  r: circle radius
247
+void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
248
+  int a = 0, b = 0;
249
+  while (a <= b) {
250
+    b = SQRT(sq(r) - sq(a));
251
+    if (a == 0) b--;
252
+    DWIN_Draw_Point(color, 1, 1, x + a, y + b);   // Draw some sector 1
253
+    DWIN_Draw_Point(color, 1, 1, x + b, y + a);   // Draw some sector 2
254
+    DWIN_Draw_Point(color, 1, 1, x + b, y - a);   // Draw some sector 3
255
+    DWIN_Draw_Point(color, 1, 1, x + a, y - b);   // Draw some sector 4
256
+    DWIN_Draw_Point(color, 1, 1, x - a, y - b);   // Draw some sector 5
257
+    DWIN_Draw_Point(color, 1, 1, x - b, y - a);   // Draw some sector 6
258
+    DWIN_Draw_Point(color, 1, 1, x - b, y + a);   // Draw some sector 7
259
+    DWIN_Draw_Point(color, 1, 1, x - a, y + b);   // Draw some sector 8
260
+    a++;
261
+  }
262
+}
263
+
264
+// Draw a circle filled with color
265
+//  bcolor: fill color
266
+//  x: the abscissa of the center of the circle
267
+//  y: ordinate of the center of the circle
268
+//  r: circle radius
269
+void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
270
+  int a = 0, b = 0;
271
+  while (a <= b) {
272
+    b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a);
273
+    if (a == 0) b--;
274
+    DWIN_Draw_Line(bcolor, x-b,y-a,x+b,y-a);
275
+    DWIN_Draw_Line(bcolor, x-a,y-b,x+a,y-b);
276
+    DWIN_Draw_Line(bcolor, x-b,y+a,x+b,y+a);
277
+    DWIN_Draw_Line(bcolor, x-a,y+b,x+a,y+b);
278
+    a++;
279
+  }
280
+}
281
+
282
+// Color Interpolator
283
+//  val : Interpolator minv..maxv
284
+//  minv : Minimum value
285
+//  maxv : Maximum value
286
+//  color1 : Start color
287
+//  color2 : End color
288
+uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
289
+  uint8_t B, G, R;
290
+  const float n = (float)(val - minv) / (maxv - minv);
291
+  R = (1 - n) * GetRColor(color1) + n * GetRColor(color2);
292
+  G = (1 - n) * GetGColor(color1) + n * GetGColor(color2);
293
+  B = (1 - n) * GetBColor(color1) + n * GetBColor(color2);
294
+  return RGB(R, G, B);
295
+}
296
+
297
+// Color Interpolator through Red->Yellow->Green->Blue (Pro UI)
298
+//  val : Interpolator minv..maxv
299
+//  minv : Minimum value
300
+//  maxv : Maximum value
301
+uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
302
+  uint8_t B, G, R;
303
+  const uint8_t maxB = 28, maxR = 28, maxG = 38;
304
+  const int16_t limv = _MAX(abs(minv), abs(maxv));
305
+  float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv;
306
+  LIMIT(n, -1, 1);
307
+  if (n < 0) {
308
+    R = 0;
309
+    G = (1 + n) * maxG;
310
+    B = (-n) * maxB;
311
+  }
312
+  else if (n < 0.5) {
313
+    R = maxR * n * 2;
314
+    G = maxG;
315
+    B = 0;
316
+  }
317
+  else {
318
+    R = maxR;
319
+    G = maxG * (1 - n);
320
+    B = 0;
321
+  }
322
+  return RGB(R, G, B);
323
+}
324
+
325
+// Draw a checkbox
326
+//  Color: frame color
327
+//  bColor: Background color
328
+//  x/y: Upper-left point
329
+//  mode : 0 : unchecked, 1 : checked
330
+void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
331
+  DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
332
+  DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
333
+}
334
+
335
+// Clear Menu by filling the menu area with background color
336
+void DWINUI::ClearMainArea() {
337
+  DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1);
338
+}
339
+
340
+#endif // DWIN_CREALITY_LCD_JYERSUI

+ 527
- 0
Marlin/src/lcd/e3v2/jyersui/dwinui.h View File

@@ -0,0 +1,527 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * DWIN Enhanced implementation for PRO UI
26
+ * Author: Miguel A. Risco-Castillo (MRISCOC)
27
+ * Version: 3.17.1
28
+ * Date: 2022/04/12
29
+ *
30
+ * Modded for JYERSUI by LCH-77
31
+ * Version: 1.9
32
+ * Date: Jun 16, 2022
33
+ */
34
+
35
+#include "dwin_lcd.h"
36
+#include "../common/dwin_set.h"
37
+#include "../common/dwin_font.h"
38
+#include "../common/dwin_color.h"
39
+#include "../common/dwin_api.h"
40
+
41
+// Custom icons
42
+//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
43
+#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
44
+  // index of every custom icon should be >= CUSTOM_ICON_START
45
+  #define CUSTOM_ICON_START         ICON_Checkbox_F
46
+  #define ICON_Checkbox_F           200
47
+  #define ICON_Checkbox_T           201
48
+  #define ICON_Fade                 202
49
+  #define ICON_Mesh                 203
50
+  #define ICON_Tilt                 204
51
+  #define ICON_Brightness           205
52
+  #define ICON_AxisD                249
53
+  #define ICON_AxisBR               250
54
+  #define ICON_AxisTR               251
55
+  #define ICON_AxisBL               252
56
+  #define ICON_AxisTL               253
57
+  #define ICON_AxisC                254
58
+#else
59
+  #define ICON_Fade                 ICON_Version
60
+  #define ICON_Mesh                 ICON_Version
61
+  #define ICON_Tilt                 ICON_Version
62
+  #define ICON_Brightness           ICON_Version
63
+  #define ICON_AxisD                ICON_Axis
64
+  #define ICON_AxisBR               ICON_Axis
65
+  #define ICON_AxisTR               ICON_Axis
66
+  #define ICON_AxisBL               ICON_Axis
67
+  #define ICON_AxisTL               ICON_Axis
68
+  #define ICON_AxisC                ICON_Axis
69
+  #define ICON_ESDiag               ICON_Info
70
+  #define ICON_Lock                 ICON_Cool
71
+  #define ICON_Reboot               ICON_ResumeEEPROM
72
+  #define ICON_ProbeAlarm           ICON_SetEndTemp
73
+  #define ICON_ProbeMargin          ICON_PrintSize
74
+  #define ICON_ProbeSelfTest        ICON_SetEndTemp
75
+  #define ICON_ProbeSet             ICON_SetEndTemp
76
+  #define ICON_ProbeDeploy          ICON_SetEndTemp
77
+  #define ICON_ProbeTest            ICON_SetEndTemp
78
+  #define ICON_ProbeTestCount       ICON_SetEndTemp
79
+  #define ICON_ProbeZSpeed          ICON_MaxSpeedZ
80
+  #define ICON_FWRetLength          ICON_StepE
81
+  #define ICON_FWRetSpeed           ICON_Setspeed
82
+  #define ICON_FWRetZRaise          ICON_MoveZ
83
+  #define ICON_FWRecExtLength       ICON_StepE
84
+  #define ICON_FWRecSpeed           ICON_Setspeed
85
+  #define ICON_HSMode               ICON_StockConfiguration
86
+  #define ICON_Sound                ICON_Cool
87
+  #define ICON_CaseLight            ICON_Motion
88
+  #define ICON_LedControl           ICON_Motion
89
+  #define ICON_MeshActive           ICON_HotendTemp
90
+  #define ICON_Park                 ICON_Motion
91
+#endif
92
+
93
+// Buttons
94
+#define BTN_Continue          85
95
+#define BTN_Cancel            87
96
+#define BTN_Confirm           89
97
+#define BTN_Print             90
98
+#define BTN_Save              91
99
+#define BTN_Purge             92
100
+
101
+// Extended UI Colors
102
+#define Color_Aqua          RGB(0,63,31)
103
+#define Color_Light_White   0xBDD7
104
+#define Color_Green         RGB(0,63,0)
105
+#define Color_Light_Green   0x3460
106
+#define Color_Cyan          0x07FF
107
+#define Color_Light_Cyan    0x04F3
108
+#define Color_Blue          RGB(0,0,31)
109
+#define Color_Light_Blue    0x3A6A
110
+#define Color_Magenta       0xF81F
111
+#define Color_Light_Magenta 0x9813
112
+#define Color_Light_Red     0x8800
113
+#define Color_Orange        0xFA20
114
+#define Color_Light_Orange  0xFBC0
115
+#define Color_Light_Yellow  0x8BE0
116
+#define Color_Brown         0xCC27
117
+#define Color_Light_Brown   0x6204
118
+#define Color_Black         0x0000
119
+#define Color_Grey          0x18E3
120
+#define Check_Color         0x4E5C
121
+#define Confirm_Color       0x34B9
122
+#define Cancel_Color        0x3186
123
+
124
+// UI element defines and constants
125
+#define DWIN_FONT_MENU font8x16
126
+#define DWIN_FONT_STAT font10x20
127
+#define DWIN_FONT_HEAD font10x20
128
+#define DWIN_FONT_ALERT font10x20
129
+#define STATUS_Y 354
130
+#define LCD_WIDTH (DWIN_WIDTH / 8)  // only if the default font is font8x16
131
+
132
+// Minimum unit (0.1) : multiple (10)
133
+#define UNITFDIGITS 1
134
+#define MINUNITMULT POW(10, UNITFDIGITS)
135
+
136
+constexpr uint8_t  TITLE_HEIGHT = 30,                          // Title bar height
137
+                   MLINE = 53,                                 // Menu line height
138
+                   TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE,  // Total rows
139
+                   MROWS = TROWS - 1,                          // Other-than-Back
140
+                   ICOX = 26,                                  // Menu item icon X position
141
+                   LBLX = 60,                                  // Menu item label X position
142
+                   VALX = 210,                                 // Menu item value X position
143
+                   MENU_CHR_W = 8, MENU_CHR_H = 16,            // Menu font 8x16
144
+                   STAT_CHR_W = 10;
145
+
146
+// Menuitem Y position
147
+#define MYPOS(L) (TITLE_HEIGHT + MLINE * (L))
148
+
149
+// Menuitem caption Offset
150
+#define CAPOFF ((MLINE - MENU_CHR_H) / 2)
151
+
152
+// Menuitem caption Y position
153
+#define MBASE(L) (MYPOS(L) + CAPOFF)
154
+
155
+typedef struct { uint16_t left, top, right, bottom; } rect_t;
156
+typedef struct { uint16_t x, y, w, h; } frame_rect_t;
157
+
158
+namespace DWINUI {
159
+  extern xy_int_t cursor;
160
+  extern uint16_t pencolor;
161
+  extern uint16_t textcolor;
162
+  extern uint16_t backcolor;
163
+  extern uint16_t buttoncolor;
164
+  extern uint8_t  font;
165
+  extern FSTR_P const Author;
166
+
167
+  // DWIN LCD Initialization
168
+  void init();
169
+
170
+  // Set text/number font
171
+  void setFont(uint8_t cfont);
172
+
173
+  // Get font character width
174
+  uint8_t fontWidth(uint8_t cfont);
175
+  inline uint8_t fontWidth() { return fontWidth(font); };
176
+
177
+  // Get font character height
178
+  uint8_t fontHeight(uint8_t cfont);
179
+  inline uint8_t fontHeight() { return fontHeight(font); };
180
+
181
+  // Get screen x coordinates from text column
182
+  uint16_t ColToX(uint8_t col);
183
+
184
+  // Get screen y coordinates from text row
185
+  uint16_t RowToY(uint8_t row);
186
+
187
+  // Set text/number color
188
+  void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor);
189
+  void SetTextColor(uint16_t fgcolor);
190
+  void SetBackgroundColor(uint16_t bgcolor);
191
+
192
+  // Moves cursor to point
193
+  //  x: abscissa of the display
194
+  //  y: ordinate of the display
195
+  //  point: xy coordinate
196
+  void MoveTo(int16_t x, int16_t y);
197
+  void MoveTo(xy_int_t point);
198
+
199
+  // Moves cursor relative to the actual position
200
+  //  x: abscissa of the display
201
+  //  y: ordinate of the display
202
+  //  point: xy coordinate
203
+  void MoveBy(int16_t x, int16_t y);
204
+  void MoveBy(xy_int_t point);
205
+
206
+  // Draw a line from the cursor to xy position
207
+  //  color: Line segment color
208
+  //  x/y: End point
209
+  inline void LineTo(uint16_t color, uint16_t x, uint16_t y) {
210
+    DWIN_Draw_Line(color, cursor.x, cursor.y, x, y);
211
+  }
212
+  inline void LineTo(uint16_t x, uint16_t y) {
213
+    DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y);
214
+  }
215
+
216
+  // Extend a frame box
217
+  //  v: value to extend
218
+  inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) {
219
+    frame_rect_t t;
220
+    t.x = frame.x - v;
221
+    t.y = frame.y - v;
222
+    t.w = frame.w + 2 * v;
223
+    t.h = frame.h + 2 * v;
224
+    return t;
225
+  }
226
+
227
+  // Draw an Icon with transparent background from the library ICON
228
+  //  icon: Icon ID
229
+  //  x/y: Upper-left point
230
+  inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) {
231
+    DWIN_ICON_Show(ICON, icon, x, y);
232
+  }
233
+
234
+  // Draw an Icon from the library ICON with its background
235
+  //  icon: Icon ID
236
+  //  x/y: Upper-left point
237
+  inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) {
238
+    DWIN_ICON_Show(true, false, false, ICON, icon, x, y);
239
+  }
240
+  inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) {
241
+    DWIN_ICON_Show(true, false, false, libID, icon, x, y);
242
+  }
243
+
244
+  // Draw a numeric integer value
245
+  //  bShow: true=display background color; false=don't display background color
246
+  //  signedMode: 1=signed; 0=unsigned
247
+  //  size: Font size
248
+  //  color: Character color
249
+  //  bColor: Background color
250
+  //  iNum: Number of digits
251
+  //  x/y: Upper-left coordinate
252
+  //  value: Integer value
253
+  void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
254
+
255
+  // Draw a positive integer
256
+  inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
257
+    Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value);
258
+  }
259
+  inline void Draw_Int(uint8_t iNum, long value) {
260
+    Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
261
+    MoveBy(iNum * fontWidth(font), 0);
262
+  }
263
+  inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
264
+    Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value);
265
+  }
266
+  inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
267
+    Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value);
268
+  }
269
+  inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
270
+    Draw_Int(true, 0, font, color, bColor, iNum, x, y, value);
271
+  }
272
+  inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
273
+    Draw_Int(true, 0, size, color, bColor, iNum, x, y, value);
274
+  }
275
+
276
+  // Draw a signed integer
277
+  inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
278
+    Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value);
279
+  }
280
+  inline void Draw_Signed_Int(uint8_t iNum, long value) {
281
+    Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
282
+    MoveBy(iNum * fontWidth(font), 0);
283
+  }
284
+  inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
285
+    Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value);
286
+  }
287
+  inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
288
+    Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value);
289
+  }
290
+  inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
291
+    Draw_Int(true, 1, font, color, bColor, iNum, x, y, value);
292
+  }
293
+  inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
294
+    Draw_Int(true, 1, size, color, bColor, iNum, x, y, value);
295
+  }
296
+
297
+  // Draw a numeric float value
298
+  //  bShow: true=display background color; false=don't display background color
299
+  //  signedMode: 1=signed; 0=unsigned
300
+  //  size: Font size
301
+  //  color: Character color
302
+  //  bColor: Background color
303
+  //  iNum: Number of digits
304
+  //  fNum: Number of decimal digits
305
+  //  x/y: Upper-left coordinate
306
+  //  value: float value
307
+  void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
308
+
309
+  // Draw a positive floating point number
310
+  inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
311
+    Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value);
312
+  }
313
+  inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
314
+    Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
315
+    MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
316
+  }
317
+  inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
318
+    Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
319
+  }
320
+  inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
321
+    Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
322
+  }
323
+  inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
324
+    Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value);
325
+  }
326
+  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, float value) {
327
+    Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value);
328
+  }
329
+
330
+  // Draw a signed floating point number
331
+  inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
332
+    Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value);
333
+  }
334
+  inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
335
+    Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
336
+    MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
337
+  }
338
+  inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
339
+    Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value);
340
+  }
341
+  inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
342
+    Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value);
343
+  }
344
+  inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
345
+    Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value);
346
+  }
347
+  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, float value) {
348
+    Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value);
349
+  }
350
+
351
+  // Draw a char
352
+  //  color: Character color
353
+  //  x: abscissa of the display
354
+  //  y: ordinate of the display
355
+  //  c: ASCII code of char
356
+  void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c);
357
+  inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); };
358
+  // Draw a char at cursor position and increment cursor
359
+  void Draw_Char(uint16_t color, const char c);
360
+  inline void Draw_Char(const char c) { Draw_Char(textcolor, c); }
361
+
362
+  // Draw a string at cursor position
363
+  //  color: Character color
364
+  //  *string: The string
365
+  //  rlimit: For draw less chars than string length use rlimit
366
+  void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
367
+  void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
368
+  inline void Draw_String(FSTR_P  string, uint16_t rlimit = 0xFFFF) {
369
+    Draw_String(FTOP(string), rlimit);
370
+  }
371
+  inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
372
+    Draw_String(color, FTOP(string), rlimit);
373
+  }
374
+
375
+  // Draw a string
376
+  //  size: Font size
377
+  //  color: Character color
378
+  //  bColor: Background color
379
+  //  x/y: Upper-left coordinate of the string
380
+  //  *string: The string
381
+  inline void Draw_String(uint16_t x, uint16_t y, const char * const string) {
382
+    DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
383
+  }
384
+  inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
385
+    DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title));
386
+  }
387
+  inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
388
+    DWIN_Draw_String(false, font, color, backcolor, x, y, string);
389
+  }
390
+  inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
391
+    DWIN_Draw_String(false, font, color, backcolor, x, y, title);
392
+  }
393
+  inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
394
+    DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
395
+  }
396
+  inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
397
+    DWIN_Draw_String(true, font, color, bgcolor, x, y, title);
398
+  }
399
+  inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
400
+    DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
401
+  }
402
+  inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
403
+    DWIN_Draw_String(true, size, color, bgcolor, x, y, title);
404
+  }
405
+
406
+  // Draw a centered string using DWIN_WIDTH
407
+  //  bShow: true=display background color; false=don't display background color
408
+  //  size: Font size
409
+  //  color: Character color
410
+  //  bColor: Background color
411
+  //  y: Upper coordinate of the string
412
+  //  *string: The string
413
+  void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string);
414
+  inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
415
+    Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string);
416
+  }
417
+  inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
418
+    Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string));
419
+  }
420
+  inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
421
+    Draw_CenteredString(true, font, color, bcolor, y, string);
422
+  }
423
+  inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) {
424
+    Draw_CenteredString(false, size, color, backcolor, y, string);
425
+  }
426
+  inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) {
427
+    Draw_CenteredString(false, size, color, backcolor, y, title);
428
+  }
429
+  inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
430
+    Draw_CenteredString(false, font, color, backcolor, y, string);
431
+  }
432
+  inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
433
+    Draw_CenteredString(false, font, color, backcolor, y, title);
434
+  }
435
+  inline void Draw_CenteredString(uint16_t y, const char * const string) {
436
+    Draw_CenteredString(false, font, textcolor, backcolor, y, string);
437
+  }
438
+  inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
439
+    Draw_CenteredString(false, font, textcolor, backcolor, y, title);
440
+  }
441
+
442
+  // Draw a box
443
+  //  mode: 0=frame, 1=fill, 2=XOR fill
444
+  //  color: Rectangle color
445
+  //  frame: Box coordinates and size
446
+  inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) {
447
+    DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h);
448
+  }
449
+
450
+  // Draw a circle
451
+  //  Color: circle color
452
+  //  x: abscissa of the center of the circle
453
+  //  y: ordinate of the center of the circle
454
+  //  r: circle radius
455
+  void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
456
+  inline void Draw_Circle(uint16_t color, uint8_t r) {
457
+    Draw_Circle(color, cursor.x, cursor.y, r);
458
+  }
459
+
460
+  // Draw a checkbox
461
+  //  Color: frame color
462
+  //  bColor: Background color
463
+  //  x/y: Upper-left point
464
+  //  checked : 0 : unchecked, 1 : checked
465
+  void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
466
+  inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) {
467
+    Draw_Checkbox(textcolor, backcolor, x, y, checked);
468
+  }
469
+
470
+  // Color Interpolator
471
+  //  val : Interpolator minv..maxv
472
+  //  minv : Minimum value
473
+  //  maxv : Maximum value
474
+  //  color1 : Start color
475
+  //  color2 : End color
476
+  uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
477
+
478
+  // ------------------------- Buttons ------------------------------//
479
+
480
+  void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption);
481
+  inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) {
482
+    Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption));
483
+  }
484
+  inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) {
485
+    Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption);
486
+  }
487
+  void Draw_Button(uint8_t id, uint16_t x, uint16_t y);
488
+
489
+  // -------------------------- Extra -------------------------------//
490
+
491
+  // Draw a circle filled with color
492
+  //  bcolor: fill color
493
+  //  x: abscissa of the center of the circle
494
+  //  y: ordinate of the center of the circle
495
+  //  r: circle radius
496
+  void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
497
+  inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
498
+    Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
499
+  }
500
+
501
+  // Color Interpolator through Red->Yellow->Green->Blue
502
+  //  val : Interpolator minv..maxv
503
+  //  minv : Minimum value
504
+  //  maxv : Maximum value
505
+  uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
506
+
507
+  // Write buffer data to the SRAM
508
+  //  addr: SRAM start address 0x0000-0x7FFF
509
+  //  length: Bytes to write
510
+  //  data: address of the buffer with data
511
+  inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
512
+    DWIN_WriteToMem(0x5A, addr, length, data);
513
+  }
514
+
515
+  // Write buffer data to the Flash
516
+  //  addr: Flash start address 0x0000-0x3FFF
517
+  //  length: Bytes to write
518
+  //  data: address of the buffer with data
519
+  inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
520
+    DWIN_WriteToMem(0xA5, addr, length, data);
521
+  }
522
+
523
+  // Clear by filling the area with background color
524
+  // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
525
+  void ClearMainArea();
526
+
527
+};

+ 111
- 0
Marlin/src/lcd/e3v2/jyersui/endstop_diag.cpp View File

@@ -0,0 +1,111 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * DWIN End Stops diagnostic page
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 1.0
27
+ * Date: 2021/11/06
28
+ *
29
+ * Modded for JYERSUI by LCH-77
30
+ */
31
+
32
+#include "../../../inc/MarlinConfigPre.h"
33
+
34
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
35
+
36
+#include "dwin_defines.h"
37
+
38
+#if HAS_ESDIAG
39
+
40
+#include "endstop_diag.h"
41
+#include "dwinui.h"
42
+#include "dwin.h"
43
+
44
+#if HAS_FILAMENT_SENSOR
45
+  #include "../../../feature/runout.h"
46
+#endif
47
+
48
+#if HAS_BED_PROBE
49
+  #include "../../../module/probe.h"
50
+#endif
51
+
52
+ESDiagClass ESDiag;
53
+
54
+void draw_es_label(FSTR_P const flabel=nullptr) {
55
+  DWINUI::cursor.x = 40;
56
+  if (flabel) DWINUI::Draw_String(F(flabel));
57
+  DWINUI::Draw_String(F(": "));
58
+  DWINUI::MoveBy(0, 25);
59
+}
60
+
61
+void draw_es_state(const bool is_hit) {
62
+  const uint8_t LM = 130;
63
+  DWINUI::cursor.x = LM;
64
+  DWIN_Draw_Rectangle(1, Color_Bg_Window, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
65
+  is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
66
+  DWINUI::MoveBy(0, 25);
67
+}
68
+
69
+void ESDiagClass::Draw() {
70
+  CrealityDWINClass::Clear_Screen(1);
71
+  CrealityDWINClass::Draw_Title(F("End-stops Diagnostic"));
72
+  DWINUI::ClearMainArea();
73
+  DWIN_Draw_Rectangle(0, Color_White, 14, 60, 258, 330);
74
+  DWINUI::Draw_Button(BTN_Continue, 86, 250);
75
+  DWINUI::cursor.y = 80;
76
+  #define ES_LABEL(S) draw_es_label(F(STR_##S))
77
+  #if HAS_X_MIN
78
+    ES_LABEL(X_MIN);
79
+  #endif
80
+  #if HAS_Y_MIN
81
+    ES_LABEL(Y_MIN);
82
+  #endif
83
+  #if HAS_Z_MIN
84
+    ES_LABEL(Z_MIN);
85
+  #endif
86
+  #if HAS_FILAMENT_SENSOR
87
+    draw_es_label(F(STR_FILAMENT));
88
+  #endif
89
+  Update();
90
+}
91
+
92
+void ESDiagClass::Update() {
93
+  DWINUI::cursor.y = 80;
94
+  #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING)
95
+  #if HAS_X_MIN
96
+    ES_REPORT(X_MIN);
97
+  #endif
98
+  #if HAS_Y_MIN
99
+    ES_REPORT(Y_MIN);
100
+  #endif
101
+  #if HAS_Z_MIN
102
+    ES_REPORT(Z_MIN);
103
+  #endif
104
+  #if HAS_FILAMENT_SENSOR
105
+    draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE);
106
+  #endif
107
+  DWIN_UpdateLCD();
108
+}
109
+
110
+#endif  // HAS_ES_DIAG
111
+#endif  // DWIN_CREALITY_LCD_JYERSUI

+ 39
- 0
Marlin/src/lcd/e3v2/jyersui/endstop_diag.h View File

@@ -0,0 +1,39 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * DWIN End Stops diagnostic page
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 1.0
28
+ * Date: 2021/11/06
29
+ *
30
+ * Modded for JYERSUI by LCH-77
31
+ */
32
+
33
+class ESDiagClass {
34
+public:
35
+  void Draw();
36
+  void Update();
37
+};
38
+
39
+extern ESDiagClass ESDiag;

+ 244
- 0
Marlin/src/lcd/e3v2/jyersui/gcode_preview.cpp View File

@@ -0,0 +1,244 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * DWIN G-code thumbnail preview
25
+ * Author: Miguel A. Risco-Castillo
26
+ * version: 2.1
27
+ * Date: 2021/06/19
28
+ *
29
+ * Modded for JYERSUI by LCH-77
30
+ */
31
+
32
+#include "../../../inc/MarlinConfigPre.h"
33
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
34
+
35
+#include "dwin_defines.h"
36
+
37
+#if HAS_GCODE_PREVIEW
38
+
39
+#include "../../../core/types.h"
40
+#include "../../marlinui.h"
41
+#include "../../../sd/cardreader.h"
42
+#include "../../../MarlinCore.h" // for wait_for_user
43
+#include "dwin_lcd.h"
44
+#include "dwinui.h"
45
+#include "dwin.h"
46
+#include "base64.hpp"
47
+#include "gcode_preview.h"
48
+
49
+typedef struct {
50
+  char name[13] = "";   //8.3 + null
51
+  uint32_t thumbstart = 0;
52
+  int thumbsize = 0;
53
+  int thumbheight = 0;
54
+  int thumbwidth = 0;
55
+  uint8_t *thumbdata = nullptr;
56
+  float time = 0;
57
+  float filament = 0;
58
+  float layer = 0;
59
+  float width = 0;
60
+  float height = 0;
61
+  float length = 0;
62
+  void setname(const char * const fn);
63
+  void clear();
64
+} fileprop_t;
65
+fileprop_t fileprop;
66
+
67
+void fileprop_t::setname(const char * const fn) {
68
+  const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn));
69
+  memcpy(&name[0], fn, len);
70
+  name[len] = '\0';
71
+}
72
+
73
+void fileprop_t::clear() {
74
+  fileprop.name[0] = '\0';
75
+  fileprop.thumbstart = 0;
76
+  fileprop.thumbsize = 0;
77
+  fileprop.thumbheight = 0;
78
+  fileprop.thumbwidth = 0;
79
+  fileprop.thumbdata = nullptr;
80
+  fileprop.time = 0;
81
+  fileprop.filament = 0;
82
+  fileprop.layer = 0;
83
+  fileprop.height = 0;
84
+  fileprop.width = 0;
85
+  fileprop.length = 0;
86
+}
87
+
88
+void Get_Value(char *buf, const char * const key, float &value) {
89
+  char num[10] = "";
90
+  char * posptr = 0;
91
+  uint8_t i = 0;
92
+  if (!!value) return;
93
+  posptr = strstr(buf, key);
94
+  if (posptr != nullptr) {
95
+    while (i < sizeof(num)) {
96
+      char c = posptr[0];
97
+      if (!ISEOL(c) && (c != 0)) {
98
+        if ((c > 47 && c < 58) || (c == '.')) num[i++] = c;
99
+        posptr++;
100
+      }
101
+      else {
102
+        num[i] = '\0';
103
+        value = atof(num);
104
+        return;
105
+      }
106
+    }
107
+  }
108
+}
109
+
110
+bool Has_Preview() {
111
+  const char * tbstart = "; thumbnail begin 230x180";
112
+  char * posptr = 0;
113
+  uint8_t nbyte = 1;
114
+  uint32_t indx = 0;
115
+  char buf[256];
116
+  float tmp = 0;
117
+
118
+  fileprop.clear();
119
+  fileprop.setname(card.filename);
120
+
121
+  card.openFileRead(fileprop.name);
122
+
123
+  while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) {
124
+    nbyte = card.read(buf, sizeof(buf) - 1);
125
+    if (nbyte > 0) {
126
+      buf[nbyte] = '\0';
127
+      Get_Value(buf, ";TIME:", fileprop.time);
128
+      Get_Value(buf, ";Filament used:", fileprop.filament);
129
+      Get_Value(buf, ";Layer height:", fileprop.layer);
130
+      Get_Value(buf, ";MINX:", tmp);
131
+      Get_Value(buf, ";MAXX:", fileprop.width);
132
+      fileprop.width -= tmp;
133
+      tmp = 0;
134
+      Get_Value(buf, ";MINY:", tmp);
135
+      Get_Value(buf, ";MAXY:", fileprop.length);
136
+      fileprop.length -= tmp;
137
+      tmp = 0;
138
+      Get_Value(buf, ";MINZ:", tmp);
139
+      Get_Value(buf, ";MAXZ:", fileprop.height);
140
+      fileprop.height -= tmp;
141
+      posptr = strstr(buf, tbstart);
142
+      if (posptr != NULL) {
143
+        fileprop.thumbstart = indx + (posptr - &buf[0]);
144
+      }
145
+      else {
146
+        indx += _MAX(10, nbyte - (signed)strlen(tbstart));
147
+        card.setIndex(indx);
148
+      }
149
+    }
150
+  }
151
+
152
+  if (!fileprop.thumbstart) {
153
+    card.closefile();
154
+    LCD_MESSAGE_F("Thumbnail not found");
155
+    return 0;
156
+  }
157
+
158
+  // Get the size of the thumbnail
159
+  card.setIndex(fileprop.thumbstart + strlen(tbstart));
160
+  for (uint8_t i = 0; i < 16; i++) {
161
+    char c = card.get();
162
+    if (!ISEOL(c)) {
163
+      buf[i] = c;
164
+    }
165
+    else {
166
+      buf[i] = '\0';
167
+      break;
168
+    }
169
+  }
170
+  fileprop.thumbsize = atoi(buf);
171
+
172
+  // Exit if there isn't a thumbnail
173
+  if (!fileprop.thumbsize) {
174
+    card.closefile();
175
+    LCD_MESSAGE_F("Invalid Thumbnail Size");
176
+    return 0;
177
+  }
178
+
179
+  uint16_t readed = 0;
180
+  uint8_t buf64[fileprop.thumbsize];
181
+
182
+  fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)];  // Reserve space for the JPEG thumbnail
183
+
184
+  while (readed < fileprop.thumbsize) {
185
+    uint8_t c = card.get();
186
+    if (!ISEOL(c) && (c != ';') && (c != ' ')) {
187
+      buf64[readed] = c;
188
+      readed++;
189
+    }
190
+  }
191
+  card.closefile();
192
+  buf64[readed] = 0;
193
+
194
+  fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata);  card.closefile();
195
+  DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata);
196
+  delete[] fileprop.thumbdata;
197
+  return true;
198
+}
199
+
200
+void Preview_DrawFromSD() {
201
+  bool _has_preview = Has_Preview();
202
+  CrealityDWIN.Popup_Handler(PrintConfirm, _has_preview);
203
+  if (_has_preview) {
204
+    char buf[46];
205
+    char str_1[6] = "", str_2[6] = "", str_3[6] = "";
206
+    // DWIN_Draw_Rectangle(1, Def_Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
207
+    if (fileprop.time) {
208
+      sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60);
209
+      DWINUI::Draw_String(20, 10, buf);
210
+    }
211
+    if (fileprop.filament) {
212
+      sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1));
213
+      DWINUI::Draw_String(20, 30, buf);
214
+    }
215
+    if (fileprop.layer) {
216
+      sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1));
217
+      DWINUI::Draw_String(20, 50, buf);
218
+    }
219
+    if (fileprop.width) {
220
+      sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3));
221
+      DWINUI::Draw_String(20, 70, buf);
222
+    }
223
+    // DWINUI::Draw_Button(BTN_Print, 26, 290);
224
+    // DWINUI::Draw_Button(BTN_Cancel, 146, 290);
225
+    DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00);
226
+    // Draw_Select_Highlight(true, 290);
227
+    DWIN_UpdateLCD();
228
+  }
229
+  // else {
230
+  //   HMI_flag.select_flag = 1;
231
+  //   wait_for_user = false;
232
+  // }
233
+}
234
+
235
+bool Preview_Valid() {
236
+  return !!fileprop.thumbstart;
237
+}
238
+
239
+void Preview_Reset() {
240
+  fileprop.thumbsize = 0;
241
+}
242
+
243
+#endif // HAS_GCODE_PREVIEW
244
+#endif // DWIN_LCD_PROUI

+ 34
- 0
Marlin/src/lcd/e3v2/jyersui/gcode_preview.h View File

@@ -0,0 +1,34 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * DWIN G-code thumbnail preview
25
+ * Author: Miguel A. Risco-Castillo
26
+ * version: 2.1
27
+ * Date: 2021/06/19
28
+ */
29
+
30
+#pragma once
31
+
32
+void Preview_DrawFromSD();
33
+bool Preview_Valid();
34
+void Preview_Reset();

+ 83
- 0
Marlin/src/lcd/e3v2/jyersui/lockscreen.cpp View File

@@ -0,0 +1,83 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Lock screen implementation for PRO UI
25
+ * Author: Miguel A. Risco-Castillo (MRISCOC)
26
+ * Version: 2.2.0
27
+ * Date: 2022/04/11
28
+ *
29
+ * Modded for JYERSUI by LCH-77
30
+ */
31
+
32
+#include "../../../inc/MarlinConfigPre.h"
33
+
34
+#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
35
+
36
+#include "dwin_defines.h"
37
+
38
+#if HAS_LOCKSCREEN
39
+
40
+#include "../common/dwin_color.h"
41
+#include "dwinui.h"
42
+#include "dwin.h"
43
+#include "lockscreen.h"
44
+
45
+LockScreenClass lockScreen;
46
+
47
+uint8_t LockScreenClass::lock_pos = 0;
48
+bool LockScreenClass::unlocked = false;
49
+uint8_t LockScreenClass::rprocess = 0;
50
+
51
+void LockScreenClass::init() {
52
+  lock_pos = 0;
53
+  unlocked = false;
54
+  draw();
55
+}
56
+
57
+void LockScreenClass::draw() {
58
+  CrealityDWINClass::Clear_Screen(1);
59
+  CrealityDWINClass::Draw_Title(GET_TEXT_F(MSG_LOCKSCREEN));
60
+  DWINUI::ClearMainArea();
61
+  DWINUI::Draw_Icon(ICON_LOGO, 71, 120);  // CREALITY logo
62
+  DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED));
63
+  DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK));
64
+  DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
65
+  DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20);
66
+  DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
67
+  DWIN_UpdateLCD();
68
+}
69
+
70
+void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
71
+  switch (encoder_diffState) {
72
+    case ENCODER_DIFF_CW:    lock_pos += 8; break;
73
+    case ENCODER_DIFF_CCW:   lock_pos -= 8; break;
74
+    case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
75
+    default: break;
76
+  }
77
+  DWIN_Draw_Box(1, BarFill_Color, 0, 260, DWIN_WIDTH, 20);
78
+  DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
79
+  DWIN_UpdateLCD();
80
+}
81
+
82
+#endif // HAS_LOCKSCREEN
83
+#endif // DWIN_CREALITY_LCD_JYERSUI

+ 49
- 0
Marlin/src/lcd/e3v2/jyersui/lockscreen.h View File

@@ -0,0 +1,49 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Lock screen implementation for PRO UI
26
+ * Author: Miguel A. Risco-Castillo (MRISCOC)
27
+ * Version: 2.2.0
28
+ * Date: 2022/04/11
29
+ *
30
+ * Modded for JYERSUI by LCH-77
31
+ */
32
+
33
+#include "../../../core/types.h"
34
+#include "../common/encoder.h"
35
+#include <stdint.h>
36
+
37
+class LockScreenClass {
38
+private:
39
+  static bool unlocked;
40
+  static uint8_t lock_pos;
41
+public:
42
+  static uint8_t rprocess;
43
+  static void init();
44
+  static void onEncoder(EncoderState encoder_diffState);
45
+  static void draw();
46
+  static bool isUnlocked() { return unlocked; }
47
+};
48
+
49
+extern LockScreenClass lockScreen;

+ 86
- 0
Marlin/src/lcd/e3v2/jyersui/plot.cpp View File

@@ -0,0 +1,86 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * DWIN Single var plot
25
+ * Author: Miguel A. Risco-Castillo
26
+ * Version: 2.0
27
+ * Date: 2022/01/31
28
+ *
29
+ * Modded for JYERSUI by LCH-77
30
+ */
31
+
32
+#include "../../../inc/MarlinConfigPre.h"
33
+
34
+#ifdef DWIN_CREALITY_LCD_JYERSUI
35
+
36
+#include "dwin_defines.h"
37
+
38
+#ifdef HAS_PIDPLOT
39
+
40
+#include "plot.h"
41
+
42
+#include "../../../core/types.h"
43
+#include "../../marlinui.h"
44
+#include "dwin_lcd.h"
45
+#include "dwinui.h"
46
+#include "dwin.h"
47
+
48
+#define Plot_Bg_Color RGB( 1, 12,  8)
49
+
50
+PlotClass Plot;
51
+
52
+uint16_t grphpoints, r, x2, y2 = 0;
53
+frame_rect_t grphframe = {0};
54
+float scale = 0;
55
+
56
+void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) {
57
+  grphframe = frame;
58
+  grphpoints = 0;
59
+  scale = frame.h / max;
60
+  x2 = frame.x + frame.w - 1;
61
+  y2 = frame.y + frame.h - 1;
62
+  r = round((y2) - ref * scale);
63
+  DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
64
+  for (uint8_t i = 1; i < 4; i++)  if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h);
65
+  DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
66
+  DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
67
+}
68
+
69
+void PlotClass::Update(const float value) {
70
+  if (!scale) return;
71
+  uint16_t y = round((y2) - value * scale);
72
+  if (grphpoints < grphframe.w) {
73
+    DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
74
+  }
75
+  else {
76
+    DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
77
+    if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
78
+    DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r);
79
+    DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y);
80
+  }
81
+  grphpoints++;
82
+}
83
+
84
+#endif // HAS_PIDPLOT
85
+
86
+#endif // DWIN_CREALITY_LCD_JYERSUI

+ 41
- 0
Marlin/src/lcd/e3v2/jyersui/plot.h View File

@@ -0,0 +1,41 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * DWIN Single var plot
26
+ * Author: Miguel A. Risco-Castillo
27
+ * Version: 1.0
28
+ * Date: 2022/01/30
29
+ *
30
+ * Modded for JYERSUI by LCH-77
31
+ */
32
+
33
+#include "dwinui.h"
34
+
35
+class PlotClass {
36
+public:
37
+  void Draw(frame_rect_t frame, float max, float ref = 0);
38
+  void Update(float value);
39
+};
40
+
41
+extern PlotClass Plot;

+ 3
- 3
Marlin/src/lcd/e3v2/proui/base64.hpp View File

@@ -152,7 +152,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch
152 152
     output += 4;
153 153
   }
154 154
 
155
-  switch(input_length % 3) {
155
+  switch (input_length % 3) {
156 156
     case 0:
157 157
       output[0] = '\0';
158 158
       break;
@@ -192,7 +192,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
192 192
     output += 3;
193 193
   }
194 194
 
195
-  switch(output_length % 3) {
195
+  switch (output_length % 3) {
196 196
     case 1:
197 197
       output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
198 198
       break;
@@ -205,4 +205,4 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
205 205
   return output_length;
206 206
 }
207 207
 
208
-#endif // ifndef
208
+#endif // BASE64_H_INCLUDED

+ 2
- 4
Marlin/src/lcd/e3v2/proui/gcode_preview.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * DWIN g-code thumbnail preview
24
+ * DWIN G-code thumbnail preview
25 25
  * Author: Miguel A. Risco-Castillo
26 26
  * version: 2.1
27 27
  * Date: 2021/06/19
@@ -214,9 +214,7 @@ bool Has_Preview() {
214 214
 void Preview_DrawFromSD() {
215 215
   if (Has_Preview()) {
216 216
     char buf[46];
217
-    char str_1[6] = "";
218
-    char str_2[6] = "";
219
-    char str_3[6] = "";
217
+    char str_1[6] = "", str_2[6] = "", str_3[6] = "";
220 218
     DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1);
221 219
     if (fileprop.time) {
222 220
       sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60);

+ 1
- 1
Marlin/src/lcd/e3v2/proui/gcode_preview.h View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * DWIN g-code thumbnail preview
2
+ * DWIN G-code thumbnail preview
3 3
  * Author: Miguel A. Risco-Castillo
4 4
  * version: 2.1
5 5
  * Date: 2021/06/19

+ 3
- 3
Marlin/src/module/settings.cpp View File

@@ -503,7 +503,7 @@ typedef struct SettingsDataStruct {
503 503
   #if ENABLED(DWIN_LCD_PROUI)
504 504
     uint8_t dwin_data[eeprom_data_size];
505 505
   #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
506
-    uint8_t dwin_settings[CrealityDWIN.eeprom_data_size];
506
+    uint8_t dwin_settings[eeprom_data_size];
507 507
   #endif
508 508
 
509 509
   //
@@ -1525,7 +1525,7 @@ void MarlinSettings::postprocess() {
1525 1525
     #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
1526 1526
     {
1527 1527
       _FIELD_TEST(dwin_settings);
1528
-      char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
1528
+      char dwin_settings[eeprom_data_size] = { 0 };
1529 1529
       CrealityDWIN.Save_Settings(dwin_settings);
1530 1530
       EEPROM_WRITE(dwin_settings);
1531 1531
     }
@@ -2497,7 +2497,7 @@ void MarlinSettings::postprocess() {
2497 2497
       }
2498 2498
       #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
2499 2499
       {
2500
-        const char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 };
2500
+        const char dwin_settings[eeprom_data_size] = { 0 };
2501 2501
         _FIELD_TEST(dwin_settings);
2502 2502
         EEPROM_READ(dwin_settings);
2503 2503
         if (!validating) CrealityDWIN.Load_Settings(dwin_settings);

+ 8
- 0
Marlin/src/module/temperature.cpp View File

@@ -53,6 +53,8 @@
53 53
   #include "../lcd/e3v2/creality/dwin.h"
54 54
 #elif ENABLED(DWIN_LCD_PROUI)
55 55
   #include "../lcd/e3v2/proui/dwin.h"
56
+#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
57
+  #include "../lcd/e3v2/jyersui/dwin.h"
56 58
 #endif
57 59
 
58 60
 #if ENABLED(EXTENSIBLE_UI)
@@ -644,12 +646,14 @@ volatile bool Temperature::raw_temps_ready = false;
644 646
 
645 647
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED));
646 648
     TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
649
+    TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START));
647 650
 
648 651
     if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) {
649 652
       SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
650 653
       SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
651 654
       TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
652 655
       TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
656
+      TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH));
653 657
       TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
654 658
       return;
655 659
     }
@@ -744,6 +748,7 @@ volatile bool Temperature::raw_temps_ready = false;
744 748
         SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH);
745 749
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH));
746 750
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH));
751
+        TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TEMP_TOO_HIGH));
747 752
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH)));
748 753
         break;
749 754
       }
@@ -782,6 +787,7 @@ volatile bool Temperature::raw_temps_ready = false;
782 787
         TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0));
783 788
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT));
784 789
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT));
790
+        TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_TUNING_TIMEOUT));
785 791
         TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT)));
786 792
         SERIAL_ECHOPGM(STR_PID_AUTOTUNE);
787 793
         SERIAL_ECHOLNPGM(STR_PID_TIMEOUT);
@@ -839,6 +845,7 @@ volatile bool Temperature::raw_temps_ready = false;
839 845
 
840 846
         TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
841 847
         TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE));
848
+        TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE));
842 849
 
843 850
         goto EXIT_M303;
844 851
       }
@@ -857,6 +864,7 @@ volatile bool Temperature::raw_temps_ready = false;
857 864
 
858 865
     TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE));
859 866
     TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE));
867
+    TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWINClass::DWIN_PidTuning(PID_DONE));
860 868
 
861 869
     EXIT_M303:
862 870
       TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);

Loading…
Cancel
Save