Last active
March 11, 2025 06:11
-
-
Save atomofiron/93594256398c7e4a7a790b0435dcb821 to your computer and use it in GitHub Desktop.
Halcyon TFT LCD Display Module with STM32F103C8 via Arduino Framework
STM32 with CS32 chip
platformio.ini
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = stm32cube
build_flags = -DUSE_HAL_DRIVER
monitor_speed = 115200
debug_tool = stlink
debug_server = openocd
upload_flags = -c set CPUTAPID 0x2ba01477
Arduino IDE on MacOS ~/Library/Arduino15/packages/STMicroelectronics/tools/xpack-openocd/0.12.0-4/openocd/scripts/interface/stlink.cfg
...
set CPUTAPID 0x2ba01477


sources: VIK, Halcyon Modules, hlc_tft_display/config.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_GFX.h> | |
#include <Adafruit_ST7789.h> | |
#include <SPI.h> | |
// STM32F103C8 | |
#define SERIAL_BAUD 115200 | |
#define WIDTH 135 | |
#define HEIGHT 240 | |
// PA1, PA2, PA3, PA4, PB0, PB1, PB10, PB11 don't work | |
#define TFT_CS PB6 | |
#define TFT_DC PB7 | |
#define TFT_RST -1 // most likely SWRESET used | |
#define SPI_MODE SPI_MODE0 // LCD_SPI_MODE was 3 | |
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); | |
void setup() { | |
Serial.begin(SERIAL_BAUD); | |
while (!Serial); | |
Serial.println("setup..."); | |
tft.init(WIDTH, HEIGHT, SPI_MODE); | |
tft.setRotation(1); | |
tft.setTextSize(2); | |
tft.fillScreen(ST77XX_BLACK); | |
delay(500); | |
greeting(ST77XX_WHITE); | |
Serial.println("setup done"); | |
} | |
void loop() { | |
Serial.println("loop"); | |
delay(500); | |
tft.fillScreen(ST77XX_RED); | |
greeting(ST77XX_BLACK); | |
delay(500); | |
tft.fillScreen(ST77XX_BLUE); | |
greeting(ST77XX_BLACK); | |
delay(500); | |
tft.fillScreen(ST77XX_GREEN); | |
greeting(ST77XX_BLACK); | |
} | |
void greeting(uint16_t color) { | |
tft.setCursor(10, 10); | |
tft.setTextColor(color); | |
tft.println("Hello, Halcyon!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment