Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DGUS_LCD_UI_IA_CREALITY #25143

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2939,23 +2939,16 @@

/**
* DGUS Touch Display with DWIN OS. (Choose one.)
* ORIGIN : https://www.aliexpress.com/item/32993409517.html
* FYSETC : https://www.aliexpress.com/item/32961471929.html
* MKS : https://www.aliexpress.com/item/1005002008179262.html
*
* Flash display with DGUS Displays for Marlin:
* - Format the SD card to FAT32 with an allocation size of 4kb.
* - Download files as specified for your type of display.
* - Plug the microSD card into the back of the display.
* - Boot the display and wait for the update to complete.
*
* ORIGIN (Marlin DWIN_SET)
* - Download https://github.com/coldtobi/Marlin_DGUS_Resources
* - Copy the downloaded DWIN_SET folder to the SD card.
* - Product: https://www.aliexpress.com/item/32993409517.html
*
* FYSETC (Supplier default)
* - Download https://github.com/FYSETC/FYSTLCD-2.0
* - Copy the downloaded SCREEN folder to the SD card.
* - Product: https://www.aliexpress.com/item/32961471929.html
*
* HIPRECY (Supplier default)
* - Download https://github.com/HiPrecy/Touch-Lcd-LEO
Expand All @@ -2964,17 +2957,24 @@
* MKS (MKS-H43) (Supplier default)
* - Download https://github.com/makerbase-mks/MKS-H43
* - Copy the downloaded DWIN_SET folder to the SD card.
* - Product: https://www.aliexpress.com/item/1005002008179262.html
*
* RELOADED (T5UID1)
* - Download https://github.com/Desuuuu/DGUS-reloaded/releases
* - Copy the downloaded DWIN_SET folder to the SD card.
*
* IA_CREALITY (T5UID1)
* - Download https://github.com/InsanityAutomation/Marlin/raw/CrealityDwin2.0_Bleeding/TM3D_Combined480272_Landscape_V7.7z
* - Copy the downloaded DWIN_SET folder to the SD card.
*
* Flash display with DGUS Displays for Marlin:
* - Format the SD card to FAT32 with an allocation size of 4kb.
* - Download files as specified for your type of display.
* - Plug the microSD card into the back of the display.
* - Boot the display and wait for the update to complete.
*/
//#define DGUS_LCD_UI_ORIGIN
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY
//#define DGUS_LCD_UI_MKS
//#define DGUS_LCD_UI_RELOADED
#if ENABLED(DGUS_LCD_UI_MKS)
//#define DGUS_LCD_UI ORIGIN
#if DGUS_UI_IS(MKS)
#define USE_MKS_GREEN_UI
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1864,11 +1864,11 @@

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

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

#if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_MKS)
#if DGUS_UI_IS(FYSETC, MKS)
//#define DGUS_UI_MOVE_DIS_OPTION // Disabled by default for FYSETC and MKS
#else
#define DGUS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY
Expand Down
10 changes: 10 additions & 0 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,3 +742,13 @@
#define _HAS_E_TEMP(N) || TEMP_SENSOR(N)
#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP))
#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2)

#define _UI_NONE 0
#define _UI_ORIGIN 101
#define _UI_FYSETC 102
#define _UI_HIPRECY 103
#define _UI_MKS 104
#define _UI_RELOADED 105
#define _UI_IA_CREALITY 106
#define _DGUS_UI_IS(N) || (DGUS_LCD_UI == _UI_ ## N)
#define DGUS_UI_IS(V...) (0 MAP(_DGUS_UI_IS, V))
24 changes: 19 additions & 5 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@
#define FYSETC_MINI_12864_2_1
#endif

// Updated DGUS_UI shorthand single option can be used, or old settings, for now
#if DGUS_UI_IS(ORIGIN)
#define DGUS_LCD_UI_ORIGIN
#elif DGUS_UI_IS(FYSETC)
#define DGUS_LCD_UI_FYSETC
#elif DGUS_UI_IS(HIPRECY)
#define DGUS_LCD_UI_HIPRECY
#elif DGUS_UI_IS(MKS)
#define DGUS_LCD_UI_MKS
#elif DGUS_UI_IS(RELOADED)
#define DGUS_LCD_UI_RELOADED
#elif DGUS_UI_IS(IA_CREALITY)
#define DGUS_LCD_UI_IA_CREALITY
#endif

