Giter Site home page Giter Site logo

jangocheng / go-max7219 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from d2r2/go-max7219

0.0 1.0 0.0 3.27 MB

Golang library to interact with LED driver MAX7219 via SPI-bus from Raspberry PI or counterparts.

License: MIT License

Go 99.04% Shell 0.96%

go-max7219's Introduction

MAX7219 driver and 8x8 LED matrix display

Build Status Go Report Card GoDoc MIT License

This library written in Go programming language to output a text messages to 8x8 LED matrix display (pdf reference) via MAX7219 driver chip (pdf reference) from Raspberry PI or counterparts: image image

Compatibility

Tested on Raspberry PI 1 (model B) and Banana PI (model M1).

Golang usage

func main() {
	// Create new LED matrix with number of cascaded devices is equal to 1
	mtx := max7219.NewMatrix(1)
	// Open SPI device with spibus and spidev parameters equal to 0 and 0.
	// Set LED matrix brightness is equal to 7
	err := mtx.Open(0, 0, 7)
	if err != nil {
		log.Fatal(err)
	}
	defer mtx.Close()
	// Output text message to LED matrix
	mtx.SlideMessage("Hello world!!! Hey Beavis, let's rock!",
		max7219.FontCP437, true, 50*time.Millisecond)
	// Wait 1 sec, then continue output new text
	time.Sleep(1 * time.Second)
	// Output national text (russian in example) to LED matrix
	mtx.SlideMessage("Привет мир!!! Шарик, ты - балбес!!!",
		max7219.FontZXSpectrumRus, true, 50*time.Millisecond)
}

Getting help

GoDoc documentation

Installation

$ go get -u github.com/d2r2/go-max7219

Quick Start

To output a single letter to LED matrix by specifing ascii code use OutputAsciiCode call:

	// Output a sequence of ascii codes in a loop
	font = max7219.FontCP437
	for i := 0; i <= len(font.GetLetterPatterns()); i++ {
		mtx.OutputAsciiCode(0, font, i, true)
		time.Sleep(500 * time.Millisecond)
	}

To output a single national letter either unicode letter (rune) to LED matrix use OutputChar call:

	// Output non-latin national letter (russian for example).
	// You must be sure, that your national letter will match code page of the font used.
	mtx.OutputChar(0, max7219.FontZXSpectrumRus, 'Я', true)

This functionality works not only with Raspberry PI, but with counterparts as well (tested with Raspberry PI and Banana PI). It will works with any Raspberry PI clone, which support Kernel SPI bus, but you should in advance make SPI bus device available in /dev/ list.

More national fonts

If you want to add your national fonts you could use linux shell scripts in folder "extract_fonts" to convert font image to bit patterns. Let me know if you need assistance in this.

Credits

This project is mainly a fork of respective functionality originally written by Richard Hull in python: https://github.com/rm-hull/max7219. Nevertheless it differs in some parts: refuse some functionality (works only with matrix led), include extra functionality (extra fonts, support of national languages).

Contact

Please use Github issue tracker for filing bugs or feature requests.

License

Go-max7219 is licensed under MIT License.

go-max7219's People

Contributors

d2r2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.