gobotlcd

package module
v0.0.0-...-87e367a Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

Gobot LCD Gobot driver

GoDoc Go Report Card

A GoBot driver for LCDs. Requires an I2C connection. Has only been tested with a 20x4 display.

Getting started
go get -u github.com/ChrisTrenkamp/gobotlcd
Hello World
package main

import (
	"fmt"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/raspi"

	"github.com/ChrisTrenkamp/gobotlcd"
)

var smiley = gobotlcd.NewCharacter([8]byte{
	0x00,
	0x00,
	0x0A,
	0x00,
	0x00,
	0x11,
	0x0E,
	0x00,
})

func main() {
	rpi := raspi.NewAdaptor()
	lcd := gobotlcd.NewLiquidCrystalLCD(rpi, 16, 2, gobotlcd.DotSize5x8)

	work := func() {
		lcd.BacklightOn()
		lcd.RegisterCharacter(0, smiley)
		lcd.Home()
		fmt.Fprintf(lcd, "Hello World! %v", smiley)
	}

	robot := gobot.NewRobot("LiquidCrystalLCD",
		[]gobot.Connection{rpi},
		[]gobot.Device{lcd},
		work,
	)

	robot.Start()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomCharacter

type CustomCharacter struct {
	CharMap  [8]byte
	Register byte
}

CustomCharacter holds the bytes and register for custom characters

func NewCharacter

func NewCharacter(charmap [8]byte) *CustomCharacter

NewCharacter creates a new custom character map to display

func (*CustomCharacter) String

func (c *CustomCharacter) String() string

String will return an ASCII value of the register. Use this with Fprintf and pass in your custom character, or call LiquidCrystalLCD.Write and pass in the register value.

cchar := liquidcrystallcd.NewCharacter([8]byte{...})
lcd.RegisterCharacter(0, cchar)
lcd.Home()
fmt.Fprintf(lcd, "This is a custom character: %v", cchar) // Use Fprintf...
lcd.Write([]byte{0}) // ... or call the Write method

type DotSize

type DotSize byte

DotSize reprexents either a 5x8 or 5x10 dot mode for the lcd

const (
	//DotSize5x10 is used to connect to a 5x10 dot size LCD
	DotSize5x10 DotSize = lcd5x10Dots
	//DotSize5x8 is used to connect to a 5x8 dot size LCD
	DotSize5x8 DotSize = lcd5x8Dots
)

type GobotLCD

type GobotLCD struct {
	i2c.Config
	// contains filtered or unexported fields
}

GobotLCD controls a Liquid Crystal LCD with an I2C connection.

func New

func New(a i2c.Connector, cols, rows byte, dotSize DotSize, options ...func(i2c.Config)) *GobotLCD

New connects to an LCD with the given I2C connection, the given row and column size, and the given dot size.

func (*GobotLCD) AutoScrollOff

func (lcd *GobotLCD) AutoScrollOff() error

AutoScrollOff 'right justifies' the text so that the cursor moves when printing characters rather than moving the display

func (*GobotLCD) AutoScrollOn

func (lcd *GobotLCD) AutoScrollOn() error

AutoScrollOn 'left justifies' the text so that the display moves when printing characters rather than moving the cursor

func (*GobotLCD) BacklightOff

func (lcd *GobotLCD) BacklightOff() error

BacklightOff turns the lcd light off

func (*GobotLCD) BacklightOn

func (lcd *GobotLCD) BacklightOn() error

BacklightOn turns the lcd light on

func (*GobotLCD) Clear

func (lcd *GobotLCD) Clear() error

Clear wipes all text from the screen and positions the cursor at the top-left

func (*GobotLCD) Connection

func (lcd *GobotLCD) Connection() gobot.Connection

Connection returns the Connection associated with the Driver

func (*GobotLCD) CursorOff

func (lcd *GobotLCD) CursorOff() error

CursorOff turns off the blinking cursor

func (*GobotLCD) CursorOn

func (lcd *GobotLCD) CursorOn() error

CursorOn turns on the blinking cursor

func (*GobotLCD) DisplayOff

func (lcd *GobotLCD) DisplayOff() error

DisplayOff turns the text display off

func (*GobotLCD) DisplayOn

func (lcd *GobotLCD) DisplayOn() error

DisplayOn turns the text display on

func (*GobotLCD) Halt

func (lcd *GobotLCD) Halt() (err error)

Halt terminates the Driver

func (*GobotLCD) Home

func (lcd *GobotLCD) Home() error

Home returns the cursor to the top-left

func (*GobotLCD) Name

func (lcd *GobotLCD) Name() string

Name returns the label for the Driver

func (*GobotLCD) PrintLeftToRight

func (lcd *GobotLCD) PrintLeftToRight() error

PrintLeftToRight prints text from left to right. e.g. 'foo' will display as 'foo'

func (*GobotLCD) PrintRightToLeft

func (lcd *GobotLCD) PrintRightToLeft() error

PrintRightToLeft prints text from right to left. e.g. 'foo' will display as 'oof'

func (*GobotLCD) RegisterCharacter

func (lcd *GobotLCD) RegisterCharacter(location byte, charmap *CustomCharacter) error

RegisterCharacter registers a custom character to display on the lcd. Any custom characters currently on the lcd will be immediately replaced. location may be a number from 0 - 7.

func (*GobotLCD) SetCursor

func (lcd *GobotLCD) SetCursor(col, row byte) error

SetCursor positions the cursor at the specified row/column.

func (*GobotLCD) SetName

func (lcd *GobotLCD) SetName(name string)

SetName sets the label for the Driver

func (*GobotLCD) ShiftDisplayLeft

func (lcd *GobotLCD) ShiftDisplayLeft() error

ShiftDisplayLeft moves the text on the entire display to the left

func (*GobotLCD) ShiftDisplayRight

func (lcd *GobotLCD) ShiftDisplayRight() error

ShiftDisplayRight moves the text on the entire display to the right

func (*GobotLCD) Start

func (lcd *GobotLCD) Start() (err error)

Start initiates the Driver

func (*GobotLCD) UnderlineOff

func (lcd *GobotLCD) UnderlineOff() error

UnderlineOff turns off the underline cursor

func (*GobotLCD) UnderlineOn

func (lcd *GobotLCD) UnderlineOn() error

UnderlineOn turns on the underline cursor

func (*GobotLCD) Write

func (lcd *GobotLCD) Write(str []byte) (int, error)

Write satisfies the io.Writer interface so it can be used with fmt or the I/O of your choice.

Jump to

Keyboard shortcuts

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