MKS_MINI, FYSETC RGB, backlight (#15334)

This commit is contained in:
DrDitto 2019-09-25 17:41:04 -06:00 committed by Scott Lahteine
parent ddd9d9032a
commit 04e4eb35be
5 changed files with 154 additions and 82 deletions

View file

@ -974,6 +974,12 @@ void setup() {
// UI must be initialized before EEPROM // UI must be initialized before EEPROM
// (because EEPROM code calls the UI). // (because EEPROM code calls the UI).
// Set up LEDs early
#if HAS_COLOR_LEDS
leds.setup();
#endif
ui.init(); ui.init();
ui.reset_status(); ui.reset_status();
@ -1068,10 +1074,6 @@ void setup() {
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF
#endif #endif
#if HAS_COLOR_LEDS
leds.setup();
#endif
#if HAS_CASE_LIGHT #if HAS_CASE_LIGHT
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL) #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN); if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);

View file

@ -170,20 +170,27 @@ uint8_t u8g_dev_uc1701_mini12864_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t m
case U8G_DEV_MSG_INIT: case U8G_DEV_MSG_INIT:
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_init_seq); u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_init_seq);
#if ENABLED(MKS_MINI_12864)
u8g_Delay(5);
#endif
break; break;
case U8G_DEV_MSG_STOP: break; case U8G_DEV_MSG_STOP: break;
case U8G_DEV_MSG_PAGE_NEXT: { case U8G_DEV_MSG_PAGE_NEXT: {
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_data_start); u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_data_start);
#if ENABLED(MKS_MINI_12864)
u8g_Delay(5);
#endif
u8g_WriteByte(u8g, dev, 0x0B0 | (2 * pb->p.page)); /* select current page */ u8g_WriteByte(u8g, dev, 0x0B0 | (2 * pb->p.page)); /* select current page */
u8g_SetAddress(u8g, dev, 1); /* data mode */ u8g_SetAddress(u8g, dev, 1); /* data mode */
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf); u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf);
u8g_SetChipSelect(u8g, dev, 0); u8g_SetChipSelect(u8g, dev, 0);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_data_start); u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_HAL_data_start);
#if ENABLED(MKS_MINI_12864)
u8g_Delay(5);
#endif
u8g_WriteByte(u8g, dev, 0x0B0 | (2 * pb->p.page + 1)); /* select current page */ u8g_WriteByte(u8g, dev, 0x0B0 | (2 * pb->p.page + 1)); /* select current page */
u8g_SetAddress(u8g, dev, 1); /* data mode */ u8g_SetAddress(u8g, dev, 1); /* data mode */
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
@ -192,10 +199,16 @@ uint8_t u8g_dev_uc1701_mini12864_HAL_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t m
case U8G_DEV_MSG_CONTRAST: case U8G_DEV_MSG_CONTRAST:
u8g_SetChipSelect(u8g, dev, 1); u8g_SetChipSelect(u8g, dev, 1);
#if ENABLED(MKS_MINI_12864)
u8g_Delay(5);
#endif
u8g_SetAddress(u8g, dev, 0); /* instruction mode */ u8g_SetAddress(u8g, dev, 0); /* instruction mode */
u8g_WriteByte(u8g, dev, 0x081); u8g_WriteByte(u8g, dev, 0x081);
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
u8g_SetChipSelect(u8g, dev, 0); u8g_SetChipSelect(u8g, dev, 0);
#if ENABLED(MKS_MINI_12864)
u8g_Delay(5);
#endif
return 1; return 1;
} }
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);

View file