/**
* General Flags that may be set below by specific LCDs
*
Expand Down Expand Up @@ -462,12 +477,11 @@
#endif

// Aliases for LCD features
#if ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS)
#define HAS_DGUS_LCD_CLASSIC 1
#endif

#if EITHER(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED)
#if !DGUS_UI_IS(NONE)
#define HAS_DGUS_LCD 1
#if DGUS_UI_IS(ORIGIN, FYSETC, HIPRECY, MKS)
#define HAS_DGUS_LCD_CLASSIC 1
#endif
#endif

// Extensible UI serial touch screens. (See src/lcd/extui)
Expand Down
45 changes: 31 additions & 14 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
#elif defined(HOME_USING_SPREADCYCLE)
#error "HOME_USING_SPREADCYCLE is now obsolete. Please remove it."
#elif defined(DGUS_LCD)
#error "DGUS_LCD is now DGUS_LCD_UI_(ORIGIN|FYSETC|HIPRECY)."
#error "DGUS_LCD is now DGUS_LCD_UI ORIGIN|FYSETC|HIPRECY)."
#elif defined(DGUS_SERIAL_PORT)
#error "DGUS_SERIAL_PORT is now LCD_SERIAL_PORT."
#elif defined(DGUS_BAUDRATE)
Expand Down Expand Up @@ -3009,7 +3009,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
+ (DISABLED(IS_LEGACY_TFT) && ENABLED(TFT_GENERIC)) \
+ (ENABLED(IS_LEGACY_TFT) && COUNT_ENABLED(TFT_320x240, TFT_320x240_SPI, TFT_480x320, TFT_480x320_SPI)) \
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \
+ COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \
+ 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) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \
Expand Down Expand Up @@ -4270,34 +4270,51 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#undef _BAD_DRIVER

/**
* Require certain features for DGUS_LCD_UI_RELOADED.
* Require certain features for DGUS_LCD_UI RELOADED.
*/
#if ENABLED(DGUS_LCD_UI_RELOADED)
#if DGUS_UI_IS(RELOADED)
#if BUFSIZE < 4
#error "DGUS_LCD_UI_RELOADED requires a BUFSIZE of at least 4."
#error "DGUS_LCD_UI RELOADED requires a BUFSIZE of at least 4."
#elif HOTENDS < 1
#error "DGUS_LCD_UI_RELOADED requires at least 1 hotend."
#error "DGUS_LCD_UI RELOADED requires at least 1 hotend."
#elif EXTRUDERS < 1
#error "DGUS_LCD_UI_RELOADED requires at least 1 extruder."
#error "DGUS_LCD_UI RELOADED requires at least 1 extruder."
#elif !HAS_HEATED_BED
#error "DGUS_LCD_UI_RELOADED requires a heated bed."
#error "DGUS_LCD_UI RELOADED requires a heated bed."
#elif FAN_COUNT < 1
#error "DGUS_LCD_UI_RELOADED requires a fan."
#error "DGUS_LCD_UI RELOADED requires a fan."
#elif !HAS_BED_PROBE
#error "DGUS_LCD_UI_RELOADED requires a bed probe."
#error "DGUS_LCD_UI RELOADED requires a bed probe."
#elif !HAS_MESH
#error "DGUS_LCD_UI_RELOADED requires mesh leveling."
#error "DGUS_LCD_UI RELOADED requires mesh leveling."
#elif DISABLED(LCD_BED_TRAMMING)
#error "DGUS_LCD_UI_RELOADED requires LCD_BED_TRAMMING."
#error "DGUS_LCD_UI RELOADED requires LCD_BED_TRAMMING."
#elif DISABLED(BABYSTEP_ALWAYS_AVAILABLE)
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ALWAYS_AVAILABLE."
#elif DISABLED(BABYSTEP_ZPROBE_OFFSET)
#error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ZPROBE_OFFSET."
#error "DGUS_LCD_UI RELOADED requires BABYSTEP_ZPROBE_OFFSET."
#elif ENABLED(AUTO_BED_LEVELING_UBL) && DISABLED(UBL_SAVE_ACTIVE_ON_M500)
#warning "Without UBL_SAVE_ACTIVE_ON_M500, your mesh will not be saved when using the touchscreen."
#endif
#endif

/**
* Require certain features for DGUS_LCD_UI IA_CREALITY.
*/
#if DGUS_UI_IS(IA_CREALITY)
#if DISABLED(ADVANCED_PAUSE_FEATURE)
#error "DGUS_LCD_UI IA_CREALITY requires ADVANCED_PAUSE_FEATURE."
#elif DISABLED(LCD_BED_TRAMMING)
#error "DGUS_LCD_UI IA_CREALITY requires LCD_BED_TRAMMING."
#elif DISABLED(CLASSIC_JERK)
#error "DGUS_LCD_UI IA_CREALITY requires CLASSIC_JERK."
#elif DISABLED(BABYSTEPPING)
#error "DGUS_LCD_UI IA_CREALITY requires BABYSTEPPING."
#elif NONE(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
#error "DGUS_LCD_UI IA_CREALITY requires AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, or MESH_BED_LEVELING."
#endif
#endif

// JTAG support in the HAL
#if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE)
#error "DISABLE_DEBUG is not supported for the selected MCU/Board."
Expand Down
183 changes: 183 additions & 0 deletions Marlin/src/lcd/extui/ia_creality/FileNavigator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

