Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply EXP headers, improve ST7920 delay defaults #22641

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Marlin/src/HAL/AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
#include <avr/interrupt.h>
#include <avr/io.h>

//
// Default graphical display delays
//
#if F_CPU >= 20000000
#define CPU_ST7920_DELAY_1 DELAY_NS(150)
#define CPU_ST7920_DELAY_2 DELAY_NS( 0)
#define CPU_ST7920_DELAY_3 DELAY_NS(150)
#elif F_CPU == 16000000
#define CPU_ST7920_DELAY_1 DELAY_NS(125)
#define CPU_ST7920_DELAY_2 DELAY_NS( 0)
#define CPU_ST7920_DELAY_3 DELAY_NS(188)
#endif

#ifndef pgm_read_ptr
// Compatibility for avr-libc 1.8.0-4.1 included with Ubuntu for
// Windows Subsystem for Linux on Windows 10 as of 10/18/2019
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/LINUX/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ uint8_t _getc();
extern MSerialT usb_serial;
#define MYSERIAL1 usb_serial

#define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750)
#define ST7920_DELAY_3 DELAY_NS(750)
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

//
// Interrupts
Expand Down
12 changes: 3 additions & 9 deletions Marlin/src/HAL/LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ extern "C" volatile uint32_t _millis;
//
// Default graphical display delays
//
#ifndef ST7920_DELAY_1
#define ST7920_DELAY_1 DELAY_NS(600)
#endif
#ifndef ST7920_DELAY_2
#define ST7920_DELAY_2 DELAY_NS(750)
#endif
#ifndef ST7920_DELAY_3
#define ST7920_DELAY_3 DELAY_NS(750)
#endif
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1;
extern DefaultSerial1 USBSerial;
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/NATIVE_SIM/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ extern MSerialT serial_stream_3;
#endif


#define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750)
#define ST7920_DELAY_3 DELAY_NS(750)
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

//
// Interrupts
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/HAL/STM32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@

#include <stdint.h>

//
// Default graphical display delays
//
#define CPU_ST7920_DELAY_1 DELAY_NS(300)
#define CPU_ST7920_DELAY_2 DELAY_NS( 40)
#define CPU_ST7920_DELAY_3 DELAY_NS(340)

//
// Serial Ports
//
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/HAL/STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
// Defines
// ------------------------

//
// Default graphical display delays
//
#define CPU_ST7920_DELAY_1 DELAY_NS(300)
#define CPU_ST7920_DELAY_2 DELAY_NS( 40)
#define CPU_ST7920_DELAY_3 DELAY_NS(340)

#ifndef STM32_FLASH_SIZE
#if ANY(MCU_STM32F103RE, MCU_STM32F103VE, MCU_STM32F103ZE)
#define STM32_FLASH_SIZE 512
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/TEENSY31_32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

#include <stdint.h>

#define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750)
#define ST7920_DELAY_3 DELAY_NS(750)
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

//#undef MOTHERBOARD
//#define MOTHERBOARD BOARD_TEENSY31_32
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/TEENSY35_36/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#include <stdint.h>
#include <util/atomic.h>

#define ST7920_DELAY_1 DELAY_NS(600)
#define ST7920_DELAY_2 DELAY_NS(750)
#define ST7920_DELAY_3 DELAY_NS(750)
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

// ------------------------
// Defines
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/TEENSY40_41/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
#include "../../feature/ethernet.h"
#endif

//#define ST7920_DELAY_1 DELAY_NS(600)
//#define ST7920_DELAY_2 DELAY_NS(750)
//#define ST7920_DELAY_3 DELAY_NS(750)
#define CPU_ST7920_DELAY_1 DELAY_NS(600)
#define CPU_ST7920_DELAY_2 DELAY_NS(750)
#define CPU_ST7920_DELAY_3 DELAY_NS(750)

// ------------------------
// Defines
Expand Down
15 changes: 11 additions & 4 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,18 @@
#elif ENABLED(CR10_STOCKDISPLAY)

#define IS_RRD_FG_SC 1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#define LCD_ST7920_DELAY_1 DELAY_NS(125)
#define LCD_ST7920_DELAY_2 DELAY_NS(125)
#define LCD_ST7920_DELAY_3 DELAY_NS(125)

#elif ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, ANET_FULL_GRAPHICS_LCD, ANET_FULL_GRAPHICS_LCD_ALT_WIRING, BQ_LCD_SMART_CONTROLLER, K3D_FULL_GRAPHIC_SMART_CONTROLLER)
#elif ENABLED(ANET_FULL_GRAPHICS_LCD, ANET_FULL_GRAPHICS_LCD_ALT_WIRING)

#define IS_RRD_FG_SC 1
#define LCD_ST7920_DELAY_1 DELAY_NS(150)
#define LCD_ST7920_DELAY_2 DELAY_NS(150)
#define LCD_ST7920_DELAY_3 DELAY_NS(150)

