Documentation ¶
Overview ¶
Package st7789 implements a driver for the ST7789 TFT displays, it comes in various screen sizes.
Datasheets: https://cdn-shop.adafruit.com/product-files/3787/3787_tft_QT154H2201__________20190228182902.pdf
http://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdf
Index ¶
- Constants
- type Color
- type ColorFormat
- type Config
- type Device
- type DeviceOf
- func (d *DeviceOf[T]) Configure(cfg Config)
- func (d *DeviceOf[T]) Display() error
- func (d *DeviceOf[T]) DrawBitmap(x, y int16, bitmap pixel.Image[T]) error
- func (d *DeviceOf[T]) DrawFastHLine(x0, x1, y int16, c color.RGBA)
- func (d *DeviceOf[T]) DrawFastVLine(x, y0, y1 int16, c color.RGBA)
- func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) errordeprecated
- func (d *DeviceOf[T]) EnableBacklight(enable bool)
- func (d *DeviceOf[T]) FillRectangle(x, y, width, height int16, c color.RGBA) error
- func (d *DeviceOf[T]) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error
- func (d *DeviceOf[T]) FillScreen(c color.RGBA)
- func (d *DeviceOf[T]) GetHighestScanLine() uint16
- func (d *DeviceOf[T]) GetLowestScanLine() uint16
- func (d *DeviceOf[T]) GetScanLine() uint16
- func (d *DeviceOf[T]) InvertColors(invert bool)
- func (d *DeviceOf[T]) IsBGR(bgr bool)
- func (d *DeviceOf[T]) Rotation() Rotation
- func (d *DeviceOf[T]) SetColorFormat(format ColorFormat)
- func (d *DeviceOf[T]) SetPixel(x int16, y int16, c color.RGBA)
- func (d *DeviceOf[T]) SetRotation(rotation Rotation) error
- func (d *DeviceOf[T]) SetScroll(line int16)
- func (d *DeviceOf[T]) SetScrollArea(topFixedArea, bottomFixedArea int16)
- func (d *DeviceOf[T]) Size() (w, h int16)
- func (d *DeviceOf[T]) Sleep(sleepEnabled bool) error
- func (d *DeviceOf[T]) StopScroll()
- func (d *DeviceOf[T]) Sync()
- func (d *DeviceOf[T]) SyncToScanLine(scanline uint16)
- type FrameRate
- type Rotation
Constants ¶
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 RAMCTRL = 0xB0 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 GMCTRP1 = 0xE0 GMCTRN1 = 0xE1 GSCAN = 0x45 VSCRDEF = 0x33 VSCRSADD = 0x37 ColorRGB444 ColorFormat = 0b011 ColorRGB565 ColorFormat = 0b101 ColorRGB666 ColorFormat = 0b111 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 )
Registers
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorFormat ¶
type ColorFormat uint8
The color format used on the display, like RGB565, RGB666, and RGB444.
type Config ¶
type Config struct { Width int16 Height int16 Rotation Rotation RowOffset int16 ColumnOffset int16 FrameRate FrameRate VSyncLines int16 // Gamma control. Look in the LCD panel datasheet or provided example code // to find these values. If not set, the defaults will be used. PVGAMCTRL []uint8 // Positive voltage gamma control (14 bytes) NVGAMCTRL []uint8 // Negative voltage gamma control (14 bytes) }
Config is the configuration for the display
type DeviceOf ¶
type DeviceOf[T Color] struct { // contains filtered or unexported fields }
DeviceOf is a generic version of Device. It supports multiple different pixel formats.
func NewOf ¶
NewOf creates a new ST7789 connection with a particular pixel format. The SPI wire must already be configured.
func (*DeviceOf[T]) Display ¶
Display does nothing, there's no buffer as it might be too big for some boards
func (*DeviceOf[T]) DrawBitmap ¶
DrawBitmap copies the bitmap to the internal buffer on the screen at the given coordinates. It returns once the image data has been sent completely.
func (*DeviceOf[T]) DrawFastHLine ¶
DrawFastHLine draws a horizontal line faster than using SetPixel
func (*DeviceOf[T]) DrawFastVLine ¶
DrawFastVLine draws a vertical line faster than using SetPixel
func (*DeviceOf[T]) EnableBacklight ¶
EnableBacklight enables or disables the backlight
func (*DeviceOf[T]) FillRectangle ¶
FillRectangle fills a rectangle at a given coordinates with a color
func (*DeviceOf[T]) FillRectangleWithBuffer ¶
FillRectangleWithBuffer fills buffer with a rectangle at a given coordinates.
func (*DeviceOf[T]) FillScreen ¶
FillScreen fills the screen with a given color
func (*DeviceOf[T]) GetHighestScanLine ¶
GetHighestScanLine calculates the last scanline id in the frame before VSYNC pause
func (*DeviceOf[T]) GetLowestScanLine ¶
GetLowestScanLine calculate the first scanline id to appear after VSYNC pause
func (*DeviceOf[T]) GetScanLine ¶
GetScanLine reads the current scanline value from the display
func (*DeviceOf[T]) InvertColors ¶
InvertColors inverts the colors of the screen
func (*DeviceOf[T]) SetColorFormat ¶
func (d *DeviceOf[T]) SetColorFormat(format ColorFormat)
Control the color format that is used when writing to the screen. The default is RGB565, setting it to any other value will break functions like SetPixel, FillRectangle, etc. Instead, you can write color data in the specified color format using DrawRGBBitmap8.
func (*DeviceOf[T]) SetRotation ¶
SetRotation changes the rotation of the device (clock-wise)
func (*DeviceOf[T]) SetScrollArea ¶
SetScrollArea sets an area to scroll with fixed top and bottom parts of the display.
func (*DeviceOf[T]) Sleep ¶
Set the sleep mode for this LCD panel. When sleeping, the panel uses a lot less power. The LCD won't display an image anymore, but the memory contents will be kept.
func (*DeviceOf[T]) StopScroll ¶
func (d *DeviceOf[T]) StopScroll()
StopScroll returns the display to its normal state.
func (*DeviceOf[T]) Sync ¶
func (d *DeviceOf[T]) Sync()
Sync waits for the display to hit the next VSYNC pause
func (*DeviceOf[T]) SyncToScanLine ¶
SyncToScanLine waits for the display to hit a specific scanline
A scanline value of 0 will forward to the beginning of the next VSYNC, even if the display is currently in a VSYNC pause.
Syncline values appear to increment once for every two vertical lines on the display.
NOTE: Use GetHighestScanLine and GetLowestScanLine to obtain the highest and lowest useful values. Values are affected by front and back porch vsync settings (derived from VSyncLines configuration option).