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
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 206 additions and 109 deletions

View file

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

View file

@ -34,19 +34,30 @@
#include "ultralcd_st7920_u8glib_rrd_AVR.h"
#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)
#ifdef ARDUINO_ARCH_STM32F1
#define ST7920_DAT(V) !!((V) & 0x80)
#else

View file

@ -21,15 +21,6 @@
*/
#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
*/
@ -205,3 +196,15 @@
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#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,9 +37,15 @@
// Alter timing for graphical display
#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
#include "pins_MELZI.h"

View file

@ -29,9 +29,15 @@
// Alter timing for graphical display
#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
#include "pins_MELZI.h"

View file

@ -28,9 +28,15 @@
#define BOARD_INFO_NAME "Melzi (Tronxy)"
#if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(0)
#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(0)
#endif
#endif
#include "pins_MELZI.h"

View file

@ -24,10 +24,16 @@
#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)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(188)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(0)
#endif
#endif
#include "pins_MELZI.h"

View file

@ -172,6 +172,18 @@
#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 // HAS_SPI_LCD
@ -203,9 +215,3 @@
#endif
#define ON_BOARD_SPI_DEVICE 1 // SPI1
#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,9 +143,15 @@
// Alter timing for graphical display
#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
//

View file

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

View file

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

View file

@ -111,6 +111,18 @@
#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
// Motor current PWM pins
@ -129,9 +141,3 @@
#define MISO_PIN P1B4
#define MOSI_PIN P1B5
#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
#if HAS_GRAPHICAL_LCD
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 DELAY_NS(600)
#endif
#endif
#endif // HAS_SPI_LCD

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -246,7 +246,7 @@
//#define MOSI 22 // 12 B2 ICSP-03 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_2 DELAY_NS(313)
#define BOARD_ST7920_DELAY_3 DELAY_NS(313)