segdisp

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Overview

Package segdisp provides support for alphanumeric displays that may display symbols symbols composed of individual segments. Typical representatives of this group of displays are 7/8/9/10-segment displays intended for displaying numeric values and 14/16-segment displays that allow also displaying latin letters.

Index

Constants

View Source
const (
	A = 1 << iota // top | : : bottom
	B             //     :^: :
	C             //     : :^:
	D             //     : : |
	E             //     : :_:
	F             //     :_: :
	G             //     : | :
	Q             //         ' (dot)
)

Segment bits

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver16

type Driver16 interface {
	Display16(symbols []uint16)
}

Driver16 is the interface that wraps the Display16 method.

Display16 gives the driver the symbols to be displayed on the 14/16-segment display. See Display8 for more information.

type Driver8

type Driver8 interface {
	Display8(symbols []uint8)
}

Driver8 is the interface that wraps the Display8 method.

Display8 gives the driver the symbols to be displayed on the 7/8-segment display. The symbol is an 8-bit bitmap which determines which segments of the symbol should be visible. Display8 may use the provided symbols slice (e.g. periodicaly display its content) until the next Display8 or Stop call.

type Seg8

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

A Seg8 provides an interface to print on the 7/8-segment displays. The display is considered as a metrix of symbols. Internally Seg8 maintains two buffers each of which covers the entire display. The first one is used by all Set* and Write* methods, the second one contains currently displayed symbols. The Swap method swaps buffers ensuring glitchless content on the display.

func NewSeg8

func NewSeg8(lineLen, lineNum int, drv Driver8) *Seg8

func (*Seg8) Clear

func (d *Seg8) Clear()

func (*Seg8) SetChar

func (d *Seg8) SetChar(x, y int, c byte)

SetChar works like SetSymbol but converts the ASCII char c to the symbol before writting to the inactive buffer.

func (*Seg8) SetPos

func (d *Seg8) SetPos(x, y int)

SetPos sets the current writting pusition for the Write* methods.

func (*Seg8) SetSymbol

func (d *Seg8) SetSymbol(x, y int, sym byte)

SetSymbol writes the symbol at the given position in the inactive buffer.

func (*Seg8) Swap

func (d *Seg8) Swap()

Swap swaps the Seg8 internal buffers so the currently inactive buffer is passed to the driver which makes it active and the previously active buffer becomes inactive.

func (*Seg8) Write

func (d *Seg8) Write(p []byte) (int, error)

Write implements io.Writer. It writes all bytes of p to the inactive buffer starting from the current writting position. See WritByte for more information.

func (*Seg8) WriteByte

func (d *Seg8) WriteByte(b byte) (err error)

WritByte writes a byte at the current position to the inactive buffer. The byte is considered an ASCII character (not all ASCII characters are possible to display on 7/8-segment display). The '\n' character moves the current writing position at the beginning of the next line or swaps the buffers if written on the last line of the display (see Swap method) and sets the writting position at the beggining of the first line of the inactive buffer.

func (*Seg8) WriteString

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

WriteString implements io.StringWriter. See Write for more information.

type ShiftReg8

type ShiftReg8 interface {
	// WriteBytes writes provided bytes to the shift register. The bit order
	// is implementation specific.
	WriteBytes(p []byte)

	// Latch copies the current content of the shift register to its parallel
	// output.
	Latch()
}

ShiftReg8 is the interface that allows to write data to an 8-bit shift register or to the cascade of such registers that togather make n*8-bit register.

type TimeMux8

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

A TimeMux8 is a driver to the time multiplexed 7/8-segment displays. It assumes the display digits are driven by a 16-bit shift register (or a cascade of two 8-bit registers). The used ShiftReg implementation should provide the correct bit order that match the hardware configuration.

func NewTimeMux8

func NewTimeMux8(sr ShiftReg8, commonAnode bool, fps int) *TimeMux8

NewTimeMux8 returns the ready to use TimeMux8 driver. The returned driver is stopped (doesn't refresh the connected display). Use Start to start it. The commonAnode parameter controlls the polarity of the generated signals. If the commonAnode is false the first byte sent to the shift register selects the digit using bit of value 0 at one of the eight possible positions (the remaining bits are equal to 1) then the second byte selects the segments of this digit using ones. If the commonAnode is true the digit is seleted using bit of value 1 (the remaining bits are equal to 0) and the segments are selected using zeros. The fps parameter determines how many times per second the display is refreshed (in case of LED based displays the fps >= 60 gives flickerless picture).

func (*TimeMux8) Display8

func (tm *TimeMux8) Display8(symbols []uint8)

Display8 implements Driver8.

func (*TimeMux8) Start

func (tm *TimeMux8) Start()

Start starts the refreshing goroutine.

func (*TimeMux8) Stop

func (tm *TimeMux8) Stop()

Stop stops the refreshing goroutine.

Jump to

Keyboard shortcuts

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