Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,73 @@ Curious? Look at [supported devices](https://periph.io/device/) for more
examples!


## Supported Devices

| Package | Description |
|---------|-------------|
| [ads1x15](ads1x15) | ADS1015/ADS1115 analog-to-digital converters via I²C |
| [adxl345](adxl345) | ADXL345 3-axis accelerometer over SPI |
| [aht20](aht20) | AHT20 temperature/humidity sensor over I²C |
| [aip31068](aip31068) | AIP31068 HD44780-compatible I²C LCD driver |
| [am2320](am2320) | AOSONG AM2320 temperature/humidity sensor |
| [apa102](apa102) | APA102 LED strip over SPI |
| [as7262](as7262) | AMS AS7262 6-channel visible spectral sensor via I²C |
| [bh1750](bh1750) | ROHM BH1750 ambient light sensor over I²C |
| [bitbang](bitbang) | Software bit-banging protocols (I²C, SPI, UART) via GPIO pins |
| [bmxx80](bmxx80) | Bosch BMP180/BME280/BMP280 temperature/pressure/humidity sensor over I²C or SPI |
| [cap1xxx](cap1xxx) | Microchip CAP1xxx capacitive touch sensors over I²C |
| [ccs811](ccs811) | CCS811 volatile organic compound (VOC) sensor via I²C |
| [common](common) | Shared utility functions used across multiple packages |
| [dht22](dht22) | DHT22/AM2302 temperature/humidity sensor |
| [ds18b20](ds18b20) | DS18B20/DS18S20/MAX31820 1-wire temperature sensors |
| [ds248x](ds248x) | Maxim DS2483/DS2482-100 1-wire interface chip over I²C |
| [ep0099](ep0099) | EP-0099 Raspberry Pi HAT with 4 relays via I²C |
| [epd](epd) | Waveshare e-paper display series |
| [gc9a01](gc9a01) | GC9A01 240x240 round RGB LCD display over SPI |
| [hd44780](hd44780) | Hitachi HD44780 LCD display chipset |
| [hdc302x](hdc302x) | Texas Instruments HDC3021/3022 temperature/humidity sensor over I²C |
| [ht16k33](ht16k33) | Holtek HT16K33 16×8 LED driver |
| [hx711](hx711) | HX711 24-bit analog-to-digital converter (load cells) |
| [ina219](ina219) | Texas Instruments INA219 current/voltage/power monitor over I²C |
| [inky](inky) | Pimoroni Inky pHAT/wHAT e-ink displays |
| [lepton](lepton) | FLIR Lepton infrared (IR) camera |
| [lirc](lirc) | Infrared receiver support via Linux LIRC |
| [matrixorbital](matrixorbital) | MatrixOrbital character LCD displays |
| [max7219](max7219) | MAX7219 7-segment and LED matrix displays |
| [mcp23xxx](mcp23xxx) | Microchip MCP23xxx GPIO expanders |
| [mcp472x](mcp472x) | Microchip MCP472x digital-to-analog converters |
| [mcp9808](mcp9808) | Microchip MCP9808 temperature sensor |
| [mfrc522](mfrc522) | MFRC522 Mifare RFID card reader |
| [mpu9250](mpu9250) | MPU-9250 9-axis IMU (gyroscope, accelerometer, magnetometer) |
| [nrzled](nrzled) | WS2811/WS2812/WS2812B and compatible NRZ-encoded LEDs (SK6812, UCS1903) |
| [nxp74hc595](nxp74hc595) | 74HC595 serial-in parallel-out shift register |
| [pca9548](pca9548) | PCA9548 8-port I²C multiplexer |
| [pca9633](pca9633) | PCA9633 4-channel LED PWM controller |
| [pca9685](pca9685) | PCA9685 16-channel PWM controller (servos, LEDs) |
| [pcf857x](pcf857x) | TI/NXP PCF857x I²C I/O expander |
| [piblaster](piblaster) | PWM via the pi-blaster daemon on Raspberry Pi |
| [rainbowhat](rainbowhat) | Pimoroni Rainbow HAT |
| [scd4x](scd4x) | Sensirion SCD4x CO₂ sensors |
| [screen1d](screen1d) | 1D display output to terminal via ANSI color codes |
| [serlcd](serlcd) | SparkFun SerLCD intelligent LCD display |
| [sgp30](sgp30) | Sensirion SGP30 multi-gas sensor (TVOC and CO₂eq) |
| [sht4x](sht4x) | Sensirion SHT-40/SHT-41/SHT-45 temperature/humidity sensors |
| [sn3218](sn3218) | SN3218 18-channel LED driver over I²C |
| [ssd1306](ssd1306) | SSD1306/SH1106/SH1107 monochrome OLED displays |
| [st7567](st7567) | ST7567 single-chip dot matrix LCD |
| [tca95xx](tca95xx) | Texas Instruments TCA95xx 8-bit I²C GPIO expanders |
| [tic](tic) | Tic stepper motor controllers via I²C |
| [tlv493d](tlv493d) | Infineon TLV493D 3D magnetic (Hall effect) sensor |
| [tm1637](tm1637) | TM1637 LED display driver over GPIO |
| [tmp102](tmp102) | Texas Instruments TMP102 temperature sensor over I²C |
| [unicornhd](unicornhd) | Pimoroni Unicorn HD HAT (16×16 RGB LED matrix) |
| [videosink](videosink) | Display driver serving frames over HTTP |
| [waveshare1602](waveshare1602) | Waveshare 1602 LCD display |
| [waveshare2in13v2](waveshare2in13v2) | Waveshare 2.13" v2 e-paper display |
| [waveshare2in13v3](waveshare2in13v3) | Waveshare 2.13" v3 e-paper display |
| [waveshare2in13v4](waveshare2in13v4) | Waveshare 2.13" v4 e-paper display |


## Authors

`periph` was initiated with ❤️️ and passion by [Marc-Antoine
Expand Down
18 changes: 18 additions & 0 deletions gc9a01/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2025 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.

// Package gc9a01 controls a GC9A01 240x240 round RGB LCD display over SPI.
//
// The GC9A01 is a single-chip driver for 240x240 resolution TFT LCD displays
// with 65K colors (RGB565). It communicates via 4-wire SPI.
//
// # Datasheet
//
// https://www.buydisplay.com/download/ic/GC9A01A.pdf
//
// # Wiring
//
// Connect SDA to SPI_MOSI, SCL to SPI_CLK, CS to SPI_CS, DC to a GPIO pin.
// Optionally connect RST to a GPIO pin for hardware reset.
package gc9a01
119 changes: 119 additions & 0 deletions gc9a01/example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright 2025 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.

package gc9a01_test

import (
"fmt"
"image"
"image/color"
"image/draw"
"log"
"math"
"time"

"periph.io/x/conn/v3/gpio/gpioreg"
"periph.io/x/conn/v3/spi/spireg"
"periph.io/x/devices/v3/gc9a01"
"periph.io/x/host/v3"
)

func Example() {
// Make sure periph is initialized.
if _, err := host.Init(); err != nil {
log.Fatal(err)
}

// Use spireg SPI bus registry to find the first available SPI bus.
p, err := spireg.Open("")
if err != nil {
log.Fatal(err)
}
defer p.Close()

// Data/Command pin.
dc := gpioreg.ByName("GPIO25")
if dc == nil {
log.Fatal("failed to find DC pin")
}

// Optional reset pin.
rst := gpioreg.ByName("GPIO27")

dev, err := gc9a01.New(p, dc, rst, &gc9a01.DefaultOpts)
if err != nil {
log.Fatal(err)
}
fmt.Printf("device=%s\n", dev.String())

// Draw a colorful bullseye pattern.
img := image.NewNRGBA(dev.Bounds())
colors := []color.NRGBA{
{0xFF, 0x00, 0x00, 0xFF}, // Red
{0xFF, 0xA5, 0x00, 0xFF}, // Orange
{0xFF, 0xFF, 0x00, 0xFF}, // Yellow
{0x00, 0xFF, 0x00, 0xFF}, // Green
{0x00, 0x00, 0xFF, 0xFF}, // Blue
{0x4B, 0x00, 0x82, 0xFF}, // Indigo
{0xEE, 0x82, 0xEE, 0xFF}, // Violet
}
cx, cy := 120, 120
for y := 0; y < 240; y++ {
for x := 0; x < 240; x++ {
dx := float64(x - cx)
dy := float64(y - cy)
dist := math.Sqrt(dx*dx + dy*dy)
ring := int(dist / 18)
if ring < len(colors) {
img.SetNRGBA(x, y, colors[ring])
}
}
}
if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil {
log.Fatal(err)
}
time.Sleep(3 * time.Second)

// Draw a gradient.
for y := 0; y < 240; y++ {
for x := 0; x < 240; x++ {
img.SetNRGBA(x, y, color.NRGBA{
R: uint8(x * 255 / 239),
G: uint8(y * 255 / 239),
B: 128,
A: 255,
})
}
}
if err := dev.Draw(dev.Bounds(), img, image.Point{}); err != nil {
log.Fatal(err)
}
time.Sleep(3 * time.Second)

// Clear to white using image.Uniform.
white := &image.Uniform{color.NRGBA{0xFF, 0xFF, 0xFF, 0xFF}}
if err := dev.Draw(dev.Bounds(), white, image.Point{}); err != nil {
log.Fatal(err)
}

// Draw a filled red circle in the center using draw.Draw.
red := &image.Uniform{color.NRGBA{0xFF, 0x00, 0x00, 0xFF}}
circle := image.NewNRGBA(dev.Bounds())
draw.Draw(circle, circle.Bounds(), white, image.Point{}, draw.Src)
for y := 0; y < 240; y++ {
for x := 0; x < 240; x++ {
dx := float64(x - cx)
dy := float64(y - cy)
if dx*dx+dy*dy <= 80*80 {
circle.Set(x, y, red)
}
}
}
if err := dev.Draw(dev.Bounds(), circle, image.Point{}); err != nil {
log.Fatal(err)
}
time.Sleep(3 * time.Second)

_ = dev.Halt()
}
Loading
Loading