Skip to content

Commit 7bd4d8b

Browse files
ellenspthinkyhead
andcommitted
✨ New DGUS_LCD_UI: IA_CREALITY (#25143, #25175, #25374)
Co-Authored-By: Scott Lahteine <[email protected]>
1 parent a1df90f commit 7bd4d8b

File tree

14 files changed

+2838
-42
lines changed

14 files changed

+2838
-42
lines changed

Marlin/Configuration.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,23 +2939,16 @@
29392939

29402940
/**
29412941
* DGUS Touch Display with DWIN OS. (Choose one.)
2942-
* ORIGIN : https://www.aliexpress.com/item/32993409517.html
2943-
* FYSETC : https://www.aliexpress.com/item/32961471929.html
2944-
* MKS : https://www.aliexpress.com/item/1005002008179262.html
2945-
*
2946-
* Flash display with DGUS Displays for Marlin:
2947-
* - Format the SD card to FAT32 with an allocation size of 4kb.
2948-
* - Download files as specified for your type of display.
2949-
* - Plug the microSD card into the back of the display.
2950-
* - Boot the display and wait for the update to complete.
29512942
*
29522943
* ORIGIN (Marlin DWIN_SET)
29532944
* - Download https://github.com/coldtobi/Marlin_DGUS_Resources
29542945
* - Copy the downloaded DWIN_SET folder to the SD card.
2946+
* - Product: https://www.aliexpress.com/item/32993409517.html
29552947
*
29562948
* FYSETC (Supplier default)
29572949
* - Download https://github.com/FYSETC/FYSTLCD-2.0
29582950
* - Copy the downloaded SCREEN folder to the SD card.
2951+
* - Product: https://www.aliexpress.com/item/32961471929.html
29592952
*
29602953
* HIPRECY (Supplier default)
29612954
* - Download https://github.com/HiPrecy/Touch-Lcd-LEO
@@ -2964,17 +2957,24 @@
29642957
* MKS (MKS-H43) (Supplier default)
29652958
* - Download https://github.com/makerbase-mks/MKS-H43
29662959
* - Copy the downloaded DWIN_SET folder to the SD card.
2960+
* - Product: https://www.aliexpress.com/item/1005002008179262.html
29672961
*
29682962
* RELOADED (T5UID1)
29692963
* - Download https://github.com/Desuuuu/DGUS-reloaded/releases
29702964
* - Copy the downloaded DWIN_SET folder to the SD card.
2965+
*
2966+
* IA_CREALITY (T5UID1)
2967+
* - Download https://github.com/InsanityAutomation/Marlin/raw/CrealityDwin2.0_Bleeding/TM3D_Combined480272_Landscape_V7.7z
2968+
* - Copy the downloaded DWIN_SET folder to the SD card.
2969+
*
2970+
* Flash display with DGUS Displays for Marlin:
2971+
* - Format the SD card to FAT32 with an allocation size of 4kb.
2972+
* - Download files as specified for your type of display.
2973+
* - Plug the microSD card into the back of the display.
2974+
* - Boot the display and wait for the update to complete.
29712975
*/
2972-
//#define DGUS_LCD_UI_ORIGIN
2973-
//#define DGUS_LCD_UI_FYSETC
2974-
//#define DGUS_LCD_UI_HIPRECY
2975-
//#define DGUS_LCD_UI_MKS
2976-
//#define DGUS_LCD_UI_RELOADED
2977-
#if ENABLED(DGUS_LCD_UI_MKS)
2976+
//#define DGUS_LCD_UI ORIGIN
2977+
#if DGUS_UI_IS(MKS)
29782978
#define USE_MKS_GREEN_UI
29792979
#endif
29802980

Marlin/Configuration_adv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,11 +1867,11 @@
18671867

18681868
#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
18691869

1870-
#if ANY(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_MKS, DGUS_LCD_UI_HIPRECY)
1870+
#if DGUS_UI_IS(FYSETC, MKS, HIPRECY)
18711871
#define DGUS_PRINT_FILENAME // Display the filename during printing
18721872
#define DGUS_PREHEAT_UI // Display a preheat screen during heatup
18731873

1874-
#if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_MKS)
1874+
#if DGUS_UI_IS(FYSETC, MKS)
18751875
//#define DGUS_UI_MOVE_DIS_OPTION // Disabled by default for FYSETC and MKS
18761876
#else
18771877
#define DGUS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY

Marlin/src/core/macros.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,13 @@
745745
#define _HAS_E_TEMP(N) || TEMP_SENSOR(N)
746746
#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP))
747747
#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2)
748+
749+
#define _UI_NONE 0
750+
#define _UI_ORIGIN 101
751+
#define _UI_FYSETC 102
752+
#define _UI_HIPRECY 103
753+
#define _UI_MKS 104
754+
#define _UI_RELOADED 105
755+
#define _UI_IA_CREALITY 106
756+
#define _DGUS_UI_IS(N) || (CAT(_UI_, DGUS_LCD_UI) == CAT(_UI_, N))
757+
#define DGUS_UI_IS(V...) (0 MAP(_DGUS_UI_IS, V))

Marlin/src/inc/Conditionals_LCD.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@
3636
#define FYSETC_MINI_12864_2_1
3737
#endif
3838

39+
// Updated DGUS_UI shorthand single option can be used, or old settings, for now
40+
#if DGUS_UI_IS(ORIGIN)
41+
#define DGUS_LCD_UI_ORIGIN
42+
#elif DGUS_UI_IS(FYSETC)
43+
#define DGUS_LCD_UI_FYSETC
44+
#elif DGUS_UI_IS(HIPRECY)
45+
#define DGUS_LCD_UI_HIPRECY
46+
#elif DGUS_UI_IS(MKS)
47+
#define DGUS_LCD_UI_MKS
48+
#elif DGUS_UI_IS(RELOADED)
49+
#define DGUS_LCD_UI_RELOADED
50+
#elif DGUS_UI_IS(IA_CREALITY)
51+
#define DGUS_LCD_UI_IA_CREALITY
52+
#endif
53+
3954
/**
4055
* General Flags that may be set below by specific LCDs
4156
*
@@ -462,12 +477,11 @@
462477
#endif
463478

464479
// Aliases for LCD features
465-
#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS)
466-
#define HAS_DGUS_LCD_CLASSIC 1
467-
#endif
468-
469-
#if EITHER(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED)
480+
#if !DGUS_UI_IS(NONE)
470481
#define HAS_DGUS_LCD 1
482+
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS)
483+
#define HAS_DGUS_LCD_CLASSIC 1
484+
#endif
471485
#endif
472486

473487
// Extensible UI serial touch screens. (See src/lcd/extui)

Marlin/src/inc/SanityCheck.h

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@
513513
#elif defined(HOME_USING_SPREADCYCLE)
514514
#error "HOME_USING_SPREADCYCLE is now obsolete. Please remove it."
515515
#elif defined(DGUS_LCD)
516-
#error "DGUS_LCD is now DGUS_LCD_UI_(ORIGIN|FYSETC|HIPRECY)."
516+
#error "DGUS_LCD is now DGUS_LCD_UI ORIGIN|FYSETC|HIPRECY)."
517517
#elif defined(DGUS_SERIAL_PORT)
518518
#error "DGUS_SERIAL_PORT is now LCD_SERIAL_PORT."
519519
#elif defined(DGUS_BAUDRATE)
@@ -3061,7 +3061,7 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
30613061
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
30623062
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
30633063
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
3064-
+ COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \
3064+
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) \
30653065
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
30663066
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
30673067
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \
@@ -4322,34 +4322,53 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
43224322
#undef _BAD_DRIVER
43234323

43244324
/**
4325-
* Require certain features for DGUS_LCD_UI_RELOADED.
4325+
* Require certain features for DGUS_LCD_UI RELOADED.
43264326
*/
4327-
#if ENABLED(DGUS_LCD_UI_RELOADED)
4327+
#if DGUS_UI_IS(RELOADED)
43284328
#if BUFSIZE < 4
4329-
#error "DGUS_LCD_UI_RELOADED requires a BUFSIZE of at least 4."
4329+
#error "DGUS_LCD_UI RELOADED requires a BUFSIZE of at least 4."
43304330
#elif HOTENDS < 1
4331-
#error "DGUS_LCD_UI_RELOADED requires at least 1 hotend."
4331+
#error "DGUS_LCD_UI RELOADED requires at least 1 hotend."
43324332
#elif EXTRUDERS < 1
4333-
#error "DGUS_LCD_UI_RELOADED requires at least 1 extruder."
4333+
#error "DGUS_LCD_UI RELOADED requires at least 1 extruder."
43344334
#elif !HAS_HEATED_BED
4335-
#error "DGUS_LCD_UI_RELOADED requires a heated bed."
4335+
#error "DGUS_LCD_UI RELOADED requires a heated bed."
43364336
#elif FAN_COUNT < 1
4337-
#error "DGUS_LCD_UI_RELOADED requires a fan."
4337+
#error "DGUS_LCD_UI RELOADED requires a fan."
43384338
#elif !HAS_BED_PROBE
4339-
#error "DGUS_LCD_UI_RELOADED requires a bed probe."
4339+
#error "DGUS_LCD_UI RELOADED requires a bed probe."
43404340
#elif !HAS_MESH
4341-
#error "DGUS_LCD_UI_RELOADED requires mesh leveling."
4341+
#error "DGUS_LCD_UI RELOADED requires mesh leveling."
43424342
#elif DISABLED(LCD_BED_TRAMMING)
4343-
#error "DGUS_LCD_UI_RELOADED requires LCD_BED_TRAMMING."
4343+
#error "DGUS_LCD_UI RELOADED requires LCD_BED_TRAMMING."
43444344
#elif DISABLED(BABYSTEP_ALWAYS_AVAILABLE)
4345-
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
4345+
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
43464346
#elif DISABLED(BABYSTEP_ZPROBE_OFFSET)
4347-
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ZPROBE_OFFSET."
4347+
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ZPROBE_OFFSET."
43484348
#elif ENABLED(AUTO_BED_LEVELING_UBL) && DISABLED(UBL_SAVE_ACTIVE_ON_M500)
43494349
#warning "Without UBL_SAVE_ACTIVE_ON_M500, your mesh will not be saved when using the touchscreen."
43504350
#endif
43514351
#endif
43524352

4353+
/**
4354+
* Require certain features for DGUS_LCD_UI IA_CREALITY.
4355+
*/
4356+
#if DGUS_UI_IS(IA_CREALITY)
4357+
#if DISABLED(ADVANCED_PAUSE_FEATURE)
4358+
#error "DGUS_LCD_UI IA_CREALITY requires ADVANCED_PAUSE_FEATURE."
4359+
#elif DISABLED(LCD_BED_TRAMMING)
4360+
#error "DGUS_LCD_UI IA_CREALITY requires LCD_BED_TRAMMING."
4361+
#elif DISABLED(CLASSIC_JERK)
4362+
#error "DGUS_LCD_UI IA_CREALITY requires CLASSIC_JERK."
4363+
#elif DISABLED(BABYSTEPPING)
4364+
#error "DGUS_LCD_UI IA_CREALITY requires BABYSTEPPING."
4365+
#elif NUM_RUNOUT_SENSORS > 1
4366+
#error "DGUS_LCD_UI IA_CREALITY requires NUM_RUNOUT_SENSORS < 2."
4367+
#elif NONE(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
4368+
#error "DGUS_LCD_UI IA_CREALITY requires AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, or MESH_BED_LEVELING."
4369+
#endif
4370+
#endif
4371+
43534372
// JTAG support in the HAL
43544373
#if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE)
43554374
#error "DISABLE_DEBUG is not supported for the selected MCU/Board."
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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+
* lcd/extui/ia_creality/FileNavigator.cpp
25+
* ****************************************
26+
* Extensible_UI implementation for Creality DWIN
27+
* 10SPro, Max, CR10V2
28+
* Based on implementations for Anycubic Chiron and Nextion by Nick Wells and Skorpi08
29+
* Written by Insanity Automation
30+
* ***************************************/
31+
32+
#include "../../../inc/MarlinConfigPre.h"
33+
34+
#if ENABLED(DGUS_LCD_UI_IA_CREALITY)
35+
36+
#include "FileNavigator.h"
37+
38+
using namespace ExtUI;
39+
40+
#define DEBUG_OUT ENABLED(DEBUG_DWIN)
41+
#include "../../../core/debug_out.h"
42+
43+
FileList FileNavigator::filelist; // Instance of the Marlin file API
44+
char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path
45+
uint16_t FileNavigator::lastindex;
46+
uint8_t FileNavigator::folderdepth;
47+
uint16_t FileNavigator::currentindex; // override the panel request
48+
49+
FileNavigator filenavigator;
50+
51+
FileNavigator::FileNavigator() { reset(); }
52+
53+
void FileNavigator::reset() {
54+
currentfoldername[0] = '\0';
55+
folderdepth = 0;
56+
currentindex = 0;
57+
lastindex = 0;
58+
// Start at root folder
59+
while (!filelist.isAtRootDir()) filelist.upDir();
60+
refresh();
61+
}
62+
63+
void FileNavigator::refresh() { filelist.refresh(); }
64+
65+
bool FileNavigator::getIndexisDir(uint16_t index){
66+
filelist.seek(index);
67+
return filelist.isDir();
68+
}
69+
70+
const char *FileNavigator::getIndexName(uint16_t index){
71+
filelist.seek(index);
72+
return filelist.shortFilename();
73+
}
74+
75+
uint16_t FileNavigator::maxFiles() {
76+
return filelist.count();
77+
}
78+
79+
void FileNavigator::getFiles(uint16_t index) {
80+
uint16_t files = DISPLAY_FILES, fcnt = 0;
81+
if (index == 0)
82+
currentindex = 0;
83+
else {
84+
// Each time we change folder we reset the file index to 0 and keep track
85+
// of the current position as the TFT panel isn't aware of folder trees.
86+
--currentindex; // go back a file to take account of the .. added to the root.
87+
if (index > lastindex)
88+
currentindex += files + 1;
89+
else if (currentindex >= files)
90+
currentindex -= files - 1;
91+
else
92+
currentindex = 0;
93+
}
94+
lastindex = index;
95+
96+
97+
// Clear currently drawn screen
98+
for (int i = 0; i < DISPLAY_FILES; i++) {
99+
for (int j = 0; j < 20; j++)
100+
rtscheck.RTS_SndData(0, SDFILE_ADDR + (i * 20) + j);
101+
}
102+
103+
for (int j = 0; j < 10; j++) {
104+
rtscheck.RTS_SndData(0, Printfilename + j); // clear screen.
105+
rtscheck.RTS_SndData(0, Choosefilename + j); // clear filename
106+
}
107+
for (int j = 0; j < 8; j++)
108+
rtscheck.RTS_SndData(0, FilenameCount + j);
109+
for (int j = 1; j <= DISPLAY_FILES; j++) {
110+
rtscheck.RTS_SndData(10, FilenameIcon + j);
111+
rtscheck.RTS_SndData(10, FilenameIcon1 + j);
112+
}
113+
114+
DEBUG_ECHOLNPGM("index=", index, " currentindex=", currentindex, "folderdepth=", folderdepth);
115+
116+
if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
117+
files--;
118+
rtscheck.RTS_SndData("Up Directory", SDFILE_ADDR);
119+
fcnt++;
120+
}
121+
else if (currentindex == DISPLAY_FILES && folderdepth > 0)
122+
currentindex--;
123+
124+
for (uint16_t seek = currentindex; seek < currentindex + files; seek++) {
125+
if (filelist.seek(seek)) {
126+
const int filelen = strlen(filelist.filename());
127+
if (filelen > 20) {
128+
char *buf = (char *)filelist.filename();
129+
//char buf[filelen];
130+
//strcpy(&buf[filelen], filelist.filename());
131+
buf[18] = '\0'; // cutoff at screen edge
132+
rtscheck.RTS_SndData(buf, (SDFILE_ADDR + (fcnt * 20)));
133+
}
134+
else
135+
rtscheck.RTS_SndData(filelist.filename(), (SDFILE_ADDR + (fcnt * 20)));
136+
137+
if (filelist.isDir()) {
138+
rtscheck.RTS_SndData((uint8_t)4, FilenameIcon + (fcnt+1));
139+
rtscheck.RTS_SndData((unsigned long)0x041F, (FilenameNature + ((1+fcnt) * 16))); // Change BG of selected line to Blue
140+
}
141+
else {
142+
rtscheck.RTS_SndData((uint8_t)0, FilenameIcon + (fcnt+1));
143+
rtscheck.RTS_SndData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
144+
}
145+
SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n");
146+
fcnt++;
147+
}
148+
}
149+
}
150+
151+
void FileNavigator::changeDIR(char *folder) {
152+
DEBUG_ECHOLNPGM("currentfolder: ", currentfoldername, " New: ", folder);
153+
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
154+
strcat(currentfoldername, folder);
155+
strcat(currentfoldername, "/");
156+
filelist.changeDir(folder);
157+
refresh();
158+
folderdepth++;
159+
currentindex = 0;
160+
}
161+
162+
void FileNavigator::upDIR() {
163+
filelist.upDir();
164+
refresh();
165+
folderdepth--;
166+
currentindex = 0;
167+
// Remove the last child folder from the stored path
168+
if (folderdepth == 0) {
169+
currentfoldername[0] = '\0';
170+
reset();
171+
}
172+
else {
173+
char *pos = nullptr;
174+
for (uint8_t f = 0; f < folderdepth; f++)
175+
pos = strchr(currentfoldername, '/');
176+
pos[1] = '\0';
177+
}
178+
DEBUG_ECHOLNPGM("depth: ", folderdepth, " currentfoldername: ", currentfoldername);
179+
}
180+
181+
char* FileNavigator::getCurrentFolderName() { return currentfoldername; }
182+
183+
#endif // DGUS_LCD_UI_IA_CREALITY

0 commit comments

Comments
 (0)