display

package module
v1.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 14 Imported by: 0

README

Display

Documentation

Overview

Package display contains drivers for hardware displays.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBounds   = errors.New("display: out of bounds")
	ErrNotReady = errors.New("display: ready timeout")
	ErrResetPin = InvalidPin{"reset"}
	ErrDCPin    = InvalidPin{"data/command (DC)"}
)

Errors

View Source
var DefaultI2CConfig = I2CConfig{
	Device: -1,
	Addr:   0x3c,
}

DefaultI2CConfig are the default configuration values for I²C connections.

View Source
var DefaultSPIConfig = SPIConfig{
	Bus:       0,
	Device:    0,
	Mode:      0,
	SpeedHz:   8_000_000,
	BatchSize: 4096,
	Reset:     gpioreg.ByName("GPIO25"),
	DC:        gpioreg.ByName("GPIO24"),
}

DefaultSPIConfig are the default configuration values for SPI connections.

View Source
var ValidSPISpeeds = []uint32{
	500_000,
	1_000_000,
	2_000_000,
	4_000_000,
	8_000_000,
	16_000_000,
	20_000_000,
	24_000_000,
	28_000_000,
	32_000_000,
	36_000_000,
	40_000_000,
	48_000_000,
	50_000_000,
	52_000_000,
}

ValidSPISpeeds are common valid SPI bus speeds.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Width of the display in pixels.
	Width int

	// Height of the display in pixels.
	Height int

	// Rotation of the display.
	Rotation Rotation

	// UseMono sets 1-color monochrome mode on displays that support grayscale.
	UseMono bool

	// Reset pin
	Reset gpio.PinOut

	// Backlight pin
	Backlight gpio.PinOut
}

Config is the display configuration.

type Conn

type Conn interface {
	String() string

	// Close the connection.
	Close() error

	// Reset sets the reset pin to the provided level.
	Reset(gpio.Level) error

	// Command sends a command byte with optional arguments.
	Command(byte, ...byte) error

	// Data sends data bytes.
	Data(...byte) error

	// Interface is the underlying interface.
	Interface() interface{}
}

Conn is the connection interface for communicating with hardware.

func OpenI2C

func OpenI2C(config *I2CConfig) (Conn, error)

func OpenParallel added in v1.1.7

func OpenParallel(config *ParallelConfig) (Conn, error)

OpenParallel opens a parallel connection (also known as 8080 connection).

func OpenSPI

func OpenSPI(config *SPIConfig) (Conn, error)

type Display

type Display interface {
	draw.Image

	// String gives a description of the display.
	String() string

	// Close the display driver.
	Close() error

	// Clear the display buffer.
	Clear()

	// Fill the display buffer with a single color.
	Fill(color.Color)

	// Show toggles the display on or off.
	Show(bool) error

	// SetContrast adjusts the contrast level.
	SetContrast(level uint8) error

	// SetRotation adjusts the pixel rotation.
	SetRotation(Rotation) error

	// Refresh redraws the display.
	Refresh() error
}

Display is an OLED display.

func GP1278 added in v1.1.7

func GP1278(conn Conn, config *Config) (Display, error)

GP1278 is a driver for GP1287AI/BI VFD displays.

func GP1294 added in v1.1.7

func GP1294(c Conn, config *Config) (Display, error)

func GU3000 added in v1.1.7

func GU3000(conn Conn, config *Config) (Display, error)

func SH1106

func SH1106(conn Conn, config *Config) (Display, error)

SH1106 is a driver for the Sino Wealth SH1106 OLED display.

func SH1122 added in v1.1.7

func SH1122(c Conn, config *Config) (Display, error)

func SSD1305

func SSD1305(conn Conn, config *Config) (Display, error)

SSD1305 is a driver for the Sino Wealth SSD1305 OLED display.

func SSD1306

func SSD1306(conn Conn, config *Config) (Display, error)

func SSD1322

func SSD1322(c Conn, config *Config) (Display, error)

SSD1322 is a driver for Solomon Systech SSD1322 OLED display.

func ST7735

func ST7735(c Conn, config *Config) (Display, error)

func ST7789

func ST7789(c Conn, config *Config) (Display, error)

type I2CConfig

type I2CConfig struct {
	// Device is the I²C device, use -1 to use the first available device.
	Device int

	// Addr is the I²C address.
	Addr uint8

	// Reset pin.
	Reset gpio.PinOut
}

I2CConfig describes the I²C bus configuration.

type InvalidPin added in v1.1.7

type InvalidPin struct {
	Name string
}

func (InvalidPin) Error added in v1.1.7

func (err InvalidPin) Error() string

type Parallel added in v1.1.7

type Parallel interface {
	Conn
}

type ParallelConfig added in v1.1.7

type ParallelConfig struct {
	// Data pins.
	D0, D1, D2, D3, D4, D5, D6, D7 gpio.PinOut

	// Write pin.
	Write gpio.PinOut

	// Ready pin.
	Ready gpio.PinIn

	// UpdateFrequency is the maximum update frequency.
	UpdateFrequency physic.Frequency
}

ParallelConfig is the configuration for a parallel (aka 8080) connection.

type Rotation

type Rotation uint8

Rotation defines pixel rotation.

const (
	NoRotation Rotation = iota
	Rotate90            // Rotate 90° clock wise
	Rotate180           // Rotate 180°
	Rotate270           // Rotate 270° clock wise
)

Supported rotations.

func (Rotation) String

func (r Rotation) String() string

type SPI

type SPI interface {
	Conn

	// SetDataLow changes the data/command direction behaviour.
	SetDataLow(bool)

	// SetMode requests a SPI mode.
	SetMode(mode conn.SPIMode) error

	// SetMaxSpeed requests a SPI speed.
	SetMaxSpeed(hz int) error
}

type SPIConfig

type SPIConfig struct {
	Bus       int
	Device    int
	Mode      uint8
	SpeedHz   uint32
	DataLow   bool
	BatchSize uint
	Reset     gpio.PinOut
	DC        gpio.PinOut
	CE        gpio.PinOut
}

SPIConfig describes the SPI bus configuration.

Directories

Path Synopsis
cmd
display-test command
oled-test-spi command
Package draw provides provides image composition functions.
Package draw provides provides image composition functions.
Package framebuffer provides access to the operating system's native framebuffer
Package framebuffer provides access to the operating system's native framebuffer
internal
Package pixel implements a color and image library suitable for OLED and LCD pixel displays.
Package pixel implements a color and image library suitable for OLED and LCD pixel displays.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL