i2c

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

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

Go to latest
Published: Aug 23, 2014 License: BSD-2-Clause Imports: 4 Imported by: 8

Documentation

Overview

Package i2c provides low level control over the linux i2c bus.

Before usage you should load the i2c-dev kenel module

sudo modprobe i2c-dev

Each i2c bus can address 127 independent i2c devices, and most linux systems contain several buses.

Index

Constants

View Source
const (
	// Commands
	CMD_Clear_Display        = 0x01
	CMD_Return_Home          = 0x02
	CMD_Entry_Mode           = 0x04
	CMD_Display_Control      = 0x08
	CMD_Cursor_Display_Shift = 0x10
	CMD_Function_Set         = 0x20
	CMD_DDRAM_Set            = 0x80

	// Options
	OPT_Increment = 0x02 // CMD_Entry_Mode
	// OPT_Display_Shift  = 0x01 // CMD_Entry_Mode
	OPT_Enable_Display = 0x04 // CMD_Display_Control
	OPT_Enable_Cursor  = 0x02 // CMD_Display_Control
	OPT_Enable_Blink   = 0x01 // CMD_Display_Control
	OPT_Display_Shift  = 0x08 // CMD_Cursor_Display_Shift
	OPT_Shift_Right    = 0x04 // CMD_Cursor_Display_Shift 0 = Left
	OPT_2_Lines        = 0x08 // CMD_Function_Set 0 = 1 line
	OPT_5x10_Dots      = 0x04 // CMD_Function_Set 0 = 5x7 dots
)

Variables

This section is empty.

Functions

This section is empty.

Types

type I2C

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

I2C represents a connection to an i2c device.

func New

func New(addr uint8, bus int) (*I2C, error)

New opens a connection to an i2c device.

func (*I2C) Close

func (i2c *I2C) Close() error

func (*I2C) Read

func (i2c *I2C) Read(p []byte) (int, error)

func (*I2C) Write

func (i2c *I2C) Write(buf []byte) (int, error)

Write sends buf to the remote i2c device. The interpretation of the message is implementation dependant.

func (*I2C) WriteByte

func (i2c *I2C) WriteByte(b byte) (int, error)

type Lcd

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

func NewLcd

func NewLcd(i2c *I2C, en, rw, rs, d4, d5, d6, d7, backlight byte) (*Lcd, error)

func (*Lcd) BacklightOff

func (lcd *Lcd) BacklightOff()

func (*Lcd) BacklightOn

func (lcd *Lcd) BacklightOn()

func (*Lcd) Clear

func (lcd *Lcd) Clear()

func (*Lcd) Command

func (lcd *Lcd) Command(cmd byte)

func (*Lcd) Home

func (lcd *Lcd) Home()

func (*Lcd) SetPosition

func (lcd *Lcd) SetPosition(line, pos byte)

func (*Lcd) Write

func (lcd *Lcd) Write(buf []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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