gc9a01

package
v0.0.0-...-7691dab Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package gc9a01 implements a driver for the gc9a01 LCD round display

Datasheet: https://www.waveshare.com/w/upload/5/5e/GC9A01A.pdf

Index

Constants

View Source
const (
	NOP        = 0x00
	SWRESET    = 0x01
	RDDIDIF    = 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
	PTLAR      = 0x30
	VSCRDEF    = 0x33
	TEOFF      = 0x34
	TEON       = 0x35
	MADCTR     = 0x36
	VSCRSADD   = 0x37
	IDMOFF     = 0x38
	IDMON      = 0x39
	COLMOD     = 0x3A
	RMEMCON    = 0x3C
	STTRSCL    = 0x44
	GTSCL      = 0x45
	WRDISBV    = 0x51
	WRCTRLD    = 0x51
	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
	RGBICTR    = 0xB0
	BLPCHCTRL  = 0xB5
	DISFNCTL   = 0xB6
	TECTL      = 0xBA
	INTCTL     = 0xBA
	FRMCTL     = 0xE8
	SPICTL     = 0xE9
	PWCTR1     = 0xC1
	PWCTR2     = 0xC2
	PWCTR3     = 0xC3
	PWCTR4     = 0xC4
	PWCTR7     = 0xC7
	INTEN1     = 0xFE
	INTEN2     = 0xEF
	GMSET1     = 0xF0
	GMSET2     = 0xF1
	GMSET3     = 0xF2
	GMSET4     = 0xF3

	HORIZONTAL Orientation = 0
	VERTICAL   Orientation = 1
)

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 {
	Orientation  Orientation
	RowOffset    int16
	ColumnOffset int16
	FrameRate    FrameRate
	VSyncLines   int16
	Width        int16
	Height       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 drivers.SPI, resetPin, dcPin, csPin, 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)

Data sends data to the display.

func (*Device) Display

func (d *Device) Display() error

Display sends the whole buffer to the screen

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

FillRectangleWithBuffer fills buffer with a rectangle at a given coordinates.

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)

InvertColors inverts the colors of the screen

func (*Device) IsBGR

func (d *Device) IsBGR(bgr bool)

IsBGR changes the color mode (RGB/BGR)

func (*Device) Reset

func (d *Device) Reset()

Reset the Device

func (*Device) Rx

func (d *Device) Rx(command uint8, data []byte)

Rx reads data from the display

func (*Device) SetDeviceOrientation

func (d *Device) SetDeviceOrientation()

Sets Device configuration for screen orientation using the initialzation values

func (*Device) SetPixel

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

SetPixel sets a pixel in the screen

func (*Device) SetScroll

func (d *Device) SetScroll(line int16)

SetScroll sets the vertical scroll address of the display.

func (*Device) SetScrollArea

func (d *Device) SetScrollArea(topFixedArea, bottomFixedArea int16)

SetScrollArea sets an area to scroll with fixed top and bottom parts of the display.

func (*Device) Size

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

Size returns the current size of the display.

func (*Device) StopScroll

func (d *Device) StopScroll()

StopScroll returns the display to its normal state.

func (*Device) Tx

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

Tx sends data to the display

type FrameRate

type FrameRate uint8

FrameRate controls the frame rate used by the display.

type Orientation

type Orientation uint8

Rotation controls the rotation used by the display.

Jump to

Keyboard shortcuts

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