#elif ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, BQ_LCD_SMART_CONTROLLER, K3D_FULL_GRAPHIC_SMART_CONTROLLER)

#define IS_RRD_FG_SC 1

Expand Down
54 changes: 0 additions & 54 deletions Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,60 +33,6 @@

#include "ultralcd_st7920_u8glib_rrd_AVR.h"

#if F_CPU >= 20000000
#define CPU_ST7920_DELAY_1 DELAY_NS(150)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(150)
#elif MB(3DRAG, K8200, K8400)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(188)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(MINIRAMBO, EINSY_RAMBO, EINSY_RETRO, SILVER_GATE)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(250)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(RAMBO)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
#elif MB(BQ_ZUM_MEGA_3D)
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(189)
#elif defined(ARDUINO_ARCH_STM32)
#define CPU_ST7920_DELAY_1 DELAY_NS(300)
#define CPU_ST7920_DELAY_2 DELAY_NS(40)
#define CPU_ST7920_DELAY_3 DELAY_NS(340)
#elif F_CPU == 16000000
#define CPU_ST7920_DELAY_1 DELAY_NS(125)
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
#define CPU_ST7920_DELAY_3 DELAY_NS(188)
#else
#error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
#endif

#ifndef ST7920_DELAY_1
#ifdef BOARD_ST7920_DELAY_1
#define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
#else
#define ST7920_DELAY_1 CPU_ST7920_DELAY_1
#endif
#endif
#ifndef ST7920_DELAY_2
#ifdef BOARD_ST7920_DELAY_2
#define ST7920_DELAY_2 BOARD_ST7920_DELAY_2
#else
#define ST7920_DELAY_2 CPU_ST7920_DELAY_2
#endif
#endif
#ifndef ST7920_DELAY_3
#ifdef BOARD_ST7920_DELAY_3
#define ST7920_DELAY_3 BOARD_ST7920_DELAY_3
#else
#define ST7920_DELAY_3 CPU_ST7920_DELAY_3
#endif
#endif

// Optimize this code with -O3
#pragma GCC optimize (3)

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/esp32/pins_MRR_ESPE.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
// LCDs and Controllers //
//////////////////////////

#if HAS_MARLINUI_U8GLIB
#if HAS_WIRED_LCD

#define LCD_PINS_RS 13
#define LCD_PINS_ENABLE 17
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
* ------ ------
* EXP2 EXP1
*/

#define EXP1_03_PIN -1
#define EXP1_04_PIN -1
#define EXP1_05_PIN -1
Expand Down
17 changes: 8 additions & 9 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@
#endif

/**
* ------ ------
* NC | 1 2 | GND 5V | 1 2 | GND
* RESET | 3 4 | 1.31 (SD_DETECT) (LCD_D7) 1.23 | 3 4 | 1.22 (LCD_D6)
* (MOSI) 0.18 | 5 6 3.25 (BTN_EN2) (LCD_D5) 1.21 | 5 6 1.20 (LCD_D4)
* (SD_SS) 0.16 | 7 8 | 3.26 (BTN_EN1) (LCD_RS) 1.19 | 7 8 | 1.18 (LCD_EN)
* (SCK) 0.15 | 9 10 | 0.17 (MISO) (BTN_ENC) 0.28 | 9 10 | 1.30 (BEEPER)
* ------ ------
* EXP2 EXP1
* ------ ------
* (BEEPER) 1.30 |10 9 | 0.28 (BTN_ENC) (MISO) 0.17 |10 9 | 0.15 (SCK)
* (LCD_EN) 1.18 | 8 7 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 8 7 | 0.16 (SD_SS)
* (LCD_D4) 1.20 6 5 | 1.21 (LCD_D5) (BTN_EN2) 3.25 6 5 | 0.18 (MOSI)
* (LCD_D6) 1.22 | 4 3 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 4 3 | RESET
* GND | 2 1 | 5V GND | 2 1 | NC
* ------ ------
* EXP1 EXP2
*/

#define EXP1_03_PIN P1_23
#define EXP1_04_PIN P1_22
#define EXP1_05_PIN P1_21
Expand Down
19 changes: 9 additions & 10 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,15 @@
#define TMC_BAUD_RATE 19200
#endif

/** ------ ------
* NC | 1 2 | GND 5V | 1 2 | GND
* RESET | 3 4 | 1.31 1.23 | 3 4 | 1.22
* 0.18 | 5 6 3.25 1.21 | 5 6 1.20
* 0.16 | 7 8 | 3.26 1.19 | 7 8 | 1.18
* 0.15 | 9 10| 0.17 0.28 | 9 10| 1.30
* ------ ------
* EXP2 EXP1
/** ------ ------
* 1.30 |10 9 | 0.28 0.17 |10 9 | 0.15
* 1.18 | 8 7 | 1.19 3.26 | 8 7 | 0.16
* 1.20 6 5 | 1.21 3.25 6 5 | 0.18
* 1.22 | 4 3 | 1.23 1.31 | 4 3 | RESET
* GND | 2 1 | 5V GND | 2 1 | NC
* ------ ------
* EXP1 EXP2
*/

