lcd

package module
v0.0.0-...-131bf4c Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 3 Imported by: 0

README

Go Report Card

rpi-lcd

Description

Golang library for accessing I2C LCD screen connected to the RaspberryPi.

Tested LCDs:

Installation

go get github.com/mskrha/rpi-lcd

Usage

package main

import (
	"fmt"
	"time"

	"github.com/mskrha/rpi-lcd"
)

func main() {
	l := lcd.New(lcd.LCD{Bus: "/dev/i2c-1", Address: 0x27, Rows: 2, Cols: 16, Backlight: true})

	if err := l.Init(); err != nil {
		panic(err)
	}

	for {
		if err := l.Print(1, 0, time.Now().Format("02.01.")); err != nil {
			fmt.Println(err)
			return
		}
		if err := l.Print(1, 8, time.Now().Format("15:04:05")); err != nil {
			fmt.Println(err)
			return
		}
		time.Sleep(time.Second)
	}
}

Notes

Inspired by the Adafruit Liquid Crystal library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LCD

type LCD struct {
	Bus       string
	Address   int
	Rows      uint
	Cols      uint
	Backlight bool
	// contains filtered or unexported fields
}

func New

func New(in LCD) *LCD

func (*LCD) Clear

func (l *LCD) Clear() error

func (*LCD) Close

func (l *LCD) Close()

func (*LCD) Init

func (l *LCD) Init() error

func (*LCD) Print

func (l *LCD) Print(row, col uint, msg string) error

Jump to

Keyboard shortcuts

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