@ -21,7 +21,7 @@
*/ */
/** /**
* ultralcd_DOGM.cpp * lcd/dogm/ultralcd_DOGM.h
* *
* Implementation of the LCD display routines for a DOGM128 graphic display. * Implementation of the LCD display routines for a DOGM128 graphic display.
* by STB for ErikZalm/Marlin. Common LCD 128x64 pixel graphic displays. * by STB for ErikZalm/Marlin. Common LCD 128x64 pixel graphic displays.

View file

@ -22,7 +22,7 @@
#pragma once #pragma once
/** /**
* ultralcd_DOGM.h * lcd/dogm/ultralcd_DOGM.h
*/ */
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
@ -30,7 +30,8 @@
#include <U8glib.h> #include <U8glib.h>
#include "HAL_LCD_class_defines.h" #include "HAL_LCD_class_defines.h"
// LCD selection //#define ALTERNATIVE_LCD
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_CLASS U8GLIB_ST7920_128X64_4X
#if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN) #if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN)
@ -40,102 +41,159 @@
#endif #endif
#elif ENABLED(U8GLIB_ST7920) #elif ENABLED(U8GLIB_ST7920)
// RepRap Discount Full Graphics Smart Controller // RepRap Discount Full Graphics Smart Controller
#if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN) #if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SCK_PIN) && (LCD_PINS_ENABLE == MOSI_PIN)
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL // 2 stripes, HW SPI (Shared with SD card. Non-standard LCD adapter on AVR.)
#define U8G_PARAM LCD_PINS_RS // 2 stripes, HW SPI (shared with SD card, on AVR does not use standard LCD adapter) #define U8G_PARAM LCD_PINS_RS
#else #else
//#define U8G_CLASS U8GLIB_ST7920_128X64_4X #if ENABLED(ALTERNATIVE_LCD)
//#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS // Original u8glib device. 2 stripes, SW SPI #define U8G_CLASS U8GLIB_ST7920_128X64_4X // 2 stripes, SW SPI (Original u8glib device)
#define U8G_CLASS U8GLIB_ST7920_128X64_RRD #else
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS // Number of stripes can be adjusted in ultralcd_st7920_u8glib_rrd.h with PAGE_HEIGHT #define U8G_CLASS U8GLIB_ST7920_128X64_RRD // Adjust stripes with PAGE_HEIGHT in ultralcd_st7920_u8glib_rrd.h
// AVR version ignores these pin settings #endif
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS // AVR version ignores these pin settings
// HAL version uses these pin settings // HAL version uses these pin settings
#endif #endif
#elif ENABLED(CARTESIO_UI) #elif ENABLED(CARTESIO_UI)
// The CartesioUI display
//#define U8G_CLASS U8GLIB_DOGM128_2X // CartesioUI LCD
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes
#define U8G_CLASS U8GLIB_DOGM128_2X #if ENABLED(ALTERNATIVE_LCD)
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes #define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes
#define FORCE_SOFT_SPI // SW-SPI
#else
#define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes (HW-SPI)
#endif
#elif ENABLED(U8GLIB_LM6059_AF) #elif ENABLED(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250) // Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
//#define U8G_CLASS U8GLIB_LM6059
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 8 stripes #if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_LM6059_2X #define U8G_CLASS U8GLIB_LM6059 // 8 stripes (HW-SPI)
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes #else
#define U8G_CLASS U8GLIB_LM6059_2X // 4 stripes (HW-SPI)
#endif
#elif ENABLED(U8GLIB_ST7565_64128N) #elif ENABLED(U8GLIB_ST7565_64128N)
// The MaKrPanel, Mini Viki, Viki 2.0 & AZSMZ 12864 ST7565 controller
// MaKrPanel, Mini Viki, Viki 2.0, AZSMZ 12864 ST7565 controller
#define SMART_RAMPS (MB(RAMPS_SMART_EFB) || MB(RAMPS_SMART_EEB) || MB(RAMPS_SMART_EFF) || MB(RAMPS_SMART_EEF) || MB(RAMPS_SMART_SF)) #define SMART_RAMPS (MB(RAMPS_SMART_EFB) || MB(RAMPS_SMART_EEB) || MB(RAMPS_SMART_EFF) || MB(RAMPS_SMART_EEF) || MB(RAMPS_SMART_SF))
#if DOGLCD_SCK == SCK_PIN && DOGLCD_MOSI == MOSI_PIN && !SMART_RAMPS #define U8G_CLASS U8GLIB_64128N_2X_HAL // 4 stripes (HW-SPI)
#define U8G_CLASS U8GLIB_64128N_2X_HAL #if SMART_RAMPS || DOGLCD_SCK != SCK_PIN || DOGLCD_MOSI != MOSI_PIN
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // using HW-SPI #define FORCE_SOFT_SPI // SW-SPI
#else
#define U8G_CLASS U8GLIB_64128N_2X_HAL
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // using SW-SPI
#endif #endif
#elif ENABLED(MKS_12864OLED_SSD1306) #elif ENABLED(MKS_12864OLED_SSD1306)
// MKS 128x64 (SSD1306) OLED I2C LCD // MKS 128x64 (SSD1306) OLED I2C LCD
#define U8G_CLASS U8GLIB_SSD1306_128X64
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 8 stripes #define FORCE_SOFT_SPI // SW-SPI
//#define U8G_CLASS U8GLIB_SSD1306_128X64_2X
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes #if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes
#else
#define U8G_CLASS U8GLIB_SSD1306_128X64 // 8 stripes
#endif
#elif ENABLED(U8GLIB_SSD1306) #elif ENABLED(U8GLIB_SSD1306)
// Generic support for SSD1306 OLED I2C LCDs
//#define U8G_CLASS U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE // Generic SSD1306 OLED I2C LCD
//#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X #if ENABLED(ALTERNATIVE_LCD)
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes #define U8G_CLASS U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE // 4 stripes
#else
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes
#endif
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST)
#elif ENABLED(MKS_12864OLED) #elif ENABLED(MKS_12864OLED)
// MKS 128x64 (SH1106) OLED I2C LCD // MKS 128x64 (SH1106) OLED I2C LCD
#define U8G_CLASS U8GLIB_SH1106_128X64
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 8 stripes #define FORCE_SOFT_SPI // SW-SPI
//#define U8G_CLASS U8GLIB_SH1106_128X64_2X
//#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes #if ENABLED(ALTERNATIVE_LCD)
#elif ENABLED(U8GLIB_SH1106) #define U8G_CLASS U8GLIB_SH1106_128X64_2X // 4 stripes
// Generic support for SH1106 OLED I2C LCDs
//#define U8G_CLASS U8GLIB_SH1106_128X64_2X_I2C_2_WIRE
//#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
#define U8G_CLASS U8GLIB_SH1106_128X64_2X
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // 4 stripes
#elif ENABLED(U8GLIB_SSD1309)
// Generic support for SSD1309 OLED I2C LCDs
#define U8G_CLASS U8GLIB_SSD1309_128X64
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST)
#elif ENABLED(MINIPANEL)
// MINIPanel display
//#define U8G_CLASS U8GLIB_MINI12864
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 8 stripes
#define U8G_CLASS U8GLIB_MINI12864_2X
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 8 stripes
#elif ENABLED(FYSETC_MINI_12864)
// The FYSETC_MINI_12864 display
#define U8G_CLASS U8GLIB_MINI12864_2X_HAL
#if ENABLED(FORCE_SOFT_SPI)
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // 4 stripes SW-SPI
#else #else
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // 4 stripes HW-SPI #define U8G_CLASS U8GLIB_SH1106_128X64 // 8 stripes
#endif #endif
#elif ENABLED(U8GLIB_SH1106)
// Generic SH1106 OLED I2C LCD
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SH1106_128X64_2X_I2C_2_WIRE // 4 stripes
#else
#define U8G_CLASS U8GLIB_SH1106_128X64_2X // 4 stripes
#endif
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // I2C
#elif ENABLED(U8GLIB_SSD1309)
// Generic support for SSD1309 OLED I2C LCDs
#define U8G_CLASS U8GLIB_SSD1309_128X64
#define U8G_PARAM (U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST) // I2C
#elif ENABLED(FYSETC_MINI_12864)
// The FYSETC Mini 12864 display
#define U8G_CLASS U8GLIB_MINI12864_2X_HAL // 4 stripes
#elif ENABLED(MKS_MINI_12864)
// The MKS_MINI_12864 V1/V2 aren't exact copies of the MiniPanel.
// Panel management is in u8g_dev_uc1701_mini12864_HAL.cpp with
// extra delays added to remove glitches seen with fast MCUs.
#define U8G_CLASS U8GLIB_MINI12864_2X_HAL // 8 stripes (HW-SPI)
#elif ENABLED(MINIPANEL)
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_MINI12864
#else
#define U8G_CLASS U8GLIB_MINI12864_2X // 8 stripes (HW-SPI)
#endif
#elif ENABLED(U8GLIB_SH1106_EINSTART) #elif ENABLED(U8GLIB_SH1106_EINSTART)
// Connected via motherboard header // Connected via motherboard header
#define U8G_CLASS U8GLIB_SH1106_128X64 #define U8G_CLASS U8GLIB_SH1106_128X64
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, LCD_PINS_DC, LCD_PINS_RS #define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, LCD_PINS_DC, LCD_PINS_RS
#elif ENABLED(FSMC_GRAPHICAL_TFT) #elif ENABLED(FSMC_GRAPHICAL_TFT)
// Unspecified 320x240 TFT pre-initialized by built-in bootloader // Unspecified 320x240 TFT pre-initialized by built-in bootloader
#define U8G_CLASS U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 #define U8G_CLASS U8GLIB_TFT_320X240_UPSCALE_FROM_128X64
#define U8G_PARAM FSMC_CS_PIN, FSMC_RS_PIN #define U8G_PARAM FSMC_CS_PIN, FSMC_RS_PIN
#else #else
// for regular DOGM128 display with HW-SPI
//#define U8G_CLASS U8GLIB_DOGM128 #if ENABLED(ALTERNATIVE_LCD)
//#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI Com: CS, A0 // 8 stripes #define U8G_CLASS U8GLIB_DOGM128 // 8 stripes (HW-SPI)
#define U8G_CLASS U8GLIB_DOGM128_2X #else
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI Com: CS, A0 // 4 stripes #define U8G_CLASS U8GLIB_DOGM128_2X // 4 stripes (HW-SPI)
#endif
#endif
// Use HW-SPI if no other option is specified
#ifndef U8G_PARAM
#if ENABLED(FORCE_SOFT_SPI)
#define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // SW-SPI
#else
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
#endif
#endif #endif
#ifndef LCD_PIXEL_WIDTH #ifndef LCD_PIXEL_WIDTH

View file

@ -217,7 +217,6 @@
#define DOGLCD_A0 P0_16 #define DOGLCD_A0 P0_16
#define DOGLCD_SCK P0_07 #define DOGLCD_SCK P0_07
#define DOGLCD_MOSI P1_20 #define DOGLCD_MOSI P1_20
#define FORCE_SOFT_SPI
#define LCD_BACKLIGHT_PIN -1 #define LCD_BACKLIGHT_PIN -1