Improve U8G+SPI delay override (#18386)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Jason Smith 2020-06-22 13:27:01 -07:00 committed by GitHub
parent b6cd8b230e
commit 819e48972d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 206 additions and 109 deletions

View File

@ -106,15 +106,9 @@
#elif ENABLED(CR10_STOCKDISPLAY) #elif ENABLED(CR10_STOCKDISPLAY)
#define IS_RRD_FG_SC #define IS_RRD_FG_SC
#ifndef ST7920_DELAY_1 #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#define ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#ifndef ST7920_DELAY_2
#define ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef ST7920_DELAY_3
#define ST7920_DELAY_3 DELAY_NS(125)
#endif
#elif ENABLED(MKS_12864OLED) #elif ENABLED(MKS_12864OLED)

View File

@ -34,19 +34,30 @@
#include "ultralcd_st7920_u8glib_rrd_AVR.h" #include "ultralcd_st7920_u8glib_rrd_AVR.h"
#ifndef ST7920_DELAY_1 #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 #define ST7920_DELAY_1 CPU_ST7920_DELAY_1
#endif #endif
#endif
#ifndef ST7920_DELAY_2 #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 #define ST7920_DELAY_2 CPU_ST7920_DELAY_2
#endif #endif
#endif
#ifndef ST7920_DELAY_3 #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 #define ST7920_DELAY_3 CPU_ST7920_DELAY_3
#endif #endif
#endif
// Optimize this code with -O3 // Optimize this code with -O3
#pragma GCC optimize (3) #pragma GCC optimize (3)
#ifdef ARDUINO_ARCH_STM32F1 #ifdef ARDUINO_ARCH_STM32F1
#define ST7920_DAT(V) !!((V) & 0x80) #define ST7920_DAT(V) !!((V) & 0x80)
#else #else

View File

@ -21,15 +21,6 @@
*/ */
#pragma once #pragma once
/**
* Override default LCD timing for Formbot T-Rex 2+ machines.
* The long LCD cables and the routing near electrically noisy stepper motors
* requires a slightly longer setup and hold time on the signals.
*/
#define BOARD_ST7920_DELAY_1 DELAY_NS(200)
#define BOARD_ST7920_DELAY_2 DELAY_NS(200)
#define BOARD_ST7920_DELAY_3 DELAY_NS(200)
/** /**
* Formbot pin assignments * Formbot pin assignments
*/ */
@ -205,3 +196,15 @@
#define LCD_PINS_D6 27 #define LCD_PINS_D6 27
#define LCD_PINS_D7 29 #define LCD_PINS_D7 29
#endif #endif
#if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(200)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(200)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(200)
#endif
#endif

View File

@ -37,10 +37,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125) #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif #endif
#endif
#include "pins_MELZI.h" #include "pins_MELZI.h"

View File

@ -29,10 +29,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125) #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif #endif
#endif
#include "pins_MELZI.h" #include "pins_MELZI.h"

View File

@ -28,10 +28,16 @@
#define BOARD_INFO_NAME "Melzi (Tronxy)" #define BOARD_INFO_NAME "Melzi (Tronxy)"
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(0) #define BOARD_ST7920_DELAY_1 DELAY_NS(0)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(0) #define BOARD_ST7920_DELAY_3 DELAY_NS(0)
#endif #endif
#endif
#include "pins_MELZI.h" #include "pins_MELZI.h"

View File

@ -24,10 +24,16 @@
#define BOARD_INFO_NAME "Melzi V2" #define BOARD_INFO_NAME "Melzi V2"
#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(0) #define BOARD_ST7920_DELAY_1 DELAY_NS(0)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(188) #define BOARD_ST7920_DELAY_2 DELAY_NS(188)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(0) #define BOARD_ST7920_DELAY_3 DELAY_NS(0)
#endif #endif
#endif
#include "pins_MELZI.h" #include "pins_MELZI.h"

View File

@ -172,6 +172,18 @@
#endif // !FYSETC_MINI_12864 #endif // !FYSETC_MINI_12864
#if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif
#endif
#endif #endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD
@ -203,9 +215,3 @@
#endif #endif
#define ON_BOARD_SPI_DEVICE 1 // SPI1 #define ON_BOARD_SPI_DEVICE 1 // SPI1
#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card
#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif

View File

@ -143,10 +143,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125) #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125) #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125) #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif #endif
#endif
// //
// Camera // Camera

View File

@ -159,10 +159,16 @@
#endif #endif
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(715) #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#endif #endif
#endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD

View File

@ -159,10 +159,16 @@
#endif #endif
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(715) #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#endif #endif
#endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD

View File

