Skip to content

Commit 7c4a05a

Browse files
authored
Add support for Pirate Audio ST7789 HAT (#203)
1 parent 662e8db commit 7c4a05a

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ elseif(WAVESHARE_ST7789VW_HAT)
208208
elseif(WAVESHARE_ST7735S_HAT)
209209
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DST7735S -DWAVESHARE_ST7735S_HAT")
210210
message(STATUS "Targeting WaveShare 128x128 1.44inch LCD Hat with ST7735S controller")
211+
elseif(PIRATE_AUDIO_ST7789_HAT)
212+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DST7789 -DPIRATE_AUDIO_ST7789_HAT")
213+
message(STATUS "Targeting Pirate Audio 240x240 1.3inch IPS LCD Hat with ST7789 controller")
211214
elseif(ILI9340)
212215
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DILI9340")
213216
message(STATUS "Targeting ILI9340")

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The following LCD displays have been tested:
6161
- [Arduino A000096 1.77" 160x128 LCD Screen](https://store.arduino.cc/arduino-lcd-screen) with ST7735R controller
6262
- [Tontec 3.5" 320x480 LCD Display](https://www.ebay.com/p/Tontec-3-5-Inches-Touch-Screen-for-Raspberry-Pi-Display-TFT-Monitor-480x320-LCD/1649448059) with MZ61581-PI-EXT 2016.1.28 controller
6363
- [Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD](https://www.adafruit.com/product/3787) with ST7789 controller
64+
- [Pirate Audio 240x240, 1.3inch IPS LCD display HAT for Raspberry Pi](https://shop.pimoroni.com/collections/pirate-audio) with ST7789 controller
6465
- [WaveShare 240x240, 1.3inch IPS LCD display HAT for Raspberry Pi](https://www.waveshare.com/1.3inch-lcd-hat.htm) with ST7789VW controller
6566
- [WaveShare 128x128, 1.44inch LCD display HAT for Raspberry Pi](https://www.waveshare.com/1.44inch-lcd-hat.htm) with ST7735S controller
6667
- [KeDei 3.5 inch SPI TFTLCD 480*320 16bit/18bit version 6.3 2018/4/9](https://github.com/juj/fbcp-ili9341/issues/40) with MPI3501 controller
@@ -115,6 +116,7 @@ When using one of the displays that stack on top of the Pi that are already reco
115116
- `-DFREEPLAYTECH_WAVESHARE32B=ON`: If you are running on the [Freeplay CM3 or Zero](https://www.freeplaytech.com/product/freeplay-cm3-diy-kit/) device, pass this flag. (this is not a hat, but still a preconfigured pin assignment)
116117
- `-DWAVESHARE35B_ILI9486=ON`: If specified, targets a [Waveshare 3.5" 480x320 ILI9486](https://www.amazon.co.uk/dp/B01N48NOXI/ref=pe_3187911_185740111_TE_item) display.
117118
- `-DTONTEC_MZ61581=ON`: If you are running on the [Tontec 3.5" 320x480 LCD Display](https://www.ebay.com/p/Tontec-3-5-Inches-Touch-Screen-for-Raspberry-Pi-Display-TFT-Monitor-480x320-LCD/1649448059) display, pass this.
119+
- `-DPIRATE_AUDIO_ST7789_HAT=ON`: If specified, targets a [Pirate Audio 240x240, 1.3inch IPS LCD display HAT for Raspberry Pi](https://shop.pimoroni.com/collections/pirate-audio) with ST7789 display controller
118120
- `-DWAVESHARE_ST7789VW_HAT=ON`: If specified, targets a [240x240, 1.3inch IPS LCD display HAT for Raspberry Pi](https://www.waveshare.com/1.3inch-lcd-hat.htm) with ST7789VW display controller.
119121
- `-DWAVESHARE_ST7735S_HAT=ON`: If specified, targets a [128x128, 1.44inch LCD display HAT for Raspberry Pi](https://www.waveshare.com/1.3inch-lcd-hat.htm) with ST7735S display controller.
120122
- `-DKEDEI_V63_MPI3501=ON`: If specified, targets a [KeDei 3.5 inch SPI TFTLCD 480*320 16bit/18bit version 6.3 2018/4/9](https://github.com/juj/fbcp-ili9341/issues/40) display with MPI3501 display controller.

pirate_audio_st7789_hat.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
// Data specific to Pirate Audio series 240x240, 1.3inch IPS LCD ST7789 hat, https://shop.pimoroni.com/collections/pirate-audio
4+
#ifdef PIRATE_AUDIO_ST7789_HAT
5+
6+
#if !defined(GPIO_TFT_DATA_CONTROL)
7+
#define GPIO_TFT_DATA_CONTROL 9
8+
#endif
9+
10+
#if !defined(GPIO_TFT_BACKLIGHT)
11+
#define GPIO_TFT_BACKLIGHT 13
12+
#endif
13+
14+
#define DISPLAY_USES_CS1
15+
16+
// CS1 line is for the LCD
17+
#define DISPLAY_SPI_DRIVE_SETTINGS (1)
18+
19+
#endif

spi.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ int InitSPI()
532532
#ifdef GPIO_TFT_DATA_CONTROL
533533
SET_GPIO_MODE(GPIO_TFT_DATA_CONTROL, 0x01); // Data/Control pin to output (0x01)
534534
#endif
535+
// The Pirate Audio hat ST7789 based display has Data/Control on the MISO pin, so only initialize the pin as MISO if the
536+
// Data/Control pin does not use it.
537+
#if !defined(GPIO_TFT_DATA_CONTROL) || GPIO_TFT_DATA_CONTROL != GPIO_SPI0_MISO
535538
SET_GPIO_MODE(GPIO_SPI0_MISO, 0x04);
539+
#endif
536540
SET_GPIO_MODE(GPIO_SPI0_MOSI, 0x04);
537541
SET_GPIO_MODE(GPIO_SPI0_CLK, 0x04);
538542

st7735r.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "waveshare_st7789vw_hat.h"
4040
#elif defined(WAVESHARE_ST7735S_HAT)
4141
#include "waveshare_st7735s_hat.h"
42+
#elif defined(PIRATE_AUDIO_ST7789_HAT)
43+
#include "pirate_audio_st7789_hat.h"
4244
#endif
4345

4446
#define InitSPIDisplay InitST7735R

0 commit comments

Comments
 (0)