-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
[FR] Support TFT SPI screens on STM32H7 platform #25046
Comments
@vovodroid, will you be able to test various development versions of code? |
No, I don't have STM32H7 boards, but it would good to have compiled code ready. |
@jmz52 I have a BTT SKR 3 and a Makerbase MKS TS35 3.5 V2 (SPI interface) and would be able to do some testing. |
@ellensp Which screen do you use now with SKR 3? |
@vovodroid none, I only got it a few days ago, not in use yet. Thus can be used for testing for a while. |
Ditto. I also have a Biqu SE Plus with the BTT TFT35 SPI TFT ( On a related note, the BTT SPI screen is not for sale as a standalone product currently, so it’d be a really limited upgrade path/combo when used on the SE Plus with an SKR 3. Since MKS sells their SPI TFT as a standalone product at retail, this FR would still make sense to get working On H7 mcus. |
I want to work on this, too. Not sure how generic my implementation is but I am willing to read the docs and get a really good one done. Do you guys want to work on this together instead of everyone getting their own hands into it? |
Code is ready for testing - https://github.com/jmz52/Marlin/tree/H7-wip TFT SPI code works fine, but touch screen support was not tested beyond mere compilation. |
I changed the motherboard to I hooked up an MKS TS35 V2.0 ( |
Just in case - have you updated TFT and touch pins definitions for MKS TS35? |
I commented out #if ENABLED(MKS_TS35_V2_0)
#define TFT_CS_PIN EXP1_07_PIN
#define TFT_SCK_PIN EXP2_02_PIN
#define TFT_MISO_PIN EXP2_01_PIN
#define TFT_MOSI_PIN EXP2_06_PIN
#define TFT_DC_PIN EXP1_08_PIN
#define TFT_A0_PIN TFT_DC_PIN
#define TFT_RESET_PIN EXP1_04_PIN
#define LCD_BACKLIGHT_PIN EXP1_03_PIN
#define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN
#define TOUCH_BUTTONS_HW_SPI
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
#ifndef TFT_WIDTH
#define TFT_WIDTH 480
#endif
#ifndef TFT_HEIGHT
#define TFT_HEIGHT 320
#endif
#define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
#define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
#define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO
#define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI
#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI
#define TFT_BUFFER_SIZE 14400
#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X -17253
#endif
#ifndef TOUCH_CALIBRATION_Y
#define TOUCH_CALIBRATION_Y 11579
#endif
#ifndef TOUCH_OFFSET_X
#define TOUCH_OFFSET_X 514
#endif
#ifndef TOUCH_OFFSET_Y
#define TOUCH_OFFSET_Y -24
#endif
#ifndef TOUCH_ORIENTATION
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#endif
#endif
Yup. I'm quite familiar with this issue since it causes a lot of headaches in Marlin's EXP1/2 numbering 🙂 Most of my EXP cables have the tabs shaved off because of it. |
@thisiskeithb, please check following configuration: |
Shouldn't that be set via conditionals when Marlin/Marlin/src/inc/Conditionals_LCD.h Lines 1474 to 1478 in ef3f484
I defined it anyway and updated |
The are a bit different. As I've found the H7 driver detection code only worked in half-duplex SPI (used by ST7735) but it hangs in full-duplex mode. With updated code my TS35 is now displays proper UI, but touch is not working. This could be either code issue or wiring mess issue. Update |
Success! We'll have to tweak some pins files to differentiate between Touch also worked on the |
@jmz52: Other than refactoring / fixing the |
I was waiting for #25359 to avoid conflicts in initialization section |
Please retest code from new branch - https://github.com/jmz52/Marlin/tree/stm32h7-tft-spi |
Paired with my to-be-submitted PR to split up the
Here's the expand me:
diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h
index 09b305f..38f3b1e 100644
--- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h
+++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h
@@ -455,6 +455,92 @@
#define BTN_EN1 EXP2_03_PIN
#define BTN_EN2 EXP2_05_PIN
+ #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI
+
+ #define TFT_SCK_PIN EXP2_02_PIN
+ #define TFT_MISO_PIN EXP2_01_PIN
+ #define TFT_MOSI_PIN EXP2_06_PIN
+
+ #define BTN_EN1 EXP2_03_PIN
+ #define BTN_EN2 EXP2_05_PIN
+
+ #ifndef TFT_WIDTH
+ #define TFT_WIDTH 480
+ #endif
+ #ifndef TFT_HEIGHT
+ #define TFT_HEIGHT 320
+ #endif
+
+ #if ENABLED(BTT_TFT35_SPI_V1_0)
+
+ #define TFT_CS_PIN EXP2_04_PIN
+ #define TFT_DC_PIN EXP2_07_PIN
+ #define TFT_A0_PIN TFT_DC_PIN
+
+ #define TOUCH_INT_PIN EXP1_07_PIN
+ #define TOUCH_MISO_PIN EXP1_06_PIN
+ #define TOUCH_MOSI_PIN EXP1_03_PIN
+ #define TOUCH_SCK_PIN EXP1_05_PIN
+ #define TOUCH_CS_PIN EXP1_04_PIN
+
+ #ifndef TOUCH_CALIBRATION_X
+ #define TOUCH_CALIBRATION_X 17540
+ #endif
+ #ifndef TOUCH_CALIBRATION_Y
+ #define TOUCH_CALIBRATION_Y -11388
+ #endif
+ #ifndef TOUCH_OFFSET_X
+ #define TOUCH_OFFSET_X -21
+ #endif
+ #ifndef TOUCH_OFFSET_Y
+ #define TOUCH_OFFSET_Y 337
+ #endif
+ #ifndef TOUCH_ORIENTATION
+ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
+ #endif
+
+ #elif ENABLED(MKS_TS35_V2_0)
+
+ #define TFT_CS_PIN EXP1_07_PIN
+ #define TFT_DC_PIN EXP1_08_PIN
+ #define TFT_A0_PIN TFT_DC_PIN
+
+ #define TFT_RESET_PIN EXP1_04_PIN
+
+ #define LCD_BACKLIGHT_PIN EXP1_03_PIN
+ #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN
+
+ #define TOUCH_BUTTONS_HW_SPI
+ #define TOUCH_BUTTONS_HW_SPI_DEVICE 1
+
+ #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
+ #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
+ #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO
+ #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI
+
+ #define LCD_READ_ID 0xD3
+ #define LCD_USE_DMA_SPI
+
+ #define TFT_BUFFER_SIZE 14400
+
+ #ifndef TOUCH_CALIBRATION_X
+ #define TOUCH_CALIBRATION_X -17253
+ #endif
+ #ifndef TOUCH_CALIBRATION_Y
+ #define TOUCH_CALIBRATION_Y 11579
+ #endif
+ #ifndef TOUCH_OFFSET_X
+ #define TOUCH_OFFSET_X 514
+ #endif
+ #ifndef TOUCH_OFFSET_Y
+ #define TOUCH_OFFSET_Y -24
+ #endif
+ #ifndef TOUCH_ORIENTATION
+ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
+ #endif
+
+ #endif
+
#else
#define LCD_PINS_RS EXP1_04_PIN
@@ -513,27 +599,6 @@
#endif
#endif
-#if HAS_SPI_TFT
- //
- // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE)
- //
- #define TFT_CS_PIN EXP2_04_PIN
- #define TFT_A0_PIN EXP2_07_PIN
- #define TFT_SCK_PIN EXP2_02_PIN
- #define TFT_MISO_PIN EXP2_01_PIN
- #define TFT_MOSI_PIN EXP2_06_PIN
-
- #define TOUCH_INT_PIN EXP1_07_PIN
- #define TOUCH_MISO_PIN EXP1_06_PIN
- #define TOUCH_MOSI_PIN EXP1_03_PIN
- #define TOUCH_SCK_PIN EXP1_05_PIN
- #define TOUCH_CS_PIN EXP1_04_PIN
-
- #define BTN_EN1 EXP2_03_PIN
- #define BTN_EN2 EXP2_05_PIN
- #define BTN_ENC EXP1_02_PIN
-#endif
-
//
// NeoPixel LED
// Test config diff: expand me:
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 8818b04..e82601d 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -37,6 +37,10 @@
*/
#define CONFIGURATION_H_VERSION 02010300
+// Define TFTs here for faster testing
+#define MKS_TS35_V2_0
+//#define BTT_TFT35_SPI_V1_0
+
//===========================================================================
//============================= Getting Started =============================
//===========================================================================
@@ -67,7 +71,7 @@
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
- #define MOTHERBOARD BOARD_RAMPS_14_EFB
+ #define MOTHERBOARD BOARD_BTT_SKR_V3_0_EZ
#endif
/**
@@ -78,7 +82,7 @@
*
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
*/
-#define SERIAL_PORT 0
+#define SERIAL_PORT -1
/**
* Serial Port Baud Rate
@@ -2289,13 +2293,13 @@
* M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes)
* M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.)
*/
-//#define EEPROM_SETTINGS // Persistent storage with M500 and M501
+#define EEPROM_SETTINGS // Persistent storage with M500 and M501
//#define DISABLE_M503 // Saves ~2700 bytes of flash. Disable for release!
#define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM.
#define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load
#if ENABLED(EEPROM_SETTINGS)
- //#define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
- //#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
+ #define EEPROM_AUTO_INIT // Init EEPROM automatically on any errors.
+ #define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build.
#endif
// @section host
@@ -2668,7 +2672,7 @@
// If you have a speaker that can produce tones, enable it here.
// By default Marlin assumes you have a buzzer with a fixed frequency.
//
-//#define SPEAKER
+#define SPEAKER
//
// The duration and frequency for the UI feedback sound.
@@ -3272,7 +3276,7 @@
* root of your SD card, together with the compiled firmware.
*/
//#define TFT_CLASSIC_UI
-//#define TFT_COLOR_UI
+#define TFT_COLOR_UI
//#define TFT_LVGL_UI
#if ENABLED(TFT_COLOR_UI)
@@ -3318,7 +3322,7 @@
//
// Touch Screen Settings
//
-//#define TOUCH_SCREEN
+#define TOUCH_SCREEN
#if ENABLED(TOUCH_SCREEN)
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
diff --git a/platformio.ini b/platformio.ini
index e3bdb6f..12f2fc4 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -13,7 +13,7 @@
[platformio]
src_dir = Marlin
boards_dir = buildroot/share/PlatformIO/boards
-default_envs = mega2560
+default_envs = STM32H723Vx_btt
include_dir = Marlin
extra_configs =
Marlin/config.ini Related: #25579 was just merged, so rebasing https://github.com/jmz52/Marlin/tree/stm32h7-tft-spi to the latest |
Closing since there's now a PR to add support: |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
Currently "SPI TFT is currently only supported on STM32F1 and STM32F4 hardware", while new BTT SKR 3 board is STM32H7 based. Thus it's impossible to replace stock BTT SKR 2 board with SKR 3, as Biqu S1 SE uses TFT35 SPI screen.
I tried to add
#include "stm32h7xx_hal.h"
, but build failed with errorhttps://github.com/MarlinFirmware/Marlin/blob/bugfix-2.1.x/Marlin/src/HAL/STM32/tft/xpt2046.cpp#L146
Are you looking for hardware support?
Biqu S1 SE (Plus)
Describe the feature you want
Support TFT SPI screens on STM32H7 pratform
Additional context
No response
The text was updated successfully, but these errors were encountered: