Anyone working on a MAX7219 8x8 LED matrix display library?
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
The visualisation tool produce bytes in the wrong format.
eg. "1" == 0x7e1818181c181800 == b'\x7e\x18\x18\x18\x1c\x18\x18\x00'
You'd need to reverse that to be b'\x00\x18\x18\x1c\x18\x18\x18\x7e'
Then convert from lsb to msb b'\x00\x18\x18\x38\x18\x18\x18\x7e'
Then draw each in the byte array down a single 8x8 segment.
Worth noting, my quad 8x8 module draws characters upside down compared to my individual 8x8 module boards.
eg. "1" == 0x7e1818181c181800 == b'\x7e\x18\x18\x18\x1c\x18\x18\x00'
You'd need to reverse that to be b'\x00\x18\x18\x1c\x18\x18\x18\x7e'
Then convert from lsb to msb b'\x00\x18\x18\x38\x18\x18\x18\x7e'
Then draw each in the byte array down a single 8x8 segment.
Worth noting, my quad 8x8 module draws characters upside down compared to my individual 8x8 module boards.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
I noticed you are mixing tabs and spaces in your code. This is a recipe for hard to find bugs, I really recommend configuring your text editor to use spaces all the time for Python code.
Otherwise, great work!
Otherwise, great work!
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Is this library exclusive for pyboard?. I have tried wiht an esp8266 module (lolin nodemcu) with:
esp8266 max7219
3v VCC
GND GND
d7(Pin 13) MOSI DIN
d8(Pin 15) CS CS
d5(Pin 14) SCK CLK
And then:
But the display lights all the leds, and nothing more.
esp8266 max7219
3v VCC
GND GND
d7(Pin 13) MOSI DIN
d8(Pin 15) CS CS
d5(Pin 14) SCK CLK
And then:
Code: Select all
import max7219
from machine import Pin, SPI
spi = SPI(1)
display = max7219.Matrix8x8(spi, Pin(15), 1)
display.text('1',0,0,1)
display.show()
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
@deshipu fixed the tabs -> spaces. Thanks for that.
@benalb added ESP8266 eg to the readme. Had to drop the SPI freq from 80MHz to 10MHz to make it work.
@benalb added ESP8266 eg to the readme. Had to drop the SPI freq from 80MHz to 10MHz to make it work.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
It works now, Thank you, great work.mcauser wrote:@benalb added ESP8266 eg to the readme. Had to drop the SPI freq from 80MHz to 10MHz to make it work.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Thank you mcauser.mcauser wrote: ↑Sun Oct 01, 2017 1:50 pmI added cascading to deshipu's driver, and added framebuf to give text and shape support:
Works on my single 8x8 matrix, quad 8x8 matrices and 2x quad 8x8 matrices.
https://github.com/mcauser/micropython-max7219
If you have a chain of 4x 8x8 matrices and you want to only update the 2nd matrix (closest to the DIN matrix), you need to send NOOPs to each of the other matrices. You write to the furthest away from DIN matrix first. For each row, the right most pixel is the least significant bit.
eg. Light the top row of the 2nd matrix and leave the others unchanged.Code: Select all
_NOOP = const(0) cs.low() spi.write(bytearray([_NOOP, _NOOP])) spi.write(bytearray([_NOOP, _NOOP])) spi.write(bytearray([1, 255])) spi.write(bytearray([_NOOP, _NOOP])) cs.high()
Works well, only the scroll function is not performing as expected (maybe my bad?).
But I wrote my own:
Code: Select all
import max7219
from machine import Pin, SPI
import utime
class max7219_Scroll:
def __init__(self,CS,modules):
self.CS = CS
self.modules = modules
self.spi = SPI(1, baudrate=10000000, polarity=0, phase=0)
self.display = max7219.Matrix8x8(self.spi, Pin(self.CS), self.modules)
def Scroll(self,tex, hell, repeat):
self.display.brightness(hell)
for r in range (0,repeat,1):
for e in range (self.modules*8,-8*(self.modules+len(tex)),-1):
self.display.fill(0)
self.display.text(tex,e,0,1)
self.display.show()
utime.sleep(0.01)
DotMx=max7219_Scroll(2,4)
DotMx.Scroll(str('Hello, uPy!!!'),5,2)
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Actually, I have a (currently quite hacky!) async scroll working against @mcauser's code somewhere. If anyone is interested I can polish it up and submit is as a pull request?
It's really not very different to @d4ß's solution (as I recall, add an async, sprinkle an await.asyncio.sleep...) but is non-blocking.
It's really not very different to @d4ß's solution (as I recall, add an async, sprinkle an await.asyncio.sleep...) but is non-blocking.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
@d4ß The scroll method points to the FrameBuffer.scroll method:
http://docs.micropython.org/en/latest/w ... fer.scroll
It just shifts the contents of the FrameBuffer, leaving artefacts from the original buffer behind.
ie. if you scroll 1px from left to right, the 2 right most columns will be identical.
Your solution is similar to the one I recently created for a guy who emailed me asking similar.
We called it .marquee() after the obsolete html <marquee> tag.
https://developer.mozilla.org/en-US/doc ... nt/marquee
Currently supports left -> right, right -> left, up -> down, down -> up.
I wanted to add diagonal scrolling before I made a PR.
I'll share it soon.
I'm also working on a version where you can rotate individual matrices and arrange them in any order.
eg. 3x quad displays stacked in the shape of an S, or mixing quad displays with individual ones from different manufacturers where the orientation is different.
@mattyt an asyncio version sounds nice. I haven't played much with asyncio yet.
If you've got it working, submit a PR and I'll merge it in.
I'm going to add an examples folder with a ton of useful real world examples soon too.
http://docs.micropython.org/en/latest/w ... fer.scroll
It just shifts the contents of the FrameBuffer, leaving artefacts from the original buffer behind.
ie. if you scroll 1px from left to right, the 2 right most columns will be identical.
Your solution is similar to the one I recently created for a guy who emailed me asking similar.
We called it .marquee() after the obsolete html <marquee> tag.
https://developer.mozilla.org/en-US/doc ... nt/marquee
Currently supports left -> right, right -> left, up -> down, down -> up.
I wanted to add diagonal scrolling before I made a PR.
I'll share it soon.
I'm also working on a version where you can rotate individual matrices and arrange them in any order.
eg. 3x quad displays stacked in the shape of an S, or mixing quad displays with individual ones from different manufacturers where the orientation is different.
@mattyt an asyncio version sounds nice. I haven't played much with asyncio yet.
If you've got it working, submit a PR and I'll merge it in.
I'm going to add an examples folder with a ton of useful real world examples soon too.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
@mcauser if you have a neat marquee method then could you share that and I'll asyncify it? Better than having competing scroll methods, especially since my hacky solution only scrolls in one direction.
Re: Anyone working on a MAX7219 8x8 LED matrix display library?
Mike,
The MAX7219 driver works fine for me when using 'graphics' like pixel(), hline(), rect(), etc. but refuses to display text. And with scroll() the display blanks completely. I've tried with a single 8x8 and a quad 8x8, both with software-SPI and with ESP32 and ESP8266 with the latest firmware without success and without a clue what I could be doing wrong See also my code below.
Any suggestion?
Regards, Rob.
The MAX7219 driver works fine for me when using 'graphics' like pixel(), hline(), rect(), etc. but refuses to display text. And with scroll() the display blanks completely. I've tried with a single 8x8 and a quad 8x8, both with software-SPI and with ESP32 and ESP8266 with the latest firmware without success and without a clue what I could be doing wrong See also my code below.
Any suggestion?
Regards, Rob.
Code: Select all
# test quadruple 8x8 led matrix with max7219 controller on ESP8266
from machine import Pin, SPI
import max7219
from time import sleep
spi = SPI(-1, baudrate=1000000, polarity=0, phase=0, sck=Pin(2), mosi=Pin(0), miso=Pin(5))
d = max7219.Matrix8x8(spi, Pin(4), 4)
d.brightness(4)
d.text=("7219",0,0,1)
d.show()