ht16k33

package
v3.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ht16k33 implements interfacing code to Holtek HT16K33 Alphanumeric 16x8 LED driver.

More Details

Datasheets

http://www.holtek.com/documents/10179/116711/HT16K33v120.pdf

Product Page

http://www.holtek.com/productdetail/-/vg/HT16K33

Example
package main

import (
	"fmt"
	"log"
	"time"

	"periph.io/x/periph/conn/i2c/i2creg"
	"periph.io/x/periph/experimental/devices/ht16k33"
	"periph.io/x/periph/host"
)

func main() {
	// Make sure periph is initialized.
	if _, err := host.Init(); err != nil {
		log.Fatal(err)
	}

	bus, err := i2creg.Open("")
	if err != nil {
		log.Fatal(err)
	}
	defer bus.Close()

	display, err := ht16k33.NewAlphaNumericDisplay(bus, ht16k33.I2CAddr)
	if err != nil {
		log.Fatal(err)
	}
	defer display.Halt()

	if _, err := display.WriteString("ABCD"); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)

	if _, err := display.WriteString("GO"); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)

	if _, err := display.WriteString(fmt.Sprintf("%d", 1234)); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)

	if _, err := display.WriteString(fmt.Sprintf("%d", 60)); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)

	if _, err := display.WriteString(fmt.Sprintf("%5f", 23.99)); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)

	if _, err := display.WriteString(fmt.Sprintf("%5f", 1.45)); err != nil {
		log.Fatal(err)
	}
	time.Sleep(1 * time.Second)
}
Output:

Index

Examples

Constants

View Source
const (
	BlinkOff    = 0x00
	Blink2Hz    = 0x02
	Blink1Hz    = 0x04
	BlinkHalfHz = 0x06
)

Blinking frequencies.

View Source
const I2CAddr uint16 = 0x70

I2CAddr i2c default address.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlinkFrequency

type BlinkFrequency byte

BlinkFrequency display frequency must be a value allowed by the HT16K33.

type Dev

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

Dev is a handler to ht16k33 controller

func NewI2C

func NewI2C(bus i2c.Bus, address uint16) (*Dev, error)

NewI2C returns a Dev object that communicates over I2C.

To use on the default address, ht16k33.I2CAddr must be passed as argument.

func (*Dev) Halt

func (d *Dev) Halt() error

Halt clear the contents of display buffer.

func (d *Dev) SetBlink(freq BlinkFrequency) error

SetBlink Blink display at specified frequency.

func (*Dev) SetBrightness

func (d *Dev) SetBrightness(brightness int) error

SetBrightness of entire display to specified value.

Supports 16 levels, from 0 to 15.

func (*Dev) WriteColumn

func (d *Dev) WriteColumn(column int, data uint16) error

WriteColumn set data in a given column.

type Display

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

Display is a handler to control an alphanumeric display based on ht16k33.

func NewAlphaNumericDisplay

func NewAlphaNumericDisplay(bus i2c.Bus, address uint16) (*Display, error)

NewAlphaNumericDisplay returns a Display object that communicates over I2C to ht16k33.

To use on the default address, ht16k33.I2CAddr must be passed as argument.

func (*Display) Halt

func (d *Display) Halt() error

Halt clear all the display.

func (*Display) SetDigit

func (d *Display) SetDigit(pos int, digit rune, decimal bool) error

SetDigit at position to provided value.

func (*Display) WriteString

func (d *Display) WriteString(s string) (int, error)

WriteString print string of values to the display.

Characters in the string should be any ASCII value 32 to 127 (printable ASCII).

Jump to

Keyboard shortcuts

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