소스 검색

🚸 ProUI G-code preview, PID plot (#24282)

Miguel Risco-Castillo 1 년 전
부모
커밋
c9a9b25d41

+ 208
- 0
Marlin/src/lcd/e3v2/proui/base64.hpp 파일 보기

@@ -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 // ifndef

+ 86
- 15
Marlin/src/lcd/e3v2/proui/dwin.cpp 파일 보기

@@ -129,6 +129,14 @@
129 129
   #include "endstop_diag.h"
130 130
 #endif
131 131
 
132
+#if HAS_PIDPLOT
133
+  #include "plot.h"
134
+#endif
135
+
136
+#if HAS_GCODE_PREVIEW
137
+  #include "gcode_preview.h"
138
+#endif
139
+
132 140
 #if HAS_MESH
133 141
   #include "meshviewer.h"
134 142
 #endif
@@ -705,13 +713,19 @@ void Draw_PrintDone() {
705 713
   Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE));
706 714
   DWINUI::ClearMainArea();
707 715
   DWIN_Print_Header(nullptr);
708
-  Draw_Print_ProgressBar();
709
-  Draw_Print_Labels();
710
-  DWINUI::Draw_Icon(ICON_PrintTime, 15, 173);
711
-  DWINUI::Draw_Icon(ICON_RemainTime, 150, 171);
712
-  Draw_Print_ProgressElapsed();
713
-  Draw_Print_ProgressRemain();
714
-  DWINUI::Draw_Button(BTN_Continue, 86, 273);
716
+  if (sdprint && TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) {
717
+    DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00);
718
+    DWINUI::Draw_Button(BTN_Continue, 86, 300);
719
+  }
720
+  else {
721
+    Draw_Print_ProgressBar();
722
+    Draw_Print_Labels();
723
+    DWINUI::Draw_Icon(ICON_PrintTime, 15, 173);
724
+    DWINUI::Draw_Icon(ICON_RemainTime, 150, 171);
725
+    Draw_Print_ProgressElapsed();
726
+    Draw_Print_ProgressRemain();
727
+    DWINUI::Draw_Button(BTN_Continue, 86, 273);
728
+  }
715 729
 }
716 730
 
717 731
 void Goto_PrintDone() {
@@ -1409,6 +1423,9 @@ void EachMomentUpdate() {
1409 1423
     #if HAS_ESDIAG
1410 1424
       if (checkkey == ESDiagProcess) ESDiag.Update();
1411 1425
     #endif
1426
+    #if HAS_PIDPLOT
1427
+      if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PID_EXTR_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed());
1428
+    #endif
1412 1429
   }
1413 1430
 
1414 1431
   #if HAS_STATUS_MESSAGE_TIMEOUT
