|
@@ -0,0 +1,245 @@
|
|
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
|
+ * lcd/e3v2/jyersui/dwin.h
|
|
26
|
+ */
|
|
27
|
+
|
|
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"
|
|
36
|
+
|
|
37
|
+//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
|
|
38
|
+
|
|
39
|
+enum processID : uint8_t {
|
|
40
|
+ Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
|
|
41
|
+};
|
|
42
|
+
|
|
43
|
+enum PopupID : uint8_t {
|
|
44
|
+ 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
|
|
47
|
+};
|
|
48
|
+
|
|
49
|
+enum menuID : uint8_t {
|
|
50
|
+ MainMenu,
|
|
51
|
+ Prepare,
|
|
52
|
+ Move,
|
|
53
|
+ HomeMenu,
|
|
54
|
+ ManualLevel,
|
|
55
|
+ ZOffset,
|
|
56
|
+ Preheat,
|
|
57
|
+ ChangeFilament,
|
|
58
|
+ MenuCustom,
|
|
59
|
+ Control,
|
|
60
|
+ TempMenu,
|
|
61
|
+ PID,
|
|
62
|
+ HotendPID,
|
|
63
|
+ BedPID,
|
|
64
|
+ #if HAS_PREHEAT
|
|
65
|
+ #define _PREHEAT_ID(N) Preheat##N,
|
|
66
|
+ REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID)
|
|
67
|
+ #endif
|
|
68
|
+ Motion,
|
|
69
|
+ HomeOffsets,
|
|
70
|
+ MaxSpeed,
|
|
71
|
+ MaxAcceleration,
|
|
72
|
+ MaxJerk,
|
|
73
|
+ Steps,
|
|
74
|
+ Visual,
|
|
75
|
+ ColorSettings,
|
|
76
|
+ Advanced,
|
|
77
|
+ ProbeMenu,
|
|
78
|
+ Info,
|
|
79
|
+ Leveling,
|
|
80
|
+ LevelManual,
|
|
81
|
+ LevelView,
|
|
82
|
+ MeshViewer,
|
|
83
|
+ LevelSettings,
|
|
84
|
+ ManualMesh,
|
|
85
|
+ UBLMesh,
|
|
86
|
+ InfoMain,
|
|
87
|
+ Tune,
|
|
88
|
+ PreheatHotend
|
|
89
|
+};
|
|
90
|
+
|
|
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
|
|
119
|
+
|
|
120
|
+enum colorID : uint8_t {
|
|
121
|
+ Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
|
|
122
|
+};
|
|
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
|
|
146
|
+
|
|
147
|
+class CrealityDWINClass {
|
|
148
|
+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
|
+ static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" };
|
|
170
|
+ static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" };
|
|
171
|
+
|
|
172
|
+ static void Clear_Screen(uint8_t e=3);
|
|
173
|
+ static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10);
|
|
174
|
+ static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false);
|
|
175
|
+ static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false);
|
|
176
|
+ static void Draw_Checkbox(uint8_t row, bool value);
|
|
177
|
+ static void Draw_Title(const char * title);
|
|
178
|
+ static void Draw_Title(FSTR_P const title);
|
|
179
|
+ static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false);
|
|
180
|
+ static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false);
|
|
181
|
+ static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0);
|
|
182
|
+ static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false);
|
|
183
|
+ static void Redraw_Screen();
|
|
184
|
+
|
|
185
|
+ static void Main_Menu_Icons();
|
|
186
|
+ static void Draw_Main_Menu(uint8_t select=0);
|
|
187
|
+ static void Print_Screen_Icons();
|
|
188
|
+ static void Draw_Print_Screen();
|
|
189
|
+ static void Draw_Print_Filename(const bool reset=false);
|
|
190
|
+ static void Draw_Print_ProgressBar();
|
|
191
|
+ #if ENABLED(USE_M73_REMAINING_TIME)
|
|
192
|
+ static void Draw_Print_ProgressRemain();
|
|
193
|
+ #endif
|
|
194
|
+ static void Draw_Print_ProgressElapsed();
|
|
195
|
+ static void Draw_Print_confirm();
|
|
196
|
+ static void Draw_SD_Item(uint8_t item, uint8_t row);
|
|
197
|
+ static void Draw_SD_List(bool removed=false);
|
|
198
|
+ static void Draw_Status_Area(bool icons=false);
|
|
199
|
+ static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0);
|
|
200
|
+ static void Popup_Select();
|
|
201
|
+ static void Update_Status_Bar(bool refresh=false);
|
|
202
|
+
|
|
203
|
+ #if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
204
|
+ static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7);
|
|
205
|
+ static void Set_Mesh_Viewer_Status();
|
|
206
|
+ #endif
|
|
207
|
+
|
|
208
|
+ static FSTR_P Get_Menu_Title(uint8_t menu);
|
|
209
|
+ static uint8_t Get_Menu_Size(uint8_t menu);
|
|
210
|
+ static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true);
|
|
211
|
+
|
|
212
|
+ static void Popup_Handler(PopupID popupid, bool option = false);
|
|
213
|
+ static void Confirm_Handler(PopupID popupid);
|
|
214
|
+
|
|
215
|
+ static void Main_Menu_Control();
|
|
216
|
+ static void Menu_Control();
|
|
217
|
+ static void Value_Control();
|
|
218
|
+ static void Option_Control();
|
|
219
|
+ static void File_Control();
|
|
220
|
+ static void Print_Screen_Control();
|
|
221
|
+ static void Popup_Control();
|
|
222
|
+ static void Confirm_Control();
|
|
223
|
+
|
|
224
|
+ static void Setup_Value(float value, float min, float max, float unit, uint8_t type);
|
|
225
|
+ static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
226
|
+ static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
227
|
+ static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
228
|
+ static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
229
|
+ static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
230
|
+ static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr);
|
|
231
|
+ static void Modify_Option(uint8_t value, const char * const * options, uint8_t max);
|
|
232
|
+
|
|
233
|
+ static void Update_Status(const char * const text);
|
|
234
|
+ static void Start_Print(bool sd);
|
|
235
|
+ static void Stop_Print();
|
|
236
|
+ static void Update();
|
|
237
|
+ static void State_Update();
|
|
238
|
+ static void Screen_Update();
|
|
239
|
+ static void AudioFeedback(const bool success=true);
|
|
240
|
+ static void Save_Settings(char *buff);
|
|
241
|
+ static void Load_Settings(const char *buff);
|
|
242
|
+ static void Reset_Settings();
|
|
243
|
+};
|
|
244
|
+
|
|
245
|
+extern CrealityDWINClass CrealityDWIN;
|