Anyone working on a MAX7219 8x8 LED matrix display library?
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Hi Rob,
Try replacing:
d.text=("7219",0,0,1)
With:
d.text("7219",0,0,1)
Try replacing:
d.text=("7219",0,0,1)
With:
d.text("7219",0,0,1)
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
[duplicate removed]
Last edited by RobH on Thu Apr 12, 2018 12:03 pm, edited 1 time in total.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Sorry for the duplicate posting... overlooked 'next' pages.
@mcauser: Thanks for pointing me to the superfluous equal signs, but removing made no difference... searching further.
@mcauser: Thanks for pointing me to the superfluous equal signs, but removing made no difference... searching further.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
I’ll flash the latest version of micropython to my Wemos D1 mini and see if I can replicate the issue.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Just tested the quad 8x8 display on a PyBoard: both text display and scrolling work fine for this combination!
Rob.
Rob.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
I must have made a mistake (maybe more that one!) with my initial attempts! After migrating the program which worked on the PyBoard to the ESP32 and ESP8266 it works on these platforms too! On the ESP8266 both with hardware and software SPI, on the ESP32 only sw-SPI. I'll try to find out the problem with hw-SPI on the ESP32.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
@mcauser, suggestion for enhancement.
I have a couple of PCBs with a single monochrome 8x8 matrix and a max7219 'outside' of the PCB, probably the same as you show in a picture you posted in this forum (1 Oct 2017). With 3 of these I would like to build a 24(hor.) x 8(vert.) matrix by mounting these side-by-side with the MAX7219 below (or above) the LEDs. However when displaying text the characters are 90 degrees rotated, effectively a 8 (hor.) x 24 (vert.) display.
I have done some experiments: (1) with an external font table, rotating the font pattern and using the blit() method and (2) by a modification of the library: MONO_HLSB into MONO_VLSB. Both work fine for a single 8x8 matrix but I couldn't get this right for multiple matrices. I would appreciate some help...
Addition dd feb 19, 2019: found a solution (maybe not the most elegant!):
1. In stead of writing line-by-line, write column-by-column
2. Reverse the order of writing the modules: right to left (last module in chain first).
Thus the show-method (between self.cs(0) and self.cs(1)) becomes:
Result see attached picture.
I just needed this for text, but graphics like lines and rectangles work also nicely.
Regards, Rob
I have a couple of PCBs with a single monochrome 8x8 matrix and a max7219 'outside' of the PCB, probably the same as you show in a picture you posted in this forum (1 Oct 2017). With 3 of these I would like to build a 24(hor.) x 8(vert.) matrix by mounting these side-by-side with the MAX7219 below (or above) the LEDs. However when displaying text the characters are 90 degrees rotated, effectively a 8 (hor.) x 24 (vert.) display.
I have done some experiments: (1) with an external font table, rotating the font pattern and using the blit() method and (2) by a modification of the library: MONO_HLSB into MONO_VLSB. Both work fine for a single 8x8 matrix but I couldn't get this right for multiple matrices. I would appreciate some help...
Addition dd feb 19, 2019: found a solution (maybe not the most elegant!):
1. In stead of writing line-by-line, write column-by-column
2. Reverse the order of writing the modules: right to left (last module in chain first).
Thus the show-method (between self.cs(0) and self.cs(1)) becomes:
Code: Select all
mask = 0x80 >> y # collect 'y'-th column
for m in range(self.num-1, -1, -1): # right most module first
col = 0x00 # initial contents 'y'-th column
for bit in range(8): # all bits in column
if self.buffer[bit * self.num + m] & mask:
col |= 1 << bit # copy 1-bit to column pattern
self.spi.write(bytearray([_DIGIT0 + y, col]))
I just needed this for text, but graphics like lines and rectangles work also nicely.
Regards, Rob
- Attachments
-
- max7219_chain.jpg (52.15 KiB) Viewed 24073 times
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Hi --
I see several have encountered text being displayed backwards using @mcauser's library. I haven't seen anything specific to a resolution.
Is there any resolution available? Everything seems to be working okay with my 4x configuration with this one exception.
Also, I've seen mention of using different fonts. Are their any instructions for doing this? I would like to have 'single line' characters so I can fully utilize the matrix pixels rather than limiting them to a single character per matrix.
Thanks -- Jeff
I see several have encountered text being displayed backwards using @mcauser's library. I haven't seen anything specific to a resolution.
Is there any resolution available? Everything seems to be working okay with my 4x configuration with this one exception.
Also, I've seen mention of using different fonts. Are their any instructions for doing this? I would like to have 'single line' characters so I can fully utilize the matrix pixels rather than limiting them to a single character per matrix.
Thanks -- Jeff
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
...for clarification, the text is not actually displaying backwards, it needs to be rotated 180 degrees so it displays correctly on each matrix.
Sorry for any confusion.
Thanks -- Jeff
Sorry for any confusion.
Thanks -- Jeff
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Hi --
Figured out a solution to the rotation problem:
I'm still looking for a solution to implement different fonts...
Thanks -- Jeff
Figured out a solution to the rotation problem:
- Used a different format constant (MONO_HMSB).
- Altered the spi.write in the show() function to write buffer in a different order.
Code: Select all
from micropython import const
import framebuf
_NOOP = const(0)
_DIGIT0 = const(1)
_DECODEMODE = const(9)
_INTENSITY = const(10)
_SCANLIMIT = const(11)
_SHUTDOWN = const(12)
_DISPLAYTEST = const(15)
class Matrix8x8:
def __init__(self, spi, cs, num):
"""
Driver for cascading MAX7219 8x8 LED matrices.
>>> import max7219
>>> from machine import Pin, SPI
>>> spi = SPI(1)
>>> display = max7219.Matrix8x8(spi, Pin('X5'), 4)
>>> display.text('1234',0,0,1)
>>> display.show()
"""
self.spi = spi
self.cs = cs
self.cs.init(cs.OUT, True)
self.buffer = bytearray(8 * num)
self.num = num
# fb = framebuf.FrameBuffer(self.buffer, 8 * num, 8, framebuf.MONO_HLSB) ##jgb: Orignial code. Rotation = 0.
fb = framebuf.FrameBuffer(self.buffer, 8 * num, 8, framebuf.MONO_HMSB) ##jgb: 1 of 2 changes needed to rotate 180 degrees.
self.framebuf = fb
# Provide methods for accessing FrameBuffer graphics primitives. This is a workround
# because inheritance from a native class is currently unsupported.
# http://docs.micropython.org/en/latest/pyboard/library/framebuf.html
self.fill = fb.fill # (col)
self.pixel = fb.pixel # (x, y[, c])
self.hline = fb.hline # (x, y, w, col)
self.vline = fb.vline # (x, y, h, col)
self.line = fb.line # (x1, y1, x2, y2, col)
self.rect = fb.rect # (x, y, w, h, col)
self.fill_rect = fb.fill_rect # (x, y, w, h, col)
self.text = fb.text # (string, x, y, col=1)
self.scroll = fb.scroll # (dx, dy)
self.blit = fb.blit # (fbuf, x, y[, key])
self.init()
def _write(self, command, data):
self.cs(0)
for m in range(self.num):
self.spi.write(bytearray([command, data]))
self.cs(1)
def init(self):
for command, data in (
(_SHUTDOWN, 0),
(_DISPLAYTEST, 0),
(_SCANLIMIT, 7),
(_DECODEMODE, 0),
(_SHUTDOWN, 1),
):
self._write(command, data)
def brightness(self, value):
if not 0 <= value <= 15:
raise ValueError("Brightness out of range")
self._write(_INTENSITY, value)
def show(self):
for y in range(1, 9, 1):
self.cs(0)
for m in range(self.num):
# self.spi.write(bytearray([_DIGIT0 + y, self.buffer[(y * self.num) + m]])) ##jgb: Orignial code. Rotation = 0.
self.spi.write(bytearray([_DIGIT0 + (y-1), self.buffer[-(y * self.num) + m]])) ##jgb: 2 of 2 changes needed to rotate 180 degrees.
self.cs(1)
Thanks -- Jeff