@@ -1635,15 +1652,49 @@ void DWIN_LevelingDone() {
1635 1652
 #endif
1636 1653
 
1637 1654
 // PID process
1655
+
1656
+#if HAS_PIDPLOT
1657
+  void DWIN_Draw_PIDPopup() {
1658
+    frame_rect_t gfrm = {40, 180, DWIN_WIDTH - 80, 120};
1659
+    DWINUI::ClearMainArea();
1660
+    Draw_Popup_Bkgd();
1661
+    DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
1662
+    DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target:    Celsius"));
1663
+    switch (HMI_value.pidresult) {
1664
+      case PID_EXTR_START:
1665
+        DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running."));
1666
+        Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT);
1667
+        DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT);
1668
+        break;
1669
+      case PID_BED_START:
1670
+        DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running."));
1671
+        Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT);
1672
+        DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT);
1673
+        break;
1674
+      default:
1675
+        break;
1676
+    }
1677
+  }
1678
+#endif
1679
+
1638 1680
 void DWIN_PidTuning(pidresult_t result) {
1681
+  HMI_value.pidresult = result;
1639 1682
   switch (result) {
1640 1683
     case PID_BED_START:
1641
-      HMI_SaveProcessID(NothingToDo);
1642
-      DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running."));
1684
+      HMI_SaveProcessID(PidProcess);
1685
+      #if HAS_PIDPLOT
1686
+        DWIN_Draw_PIDPopup();
1687
+      #else
1688
+        DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running."));
1689
+      #endif
1643 1690
       break;
1644 1691
     case PID_EXTR_START:
1645
-      HMI_SaveProcessID(NothingToDo);
1646
-      DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running."));
1692
+      HMI_SaveProcessID(PidProcess);
1693
+      #if HAS_PIDPLOT
1694
+        DWIN_Draw_PIDPopup();
1695
+      #else
1696
+        DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running."));
1697
+      #endif
1647 1698
       break;
1648 1699
     case PID_BAD_EXTRUDER_NUM:
1649 1700
       checkkey = last_checkkey;
@@ -1960,10 +2011,30 @@ void HMI_LockScreen() {
1960 2011
 }
1961 2012
 
1962 2013
 
1963
-void Goto_ConfirmToPrint() {
1964
-  card.openAndPrintFile(card.filename);
1965
-  DWIN_Print_Started(true);
1966
-}
2014
+#if HAS_GCODE_PREVIEW
2015
+
2016
+  void onClick_ConfirmToPrint() {
2017
+    if (HMI_flag.select_flag) {     // Confirm
2018
+      card.openAndPrintFile(card.filename);
2019
+      return DWIN_Print_Started(true);
2020
+    }
2021
+    else {                          // Cancel
2022
+      DWIN_ResetStatusLine();
2023
+      checkkey = SelectFile;
2024
+      return Draw_Print_File_Menu();
2025
+    }
2026
+  }
2027
+
2028
+  void Goto_ConfirmToPrint() {
2029
+    Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint);
2030
+  }
2031
+
2032
+#else
2033
+  void Goto_ConfirmToPrint() {
2034
+    card.openAndPrintFile(card.filename);
2035
+    DWIN_Print_Started(true);
2036
+  }
2037
+#endif
1967 2038
 
1968 2039
 #if HAS_ESDIAG
1969 2040
   void Draw_EndStopDiag() {

+ 2
- 0
Marlin/src/lcd/e3v2/proui/dwin_defines.h 파일 보기

@@ -35,6 +35,8 @@
35 35
 #include <stddef.h>
36 36
 
37 37
 #define HAS_ESDIAG 1
38
+#define HAS_PIDPLOT 1
39
+#define HAS_GCODE_PREVIEW 1
38 40
 #if defined(__STM32F1__) || defined(STM32F1)
39 41
   #define DASH_REDRAW 1
40 42
 #endif

+ 253
- 0
Marlin/src/lcd/e3v2/proui/gcode_preview.cpp 파일 보기

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

+ 27
- 0
Marlin/src/lcd/e3v2/proui/gcode_preview.h 파일 보기

@@ -0,0 +1,27 @@
1
+/**
2
+ * DWIN g-code thumbnail preview
3
+ * Author: Miguel A. Risco-Castillo
4
+ * version: 2.1
5
+ * Date: 2021/06/19
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as
9
+ * published by the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * For commercial applications additional licenses can be requested
21
+ */
22
+
23
+#pragma once
24
+
25
+void Preview_DrawFromSD();
26
+bool Preview_Valid();
27
+void Preview_Reset();

+ 94
- 0
Marlin/src/lcd/e3v2/proui/plot.cpp 파일 보기

@@ -0,0 +1,94 @@
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
+ * This program is free software: you can redistribute it and/or modify
30
+ * it under the terms of the GNU Lesser General Public License as
31
+ * published by the Free Software Foundation, either version 3 of the License, or
32
+ * (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
+ * GNU General Public License for more details.
38
+ *
39
+ * You should have received a copy of the GNU Lesser General Public License
40
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
41
+ *
42
+ * For commercial applications additional licenses can be requested
43
+ */
44
+
45
+#include "../../../inc/MarlinConfigPre.h"
46
+
47
+#ifdef DWIN_LCD_PROUI
48
+
49
+#include "plot.h"
50
+
51
+#include "../../../core/types.h"
52
+#include "../../marlinui.h"
53
+#include "dwin_lcd.h"
54
+#include "dwinui.h"
55
+#include "dwin_popup.h"
56
+#include "dwin.h"
57
+
58
+#define Plot_Bg_Color RGB( 1, 12,  8)
59
+
60
+PlotClass Plot;
61
+
62
+uint16_t grphpoints, r, x2, y2 = 0;
63
+frame_rect_t grphframe = {0};
64
+float scale = 0;
65
+
66
+void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) {
67
+  grphframe = frame;
68
+  grphpoints = 0;
69
+  scale = frame.h / max;
70
+  x2 = frame.x + frame.w - 1;
71
+  y2 = frame.y + frame.h - 1;
72
+  r = round((y2) - ref * scale);
73
+  DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
74
+  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);
75
+  DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
76
+  DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
77
+}
78
+
79
+void PlotClass::Update(const float value) {
80
+  if (!scale) return;
81
+  uint16_t y = round((y2) - value * scale);
82
+  if (grphpoints < grphframe.w) {
83
+    DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
84
+  }
85
+  else {
86
+    DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
87
+    if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
88
+    DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r);
89
+    DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y);
90
+  }
91
+  grphpoints++;
92
+}
93
+
94
+#endif // DWIN_LCD_PROUI

