From 7249e2103b11640e1985fc34990d79a3421c7858 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 5 Sep 2021 16:53:04 -0500 Subject: [PATCH] Save labor on doc rewriting --- .../dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 7b6e73a3ba5b..7e3b9ea761cf 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -46,7 +46,11 @@ #ifndef CPU_ST7920_DELAY_1 #define BOARD_ST7920_DELAY_1 0 #endif - #define ST7920_DELAY_1 _MAX(BOARD_ST7920_DELAY_1, CPU_ST7920_DELAY_1, LCD_ST7920_DELAY_1) + #if BOARD_ST7920_DELAY_1 || CPU_ST7920_DELAY_1 || LCD_ST7920_DELAY_1 + #define ST7920_DELAY_1 DELAY_NS(_MAX(BOARD_ST7920_DELAY_1, CPU_ST7920_DELAY_1, LCD_ST7920_DELAY_1)) + #else + #define ST7920_DELAY_1 + #endif #endif #ifndef ST7920_DELAY_2 #ifndef LCD_ST7920_DELAY_2 @@ -58,7 +62,11 @@ #ifndef CPU_ST7920_DELAY_2 #define BOARD_ST7920_DELAY_2 0 #endif - #define ST7920_DELAY_2 _MAX(BOARD_ST7920_DELAY_2, CPU_ST7920_DELAY_2, LCD_ST7920_DELAY_2) + #if BOARD_ST7920_DELAY_2 || CPU_ST7920_DELAY_2 || LCD_ST7920_DELAY_2 + #define ST7920_DELAY_2 DELAY_NS(_MAX(BOARD_ST7920_DELAY_2, CPU_ST7920_DELAY_2, LCD_ST7920_DELAY_2)) + #else + #define ST7920_DELAY_2 + #endif #endif #ifndef ST7920_DELAY_3 #ifndef LCD_ST7920_DELAY_3 @@ -70,7 +78,11 @@ #ifndef CPU_ST7920_DELAY_3 #define BOARD_ST7920_DELAY_3 0 #endif - #define ST7920_DELAY_3 _MAX(BOARD_ST7920_DELAY_3, CPU_ST7920_DELAY_3, LCD_ST7920_DELAY_3) + #if BOARD_ST7920_DELAY_3 || CPU_ST7920_DELAY_3 || LCD_ST7920_DELAY_3 + #define ST7920_DELAY_3 DELAY_NS(_MAX(BOARD_ST7920_DELAY_3, CPU_ST7920_DELAY_3, LCD_ST7920_DELAY_3)) + #else + #define ST7920_DELAY_3 + #endif #endif #ifdef ARDUINO_ARCH_STM32F1 @@ -80,9 +92,9 @@ #endif #define ST7920_SND_BIT do{ \ - WRITE(ST7920_CLK_PIN, LOW); DELAY_NS(ST7920_DELAY_1); \ - WRITE(ST7920_DAT_PIN, ST7920_DAT(val)); DELAY_NS(ST7920_DELAY_2); \ - WRITE(ST7920_CLK_PIN, HIGH); DELAY_NS(ST7920_DELAY_3); \ + WRITE(ST7920_CLK_PIN, LOW); ST7920_DELAY_1; \ + WRITE(ST7920_DAT_PIN, ST7920_DAT(val)); ST7920_DELAY_2; \ + WRITE(ST7920_CLK_PIN, HIGH); ST7920_DELAY_3; \ val <<= 1; }while(0) // Optimize this code with -O3