st7789

package
v0.0.0-...-3bb5b45 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package st7789 implements a driver for the ST7789 TFT displays, it comes in various screen sizes.

Datasheet: https://cdn-shop.adafruit.com/product-files/3787/3787_tft_QT154H2201__________20190228182902.pdf

Index

Constants

View Source
const (
	NOP        = 0x00
	SWRESET    = 0x01
	RDDID      = 0x04
	RDDST      = 0x09
	SLPIN      = 0x10
	SLPOUT     = 0x11
	PTLON      = 0x12
	NORON      = 0x13
	INVOFF     = 0x20
	INVON      = 0x21
	DISPOFF    = 0x28
	DISPON     = 0x29
	CASET      = 0x2A
	RASET      = 0x2B
	RAMWR      = 0x2C
	RAMRD      = 0x2E
	PTLAR      = 0x30
	COLMOD     = 0x3A
	MADCTL     = 0x36
	MADCTL_MY  = 0x80
	MADCTL_MX  = 0x40
	MADCTL_MV  = 0x20
	MADCTL_ML  = 0x10
	MADCTL_RGB = 0x00
	MADCTL_BGR = 0x08
	MADCTL_MH  = 0x04
	RDID1      = 0xDA
	RDID2      = 0xDB
	RDID3      = 0xDC
	RDID4      = 0xDD
	FRMCTR1    = 0xB1
	FRMCTR2    = 0xB2
	FRMCTR3    = 0xB3
	INVCTR     = 0xB4
	DISSET5    = 0xB6
	PWCTR1     = 0xC0
	PWCTR2     = 0xC1
	PWCTR3     = 0xC2
	PWCTR4     = 0xC3
	PWCTR5     = 0xC4
	VMCTR1     = 0xC5
	PWCTR6     = 0xFC
	GMCTRP1    = 0xE0
	GMCTRN1    = 0xE1

	NO_ROTATION  Rotation = 0
	ROTATION_90  Rotation = 1 // 90 degrees clock-wise rotation
	ROTATION_180 Rotation = 2
	ROTATION_270 Rotation = 3
)

Registers

Variables

This section is empty.

Functions

func RGBATo565

func RGBATo565(c color.RGBA) uint16

RGBATo565 converts a color.RGBA to uint16 used in the display

Types

type Config

type Config struct {
	Width        int16
	Height       int16
	Rotation     Rotation
	RowOffset    int16
	ColumnOffset int16
}

Config is the configuration for the display

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device wraps an SPI connection.

func New

func New(bus machine.SPI, resetPin, dcPin, blPin machine.Pin) Device

New creates a new ST7789 connection. The SPI wire must already be configured.

func (*Device) Command

func (d *Device) Command(command uint8)

Command sends a command to the display

func (*Device) Configure

func (d *Device) Configure(cfg Config)

Configure initializes the display with default configuration

func (*Device) Data

func (d *Device) Data(data uint8)

Command sends a data to the display

func (*Device) Display

func (d *Device) Display() error

Display does nothing, there's no buffer as it might be too big for some boards

func (*Device) DrawFastHLine

func (d *Device) DrawFastHLine(x0, x1, y int16, c color.RGBA)

DrawFastHLine draws a horizontal line faster than using SetPixel

func (*Device) DrawFastVLine

func (d *Device) DrawFastVLine(x, y0, y1 int16, c color.RGBA)

DrawFastVLine draws a vertical line faster than using SetPixel

func (*Device) EnableBacklight

func (d *Device) EnableBacklight(enable bool)

EnableBacklight enables or disables the backlight

func (*Device) FillRectangle

func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error

FillRectangle fills a rectangle at a given coordinates with a color

func (*Device) FillRectangleWithBuffer

func (d *Device) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error

FillRectangle fills a rectangle at a given coordinates with a buffer

func (*Device) FillScreen

func (d *Device) FillScreen(c color.RGBA)

FillScreen fills the screen with a given color

func (*Device) InvertColors

func (d *Device) InvertColors(invert bool)

InverColors inverts the colors of the screen

func (*Device) IsBGR

func (d *Device) IsBGR(bgr bool)

IsBGR changes the color mode (RGB/BGR)

func (*Device) SetPixel

func (d *Device) SetPixel(x int16, y int16, c color.RGBA)

SetPixel sets a pixel in the screen

func (*Device) SetRotation

func (d *Device) SetRotation(rotation Rotation)

SetRotation changes the rotation of the device (clock-wise)

func (*Device) Size

func (d *Device) Size() (w, h int16)

Size returns the current size of the display.

func (*Device) Tx

func (d *Device) Tx(data []byte, isCommand bool)

Tx sends data to the display

type Rotation

type Rotation uint8

Jump to

Keyboard shortcuts

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