st7789

package
v0.0.0-...-078b826 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: BSD-2-Clause, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

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
	RGBCTRL    = 0xB1
	FRMCTR2    = 0xB2
	PORCTRL    = 0xB2
	FRMCTR3    = 0xB3
	INVCTR     = 0xB4
	DISSET5    = 0xB6
	PWCTR1     = 0xC0
	PWCTR2     = 0xC1
	PWCTR3     = 0xC2
	PWCTR4     = 0xC3
	PWCTR5     = 0xC4
	VMCTR1     = 0xC5
	FRCTRL2    = 0xC6
	PWCTR6     = 0xFC
	GCTRL      = 0xB7
	GMCTRP1    = 0xE0
	GMCTRN1    = 0xE1
	GSCAN      = 0x45
	VCOMS      = 0xBB
	LCMCTRL    = 0xC0
	VDVVRHEN   = 0xC2
	VRHS       = 0xC3
	VDVS       = 0xC4

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

	// Allowable frame rate codes for FRCTRL2 (Identifier is in Hz)
	FRAMERATE_111 FrameRate = 0x01
	FRAMERATE_105 FrameRate = 0x02
	FRAMERATE_99  FrameRate = 0x03
	FRAMERATE_94  FrameRate = 0x04
	FRAMERATE_90  FrameRate = 0x05
	FRAMERATE_86  FrameRate = 0x06
	FRAMERATE_82  FrameRate = 0x07
	FRAMERATE_78  FrameRate = 0x08
	FRAMERATE_75  FrameRate = 0x09
	FRAMERATE_72  FrameRate = 0x0A
	FRAMERATE_69  FrameRate = 0x0B
	FRAMERATE_67  FrameRate = 0x0C
	FRAMERATE_64  FrameRate = 0x0D
	FRAMERATE_62  FrameRate = 0x0E
	FRAMERATE_60  FrameRate = 0x0F // 60 is default
	FRAMERATE_58  FrameRate = 0x10
	FRAMERATE_57  FrameRate = 0x11
	FRAMERATE_55  FrameRate = 0x12
	FRAMERATE_53  FrameRate = 0x13
	FRAMERATE_52  FrameRate = 0x14
	FRAMERATE_50  FrameRate = 0x15
	FRAMERATE_49  FrameRate = 0x16
	FRAMERATE_48  FrameRate = 0x17
	FRAMERATE_46  FrameRate = 0x18
	FRAMERATE_45  FrameRate = 0x19
	FRAMERATE_44  FrameRate = 0x1A
	FRAMERATE_43  FrameRate = 0x1B
	FRAMERATE_42  FrameRate = 0x1C
	FRAMERATE_41  FrameRate = 0x1D
	FRAMERATE_40  FrameRate = 0x1E
	FRAMERATE_39  FrameRate = 0x1F

	MAX_VSYNC_SCANLINES = 254

	BG_SPI_CS_BACK  = 0
	BG_SPI_CS_FRONT = 1

	SPI_CLOCK_HZ = 16000000
)

Registers

Variables

View Source
var DefaultOpts = Opts{
	W: 240,
	H: 240,
}

DefaultOpts is the recommended default options.

Functions

func RGBATo565

func RGBATo565(c color.RGBA) uint16

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

Types

type Device

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

Device is an open handle to the display controller.

func NewSPI

func NewSPI(p spi.Port, dc gpio.PinOut, opts *Opts) (*Device, error)

func (*Device) Bounds

func (d *Device) Bounds() image.Rectangle

Bounds implements display.Drawer. Min is guaranteed to be {0, 0}.

func (*Device) Command

func (d *Device) Command(cmd uint8)

Command sends a command to the device

func (*Device) Data

func (d *Device) Data(data uint8)

Data sends data to the device

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) DrawImage

func (d *Device) DrawImage(reader io.Reader)

func (*Device) DrawRAW

func (d *Device) DrawRAW(img image.Image)

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) FillScreen

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

FillScreen fills the screen with a given color

func (*Device) Invert

func (d *Device) Invert(blackOnWhite bool)

Invert the display (black on white vs white on black).

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) PowerOff

func (d *Device) PowerOff() error

PowerOff the display

func (*Device) PowerOn

func (d *Device) PowerOn() error

PowerOn the display

func (*Device) SendCommand

func (d *Device) SendCommand(c []byte) error

func (*Device) SendData

func (d *Device) SendData(c []byte) error

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) SetWindow

func (d *Device) SetWindow()

func (*Device) Size

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

Size returns the current size of the display.

func (*Device) String

func (d *Device) String() string

type FrameRate

type FrameRate uint8

type Opts

type Opts struct {
	W int16
	H int16
}

Opts defines the options for the device.

type Rotation

type Rotation uint8

Jump to

Keyboard shortcuts

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