Skip to content

Commit

Permalink
Improve U8G+SPI delay override (MarlinFirmware#18386)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
  • Loading branch information
2 people authored and HairingX committed Jun 16, 2021
1 parent 2f2da88 commit a5a884b
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 109 deletions.
12 changes: 3 additions & 9 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 15 additions & 4 deletions Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,30 @@
#include "ultralcd_st7920_u8glib_rrd_AVR.h"

#ifndef ST7920_DELAY_1
#define ST7920_DELAY_1 CPU_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
#define ST7920_DELAY_2 CPU_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
#define ST7920_DELAY_3 CPU_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
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/pins/mega/pins_PICA.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
//
// Servos
//
#define SERVO0_PIN 3
#define SERVO1_PIN 4
#define SERVO2_PIN 5
#define SERVO0_PIN 3
#define SERVO1_PIN 4
#define SERVO2_PIN 5
//
// Limit Switches
//
Expand Down
21 changes: 12 additions & 9 deletions Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
12 changes: 9 additions & 3 deletions Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@

// Alter timing for graphical display
#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)
#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"
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@

// Alter timing for graphical display
#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)
#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"
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@
#define BOARD_INFO_NAME "Melzi (Tronxy)"

#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(0)
#define BOARD_ST7920_DELAY_2 DELAY_NS(125)
#define BOARD_ST7920_DELAY_3 DELAY_NS(0)
#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"
Expand Down
14 changes: 10 additions & 4 deletions Marlin/src/pins/sanguino/pins_MELZI_V2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@

#define BOARD_INFO_NAME "Melzi V2"

#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#define BOARD_ST7920_DELAY_1 DELAY_NS(0)
#define BOARD_ST7920_DELAY_2 DELAY_NS(188)
#define BOARD_ST7920_DELAY_3 DELAY_NS(0)
#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"
30 changes: 18 additions & 12 deletions Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,27 @@

#else // !FYSETC_MINI_12864

#define LCD_PINS_D4 PC13
#if ENABLED(ULTIPANEL)
#define LCD_PINS_D5 PB7
#define LCD_PINS_D6 PC15
#define LCD_PINS_D7 PC14
#endif
#define LCD_PINS_D4 PC13
#if ENABLED(ULTIPANEL)
#define LCD_PINS_D5 PB7
#define LCD_PINS_D6 PC15
#define LCD_PINS_D7 PC14
#endif

#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
Expand Down Expand Up @@ -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
16 changes: 11 additions & 5 deletions Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
//
#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION)
#define FLASH_EEPROM_EMULATION
#define EEPROM_PAGE_SIZE 0x800U // 2KB
#define EEPROM_PAGE_SIZE 0x800U // 2KB
#define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL)
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#endif

//
Expand Down Expand Up @@ -143,9 +143,15 @@

// Alter timing for graphical display
#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)
#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

//
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
// SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h)
#define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE)
#define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB)
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
#else
#define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM
#define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM
#endif

//
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
// SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h)
#define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE)
#define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB)
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE
#else
#define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM
#define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM
#endif

//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
#define SD_DETECT_PIN PC7
#define SDCARD_CONNECTION ONBOARD
#define ON_BOARD_SPI_DEVICE 1
#define ONBOARD_SD_CS_PIN PA4 // SDSS
#define ONBOARD_SD_CS_PIN PA4 // SDSS
#define SDIO_SUPPORT

#if ENABLED(RET6_12864_LCD)
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/pins/stm32f1/pins_GTM32_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@
#endif

#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#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
Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@
#endif

#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#define BOARD_ST7920_DELAY_3 DELAY_NS(715)
#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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define FLASH_EEPROM_EMULATION
#define EEPROM_PAGE_SIZE (0x800U) // 2KB
#define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL)
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB
#endif

//
Expand Down
18 changes: 12 additions & 6 deletions Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 9 additions & 3 deletions Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,15 @@

// Alter timing for graphical display
#if HAS_GRAPHICAL_LCD
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
#define BOARD_ST7920_DELAY_3 DELAY_NS(600)
#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
Expand Down
Loading

0 comments on commit a5a884b

Please sign in to comment.