Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
✨ WYH L12864 LCD (Alfawise Ex8) (MarlinFirmware#22863)
Browse files Browse the repository at this point in the history
  • Loading branch information
VragVideo authored and 0xk1f0 committed Dec 26, 2021
1 parent ca7d72a commit 9fe30f0
Show file tree
Hide file tree
Showing 56 changed files with 181 additions and 101 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,11 @@
//#define VIKI2
//#define miniVIKI

//
// Alfawise Ex8 printer LCD marked as WYH L12864 COG
//
//#define WYH_L12864

//
// MakerLab Mini Panel with graphic
// controller and SD support - https://reprap.org/wiki/Mini_panel
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@
* Set STATUS_EXPIRE_SECONDS to zero to never clear the status.
* This will prevent position updates from being displayed.
*/
#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920
// Enable this option and reduce the value to optimize screen updates.
// The normal delay is 10µs. Use the lowest value that still gives a reliable display.
//#define DOGM_SPI_DELAY_US 5
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920

#include "../../../inc/MarlinConfig.h"
#include "../../shared/Delay.h"
Expand Down Expand Up @@ -182,5 +182,5 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
}
#endif // LIGHTWEIGHT_UI

#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920

#include "u8g_com_HAL_DUE_sw_spi_shared.h"

Expand Down Expand Up @@ -141,5 +141,5 @@ uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
return 1;
}

#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // ARDUINO_ARCH_SAM
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920

#include <U8glib-HAL.h>
#include <SoftwareSPI.h>
Expand Down Expand Up @@ -143,5 +143,5 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar
return 1;
}

#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC1768
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920

#include <SoftwareSPI.h>
#include "../../shared/HAL_SPI.h"
Expand Down Expand Up @@ -205,5 +205,5 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
return 1;
}

#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // TARGET_LPC1768
4 changes: 2 additions & 2 deletions Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920

#include <U8glib-HAL.h>
#include "../../shared/Delay.h"
Expand Down Expand Up @@ -167,5 +167,5 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void
}
#endif

#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // TARGET_LPC1768
4 changes: 2 additions & 2 deletions Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_sw_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

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

#if HAS_MARLINUI_U8GLIB && DISABLED(U8GLIB_ST7920)
#if HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920

#undef SPI_SPEED
#define SPI_SPEED 2 // About 2 MHz
Expand Down Expand Up @@ -211,5 +211,5 @@ uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt
#elif !ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI, HAS_MARLINUI_HD44780) && HAS_MARLINUI_U8GLIB
#include <U8glib-HAL.h>
uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {return 0;}
#endif // HAS_MARLINUI_U8GLIB && !U8GLIB_ST7920
#endif // HAS_MARLINUI_U8GLIB && !IS_U8GLIB_ST7920
#endif // __PLAT_NATIVE_SIM__
79 changes: 41 additions & 38 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
/**
* General Flags that may be set below by specific LCDs
*
* DOGLCD : Run a Graphical LCD through U8GLib (with MarlinUI)
* IS_ULTIPANEL : Define LCD_PINS_D5/6/7 for direct-connected "Ultipanel" LCDs
* IS_ULTRA_LCD : Ultra LCD, not necessarily Ultipanel.
* IS_RRD_SC : Common RRD Smart Controller digital interface pins
* IS_RRD_FG_SC : Common RRD Full Graphical Smart Controller digital interface pins
* U8GLIB_ST7920 : Most common DOGM display SPI interface, supporting a "lightweight" display mode.
* U8GLIB_SH1106 : SH1106 OLED with I2C interface via U8GLib
* IS_U8GLIB_SSD1306 : SSD1306 OLED with I2C interface via U8GLib
* U8GLIB_SSD1309 : SSD1309 OLED with I2C interface via U8GLib
* U8GLIB_ST7565_64128N : ST7565 128x64 LCD with SPI interface via U8GLib
* U8GLIB_LM6059_AF : LM6059 with Hardware SPI via U8GLib
* DOGLCD : Run a Graphical LCD through U8GLib (with MarlinUI)
* IS_ULTIPANEL : Define LCD_PINS_D5/6/7 for direct-connected "Ultipanel" LCDs
* IS_ULTRA_LCD : Ultra LCD, not necessarily Ultipanel.
* IS_RRD_SC : Common RRD Smart Controller digital interface pins
* IS_RRD_FG_SC : Common RRD Full Graphical Smart Controller digital interface pins
* IS_U8GLIB_ST7920 : Most common DOGM display SPI interface, supporting a "lightweight" display mode.
* U8GLIB_SH1106 : SH1106 OLED with I2C interface via U8GLib
* IS_U8GLIB_SSD1306 : SSD1306 OLED with I2C interface via U8GLib (U8GLIB_SSD1306)
* U8GLIB_SSD1309 : SSD1309 OLED with I2C interface via U8GLib (HAS_U8GLIB_I2C_OLED, IS_ULTRA_LCD, DOGLCD)
* IS_U8GLIB_ST7565_64128N : ST7565 128x64 LCD with SPI interface via U8GLib
* IS_U8GLIB_LM6059_AF : LM6059 with Hardware SPI via U8GLib
*/
#if EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY)