@ -111,6 +111,18 @@
#endif // !MKS_MINI_12864 #endif // !MKS_MINI_12864
#if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif
#endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD
// Motor current PWM pins // Motor current PWM pins
@ -129,9 +141,3 @@
#define MISO_PIN P1B4 #define MISO_PIN P1B4
#define MOSI_PIN P1B5 #define MOSI_PIN P1B5
#define SS_PIN PA15 #define SS_PIN PA15
#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(125)
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#define BOARD_ST7920_DELAY_3 DELAY_NS(125)
#endif

View File

@ -237,10 +237,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(600) #define BOARD_ST7920_DELAY_3 DELAY_NS(600)
#endif #endif
#endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD

View File

@ -328,9 +328,10 @@
#define LCD_PINS_ENABLE PG5 #define LCD_PINS_ENABLE PG5
#define LCD_PINS_D4 PG7 #define LCD_PINS_D4 PG7
//#undef ST7920_DELAY_1 // CR10_STOCKDISPLAY default timing is too fast
//#undef ST7920_DELAY_2 #undef BOARD_ST7920_DELAY_1
//#undef ST7920_DELAY_3 #undef BOARD_ST7920_DELAY_2
#undef BOARD_ST7920_DELAY_3
#else #else
@ -377,10 +378,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(600) #define BOARD_ST7920_DELAY_3 DELAY_NS(600)
#endif #endif
#endif
//#define DOGLCD_CS PB12 //#define DOGLCD_CS PB12
//#define DOGLCD_A0 PA8 //#define DOGLCD_A0 PA8

View File

@ -275,11 +275,10 @@
#define LCD_PINS_ENABLE PG7 #define LCD_PINS_ENABLE PG7
#define LCD_PINS_D4 PG3 #define LCD_PINS_D4 PG3
// CR10_Stock Display needs a different delay setting on SKR PRO v1.1, so undef it here. // CR10_STOCKDISPLAY default timing is too fast
// It will be defined again at the #HAS_GRAPHICAL_LCD section below. #undef BOARD_ST7920_DELAY_1
#undef ST7920_DELAY_1 #undef BOARD_ST7920_DELAY_2
#undef ST7920_DELAY_2 #undef BOARD_ST7920_DELAY_3
#undef ST7920_DELAY_3
#elif ENABLED(MKS_MINI_12864) #elif ENABLED(MKS_MINI_12864)
#define DOGLCD_A0 PG6 #define DOGLCD_A0 PG6
@ -328,10 +327,16 @@
// Alter timing for graphical display // Alter timing for graphical display
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(600) #define BOARD_ST7920_DELAY_3 DELAY_NS(600)
#endif #endif
#endif
#endif // HAS_SPI_LCD #endif // HAS_SPI_LCD

View File

@ -191,11 +191,10 @@
#define LCD_PINS_ENABLE PD1 #define LCD_PINS_ENABLE PD1
#define LCD_PINS_D4 PC12 #define LCD_PINS_D4 PC12
// CR10_Stock Display needs a different delay setting on SKR PRO v1.1, so undef it here. // CR10_STOCKDISPLAY default timing is too fast
// It will be defined again at the #HAS_GRAPHICAL_LCD section below. #undef BOARD_ST7920_DELAY_1
#undef ST7920_DELAY_1 #undef BOARD_ST7920_DELAY_2
#undef ST7920_DELAY_2 #undef BOARD_ST7920_DELAY_3
#undef ST7920_DELAY_3
#else #else

View File

@ -185,7 +185,13 @@
// ST7920 Delays // ST7920 Delays
// //
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(715) #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#endif #endif
#endif

View File

@ -173,7 +173,13 @@
// ST7920 Delays // ST7920 Delays
// //
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(715) #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#endif #endif
#endif

View File

@ -170,7 +170,13 @@
// ST7920 Delays // ST7920 Delays
// //
#if HAS_GRAPHICAL_LCD #if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96) #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48) #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(715) #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#endif #endif
#endif

View File

@ -246,7 +246,7 @@
//#define MOSI 22 // 12 B2 ICSP-03 EXP2-05 //#define MOSI 22 // 12 B2 ICSP-03 EXP2-05
//#define MISO 23 // 13 B3 ICSP-06 EXP2-05 //#define MISO 23 // 13 B3 ICSP-06 EXP2-05
// increase delays // Alter timing for graphical display
#define BOARD_ST7920_DELAY_1 DELAY_NS(313) #define BOARD_ST7920_DELAY_1 DELAY_NS(313)
#define BOARD_ST7920_DELAY_2 DELAY_NS(313) #define BOARD_ST7920_DELAY_2 DELAY_NS(313)
#define BOARD_ST7920_DELAY_3 DELAY_NS(313) #define BOARD_ST7920_DELAY_3 DELAY_NS(313)