/* ****************************************
* lcd/extui/ia_creality/FileNavigator.cpp
* ****************************************
* Extensible_UI implementation for Creality DWIN
* 10SPro, Max, CR10V2
* Based on implementations for Anycubic Chiron and Nextion by Nick Wells and Skorpi08
* Written by Insanity Automation
* ***************************************/

#include "../../../inc/MarlinConfigPre.h"

#if ENABLED(DGUS_LCD_UI_IA_CREALITY)

#include "FileNavigator.h"

using namespace ExtUI;

#define DEBUG_OUT ENABLED(DEBUG_DWIN)
#include "../../../core/debug_out.h"

FileList FileNavigator::filelist; // Instance of the Marlin file API
char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path
uint16_t FileNavigator::lastindex;
uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentindex; // override the panel request

FileNavigator filenavigator;

FileNavigator::FileNavigator() { reset(); }

void FileNavigator::reset() {
currentfoldername[0] = '\0';
folderdepth = 0;
currentindex = 0;
lastindex = 0;
// Start at root folder
while (!filelist.isAtRootDir()) filelist.upDir();
refresh();
}

void FileNavigator::refresh() { filelist.refresh(); }

bool FileNavigator::getIndexisDir(uint16_t index){
filelist.seek(index);
return filelist.isDir();
}

const char *FileNavigator::getIndexName(uint16_t index){
filelist.seek(index);
return filelist.shortFilename();
}

uint16_t FileNavigator::maxFiles() {
return filelist.count();
}

void FileNavigator::getFiles(uint16_t index) {
uint16_t files = DISPLAY_FILES, fcnt = 0;
if (index == 0)
currentindex = 0;
else {
// Each time we change folder we reset the file index to 0 and keep track
// of the current position as the TFT panel isn't aware of folder trees.
--currentindex; // go back a file to take account of the .. added to the root.
if (index > lastindex)
currentindex += files + 1;
else if (currentindex >= files)
currentindex -= files - 1;
else
currentindex = 0;
}
lastindex = index;


// Clear currently drawn screen
for (int i = 0; i < DISPLAY_FILES; i++) {
for (int j = 0; j < 20; j++)
rtscheck.RTS_SndData(0, SDFILE_ADDR + (i * 20) + j);
}

for (int j = 0; j < 10; j++) {
rtscheck.RTS_SndData(0, Printfilename + j); // clear screen.
rtscheck.RTS_SndData(0, Choosefilename + j); // clear filename
}
for (int j = 0; j < 8; j++)
rtscheck.RTS_SndData(0, FilenameCount + j);
for (int j = 1; j <= DISPLAY_FILES; j++) {
rtscheck.RTS_SndData(10, FilenameIcon + j);
rtscheck.RTS_SndData(10, FilenameIcon1 + j);
}

DEBUG_ECHOLNPGM("index=", index, " currentindex=", currentindex, "folderdepth=", folderdepth);

if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
files--;
rtscheck.RTS_SndData("Up Directory", SDFILE_ADDR);
fcnt++;
}
else if (currentindex == DISPLAY_FILES && folderdepth > 0)
currentindex--;

for (uint16_t seek = currentindex; seek < currentindex + files; seek++) {
if (filelist.seek(seek)) {
const int filelen = strlen(filelist.filename());
if (filelen > 20) {
char *buf = (char *)filelist.filename();
//char buf[filelen];
//strcpy(&buf[filelen], filelist.filename());
buf[18] = '\0'; // cutoff at screen edge
rtscheck.RTS_SndData(buf, (SDFILE_ADDR + (fcnt * 20)));
}
else
rtscheck.RTS_SndData(filelist.filename(), (SDFILE_ADDR + (fcnt * 20)));

if (filelist.isDir()) {
rtscheck.RTS_SndData((uint8_t)4, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0x041F, (FilenameNature + ((1+fcnt) * 16))); // Change BG of selected line to Blue
}
else {
rtscheck.RTS_SndData((uint8_t)0, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
}
SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n");
fcnt++;
}
}
}

void FileNavigator::changeDIR(char *folder) {
DEBUG_ECHOLNPGM("currentfolder: ", currentfoldername, " New: ", folder);
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
strcat(currentfoldername, folder);
strcat(currentfoldername, "/");
filelist.changeDir(folder);
refresh();
folderdepth++;
currentindex = 0;
}

void FileNavigator::upDIR() {
filelist.upDir();
refresh();
folderdepth--;
currentindex = 0;
// Remove the last child folder from the stored path
if (folderdepth == 0) {
currentfoldername[0] = '\0';
reset();
}
else {
char *pos = nullptr;
for (uint8_t f = 0; f < folderdepth; f++)
pos = strchr(currentfoldername, '/');
pos[1] = '\0';
}
DEBUG_ECHOLNPGM("depth: ", folderdepth, " currentfoldername: ", currentfoldername);
}

char* FileNavigator::getCurrentFolderName() { return currentfoldername; }

#endif // DGUS_LCD_UI_IA_CREALITY
Loading