max7219-matrix

0.2.0 • Public • Published

MAX7219-Matrix

NpmVersion GitHub issues npm GitHub

Interfacing with MAX7219 8x8 LED arrays for the Raspberry Pi over SPI


Install

npm install max7219-matrix


Dependencies

The SPI device needs to be enabled on your Raspberry Pi. Sparkfun tutorial on how to do this

Check in /dev if the devices installed successfully:

$ ls -l /dev/spi*
crw-rw---- 1 root spi 153, 0 Aug 14 22:22 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 Aug 14 22:22 /dev/spidev0.1

Wiring

alt text


How to use the package

let maxMatrix = require("max7219-matrix");
 
let m = new maxMatrix.MAX7219Matrix("/dev/spidev0.0", 4);
m.processText("TEST");

Run node example/demo.js to run the snippet from above --- The demo is set for 4 LED Arrays.

  • The displayed text will always be trimmed to the first N characters, where N is the number or screens specified in the constructor. ex.: If we set the screen count to 4, and we send the text "APPLE" (max7219.processText("APPLE");), our screen will display APPL.

maxMatrix.MAX7219Matrix(device, screenCount)

  • Constructor
  • Creates an instance of the object, and initializes it with the required values.
  • The device argument specifies the SPI Device to which the screens are connected. ex.: "/dev/spidev0.0".
  • The screenCount argument specifies the number of daisy-chained MAX7219 driven 8x8 LED arrays ex.: 4.

setBrightness(brightness)

  • Set the brightness of the matrices.
  • brightness should be between 0 and 15 (inclusive)

processText(text, font)

  • Display the text, in the selected font. If the font is not specified, it defaults to CP437_FONT.
  • The following fonts can be used:
  • CP437_FONT, SINCLAIR_FONT, LCD_FONT, UKR_FONT, TINY_FONT, CP437_FONT_ROTATED (default), SINCLAIR_FONT_ROTATED and LCD_FONT_ROTATED.
  • Syntax :
m.processText("TEST", "SINCLAIR_FONT_ROTATED");

Example

The demo, found at example/demo.js, displays " TEST " in the SINCLAIR_FONT_ROTATED. (it's set for 4 daisy-chained MAX7219 matrices)


TO-DOs

  • Text rotation
  • Scrolling text
  • "Breathing" text effect
  • "Blinking" text effect

Notes

This is a project I work on in my spare time, and it's very much a work-in-progress. If you have any problems, open an issue on GitHub. Pull requests are very welcome! Any improvements made to the code are much appreciated.


Special thanks to

Dependents (0)

Package Sidebar

Install

npm i max7219-matrix

Weekly Downloads

11

Version

0.2.0

License

ISC

Unpacked Size

130 kB

Total Files

6

Last publish

Collaborators

  • heunetik