Skip to content

Commit

Permalink
Lerdge K EEPROM and TFT (#21812)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
sanek88lbl and thinkyhead committed May 15, 2021
1 parent e865cc0 commit 06e965e
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
- mks_robin_pro
- STM32F103RET6_creality
- LERDGEX
- LERDGEK
- mks_robin_nano35

# Put lengthy tests last
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/HAL/shared/eeprom_if_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@
#if ENABLED(I2C_EEPROM)

#include "eeprom_if.h"
#include <Wire.h>

#if ENABLED(SOFT_I2C_EEPROM)
#include <SlowSoftWire.h>
SlowSoftWire Wire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true);
#else
#include <Wire.h>
#endif

void eeprom_init() {
Wire.begin(
#if PINS_EXIST(I2C_SCL, I2C_SDA)
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
#endif
);
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/lcd/tft_io/st7796s.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ static const uint16_t st7796s_init[] = {

static const uint16_t lerdge_st7796s_init[] = {
DATASIZE_8BIT,
ESC_REG(ST7796S_SWRESET), ESC_DELAY(100),
ESC_REG(ST7796S_SLPOUT), ESC_DELAY(20),

ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I
ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II

Expand All @@ -165,7 +168,6 @@ static const uint16_t lerdge_st7796s_init[] = {

ESC_REG(ST7796S_PWR2), 0x0015,
ESC_REG(ST7796S_PWR3), 0x00AF,
ESC_REG(0xC3), 0x0009, // Register not documented in datasheet
ESC_REG(ST7796S_VCMPCTL), 0x0022,
ESC_REG(ST7796S_VCMOST), 0x0000,
ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,
Expand Down
62 changes: 44 additions & 18 deletions Marlin/src/pins/stm32f4/pins_LERDGE_K.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@
#define BOARD_INFO_NAME "Lerdge K"
#define DEFAULT_MACHINE_NAME "LERDGE"

#define I2C_EEPROM
// EEPROM
#if NO_EEPROM_SELECTED
#define I2C_EEPROM
#define SOFT_I2C_EEPROM // Force the use of Software I2C
#define I2C_SCL_PIN PG14
#define I2C_SDA_PIN PG13
#define MARLIN_EEPROM_SIZE 0x10000
#endif

// USB Flash Drive support
#define HAS_OTG_USB_HOST_SUPPORT

//
// Servos
//
//#define SERVO0_PIN PB11
#define SERVO0_PIN PB11

//
// Limit Switches
Expand Down Expand Up @@ -96,6 +103,13 @@
// #define E1_CS_PIN PE4
//#endif

//#define E2_STEP_PIN PF4 // best guess
//#define E2_DIR_PIN PF3 // best guess
//#define E2_ENABLE_PIN PF5 // best guess
//#ifndef E2_CS_PIN
// #define E2_CS_PIN PB2 // best guess
//#endif

#if HAS_TMC_UART
/**
* TMC2208/TMC2209 stepper drivers
Expand Down Expand Up @@ -163,24 +177,30 @@
#ifndef FAN_PIN
#define FAN_PIN PF7
#endif

#define FAN1_PIN PF6
#define FAN2_PIN PF8

#ifndef E0_AUTO_FAN_PIN
#define E0_AUTO_FAN_PIN PF6
#define E0_AUTO_FAN_PIN PB1
#endif

#ifndef E1_AUTO_FAN_PIN
#define E1_AUTO_FAN_PIN PB0
#endif

#define CONTROLLER_FAN_PIN PF8

//
// LED / Lighting
//
//#define CASE_LIGHT_PIN_CI -1
//#define CASE_LIGHT_PIN_DO -1
//#define NEOPIXEL_PIN -1
#ifndef RGB_LED_R_PIN
#define RGB_LED_R_PIN PB7
#define RGB_LED_R_PIN PB8 // swap R and G pin for compatibility with real wires
#endif
#ifndef RGB_LED_G_PIN
#define RGB_LED_G_PIN PB8
#define RGB_LED_G_PIN PB7
#endif
#ifndef RGB_LED_B_PIN
#define RGB_LED_B_PIN PB9
Expand All @@ -197,7 +217,7 @@
//
#define SDSS PC11
#define LED_PIN PA15 // Alive
#define PS_ON_PIN -1
#define PS_ON_PIN PA4
#define KILL_PIN -1
#define POWER_LOSS_PIN PA4 // Power-loss / nAC_FAULT

Expand All @@ -213,17 +233,23 @@
// LCD / Controller
//

#define TFT_RESET_PIN PD6
#define TFT_BACKLIGHT_PIN PD3
#if HAS_FSMC_TFT
//#define TFT_DRIVER LERDGE_ST7796

#define TFT_CS_PIN PD7
#define TFT_RS_PIN PD11
#define TFT_RESET_PIN PD6
#define TFT_BACKLIGHT_PIN PD3

#define TOUCH_CS_PIN PG15
#define TOUCH_SCK_PIN PB3
#define TOUCH_MOSI_PIN PB5
#define TOUCH_MISO_PIN PB4
#define TFT_CS_PIN PD7
#define TFT_RS_PIN PD11

#define BTN_EN1 PG10
#define BTN_EN2 PG11
#define BTN_ENC PG9
#define TOUCH_CS_PIN PG15
#define TOUCH_SCK_PIN PB3
#define TOUCH_MOSI_PIN PB5
#define TOUCH_MISO_PIN PB4
#endif

#if IS_NEWPANEL
#define BTN_EN1 PG10
#define BTN_EN2 PG11
#define BTN_ENC PG9
#endif
18 changes: 18 additions & 0 deletions buildroot/tests/LERDGEK
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# Build tests for LERDGEK environment
#

# exit on first failure
set -e

#
# Build with the typical configuration
#
restore_configs
opt_set MOTHERBOARD BOARD_LERDGE_K SERIAL_PORT 1
opt_enable TFT_GENERIC TFT_INTERFACE_FSMC TFT_COLOR_UI
exec_test $1 $2 "LERDGE K with Generic FSMC TFT with ColorUI" "$3"

# clean up
restore_configs
1 change: 1 addition & 0 deletions ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+<src/HAL/STM32/tft> +<src/H
HAS_FSMC_TFT = src_filter=+<src/HAL/STM32/tft/tft_fsmc.cpp> +<src/HAL/STM32F1/tft/tft_fsmc.cpp>
HAS_SPI_TFT = src_filter=+<src/HAL/STM32/tft/tft_spi.cpp> +<src/HAL/STM32F1/tft/tft_spi.cpp>
I2C_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_i2c.cpp>
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>
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
DWIN_CREALITY_LCD = src_filter=+<src/lcd/dwin>
Expand Down
3 changes: 1 addition & 2 deletions ini/stm32f4.ini
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ build_flags = ${stm_flash_drive.build_flags}
platform = ${lerdge_common.platform}
extends = lerdge_common
board_build.firmware = Lerdge_K_firmware_force.bin
build_flags = ${lerdge_common.build_flags}
-DLERDGEK
build_flags = ${lerdge_common.build_flags} -DLERDGEK

#
# Lerdge K with USB Flash Drive Support
Expand Down

0 comments on commit 06e965e

Please sign in to comment.