Skip to content

Commit

Permalink
Jyers UI
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 7, 2021
1 parent ed0c5ae commit cf20f5f
Show file tree
Hide file tree
Showing 30 changed files with 6,601 additions and 26 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,11 @@
//
//#define DWIN_CREALITY_LCD

//
// Ender-3 v2 OEM display with enhancements by Jacob Myers
//
//#define DWIN_CREALITY_LCD_JYERSUI

//
// MarlinUI for Creality's DWIN display (and others)
//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@

// @section lcd

#if EITHER(IS_ULTIPANEL, EXTENSIBLE_UI)
#if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2)
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel
#define FINE_MANUAL_MOVE 0.025 // (mm) Smallest manual move (< 0.1mm) applying to Z on most machines
#if IS_ULTIPANEL
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
#if ENABLED(DWIN_CREALITY_LCD)
#include "lcd/e3v2/creality/dwin.h"
#include "lcd/e3v2/creality/rotary_encoder.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "lcd/e3v2/jyersui/dwin.h"
#include "lcd/e3v2/jyersui/rotary_encoder.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/feature/powerloss/M1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "../../../lcd/marlinui.h"
#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented
#endif

#define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY)
Expand Down Expand Up @@ -64,6 +66,8 @@ void GcodeSuite::M1000() {
ui.goto_screen(menu_job_recovery);
#elif ENABLED(DWIN_CREALITY_LCD)
recovery.dwin_flag = true;
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) // Temporary fix until it can be better implemented
CrealityDWIN.Popup_Handler(Resume);
#elif ENABLED(EXTENSIBLE_UI)
ExtUI::onPowerLossResume();
#else
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@
#endif

// Aliases for LCD features
#if ANY(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_JYERSUI)
#define HAS_DWIN_E3V2 1
#endif

#if IS_ULTRA_LCD
#define HAS_WIRED_LCD 1
#if ENABLED(DOGLCD)
Expand All @@ -507,11 +511,11 @@
#endif
#endif

#if EITHER(HAS_WIRED_LCD, EXTENSIBLE_UI)
#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI)
#define HAS_DISPLAY 1
#endif

#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD, GLOBAL_STATUS_MESSAGE)
#if ANY(HAS_DISPLAY, HAS_DWIN_E3V2, GLOBAL_STATUS_MESSAGE)
#define HAS_STATUS_MESSAGE 1
#endif

Expand Down Expand Up @@ -1101,7 +1105,7 @@
#define HAS_ETHERNET 1
#endif

#if EITHER(DWIN_CREALITY_LCD, IS_DWIN_MARLINUI)
#if EITHER(HAS_DWIN_E3V2, 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
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
#define HAS_SOFTWARE_ENDSTOPS 1
#endif
#if ANY(EXTENSIBLE_UI, IS_NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, DWIN_CREALITY_LCD)
#if ANY(EXTENSIBLE_UI, IS_NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS, HAS_DWIN_E3V2)
#define HAS_RESUME_CONTINUE 1
#endif

Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@
#endif
#endif

#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
#define HAS_LCD_BRIGHTNESS 1
#endif

/**
* Override the SD_DETECT_STATE set in Configuration_adv.h
* and enable sharing of onboard SD host drives (all platforms but AGCM4)
Expand Down Expand Up @@ -2828,7 +2832,7 @@
#define HAS_TEMPERATURE 1
#endif

#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD)
#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, HAS_DWIN_E3V2)
#ifdef PREHEAT_6_LABEL
#define PREHEAT_COUNT 6
#elif defined(PREHEAT_5_LABEL)
Expand Down Expand Up @@ -2949,7 +2953,7 @@
* Advanced Pause - Filament Change
*/
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT)
#if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT)
#define M600_PURGE_MORE_RESUMABLE 1
#endif
#ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH
Expand Down Expand Up @@ -3205,7 +3209,7 @@
#endif

