Skip to content

Commit

Permalink
♻️ Begin LCD pins migration
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jan 22, 2024
1 parent 22fc07d commit 0994345
Show file tree
Hide file tree
Showing 84 changed files with 1,886 additions and 1,197 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/HAL_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// Public functions
// ------------------------

#if ANY(DUE_SOFTWARE_SPI, FORCE_SOFT_SPI)
#if ANY(SOFTWARE_SPI, FORCE_SOFT_SPI)

// ------------------------
// Software SPI
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@

#if HAS_MEDIA && HAS_DRIVER(TMC2130)
#if ENABLED(TMC_USE_SW_SPI)
#if DISABLED(DUE_SOFTWARE_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK))
#if DISABLED(SOFTWARE_SPI) && (_IS_HW_SPI(MOSI) || _IS_HW_SPI(MISO) || _IS_HW_SPI(SCK))
#error "DUE hardware SPI is required but is incompatible with TMC2130 software SPI. Either disable TMC_USE_SW_SPI or use separate pins for the two SPIs."
#endif
#elif ENABLED(DUE_SOFTWARE_SPI)
#elif ENABLED(SOFTWARE_SPI)
#error "DUE software SPI is required but is incompatible with TMC2130 hardware SPI. Enable TMC_USE_SW_SPI to fix."
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#define SD_MOSI_PIN 75
#else
// defaults
#define DUE_SOFTWARE_SPI
#define SOFTWARE_SPI
#ifndef SD_SCK_PIN
#define SD_SCK_PIN 52
#endif
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/HAL/LINUX/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
*/
#pragma once

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

#if ALL(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/HAL/LPC1768/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
*/
#pragma once

#include "../../core/macros.h"

#if ALL(HAS_MEDIA, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#if ALL(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
// This requirement can be removed if the SPI access to these devices is updated to use
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/HAL/NATIVE_SIM/spi_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
*/
#pragma once

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

#if ALL(HAS_MARLINUI_U8GLIB, HAS_MEDIA) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_EN == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN)
#define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently
// needed due to the speed and mode required for communicating with each device being different.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ inline void tmc_standby_setup() {
* - Init the buzzer, possibly a custom timer
* - Init more optional hardware:
* • Color LED illumination
* • Neopixel illumination
* • NeoPixel illumination
* • Controller Fan
* • Creality DWIN LCD (show boot image)
* • Tare the Probe if possible
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
#define MKS_MINI_12864
#endif

// MKS_MINI_12864_V3 , BTT_MINI_12864 and BEEZ_MINI_12864 have identical pinouts to FYSETC_MINI_12864_2_1
// MKS_MINI_12864_V3 , BTT_MINI_12864 and BEEZ_MINI_12864 are nearly identical to FYSETC_MINI_12864_2_1
#if ANY(MKS_MINI_12864_V3, BTT_MINI_12864, BEEZ_MINI_12864)
#define FYSETC_MINI_12864_2_1
#endif
Expand Down
12 changes: 0 additions & 12 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3215,18 +3215,6 @@
#undef SOUND_ON_DEFAULT
#endif

/**
* Make sure DOGLCD_SCK and DOGLCD_MOSI are defined.
*/
#if HAS_MARLINUI_U8GLIB
#ifndef DOGLCD_SCK
#define DOGLCD_SCK SD_SCK_PIN
#endif
#ifndef DOGLCD_MOSI
#define DOGLCD_MOSI SD_MOSI_PIN
#endif
#endif

