ili9341

package
v0.0.0-...-0087ba1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 5 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
	TEOFF    = 0x34 ///< TEOFF: Tearing Effect Line OFF
	TEON     = 0x35 ///< TEON: Tearing Effect Line ON
	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

)
View Source
const (
	Rotation0   = drivers.Rotation0
	Rotation90  = drivers.Rotation90 // 90 degrees clock-wise rotation
	Rotation180 = drivers.Rotation180
	Rotation270 = drivers.Rotation270

	Rotation0Mirror   = drivers.Rotation0Mirror
	Rotation90Mirror  = drivers.Rotation90Mirror
	Rotation180Mirror = drivers.Rotation180Mirror
	Rotation270Mirror = drivers.Rotation270Mirror
)

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         drivers.Rotation
	DisplayInversion bool
}

type Device

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

func NewSPI

func NewSPI(bus drivers.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) EnableTEOutput

func (d *Device) EnableTEOutput(on bool)

EnableTEOutput enables the TE ("tearing effect") line. The TE line goes high when the screen is not currently being updated and can be used to start drawing. When used correctly, it can avoid tearing entirely.

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 deprecated

func (d *Device) GetRotation() drivers.Rotation

GetRotation returns the current rotation of the device.

Deprecated: use Rotation instead.

func (*Device) Rotation

func (d *Device) Rotation() drivers.Rotation

Rotation 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 drivers.Rotation) error

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

func (d *Device) Sleep(sleepEnabled bool) error

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 (*Device) StopScroll

func (d *Device) StopScroll()

StopScroll returns the display to its normal state

type Rotation

type Rotation uint8

Jump to

Keyboard shortcuts

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