Skip to content

Commit

Permalink
MarlinUI for E3V2 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 18, 2021
1 parent 74a7b0c commit 01a0c15
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,11 @@
//
//#define DWIN_CREALITY_LCD

// MarlinUI for Creality's DWIN display (and others)
//
//#define DWIN_MARLINUI_PORTRAIT
//#define DWIN_MARLINUI_LANDSCAPE

//
// Touch Screen Settings
//
Expand Down
24 changes: 13 additions & 11 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@

// LCD Print Progress options
#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY)
#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI)
//#define SHOW_REMAINING_TIME // Display estimated time to completion
#if ENABLED(SHOW_REMAINING_TIME)
//#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation
Expand Down Expand Up @@ -1579,16 +1579,10 @@
* printing performance versus fast display updates.
*/
#if HAS_MARLINUI_U8GLIB
// Show SD percentage next to the progress bar
//#define SHOW_SD_PERCENT

// Save many cycles by drawing a hollow frame or no frame on the Info Screen
//#define XYZ_NO_FRAME
#define XYZ_HOLLOW_FRAME
// Enable to save many cycles by drawing a hollow frame on Menu Screens
#define MENU_HOLLOW_FRAME

// A bigger font is available for edit items. Costs 3120 bytes of PROGMEM.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_BIG_EDIT_FONT
Expand All @@ -1597,9 +1591,6 @@
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_SMALL_INFOFONT
// Swap the CW/CCW indicators in the graphics overlay
//#define OVERLAY_GFX_REVERSE

