mcauser / micropython-max7219

MicroPython driver for MAX7219 8x8 LED matrix modules, cascadable and with framebuf
MIT License
181 stars 56 forks source link

Wrong order of displayed text #5

Open MachmaHinne opened 5 years ago

MachmaHinne commented 5 years ago

Tried out the example for the wemos d1. But the displayed text has the wrong order. How to reverse the order?

cagedev commented 5 years ago

Could you please elaborate? How did you wire and what kind of module(s) did you use?

MachmaHinne commented 5 years ago

Yes. Thanks for the answer.

With Wemos D1 mini (ESP8266): CLK <-> D5/GPIO14 CS <-> D8/GPIO15 DIN <-> D7/GPIO13 https://www.banggood.com/5pcs-Geekcreit-MAX7219-Dot-Matrix-Module-4-in-1-Display-For-Arduino-p-1385313.html?cur_warehouse=CN Used code: import max7219 spi = machine.SPI(1, baudrate=10000000, polarity=0, phase=0) display = max7219.Matrix8x8(spi, Pin(15), 4) display.text('blah',0,0,1)

Btw, do you know how to use a different, denser font? I´m programming a clock and the four digits plus the colon does not fit width. clock

randmor commented 5 years ago

I had this problem as well when using multiple such Max7219 8x8 LED matrix display modules soldered end to end. In my code, I assemble the info I want to display into a string variable and then call a reverse() function just before I display it which will reverse the order of all the characters in the string and then display the string resulting in all the characters in proper order. Here is my reverse() function:

reverse.py.txt

And here's some code to show how to use the reverse() function:

sample_code.py.txt

I also have a demo program worth a look. It demonstrates how to scroll a longer text message across the 4-digit display from right to left showing 4 characters at a time. I'll attach that file to this message.

Max7219_ESP32_Demo.py.txt

This demo program uses a slightly modified version of the max7219 file that includes a clear() method in the Matrix8x8 class. I call this version "max7219a". Here is a copy of that file:

max7219a.py.txt

For all these files, be sure to rename the file, removing the final four characters (".txt") from the file name. Have fun with it.

randmor commented 5 years ago

With regards to your question: "Btw, do you know how to use a different, denser font?", in the Arduino C/C++ arena, there was a guy doing a 7x5 font with Max7219 8x8 LED matrix display modules. He was using displays with large numbers of these modules and was complaining of speed issues, so I assume doing the same thing in MicroPython is going to be even worse because things are generally slower in MicroPython as compared with C/C++ (even though we are using more powerful processors). However, if your project just has 4 of these 8x8 LED matrix display modules, MicroPython might be fast enough to get reasonable results. It would be a cool feature to add to Mike Causer's max7219.py library module, but will likely involve a lot of work with translating C/C++ code into MicroPython and what not... Here are a couple of links on the topic done with Arduino C/C++ which is a good programming option for ESP8266 and ESP32 MCU boards:

https://forum.arduino.cc/index.php?topic=381530.0 https://github.com/agr00m/LedMatrixSPI/wiki https://github.com/agr00m/LedMatrixSPI.

Looks like too big of a job for me! I'd suggest trying it with Arduino C/C++ with the ESP8266 or ESP32 Core installed and if you can get that working, maybe look at writing or translating it into a MicroPython version.

uxhamby commented 4 years ago

Does this help?

https://xantorohara.github.io/led-matrix-editor/#