+ 54
- 0
Marlin/src/lcd/e3v2/proui/plot.h 파일 보기

@@ -0,0 +1,54 @@
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: 1.0
27
+ * Date: 2022/01/30
28
+ *
29
+ * This program is free software: you can redistribute it and/or modify
30
+ * it under the terms of the GNU Lesser General Public License as
31
+ * published by the Free Software Foundation, either version 3 of the License, or
32
+ * (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
+ * GNU General Public License for more details.
38
+ *
39
+ * You should have received a copy of the GNU Lesser General Public License
40
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
41
+ *
42
+ * For commercial applications additional licenses can be requested
43
+ */
44
+#pragma once
45
+
46
+#include "dwinui.h"
47
+
48
+class PlotClass {
49
+public:
50
+  void Draw(frame_rect_t frame, float max, float ref = 0);
51
+  void Update(float value);
52
+};
53
+
54
+extern PlotClass Plot;

+ 13
- 5
Marlin/src/lcd/e3v2/proui/ubl_tools.cpp 파일 보기

@@ -1,10 +1,9 @@
1 1
 /**
2
- * UBL Tools and Mesh Viewer for Pro UI
3
- * Version: 1.0.0
4
- * Date: 2022/04/13
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
5 4
  *
6
- * Original Author: Henri-J-Norden
7
- * Original Source: https://github.com/Jyers/Marlin/pull/126
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
8 7
  *
9 8
  * This program is free software: you can redistribute it and/or modify
10 9
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +20,15 @@
21 20
  *
22 21
  */
23 22
 
23
+/**
24
+ * UBL Tools and Mesh Viewer for Pro UI
25
+ * Version: 1.0.0
26
+ * Date: 2022/04/13
27
+ *
28
+ * Original Author: Henri-J-Norden
29
+ * Original Source: https://github.com/Jyers/Marlin/pull/126
30
+ */
31
+
24 32
 #include "../../../inc/MarlinConfigPre.h"
25 33
 
26 34
 #if BOTH(DWIN_LCD_PROUI, AUTO_BED_LEVELING_UBL)

+ 8
- 3
buildroot/tests/STM32F103RE_creality 파일 보기

@@ -18,9 +18,14 @@ opt_disable DWIN_CREALITY_LCD
18 18
 opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY
19 19
 exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
20 20
 
21
-use_example_configs "Creality/Ender-3 V2/CrealityV422/MarlinUI"
22
-opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
23
-exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
21
+use_example_configs "Creality/Ender-3 S1"
22
+opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT
23
+opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \
24
+           SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \
25
+           BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU \
26
+           LIMITED_MAX_FR_EDITING LIMITED_MAX_ACCEL_EDITING LIMITED_JERK_EDITING BAUD_RATE_GCODE
27
+opt_set PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED 60 PREHEAT_3_FAN_SPEED 128
28
+exec_test $1 $2 "Ender-3 S1 with ProUI" "$3"
24 29
 
25 30
 restore_configs
26 31
 opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1

+ 4
- 9
buildroot/tests/STM32F401RC_creality 파일 보기

@@ -6,15 +6,10 @@
6 6
 # exit on first failure
7 7
 set -e
8 8
 
9
-use_example_configs "Creality/Ender-3 S1"
10
-opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT
11
-opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \
12
-           SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \
13
-           BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU \
14
-           LIMITED_MAX_FR_EDITING LIMITED_MAX_ACCEL_EDITING LIMITED_JERK_EDITING BAUD_RATE_GCODE
15
-opt_set MOTHERBOARD BOARD_CREALITY_V24S1_301F4 \
16
-        PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED 60 PREHEAT_3_FAN_SPEED 128
17
-exec_test $1 $2 "Ender-3 S1 with ProUI" "$3"
9
+use_example_configs "Creality/Ender-3 V2/CrealityV422/MarlinUI"
10
+opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
11
+opt_set MOTHERBOARD BOARD_CREALITY_V24S1_301F4
12
+exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
18 13
 
19 14
 # clean up
20 15
 restore_configs

Loading…
취소
저장