ili9341

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

README

TinyGo driver for TFT displays using ILI9341 driver chips.

These displays support 8-bit parallel, 16-bit parallel, or SPI interfaces.

Examples of such displays include:

Currently this driver only supports an 8-bit parallel interface using ATSAMD51 (this is the default configuration on PyPortal). It should be relatively straightforward to implement a more generic SPI-based interface as well. Please see parallel_atsamd51.go for an example of what needs to be implemented if you are interested in contributing.

Documentation

Index

Constants

View Source
const (
	TFTWIDTH  = 240 ///< ILI9341 max TFT width
	TFTHEIGHT = 320 ///< ILI9341 max TFT height

	NOP     = 0x00 ///< No-op register
	SWRESET = 0x01 ///< Software reset register
	RDDID   = 0x04 ///< Read display identification information
	RDDST   = 0x09 ///< Read Display Status

	SLPIN  = 0x10 ///< Enter Sleep Mode
	SLPOUT = 0x11 ///< Sleep Out
	PTLON  = 0x12 ///< Partial Mode ON
	NORON  = 0x13 ///< Normal Display Mode ON

	RDMODE     = 0x0A ///< Read Display Power Mode
	RDMADCTL   = 0x0B ///< Read Display MADCTL
	RDPIXFMT   = 0x0C ///< Read Display Pixel Format
	RDIMGFMT   = 0x0D ///< Read Display Image Format
	RDSELFDIAG = 0x0F ///< Read Display Self-Diagnostic Result

	INVOFF   = 0x20 ///< Display Inversion OFF
	INVON    = 0x21 ///< Display Inversion ON
	GAMMASET = 0x26 ///< Gamma Set
	DISPOFF  = 0x28 ///< Display OFF
	DISPON   = 0x29 ///< Display ON

	CASET = 0x2A ///< Column Address Set
	PASET = 0x2B ///< Page Address Set
	RAMWR = 0x2C ///< Memory Write
	RAMRD = 0x2E ///< Memory Read

	PTLAR    = 0x30 ///< Partial Area
	VSCRDEF  = 0x33 ///< Vertical Scrolling Definition
	MADCTL   = 0x36 ///< Memory Access Control
	VSCRSADD = 0x37 ///< Vertical Scrolling Start Address
	PIXFMT   = 0x3A ///< COLMOD: Pixel Format Set

	FRMCTR1 = 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors)
	FRMCTR2 = 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors)
	FRMCTR3 = 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors)
	INVCTR  = 0xB4 ///< Display Inversion Control
	DFUNCTR = 0xB6 ///< Display Function Control

	PWCTR1 = 0xC0 ///< Power Control 1
	PWCTR2 = 0xC1 ///< Power Control 2
	PWCTR3 = 0xC2 ///< Power Control 3
	PWCTR4 = 0xC3 ///< Power Control 4
	PWCTR5 = 0xC4 ///< Power Control 5
	VMCTR1 = 0xC5 ///< VCOM Control 1
	VMCTR2 = 0xC7 ///< VCOM Control 2

	RDID1 = 0xDA ///< Read ID 1
	RDID2 = 0xDB ///< Read ID 2
	RDID3 = 0xDC ///< Read ID 3
	RDID4 = 0xDD ///< Read ID 4

	GMCTRP1 = 0xE0 ///< Positive Gamma Correction
	GMCTRN1 = 0xE1 ///< Negative Gamma Correction

	MADCTL_MY  = 0x80 ///< Bottom to top
	MADCTL_MX  = 0x40 ///< Right to left
	MADCTL_MV  = 0x20 ///< Reverse Mode
	MADCTL_ML  = 0x10 ///< LCD refresh Bottom to top
	MADCTL_RGB = 0x00 ///< Red-Green-Blue pixel order
	MADCTL_BGR = 0x08 ///< Blue-Green-Red pixel order
	MADCTL_MH  = 0x04 ///< LCD refresh right to left

)

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
}

type Device

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

func NewSPI

func NewSPI(bus machine.SPI, dc, cs, rst machine.Pin) *Device

func (*Device) Configure

func (d *Device) Configure(config Config)

Configure prepares display for use

func (*Device) Display

func (d *Device) Display() error

Display sends the buffer (if any) to the screen.

func (*Device) DrawFastHLine

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

DrawFastHLine draws a horizontal line faster than using SetPixel

func (*Device) DrawFastVLine

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

DrawFastVLine draws a vertical line faster than using SetPixel

func (*Device) DrawRGBBitmap

func (d *Device) DrawRGBBitmap(x, y int16, data []uint16, w, h int16) error

DrawRGBBitmap copies an RGB bitmap to the internal buffer at given coordinates

func (*Device) DrawRGBBitmap8

func (d *Device) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error

DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates

func (*Device) DrawRectangle

func (d *Device) DrawRectangle(x, y, w, h int16, c color.RGBA) error

DrawRectangle draws a rectangle at given coordinates with a color

func (*Device) FillRectangle

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

FillRectangle fills a rectangle at 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) GetRotation

func (d *Device) GetRotation() Rotation

GetRotation returns the current rotation of the device

func (*Device) SetPixel

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

SetPixel modifies the internal buffer.

func (*Device) SetRotation

func (d *Device) SetRotation(rotation Rotation)

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

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/bottom or left/right parts of the display Rotation affects scroll direction

func (*Device) Size

func (d *Device) Size() (x, y int16)

Size returns the current size of the display.

func (*Device) StopScroll

func (d *Device) StopScroll()

StopScroll returns the display to its normal state

type Rotation

type Rotation uint8
const (
	Rotation0   Rotation = 0
	Rotation90  Rotation = 1 // 90 degrees clock-wise rotation
	Rotation180 Rotation = 2
	Rotation270 Rotation = 3
)

Jump to

Keyboard shortcuts

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