lcd

package
v0.0.0-...-328052d Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Lines int
	Cols  int
	Font  Font
}

type Controller

type Controller interface {
	// IsEightBitMode should return true if the controller supports 8-bit communication.
	IsEightBitMode() bool

	// SetBacklight should update the state of the backlight.
	SetBacklight(bool) error

	// WriteByteIR writes to the instruction register.
	WriteByteIR(byte) error

	// ReadByteIR reads from the instruction register.
	ReadByteIR() (byte, error)

	// WriteByte writes to the data register.
	io.ByteWriter

	// ReadByte reads from the data register.
	io.ByteReader
}

The Controller interface is the main interface for interacting with a LCD display.

type Expander

type Expander struct {
	ExpanderConfig
	// contains filtered or unexported fields
}

func NewExpander

func NewExpander(cfg ExpanderConfig) *Expander

func (*Expander) IsEightBitMode

func (e *Expander) IsEightBitMode() bool

func (*Expander) ReadByte

func (e *Expander) ReadByte() (byte, error)

func (*Expander) ReadByteIR

func (e *Expander) ReadByteIR() (byte, error)

func (*Expander) SetBacklight

func (e *Expander) SetBacklight(value bool) error

func (*Expander) WriteByte

func (e *Expander) WriteByte(data byte) error

func (*Expander) WriteByteIR

func (e *Expander) WriteByteIR(data byte) error

type ExpanderConfig

type ExpanderConfig struct {
	RS driver.OutputPin
	RW driver.OutputPin
	E  driver.OutputPin
	BL driver.OutputPin

	// Read operations will only be enabled if the DB_ pins also implement
	// the ioexp.InputPin interface.
	DB4 driver.OutputPin
	DB5 driver.OutputPin
	DB6 driver.OutputPin
	DB7 driver.OutputPin

	// optional
	DB0 driver.OutputPin
	DB1 driver.OutputPin
	DB2 driver.OutputPin
	DB3 driver.OutputPin

	// Flush, if set, will be called after updating pins for writing.
	Flush func() error

	// Refresh, if set, will be called before reading pins.
	Refresh func() error
}

type Font

type Font int
const (
	Font5x8 Font = iota
	Font5x10
)

type HD44780

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

func NewHD44780

func NewHD44780(c Controller, cfg Config) (*HD44780, error)

func NewHD44780I2C

func NewHD44780I2C(bus i2c.Bus, addr uint16, cfg Config) (*HD44780, error)

func (*HD44780) Clear

func (lcd *HD44780) Clear() error

Clear clears the entire display and sets DDRAM address 0 in the address counter.

func (*HD44780) Home

func (lcd *HD44780) Home() error

Home sets DDRAM address 0 in the address counter and returns the cursor to the home position.

func (*HD44780) SetBacklight

func (lcd *HD44780) SetBacklight(v bool) error

func (*HD44780) SetCursorXY

func (lcd *HD44780) SetCursorXY(x, y int) error

SetCursorXY sets the cursor position to the specified coordinates starting from top-left.

func (*HD44780) SetDisplay

func (lcd *HD44780) SetDisplay(displayOn, cursorOn, cursorBlink bool) error

func (*HD44780) SetEntryMode

func (lcd *HD44780) SetEntryMode(increment, shiftDisplay bool) error

func (*HD44780) SetFunction

func (lcd *HD44780) SetFunction(eightBitMode, twoLines, fiveByTen bool) error

SetFunction sets the number of display lines, character font, and data transmission length.

If eightBitMode is false, 4-bit communication will be used. If twoLines is false, only one line will be displayed. If fiveByTen is false, the character font will be 5x8.

func (*HD44780) Write

func (lcd *HD44780) Write(p []byte) (int, error)

func (*HD44780) WriteByte

func (lcd *HD44780) WriteByte(b byte) error

Jump to

Keyboard shortcuts

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