lcd

package module
v0.0.0-...-b98c5cf Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

lcd

This library implements a few simple GPIO-based drivers for cheap LCD modules, using periph.io.

Documentation

Overview

Package lcd is a library for displaying on certain LCDs via GPIO pins (using periph.io).

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QP5515

type QP5515 struct {
	RS, RW, E gpio.PinIO    // register select, read/write, enable signal
	DB        [8]gpio.PinIO // data bits 0 - 7
}

QP5515 implements a driver for a QP-5515 or QP-5516 module. It assumes 8-bit mode (all 8 data pins are connected). The contrast adjust (pin 3 on mine) should be connected to the centre of a 10k trimpot between 0 and 5v.

Example
host.Init()
q := &QP5515{
	RS: gpioreg.ByName("27"),
	RW: gpioreg.ByName("20"),
	E:  gpioreg.ByName("26"),
	DB: [8]gpio.PinIO{
		0: gpioreg.ByName("19"),
		1: gpioreg.ByName("25"),
		2: gpioreg.ByName("18"),
		3: gpioreg.ByName("24"),
		4: gpioreg.ByName("17"),
		5: gpioreg.ByName("23"),
		6: gpioreg.ByName("16"),
		7: gpioreg.ByName("22"),
	},
}
q.BusyWait()
q.Clear()
q.BusyWait()
q.SetFunction(true, true, false) // 8-bit, 2-line, small font
q.BusyWait()
q.SetDisplayMode(true, false, false) // display on, no cursor or blink
q.BusyWait()
q.SetEntryMode(true, false) // increment address, no shift
q.BusyWait()
if len(os.Args) == 1 {
	q.Display("github.com/")
	q.BusyWait()
	q.SetDDAddress(0x40)
	q.BusyWait()
	q.Display("DrJosh9000/lcd")
	return
}
q.Display(os.Args[1])
if len(os.Args[1]) > 16 {
	q.BusyWait()
	q.SetDDAddress(0x40)
	q.BusyWait()
	q.Display(os.Args[1][16:])
}

func (*QP5515) BusyWait

func (q *QP5515) BusyWait()

BusyWait waits until the busy flag is cleared.

func (*QP5515) Clear

func (q *QP5515) Clear()

Clear clears the display and returns the cursor to the home position.

func (*QP5515) Display

func (q *QP5515) Display(s string)

Display writes data to the display.

func (*QP5515) RawFunction

func (q *QP5515) RawFunction(a uint8)

RawFunction performs a function or sets an address for the next write.

func (*QP5515) ReadBFAC

func (q *QP5515) ReadBFAC() uint8

ReadBFAC reads the busy flag and address counter.

func (*QP5515) ReadData

func (q *QP5515) ReadData() uint8

ReadData reads a value from CG RAM or DD RAM.

func (*QP5515) ReturnHome

func (q *QP5515) ReturnHome()

ReturnHome returns the cursor to the home position and resets the display shift.

func (*QP5515) SetCGAddress

func (q *QP5515) SetCGAddress(a uint8)

SetCGAddress sets the CG RAM address (0 <= a < 64).

func (*QP5515) SetDDAddress

func (q *QP5515) SetDDAddress(a uint8)

SetDDAddress sets the DD RAM address (0 <= a < 128).

func (*QP5515) SetDisplayMode

func (q *QP5515) SetDisplayMode(display, cursor, blink bool)

SetDisplayMode turns on/off the whole display, cursor, or cursor-blinking.

func (*QP5515) SetDisplayShiftOrCursorMove

func (q *QP5515) SetDisplayShiftOrCursorMove(shift, right bool)

SetDisplayShiftOrCursorMove sets display shift or cursor move, and direction.

func (*QP5515) SetEntryMode

func (q *QP5515) SetEntryMode(increment, shift bool)

SetEntryMode sets the data entry direction and whether to also shift.

func (*QP5515) SetFunction

func (q *QP5515) SetFunction(eightbit, twolines, largefont bool)

SetFunction sets the interface data length, number of display lines, and character font. eightbit = false means switch to 4-bit operation. twolines = false means use 1 display line. largefont = false mease use 5x7 font instead of 5x10 font.

func (*QP5515) WriteData

func (q *QP5515) WriteData(b uint8)

WriteData writes a value to CG RAM or DD RAM.

type RS257543

type RS257543 struct {
	LD, CLK, DIN  gpio.PinIO // required, as described in the data sheet
	DEG, COL, CUR gpio.PinIO // optional

	RuneMap map[rune]uint8 // optional, uses a default map if nil
}

RS257543 implements a driver for the RS 257-543 module (a discontinued 4-digit LCD module based on the Hughes 0438A chip). DEG, COL, and CUR are optional, and if provided, are assumed to each be connected via an XOR gate with BP as described in the data sheet. RuneMap is also optional and if provided, is used by Display to translate each rune into 8 segments.

func (*RS257543) Clear

func (r *RS257543) Clear()

Clear resets all segments on the display.

func (*RS257543) CycleDigits

func (r *RS257543) CycleDigits(ctx context.Context)

CycleDigits animates a simple test pattern consisting of hex digits.

func (*RS257543) Display

func (r *RS257543) Display(s string)

Display displays a string on the module. Each rune in the string is translated to a digit, except for '.', which is translated into the DP ("decimal point") segment of the following digit (the DP segment is to the left of each digit).

func (*RS257543) RawDisplay

func (r *RS257543) RawDisplay(bits uint32)

RawDisplay loads bits into the display directly.

Jump to

Keyboard shortcuts

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