/**
* Z_CLEARANCE_FOR_HOMING / Z_CLEARANCE_BETWEEN_PROBES
*/
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/lcd/dogm/marlinui_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ void MarlinUI::init_lcd() {

#if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED, K3D_242_OLED_CONTROLLER)
SET_OUTPUT(LCD_PINS_DC);
#ifndef LCD_RESET_PIN
#define LCD_RESET_PIN LCD_PINS_RS
#endif
#endif

#if PIN_EXISTS(LCD_RESET)
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/lcd/dogm/marlinui_DOGM.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@
#ifdef __SAMD21__
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#else
// Hardware SPI on DUE
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
#endif
#define U8G_PARAM LCD_PINS_RS
#elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN)
// Hardware SPI shared with SD Card
#define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL
#define U8G_PARAM LCD_PINS_RS
#else
// Software SPI
#define U8G_CLASS U8GLIB_ST7920_128X64_4X
#define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS
#endif
Expand Down Expand Up @@ -97,7 +100,7 @@
#define SMART_RAMPS MB(RAMPS_SMART_EFB, RAMPS_SMART_EEB, RAMPS_SMART_EFF, RAMPS_SMART_EEF, RAMPS_SMART_SF)
#define U8G_CLASS U8GLIB_64128N_2X_HAL // 4 stripes (HW-SPI)

#if (SMART_RAMPS && defined(__SAM3X8E__)) || DOGLCD_SCK != SD_SCK_PIN || DOGLCD_MOSI != SD_MOSI_PIN
#if (SMART_RAMPS && defined(__SAM3X8E__)) || (defined(DOGLCD_SCK) && (DOGLCD_SCK != -1 && DOGLCD_SCK != SD_SCK_PIN)) || (defined(DOGLCD_MOSI) && (DOGLCD_MOSI != -1 && DOGLCD_MOSI != SD_MOSI_PIN))
#define FORCE_SOFT_SPI // SW-SPI
#endif

Expand Down Expand Up @@ -230,7 +233,7 @@
#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
#define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ void MarlinSettings::postprocess() {
if (oldpos != current_position)
report_current_position();

// Moved as last update due to interference with Neopixel init
// Moved as last update due to interference with NeoPixel init
TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast());
TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness());
TERN_(HAS_BACKLIGHT_TIMEOUT, ui.refresh_backlight_timeout());
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/esp32/pins_ENWI_ESPNP.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@

// #define FAN_SOFT_PWM_REQUIRED // check if needed

// Neopixel Rings
#define NEOPIXEL_PIN 14
// NeoPixel Rings
#define BOARD_NEOPIXEL_PIN 14
#define NEOPIXEL2_PIN 27

// SPI
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/pins/esp32/pins_MKS_TINYBEE.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
* ------ ------
* (BEEPER) 149 | 1 2 | 13 (BTN_ENC) (SPI MISO) 19 | 1 2 | 18 (SPI SCK)
* (LCD_EN) 21 | 3 4 | 4 (LCD_RS) (BTN_EN1) 14 | 3 4 | 5 (SPI CS)
* (LCD_D4) 0 5 6 | 16 (LCD_D5) (BTN_EN2) 12 5 6 | 23 (SPI MOSI)
* (LCD_D4) 0 | 5 6 16 (LCD_D5) (BTN_EN2) 12 | 5 6 23 (SPI MOSI)
* (LCD_D6) 15 | 7 8 | 17 (LCD_D7) (SPI_DET) 34 | 7 8 | RESET
* GND | 9 10 | 5V GND | 9 10 | 3.3V
* ------ ------
Expand Down Expand Up @@ -159,6 +159,8 @@
//#define SD_MOSI_PIN EXP2_06_PIN // uses esp32 default 23
//#define SD_MISO_PIN EXP2_01_PIN // uses esp32 default 19
//#define SD_SCK_PIN EXP2_02_PIN // uses esp32 default 18

// TODO: Migrate external SD Card to pins/lcd
#define SDSS EXP2_04_PIN
#define SD_DETECT_PIN EXP2_07_PIN // IO34 default is SD_DET signal (Jump to SDDET)
#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/esp32/pins_PANDA_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
* (EN1) 33 | 3 4 | (5 SDSS?) (EN) 26 | 3 4 | 27 (RS)
* (EN2) 32 5 6 | (23 MOSI?) (D4) 14 | 5 6 --
* (SDDET 2?) | 7 8 | (RESET) -- | 7 8 | --
* -- | 9 10 | -- (GND) | 9 10 | (5V)
* -- | 9 10 | -- GND | 9 10 | 5V
* ------ ------
* EXP2 EXP1
*/
Expand Down
Loading

0 comments on commit 0994345

Please sign in to comment.