sevensegment

package module
v0.0.0-...-57abbea Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

sevensegment

Golang module for controlling the Adafruit seven segment LED display with backpack (HT16K33 i2c), using golang's periphio.

Note this was developed for use on a raspberry pi.

Examples of how to use are in example.go which does some simple tasks such as displaying numbers digits at specific positions, displaying a number up to 9999, letters, particular segments and setting the brightness.

eg. (assuming device addr on i2c bus is 0x70)

go mod init main
go run example.go

periphio (i2c)
https://periph.io/
https://godoc.org/periph.io/x/periph/conn/i2c

Adafruit LED backpack HT16k33 datasheet (info about commands/settings for the HT16K33)
https://cdn-shop.adafruit.com/datasheets/ht16K33v110.pdf

Adafruit LED backpack C/C++ library
https://github.com/adafruit/Adafruit_LED_Backpack

Documentation

Index

Constants

View Source
const (
	IndMidTop   = iota
	IndMidBtt   = iota
	IndLeftTop  = iota
	IndLeftBtt  = iota
	IndRightTop = iota
)

Dot LED indicators on Segment 4

Variables

This section is empty.

Functions

func NumToArray

func NumToArray(number int) []int

Return array (reverse order) of digits for a given 1-4 digit number

Types

type SevenSegment

type SevenSegment struct {
	Buffer [10]uint16
	// contains filtered or unexported fields
}

Sevensegment with a buffer to hold desired segment state

func NewSevenSegment

func NewSevenSegment(addr byte) (ss *SevenSegment)

func (*SevenSegment) AlphaToSegments

func (ss *SevenSegment) AlphaToSegments(letter byte) uint16

Return 2 byte value which segments should be on for a supplied letter

func (*SevenSegment) ArrayToSegments

func (ss *SevenSegment) ArrayToSegments(segments_on [7]bool) uint16

Return 2 byte value representing which segments are on for supplied array of 'on' segments

func (*SevenSegment) Clear

func (ss *SevenSegment) Clear()

Clear all segments

func (*SevenSegment) DisplayOn

func (ss *SevenSegment) DisplayOn()

Command to turn on display is 0x81

func (*SevenSegment) HwPos

func (ss *SevenSegment) HwPos(human_pos int) int

Translate human pos on display (0 - 4) to corresponding rows in HT16K33 mem that reference a digit or colons, pos 5 is colons.

func (*SevenSegment) IntToSs

func (ss *SevenSegment) IntToSs(digit int) uint16

Returns 2 byt val representing the data required to turn segments on for supplied 'digit' similar to numbertable at: https://github.com/adafruit/Adafruit_LED_Backpack/blob/master/Adafruit_LEDBackpack.cpp

func (*SevenSegment) OscillatorOn

func (ss *SevenSegment) OscillatorOn()

Command to turn on oscillator

func (*SevenSegment) SetAlpha

func (ss *SevenSegment) SetAlpha(pos int, letter byte)

Set letter at position from 0 to 3 from right to left

func (*SevenSegment) SetBrightness

func (ss *SevenSegment) SetBrightness(brightness int)

Set brightness from 0-15

func (*SevenSegment) SetDigit

func (ss *SevenSegment) SetDigit(pos int, digit int)

Set digit at position from 0 to 3 from right to left

func (*SevenSegment) SetNum

func (ss *SevenSegment) SetNum(number int) (err error)

Set a number on the display up to 9999. A negative number will result in --- being displayed.

func (*SevenSegment) SetSegments

func (ss *SevenSegment) SetSegments(human_pos int, on [7]bool)

Set specific segments on for digit at pos 0 to 3 from right to left To determine which segments, we label the segments 0-6 starting from topmost horizontal, incrementing clockwise to 5, and 6 is the middle horizontal and specify which are on in an array

func (*SevenSegment) WriteData

func (ss *SevenSegment) WriteData()

Write out my buffer, this will actually display segments

func (*SevenSegment) WriteRaw

func (ss *SevenSegment) WriteRaw(data []byte)

Write raw data to bus, useful for setting up the seven segment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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