From bc74bea545652b55be90cb71562d5000dcab6553 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 6 Oct 2024 01:17:32 -0400 Subject: [PATCH] [RTduino] support TFT_eSPI demo --- .../board/ports/arduino/SConscript | 2 +- .../ports/arduino/ST7789_tft_espi_demo.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/SConscript b/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/SConscript index 3d68349796..710108bd0e 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/SConscript +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/SConscript @@ -5,7 +5,7 @@ src = [] if GetDepend(['BSP_USING_ARDUINO_ST7789_ADAFRUIT_GFX_DEMO']): src += ['ST7789_adafruit_gfx_demo.cpp'] -elif GetDepend(['BSP_USING_ARDUINO_ST7789_ADAFRUIT_GFX_DEMO']): +elif GetDepend(['BSP_USING_ARDUINO_ST7789_TFT_ESPI_DEMO']): src += ['ST7789_tft_espi_demo.cpp'] group = DefineGroup('RTduino-libraries', src, depend = ['BSP_USING_ARDUINO']) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/ST7789_tft_espi_demo.cpp b/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/ST7789_tft_espi_demo.cpp index ea069691e4..5a2a1c193b 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/ST7789_tft_espi_demo.cpp +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/arduino/ST7789_tft_espi_demo.cpp @@ -9,9 +9,35 @@ */ #include +#include + +TFT_eSPI tft; static void st7789_setup(void) { + Serial.begin(); + + // lcd init + tft.init(); + tft.fillScreen(TFT_DARKCYAN); + Serial.println("screen init success."); + + // lcd test + tft.setTextColor(TFT_BLACK); + tft.setCursor (12, 5); + tft.print("Original ADAfruit font!"); + + // The new larger fonts do not use the .setCursor call, coords are embedded + tft.setTextColor(TFT_BLACK, TFT_BLACK); // Do not plot the background colour + + // Overlay the black text on top of the rainbow plot (the advantage of not drawing the backgorund colour!) + tft.drawCentreString("Font size 2", 120, 14, 2); // Draw text centre at position 80, 12 using font 2 + + tft.drawCentreString("Font size 4", 120, 30, 4); // Draw text centre at position 80, 24 using font 4 + + tft.drawCentreString("12.34", 120, 54, 6); // Draw text centre at position 80, 24 using font 6 + + tft.drawCentreString("12.34 is in font size 6", 120, 92, 2); // Draw text centre at position 80, 90 using font 2 } static void st7789_loop(void)