// Number of VFAT entries used. Each entry has 13 UTF-16 characters
#if EITHER(SCROLL_LONG_FILENAMES, DWIN_CREALITY_LCD)
#if EITHER(SCROLL_LONG_FILENAMES, HAS_DWIN_E3V2)
#define MAX_VFAT_ENTRIES (5)
#else
#define MAX_VFAT_ENTRIES (2)
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#elif PROGRESS_MSG_EXPIRE < 0
#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, IS_DWIN_MARLINUI)
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, EXTENSIBLE_UI, OR DWIN MarlinUI."
#endif
#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
#error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, or EXTENSIBLE_UI."
#endif

#if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY)
Expand Down Expand Up @@ -2657,7 +2655,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, DGUS_LCD_UI_RELOADED) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \
+ COUNT_ENABLED(DWIN_CREALITY_LCD, 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_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/buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#endif
#endif

#if EITHER(HAS_DIGITAL_BUTTONS, DWIN_CREALITY_LCD)
#if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2)
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
#define BLEN_A 0
#define BLEN_B 1
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/lcd/e3v2/creality/rotary_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() {
}

if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
else temp_diffState = ENCODER_DIFF_CCW;
#if ENABLED(REVERSE_ENCODER_DIRECTION)
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CCW;
else temp_diffState = ENCODER_DIFF_CW;
#else
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
else temp_diffState = ENCODER_DIFF_CCW;
#endif

#if ENABLED(ENCODER_RATE_MULTIPLIER)

Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/e3v2/jyersui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DWIN for Creality Ender 3 v2

Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x/config/examples/Creality/Ender-3%20V2).

## Easy Install

Copy the `DWIN_SET` folder onto a Micro-SD card and insert the card into the slot on the DWIN screen. Cycle the machine and wait for the screen to go from blue to orange. Turn the machine off and remove the SD card. When you turn on the machine the screen will display a "Creality" loading screen.
85 changes: 85 additions & 0 deletions Marlin/src/lcd/e3v2/jyersui/creality_marlinui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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/e3v2/jyersui/creality_marlinui.cpp
* Rewrite by Jacob Myers
*/

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

#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)

#if ENABLED(ADVANCED_PAUSE_FEATURE)
#include "../../../feature/pause.h"
#endif

#include "dwin.h"
#include "../../marlinui.h"

#if ENABLED(ADVANCED_PAUSE_FEATURE)
void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
switch (message) {
case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break;
case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break;
case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break;
case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break;
default: break;
}
}
#endif

bool MarlinUI::get_blink() {
static uint8_t blink = 0;
static millis_t next_blink_ms = 0;
millis_t ms = millis();
if (ELAPSED(ms, next_blink_ms)) {
blink ^= 0xFF;
next_blink_ms = ms + 1000 - 250;
}
return blink != 0;
}

void MarlinUI::update() { CrealityDWIN.Update(); }

void MarlinUI::init() {
delay(800);
SERIAL_ECHOPGM("\nDWIN handshake ");
if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");
DWIN_Frame_SetDir(1); // Orientation 90°
DWIN_UpdateLCD(); // Show bootscreen (first image)
Encoder_Configuration();
for (uint16_t t = 0; t <= 100; t += 2) {
DWIN_ICON_Show(ICON, ICON_Bar, 15, 260);
DWIN_Draw_Rectangle(1, Color_Bg_Black, 15 + t * 242 / 100, 260, 257, 280);
DWIN_UpdateLCD();
delay(20);
}
DWIN_JPG_CacheTo1(Language_English);
CrealityDWIN.Redraw_Screen();
}

void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) {
CrealityDWIN.Draw_Popup(PSTR("Printer Kill Reason:"), error, PSTR("Restart Required"), Wait, ICON_BLTouch);
}

#endif // DWIN_CREALITY_LCD_JYERSUI
Loading

0 comments on commit cf20f5f

Please sign in to comment.