hd44780i2c

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause Imports: 3 Imported by: 15

Documentation

Overview

Package hd44780i2c implements a driver for the Hitachi HD44780 LCD display module with an I2C adapter.

Datasheet: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf

Index

Constants

View Source
const (

	// commands
	DISPLAY_CLEAR        = 0x01
	CURSOR_HOME          = 0x02
	ENTRY_MODE           = 0x04
	DISPLAY_ON_OFF       = 0x08
	CURSOR_DISPLAY_SHIFT = 0x10
	FUNCTION_MODE        = 0x20
	CGRAM_SET            = 0x40
	DDRAM_SET            = 0x80

	// flags for display entry mode
	// CURSOR_DECREASE  = 0x00
	CURSOR_INCREASE = 0x02
	// DISPLAY_SHIFT    = 0x01
	DISPLAY_NO_SHIFT = 0x00

	// flags for display on/off control
	DISPLAY_ON       = 0x04
	DISPLAY_OFF      = 0x00
	CURSOR_ON        = 0x02
	CURSOR_OFF       = 0x00
	CURSOR_BLINK_ON  = 0x01
	CURSOR_BLINK_OFF = 0x00

	// flags for function set
	// DATA_LENGTH_8BIT = 0x10
	DATA_LENGTH_4BIT = 0x00
	TWO_LINE         = 0x08
	ONE_LINE         = 0x00
	FONT_5X10        = 0x04
	FONT_5X8         = 0x00

	// flags for backlight control
	BACKLIGHT_ON  = 0x08
	BACKLIGHT_OFF = 0x00

	En = 0x04 // Enable bit
	// Rw = 0x02 // Read/Write bit
	Rs = 0x01 // Register select bit
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Width       uint8
	Height      uint8
	Font        uint8
	CursorOn    bool
	CursorBlink bool
}

Config for HD44780 I2C LCD.

type Device

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

Device wraps an I2C connection to a HD44780 I2C LCD with related data.

func New

func New(bus drivers.I2C, addr uint8) Device

New creates a new HD44780 I2C LCD connection. The I2C bus must already be configured.

This function only creates the Device object, it does not touch the device.

func (*Device) BacklightOn

func (d *Device) BacklightOn(option bool)

BacklightOn turns on/off the display backlight.

func (*Device) ClearDisplay

func (d *Device) ClearDisplay()

ClearDisplay clears all texts on the display.

func (*Device) Configure

func (d *Device) Configure(cfg Config) error

Configure sets up the display. Display itself and backlight is default on.

func (*Device) CreateCharacter

func (d *Device) CreateCharacter(cgramAddr uint8, data []byte)

CreateCharacter crates custom characters (using data parameter) and stores it under CGRAM address (using cgramAddr, 0x0-0x7).

func (d *Device) CursorBlink(option bool)

CursorBlink turns on/off the blinking cursor mode.

func (*Device) CursorOn

func (d *Device) CursorOn(option bool)

CursorOn display/hides the cursor.

func (*Device) DisplayOn

func (d *Device) DisplayOn(option bool)

DisplayOn turns on/off the display.

func (*Device) Home

func (d *Device) Home()

Home sets the cursor back to position (0, 0).

func (*Device) Print

func (d *Device) Print(data []byte)

Print prints text on the display (started from current cursor position).

It would automatically break to new line when the text is too long. You can also use \n as line breakers.

func (*Device) SetCursor

func (d *Device) SetCursor(x, y uint8)

SetCursor sets the cursor to a specific position (x, y).

if y (row) is set larger than actual rows, it would be set to 0.

Jump to

Keyboard shortcuts

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