tftdrv

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package tftdrv defines the Display Controller Interface (DCI) and provides generic drivers to the graphics controllers that can be found in a wide variety of LCD and OLED displays. The supported controllers are generally similar to each other both in terms of used DCI and the command set they provide. The de facto standard in this area was set in the early 2000s by Philips PCF8833 and Epson S1D15G00 controllers used in the first mobile phones with color display like Nokia 6100 or Siemens S65.

The subpackages provides drivers to the specific controllers.

Index

Constants

View Source
const (
	R16 PF = 1 << iota // Read  2 bytes/pixel, RGB 565
	W16                // Write 2 bytes/pixel, RGB 565
	R24                // Read  3 bytes/pixel, RGB nnn,
	W24                // Write 3 bytes/pixel, RGB nnn,
	X2L                // Unused 2 low  bits per subpixel
	X2H                // Unused 2 high bits per subpixel

	R18L = R24 | X2H // 3 bytes/pixel, 6 bits/subpixel in low  part of byte
	W18L = W24 | X2H // 3 bytes/pixel, 6 bits/subpixel in low  part of byte
	R18H = R24 | X2L // 3 bytes/pixel, 6 bits/subpixel in high part of byte
	W18H = W24 | X2L // 3 bytes/pixel, 6 bits/subpixel in high part of byte
)
View Source
const (
	None  = 0
	Write = 1
	Read  = 2
)

DCI.Cmd dataMode constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteNWriter

type ByteNWriter interface {
	WriteByteN(b byte, n int)
}

ByteNWriter is an optional interface that may be implemented by DCI to speed up drawing some colors (gray colors in case of 18/24-bit pixel format and some other in case of 16-bit pixel format).

WriteByteN writes n times the byte to the display controller using data transfer mode.

type Ctrl

type Ctrl struct {
	StartWrite func(dci DCI, reg *Reg, r image.Rectangle)
	Read       func(dci DCI, reg *Reg, r image.Rectangle, buf []byte)
	SetPF      func(dci DCI, reg *Reg, size int)
	SetDir     func(dci DCI, reg *Reg, dir int)
}

Ctrl contains display specific control functions.

type DCI

type DCI interface {
	// Cmd writes len(p) bytes from p to the display controller using command
	// transfer mode. The dataMode parameter describes the direction of possible
	// data transfer which together with p forms a complete write or read
	// transaction.
	Cmd(p []byte, dataMode int)

	// WriteBytes writes len(p) bytes from p to the display controller using
	// data transfer mode.
	WriteBytes(p []uint8)

	// ReadBytes reads len(p) bytes into p from the display controller using
	// data transfer mode. Some displays are write-only so the implementation
	// designed exclusively for write-only displays may do nothing.
	ReadBytes(p []byte)

	// End ends the conversation with the display controller. The undelying
	// shared communication interface can be used by another application until
	// next command.
	End()

	// Err returns the saved error and clears it if the clear is true.
	Err(clear bool) error
}

DCI defines the basic Display Controller Interface.

type Driver

type Driver struct {
	// contains filtered or unexported fields

} // ont 32-bit MCU the size of this struct is 256 B, a full 256 B allocation unit (see runtime/sizeclasses_mcu.go)

Driver implements pix.Driver interface with a limited support for draw.Over operation. It is designed for write-only displays (doesn't use DCI.ReadBytes method) so the alpha blending is slow and reduced to 1-bit resolution. Use DriverOver if the full-fledged Porter-Duff composition is required and the display supports reading from its frame memory.

func New

func New(dci DCI, w, h uint16, pf PF, ctrl *Ctrl) *Driver

New returns new Driver.

func (*Driver) Draw

func (d *Driver) Draw(r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op draw.Op)

func (*Driver) Err

func (d *Driver) Err(clear bool) error

func (*Driver) Fill

func (d *Driver) Fill(r image.Rectangle)

func (*Driver) Flush

func (d *Driver) Flush()

func (*Driver) Init

func (d *Driver) Init(cmds []byte)

Init initializes the display using provided initialization commands. The initialization commands depends on the LCD pannel. The command that sets the display orientation and the color order must be the last one in the cmds See ili9341.GFX for working example.

func (*Driver) SetColor

func (d *Driver) SetColor(c color.Color)

func (*Driver) SetDir

func (d *Driver) SetDir(dir int) image.Rectangle

type DriverOver

type DriverOver struct {
	// contains filtered or unexported fields

} // ont 32-bit MCU the size of this struct is 256 B (bufLen=222), a full 256 B allocation unit (see runtime/sizeclasses_mcu.go)

DriverOver implements pix.Driver interface with the full support for draw.Over operator. The DCI must fully implement ReadBytes method to read the frame memory content. If the display has write-only interface use Driver instead.

func NewOver

func NewOver(dci DCI, w, h uint16, pf PF, ctrl *Ctrl) *DriverOver

NewOver returns new DriverOver.

func (*DriverOver) Draw

func (d *DriverOver) Draw(r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op draw.Op)

func (*DriverOver) Err

func (d *DriverOver) Err(clear bool) error

func (*DriverOver) Fill

func (d *DriverOver) Fill(r image.Rectangle)

func (*DriverOver) Flush

func (d *DriverOver) Flush()

func (*DriverOver) Init

func (d *DriverOver) Init(cmds []byte)

Init initializes the display using provided initialization commands. The initialization commands depends on the LCD pannel. The command that sets the display orientation and the color order must be the last one in the cmds See ili9341.GFX, ili9486.MSP4022 as examples.

func (*DriverOver) SetColor

func (d *DriverOver) SetColor(c color.Color)

func (*DriverOver) SetDir

func (d *DriverOver) SetDir(dir int) image.Rectangle

func (*DriverOver) Size

func (d *DriverOver) Size() image.Point

type PF

type PF byte

PF describes pixel data formats supported by display cpntroller.

type Reg

type Reg struct {
	PF   [1]byte // pixel format related register
	Dir  [1]byte // direction/orientation related register
	Xarg [4]byte // scratch buffer to avoid allocation
}

Reg contains local copy of some controller registers to allow working with write-only displays.

type StringWriter

type StringWriter interface {
	WriteString(s string)
}

StringWriter is an optional interface that may be implemented by DCI to speed up drawing of immutable images.

WriteString writes len(s) bytes from s to the display controller using data transfer mode.

type WordNWriter

type WordNWriter interface {
	WriteWordN(w uint16, n int)
}

WordNWriter is an optional interface that may be implemented by a DCI to improve drawing pertformance in case of 16-bit pixel format.

WriteWordN writes n times the 16-bit word to the display controller using data transfer mode.

Directories

Path Synopsis
Package ili9341 provides driver to ILI9341 based displays.
Package ili9341 provides driver to ILI9341 based displays.
Package ili9486 provides driver to ILI9486 based displays.
Package ili9486 provides driver to ILI9486 based displays.
internal
Package ssd1351 provides driver to SSD1351 based displays.
Package ssd1351 provides driver to SSD1351 based displays.
Package st7789 provides driver to ST7789 based displays.
Package st7789 provides driver to ST7789 based displays.

Jump to

Keyboard shortcuts

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