/**
* ST7920-based LCDs can emulate a 16 x 4 character display using
* the ST7920 character-generator for very fast screen updates.
Expand Down Expand Up @@ -1651,6 +1642,17 @@

#endif // HAS_MARLINUI_U8GLIB

#if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
// Show SD percentage next to the progress bar
//#define SHOW_SD_PERCENT

// Enable to save many cycles by drawing a hollow frame on Menu Screens
#define MENU_HOLLOW_FRAME
// Swap the CW/CCW indicators in the graphics overlay
//#define OVERLAY_GFX_REVERSE
#endif

//
// Additional options for DGUS / DWIN displays
//
Expand Down Expand Up @@ -1716,7 +1718,7 @@
//
// Specify additional languages for the UI. Default specified by LCD_LANGUAGE.
//
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE)
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI)
//#define LCD_LANGUAGE_2 fr
//#define LCD_LANGUAGE_3 de
//#define LCD_LANGUAGE_4 es
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@
#define HAS_MARLINUI_U8GLIB 1
#elif IS_TFTGLCD_PANEL
// Neither DOGM nor HD44780. Fully customized interface.
#elif IS_DWIN_MARLINUI
// Since HAS_MARLINUI_U8GLIB refers to U8G displays
// the DWIN display can define its own flags
#elif DISABLED(HAS_GRAPHICAL_TFT)
#define HAS_MARLINUI_HD44780 1
#endif
Expand Down Expand Up @@ -1087,7 +1090,7 @@
#define HAS_ETHERNET 1
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#if EITHER(DWIN_CREALITY_LCD, IS_DWIN_MARLINUI)
#define SERIAL_CATCHALL 0
#ifndef LCD_SERIAL_PORT
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO)
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@

#endif

#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT) || !PIN_EXISTS(SD_DETECT)
#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI) || !PIN_EXISTS(SD_DETECT)
#define NO_LCD_REINIT 1 // Suppress LCD re-initialization
#endif

Expand Down Expand Up @@ -3258,13 +3258,17 @@
#ifndef LCD_WIDTH
#if HAS_MARLINUI_U8GLIB
#define LCD_WIDTH 21
#elif IS_DWIN_MARLINUI
// Defined by header
#else
#define LCD_WIDTH TERN(IS_ULTIPANEL, 20, 16)
#endif
#endif
#ifndef LCD_HEIGHT
#if HAS_MARLINUI_U8GLIB
#define LCD_HEIGHT 5
#elif IS_DWIN_MARLINUI
// Defined by header
#else
#define LCD_HEIGHT TERN(IS_ULTIPANEL, 4, 2)
#endif
Expand Down
7 changes: 4 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0."
#endif
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY)
#if NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI)
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, or EXTENSIBLE_UI."
#if NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, IS_DWIN_MARLINUI)
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, EXTENSIBLE_UI, OR DWIN MarlinUI."
#endif
#endif

Expand Down Expand Up @@ -1721,7 +1721,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif

#if ENABLED(MESH_EDIT_GFX_OVERLAY) && !BOTH(AUTO_BED_LEVELING_UBL, HAS_MARLINUI_U8GLIB)
#if ENABLED(MESH_EDIT_GFX_OVERLAY) && !(ENABLED(AUTO_BED_LEVELING_UBL) && EITHER(HAS_MARLINUI_U8GLIB, IS_DWIN_MARLINUI))
#error "MESH_EDIT_GFX_OVERLAY requires AUTO_BED_LEVELING_UBL and a Graphical LCD."
#endif

Expand Down Expand Up @@ -2640,6 +2640,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
+ 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) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY, DWIN_CREALITY_LCD) \
+ COUNT_ENABLED(DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
+ COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
+ COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/lcdprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

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

#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT
#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI

#include "marlinui.h"
#include "lcdprint.h"
Expand Down
21 changes: 19 additions & 2 deletions Marlin/src/lcd/lcdprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@

#include "../inc/MarlinConfig.h"

#if HAS_MARLINUI_U8GLIB
#if IS_DWIN_MARLINUI

#include "e3v2/marlinui/marlinui_dwin.h"

#define LCD_PIXEL_WIDTH DWIN_WIDTH
#define LCD_PIXEL_HEIGHT DWIN_HEIGHT
#define LCD_WIDTH ((LCD_PIXEL_WIDTH) / (MENU_FONT_WIDTH))
#define LCD_HEIGHT ((LCD_PIXEL_HEIGHT) / (MENU_LINE_HEIGHT))

// The DWIN lcd_moveto function uses row / column, not pixels
#define LCD_COL_X(col) (col)
#define LCD_ROW_Y(row) (row)
#define LCD_COL_X_RJ(len) (LCD_WIDTH - LCD_COL_X(len))

#elif HAS_MARLINUI_U8GLIB

#include "dogm/u8g_fontutf8.h"
typedef u8g_uint_t lcd_uint_t;
Expand Down Expand Up @@ -105,7 +119,10 @@
#define MENU_LINE_HEIGHT MENU_FONT_HEIGHT
#endif

#define LCD_COL_X_RJ(len) (LCD_PIXEL_WIDTH - LCD_COL_X(len))
#ifndef LCD_COL_X_RJ
#define LCD_COL_X_RJ(len) (LCD_PIXEL_WIDTH - LCD_COL_X(len))
#endif

#define SETCURSOR(col, row) lcd_moveto(LCD_COL_X(col), LCD_ROW_Y(row))
#define SETCURSOR_RJ(len, row) lcd_moveto(LCD_COL_X_RJ(len), LCD_ROW_Y(row))
#define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr)
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
bool MarlinUI::drawing_screen, MarlinUI::first_page; // = false
#endif

#if IS_DWIN_MARLINUI
bool MarlinUI::did_first_redraw;
#endif

// Encoder Handling
#if HAS_ENCODER_ACTION
uint32_t MarlinUI::encoderPosition;
Expand Down Expand Up @@ -1073,6 +1077,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;

run_current_screen();

// Apply all DWIN drawing after processing
TERN_(IS_DWIN_MARLINUI, DWIN_UpdateLCD());

#endif

TERN_(HAS_LCD_MENU, lcd_clicked = false);
Expand Down
12 changes: 11 additions & 1 deletion Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,13 @@ class MarlinUI {

#else

static void set_custom_characters(const HD44780CharSet screen_charset=CHARSET_INFO);
#if IS_DWIN_MARLINUI
static void set_font(const uint8_t font_nr);
#endif

#if HAS_MARLINUI_HD44780
static void set_custom_characters(const HD44780CharSet screen_charset=CHARSET_INFO);
#endif

#if ENABLED(LCD_PROGRESS_BAR)
static millis_t progress_bar_ms; // Start time for the current progress bar cycle
Expand Down Expand Up @@ -447,6 +453,10 @@ class MarlinUI {
static constexpr bool drawing_screen = false, first_page = true;
#endif

#if IS_DWIN_MARLINUI
static bool did_first_redraw;
#endif

static bool get_blink();
static void kill_screen(PGM_P const lcd_error, PGM_P const lcd_component);
static void draw_kill_screen();
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ bool printer_busy() {
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
if (currentScreen != screen) {

TERN_(IS_DWIN_MARLINUI, did_first_redraw = false);

TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU);

TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset());
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef void (*selectFunc_t)();
#define SS_INVERT 0x02
#define SS_DEFAULT SS_CENTER

#if HAS_MARLINUI_U8GLIB && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
#if EITHER(HAS_MARLINUI_U8GLIB, IS_DWIN_MARLINUI) && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const_float_t zvalue);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
#define BTN_EN1 PB10
#define BTN_EN2 PA6

#elif ENABLED(DWIN_CREALITY_LCD)
#elif EITHER(DWIN_CREALITY_LCD, IS_DWIN_MARLINUI)

// RET6 DWIN ENCODER LCD
#define BTN_ENC PB14
Expand Down
6 changes: 2 additions & 4 deletions buildroot/tests/STM32F103RET6_creality
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ use_example_configs "Creality/Ender-3 V2/CrealityUI"
opt_enable MARLIN_DEV_MODE BUFFER_MONITORING
exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"

use_example_configs "Creality/Ender-3 V2/CrealityUI"
opt_disable CLASSIC_JERK
use_example_configs "Creality/Ender-3 V2/MarlinUI"
opt_add SDCARD_EEPROM_EMULATION
opt_set TEMP_SENSOR_BED 0
exec_test $1 $2 "Ender 3 v2, SD EEPROM, no CLASSIC_JERK, no Bed" "$3"
exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"

restore_configs
opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1
Expand Down
1 change: 1 addition & 0 deletions ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ I2C_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_i
SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
SPI_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
DWIN_CREALITY_LCD = src_filter=+<src/lcd/e3v2/creality>
DWIN_MARLINUI_.+ = src_filter=+<src/lcd/e3v2/marlinui>
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD>
HAS_TOUCH_BUTTONS = src_filter=+<src/lcd/touch/touch_buttons.cpp>
Expand Down
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ extra_scripts =
post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
lib_deps =
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/e3v2/creality> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
-<src/lcd/e3v2/creality> -<src/lcd/e3v2/marlinui>
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
-<src/lcd/menu>
-<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
Expand Down

0 comments on commit 01a0c15

Please sign in to comment.