Expand Down Expand Up @@ -85,7 +85,7 @@
#elif ENABLED(ZONESTAR_12864LCD)
#define DOGLCD
#define IS_RRD_SC 1
#define U8GLIB_ST7920
#define IS_U8GLIB_ST7920 1

#elif ENABLED(ZONESTAR_12864OLED)
#define IS_RRD_SC 1
Expand All @@ -99,19 +99,24 @@
#define IS_ULTIPANEL 1
#define ENCODER_PULSES_PER_STEP 2

#elif ANY(miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864)
#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864)

#define IS_DOGM_12864 1

#define DOGLCD
#define IS_ULTIPANEL 1

#if ENABLED(miniVIKI)
#define U8GLIB_ST7565_64128N
#define IS_U8GLIB_ST7565_64128N 1
#elif ENABLED(VIKI2)
#define U8GLIB_ST7565_64128N
#define IS_U8GLIB_ST7565_64128N 1
#elif ENABLED(WYH_L12864)
#define IS_U8GLIB_ST7565_64128N 1
#define ST7565_XOFFSET 0x04
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define U8GLIB_LM6059_AF
#define IS_U8GLIB_LM6059_AF 1
#elif ENABLED(AZSMZ_12864)
#define U8GLIB_ST7565_64128N
#define IS_U8GLIB_ST7565_64128N 1
#endif

#elif ENABLED(OLED_PANEL_TINYBOY2)
Expand All @@ -128,7 +133,7 @@
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)

#define DOGLCD
#define U8GLIB_ST7920
#define IS_U8GLIB_ST7920 1
#define IS_ULTIPANEL 1

#elif ENABLED(MKS_12864OLED)
Expand All @@ -144,7 +149,7 @@
#elif ENABLED(SAV_3DGLCD)

#ifdef U8GLIB_SSD1306
#define IS_U8GLIB_SSD1306
#define IS_U8GLIB_SSD1306 // Allow for U8GLIB_SSD1306 + SAV_3DGLCD
#endif
#define IS_NEWPANEL 1

Expand Down Expand Up @@ -266,7 +271,7 @@
// ST7920-based graphical displays
#if ANY(IS_RRD_FG_SC, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER)
#define DOGLCD
#define U8GLIB_ST7920
#define IS_U8GLIB_ST7920 1
#define IS_RRD_SC 1
#endif

Expand All @@ -275,7 +280,7 @@
#define IS_ULTIPANEL 1
#define DOGLCD
#if ENABLED(MAKRPANEL)
#define U8GLIB_ST7565_64128N
#define IS_U8GLIB_ST7565_64128N 1
#endif
#endif

Expand Down Expand Up @@ -372,24 +377,27 @@
* I2C Panels
*/

#if EITHER(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004)
#if ANY(IS_RRD_SC, IS_DOGM_12864, OLED_PANEL_TINYBOY2, LCD_I2C_PANELOLU2)

#define LCD_I2C_TYPE_PCF8575
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define STD_ENCODER_PULSES_PER_STEP 4
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1

#if ENABLED(LCD_SAINSMART_I2C_2004)
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#if ENABLED(LCD_I2C_PANELOLU2) // PANELOLU2 LCD with status LEDs, separate encoder and click inputs
#define LCD_I2C_TYPE_MCP23017 // I2C Character-based 12864 display
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (optional)
#define IS_ULTIPANEL 1
#endif

#elif ENABLED(LCD_I2C_PANELOLU2)
#elif EITHER(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004)

// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
#define LCD_I2C_TYPE_PCF8575 // I2C Character-based 12864 display
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander

#define LCD_I2C_TYPE_MCP23017
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD (optional)
#define IS_ULTIPANEL 1
#if ENABLED(LCD_SAINSMART_I2C_2004)
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#endif

#elif ENABLED(LCD_I2C_VIKI)

Expand All @@ -416,11 +424,6 @@
#define STD_ENCODER_PULSES_PER_STEP 2
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1

