max7219

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

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 9 Imported by: 0

README

Go-Max7219

Library written in Go to allow controlling of the MAX7219 LED module.
Source forked from https://github.com/adrianh-za/go-max7219-rpi which was forked from https://github.com/d2r2/go-max7219

Enhancements

  • Works with pre-assembled 4 and 8 module MAX7219 LED module matrices. - Adrianh
  • Set the rotational direction of the MAX7219 LED modules. - Adrianh
    • Some of the pre-assembled 4 and 8 LED modules are connected "upsidedown" to the circuit board. Using the inverted rotational directions allows for supporting of these MAX7219 4 and 8 module LED module matrices. - Adrianh
  • Sliding of text with blank padding before and after text. - Adrianh
  • Debugging console output turned off

Usage

  1. go get https://github.com/alinke/go-max7219-pixelcade
  2. browse to $/go/src/github.com/alinke/go-max7219-pixelcade/examples
  3. sudo -E go run [filename].go
  4. run to end (or ctrl-c to quit)

Examples filenames

  • chars-4in1.go
  • chars.go
  • font-4in1.go
  • font.go
  • slide.go
  • slide-4in1.go
  • slide-4in1-invert.go
  • slide-8in1-and-still-text.go

Compatibility

Tested on Raspberry PI 3 B+, Orange Pi Zero 2 (use SPI device 1), and Orange Pi Zero 3 (use SPI device 1)

Acknowledgements

Thanks to Denis Dyakov for his excellent libraries and to Adrianh for adding multi-module support

Gits

https://github.com/d2r2/go-max7219

Documentation

Index

Constants

View Source
const (
	MAX7219_REG_NOOP   Max7219Reg = 0
	MAX7219_REG_DIGIT0            = iota
	MAX7219_REG_DIGIT1
	MAX7219_REG_DIGIT2
	MAX7219_REG_DIGIT3
	MAX7219_REG_DIGIT4
	MAX7219_REG_DIGIT5
	MAX7219_REG_DIGIT6
	MAX7219_REG_DIGIT7
	MAX7219_REG_DECODEMODE
	MAX7219_REG_INTENSITY
	MAX7219_REG_SCANLIMIT
	MAX7219_REG_SHUTDOWN
	MAX7219_REG_DISPLAYTEST = 0x0F
	MAX7219_REG_LASTDIGIT   = MAX7219_REG_DIGIT7
)
View Source
const MAX7219_DIGIT_COUNT = MAX7219_REG_LASTDIGIT -
	MAX7219_REG_DIGIT0 + 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

func NewDevice

func NewDevice(cascaded int) *Device

func (*Device) Brightness

func (this *Device) Brightness(intensity byte) error

func (*Device) Clear

func (this *Device) Clear(cascadeId int, redraw bool) error

func (*Device) ClearAll

func (this *Device) ClearAll(redraw bool) error

func (*Device) Close

func (this *Device) Close()

func (*Device) Command

func (this *Device) Command(reg Max7219Reg, value byte) error

func (*Device) Flush

func (this *Device) Flush() error

func (*Device) GetCascadeCount

func (this *Device) GetCascadeCount() int

func (*Device) GetLedLineCount

func (this *Device) GetLedLineCount() int

func (*Device) Open

func (this *Device) Open(spibus int, spidevice int, brightness byte) error

func (*Device) ScrollLeft

func (this *Device) ScrollLeft(redraw bool) error

func (*Device) ScrollRight

func (this *Device) ScrollRight(redraw bool) error

func (*Device) SetBufferLine

func (this *Device) SetBufferLine(cascadeId int,
	position int, value byte, redraw bool) error

type Font

type Font interface {
	// Return font code page.
	// This function allow implement national font support.
	GetCodePage() encoding.Encoding
	// Return font char's bit pattern.
	// Font height is always equal to 8 pixel.
	// Font width may vary from one font
	// to another, but ordinary not exceed 8 pixel.
	GetLetterPatterns() [][]byte
}

General interface of ASCII char set bit pattern for drawing on the LED matrix.

var (
	FontCP437    Font = &fontCP437{}
	FontSinclair Font = &fontSinclair{}
	FontLCD      Font = &fontLCD{}
	// FontBoldCyrillic   Font = &fontBoldCyrillic{}
	FontTiny           Font = &fontTiny{}
	FontMSXRus         Font = &fontMSXRus{}
	FontZXSpectrumRus  Font = &fontZXSpectrumRus{}
	FontVestaPK8000Rus Font = &fontVestaPK8000Rus{}
)

type Matrix

type Matrix struct {
	Device   *Device
	Rotation Rotation
}

func NewMatrix

func NewMatrix(cascaded int, rotate Rotation) *Matrix

func (*Matrix) Clear

func (this *Matrix) Clear()

func (*Matrix) Close

func (this *Matrix) Close()

func (*Matrix) Open

func (this *Matrix) Open(spibus int, spidevice int, brightness byte) error

func (*Matrix) OutputAsciiCode

func (this *Matrix) OutputAsciiCode(cascadeId int, font Font,
	asciiCode int, redraw bool) error

Output ascii code to the led matrix.

func (*Matrix) OutputChar

func (this *Matrix) OutputChar(cascadeId int, font Font,
	char rune, redraw bool) error

Output unicode char to the led matrix. Unicode char transforms to ascii code based on information taken from font.GetCodePage() call.

func (*Matrix) SlideMessage

func (this *Matrix) SlideMessage(text string, font Font, condensePattern bool, pixelDelay time.Duration) error

Show message sliding it by led matrix from the right to left.

type Max7219Reg

type Max7219Reg byte

type Rotation

type Rotation int
const (
	RotateNone                Rotation = 0 // No rotation needed (normally used when individual LED modules make up matrix)
	RotateClockwise           Rotation = 1 // Used to rotate 4 in 1 LED matrix clockwise
	RotateAntiClockwise       Rotation = 2 // Used to rotate 4 in 1 LED matrix anti-clockwise
	RotateClockwiseInvert     Rotation = 3 // Used to rotate 4 in 1 LED matrix clockwise (sometimes the modules are 180 degrees to the other 4 in 1 modules)
	RotateAntiClockwiseInvert Rotation = 4 // Used to rotate 4 in 1 LED matrix anti-clockwise (sometimes the modules are 180 degrees to the other 4 in 1 modules)
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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