#define EXP1_03_PIN P1_23
#define EXP1_04_PIN P1_22
#define EXP1_05_PIN P1_21
Expand All @@ -258,7 +257,7 @@
#define EXP1_09_PIN P0_28
#define EXP1_10_PIN P1_30

#define EXP2_03_PIN -1
#define EXP2_03_PIN -1 // RESET
#define EXP2_04_PIN P1_31
#define EXP2_05_PIN P0_18
#define EXP2_06_PIN P3_25
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@
* ------ ------
* EXP1 EXP2
*/

#define EXP1_03_PIN P1_22
#define EXP1_04_PIN P1_00
#define EXP1_05_PIN P0_17
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
* ------
* EXP
*/

#define EXP1_03_PIN P0_18
#define EXP1_04_PIN P0_17
#define EXP1_05_PIN P0_15
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/mega/pins_OVERLORD.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
//
// LCD / Controller
//
#if HAS_MARLINUI_U8GLIB
#if HAS_WIRED_LCD
// OVERLORD OLED pins
#define LCD_PINS_RS 20
#define LCD_PINS_D5 21
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/pins/mega/pins_SILVER_GATE.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#define HEATER_BED_PIN 8
#define TEMP_BED_PIN 6

#if HAS_MARLINUI_U8GLIB
#if HAS_WIRED_LCD
#if ENABLED(U8GLIB_ST7920) // SPI GLCD 12864 ST7920
#define LCD_PINS_RS 30
#define LCD_PINS_ENABLE 20
Expand All @@ -86,6 +86,9 @@
#define KILL_PIN 21
#define HOME_PIN 28
#endif
#define BOARD_ST7920_DELAY_1 DELAY_NS( 0)
#define BOARD_ST7920_DELAY_2 DELAY_NS(250)
#define BOARD_ST7920_DELAY_3 DELAY_NS( 0)
#endif
#endif

Expand Down
38 changes: 31 additions & 7 deletions Marlin/src/pins/pins_postprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -1221,23 +1221,47 @@
//
// Default DOGLCD SPI delays
//
#if HAS_MARLINUI_U8GLIB
#if !defined(ST7920_DELAY_1) && defined(BOARD_ST7920_DELAY_1)
#define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
#if ENABLED(U8GLIB_ST7920)
#ifndef ST7920_DELAY_1
#ifdef LCD_ST7920_DELAY_1
#define ST7920_DELAY_1 LCD_ST7920_DELAY_1
#elif defined(BOARD_ST7920_DELAY_1)
#define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
#elif defined(CPU_ST7920_DELAY_1)
#define ST7920_DELAY_1 CPU_ST7920_DELAY_1
#endif
#endif
#if !defined(ST7920_DELAY_2) && defined(BOARD_ST7920_DELAY_2)
#define ST7920_DELAY_2 BOARD_ST7920_DELAY_2
#ifndef ST7920_DELAY_2
#ifdef LCD_ST7920_DELAY_2
#define ST7920_DELAY_2 LCD_ST7920_DELAY_2
#elif defined(BOARD_ST7920_DELAY_2)
#define ST7920_DELAY_2 BOARD_ST7920_DELAY_2
#elif defined(CPU_ST7920_DELAY_2)
#define ST7920_DELAY_2 CPU_ST7920_DELAY_2
#endif
#endif
#if !defined(ST7920_DELAY_3) && defined(BOARD_ST7920_DELAY_3)
#define ST7920_DELAY_3 BOARD_ST7920_DELAY_3
#ifndef ST7920_DELAY_3
#ifdef LCD_ST7920_DELAY_3
#define ST7920_DELAY_3 LCD_ST7920_DELAY_3
#elif defined(BOARD_ST7920_DELAY_3)
#define ST7920_DELAY_3 BOARD_ST7920_DELAY_3
#elif defined(CPU_ST7920_DELAY_3)
#define ST7920_DELAY_3 CPU_ST7920_DELAY_3
#endif
#endif
#else
#undef ST7920_DELAY_1
#undef ST7920_DELAY_2
#undef ST7920_DELAY_3
#undef LCD_ST7920_DELAY_1
#undef LCD_ST7920_DELAY_2
#undef LCD_ST7920_DELAY_3
#undef BOARD_ST7920_DELAY_1
#undef BOARD_ST7920_DELAY_2
#undef BOARD_ST7920_DELAY_3
#undef CPU_ST7920_DELAY_1
#undef CPU_ST7920_DELAY_2
#undef CPU_ST7920_DELAY_3
#endif

#if !NEED_CASE_LIGHT_PIN
Expand Down
Loading