#elif ANY(IS_RRD_SC, miniVIKI, VIKI2, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, OLED_PANEL_TINYBOY2, BQ_LCD_SMART_CONTROLLER, LCD_I2C_PANELOLU2)

#define STD_ENCODER_PULSES_PER_STEP 4
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1

#endif

#if EITHER(LCD_I2C_TYPE_MCP23017, LCD_I2C_TYPE_MCP23008) && DISABLED(NO_LCD_DETECT)
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@
#define _LCD_CONTRAST_MAX 115
#elif ENABLED(VIKI2)
#define _LCD_CONTRAST_INIT 140
#elif ENABLED(WYH_L12864)
#define _LCD_CONTRAST_INIT 190
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define _LCD_CONTRAST_MIN 90
#define _LCD_CONTRAST_INIT 110
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
/**
* LCD Lightweight Screen Style
*/
#if ENABLED(LIGHTWEIGHT_UI) && DISABLED(U8GLIB_ST7920)
#if ENABLED(LIGHTWEIGHT_UI) && !IS_U8GLIB_ST7920
#error "LIGHTWEIGHT_UI requires a U8GLIB_ST7920-based display."
#endif

Expand Down Expand Up @@ -2643,6 +2643,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
+ COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, ANET_ET4_TFT28, ANET_ET5_TFT35, BIQU_BX_TFT70, BTT_TFT35_SPI_V1_0) \
+ COUNT_ENABLED(TFTGLCD_PANEL_SPI, TFTGLCD_PANEL_I2C) \
+ COUNT_ENABLED(VIKI2, miniVIKI) \
+ ENABLED(WYH_L12864) \
+ COUNT_ENABLED(ZONESTAR_12864LCD, ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) \
+ COUNT_ENABLED(ANET_FULL_GRAPHICS_LCD, ANET_FULL_GRAPHICS_LCD_ALT_WIRING) \
+ ENABLED(AZSMZ_12864) \
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/dogm/marlinui_DOGM.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS
#endif

#elif ENABLED(U8GLIB_ST7920)
#elif IS_U8GLIB_ST7920

// RepRap Discount Full Graphics Smart Controller
// and other variant LCDs using ST7920
Expand Down Expand Up @@ -72,7 +72,7 @@
#define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes (HW-SPI)
#endif

#elif ENABLED(U8GLIB_LM6059_AF)
#elif IS_U8GLIB_LM6059_AF

// Based on the Adafruit ST7565 (https://www.adafruit.com/products/250)

Expand All @@ -82,7 +82,7 @@
#define U8G_CLASS U8GLIB_LM6059_2X // 4 stripes (HW-SPI)
#endif

#elif ENABLED(U8GLIB_ST7565_64128N)
#elif IS_U8GLIB_ST7565_64128N

// MaKrPanel, Mini Viki, Viki 2.0, AZSMZ 12864 ST7565 controller

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
#define WIDTH 128
#define HEIGHT 64
#define PAGE_HEIGHT 8
#ifndef ST7565_XOFFSET
#define ST7565_XOFFSET 0x00
#endif

#define ST7565_ADC_REVERSE(N) ((N) ? 0xA1 : 0xA0)
#define ST7565_BIAS_MODE(N) ((N) ? 0xA3 : 0xA2)
Expand Down Expand Up @@ -123,7 +126,7 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = {
static const uint8_t u8g_dev_st7565_64128n_HAL_data_start[] PROGMEM = {
U8G_ESC_ADR(0), // instruction mode
U8G_ESC_CS(1), // enable chip
ST7565_COLUMN_ADR(0x00), // high 4 bits to 0, low 4 bits to 0. Changed for DisplayTech 64128N
ST7565_COLUMN_ADR(ST7565_XOFFSET), // high 4 bits to 0, low 4 bits to 0. Changed for DisplayTech 64128N
U8G_ESC_END // end of sequence
};

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

#if ENABLED(U8GLIB_ST7920)
#if IS_U8GLIB_ST7920

#include "ultralcd_st7920_u8glib_rrd_AVR.h"

Expand Down Expand Up @@ -192,5 +192,5 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_rrd_st7920_128x64_fn, &u8
void ST7920_write_byte(const uint8_t val) { ST7920_WRITE_BYTE(val); }
#endif

#endif // U8GLIB_ST7920
#endif // IS_U8GLIB_ST7920
#endif // !U8G_HAL_LINKS && (__AVR__ || ARDUINO_ARCH_STM32 || ARDUINO_ARCH_ESP32)
Loading

0 comments on commit 9fe30f0

Please sign in to comment.