Skip to content

Cascade several 7-segment display modules #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bschymanski opened this issue Mar 26, 2022 · 15 comments
Open

Cascade several 7-segment display modules #39

bschymanski opened this issue Mar 26, 2022 · 15 comments

Comments

@bschymanski
Copy link

is it possible to use (cascade) multiple max7219 7-segment display modules?

@tekktrik
Copy link
Member

Datasheet says it's doable! Check out page 13:

https://cdn-shop.adafruit.com/datasheets/MAX7219.pdf

@bschymanski
Copy link
Author

Yes, but the library does not allow to set more then 8 digits.

@tekktrik
Copy link
Member

Ah, got it! I wonder if it can be made configurable!

@bschymanski
Copy link
Author

Hi,

how should i use the code now?
This does not work: "segment = bcddigits.BCDDigits(spi, cs, nDigits=16)"

code.py output:
Traceback (most recent call last):
File "code.py", line 14, in
File "adafruit_max7219/bcddigits.py", line 41, in init
File "adafruit_max7219/max7219.py", line 101, in init
File "adafruit_max7219/bcddigits.py", line 52, in init_display
File "adafruit_max7219/max7219.py", line 161, in write_cmd
OverflowError: value must fit in 1 byte(s)

@tekktrik
Copy link
Member

tekktrik commented Apr 5, 2022

@bschymanski you'll need to save this library (as specifically this pull request branch) from GitHub and place it in your board's lib folder in order to test it

@tekktrik
Copy link
Member

tekktrik commented Apr 5, 2022

You can download the repository as this ZIP file: https://github.com/tekktrik/Adafruit_CircuitPython_MAX7219/archive/refs/heads/dev/chainable-bcd-digits.zip

Take the folder labeled adafruit_max7219 in there and use it instead of the one you've been using. That way we can test this in progress branch.

@tekktrik
Copy link
Member

tekktrik commented Apr 5, 2022

Once you do that, you should be able to use it as you've done earlier with:

segment = bcddigits.BCDDigits(spi, cs, nDigits=16)

If not, I'll have to make changes!

@bschymanski
Copy link
Author

I still get the same error:
code.py output:
Traceback (most recent call last):
File "code.py", line 15, in
File "/lib/adafruit_max7219/bcddigits.py", line 42, in init
File "/lib/adafruit_max7219/max7219.py", line 190, in init
File "/lib/adafruit_max7219/max7219.py", line 101, in init
File "/lib/adafruit_max7219/bcddigits.py", line 53, in init_display
File "/lib/adafruit_max7219/max7219.py", line 207, in write_cmd
OverflowError: value must fit in 1 byte(s)

@tekktrik
Copy link
Member

tekktrik commented Apr 5, 2022

Thanks for testing! I see the issue, I'll let you know when it's ready for another test!

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

Okay @bschymanski I should have fixed that error, so hopefully if you redownload the library and use it, it should be good!

https://github.com/tekktrik/Adafruit_CircuitPython_MAX7219/archive/refs/heads/dev/chainable-bcd-digits.zip

@bschymanski
Copy link
Author

Hi,

i am so sorry, but it sill produces the same error:

code.py output:
Traceback (most recent call last):
File "code.py", line 14, in
File "/lib/adafruit_max7219/bcddigits.py", line 42, in init
File "/lib/adafruit_max7219/max7219.py", line 190, in init
File "/lib/adafruit_max7219/max7219.py", line 101, in init
File "/lib/adafruit_max7219/bcddigits.py", line 52, in init_display
File "/lib/adafruit_max7219/max7219.py", line 213, in write_cmd
OverflowError: value must fit in 1 byte(s)

Code done running.

This ist the sketch running on the raspberry pi pico:

import time
import board
import busio
import digitalio

import adafruit_framebuf

from adafruit_max7219 import bcddigits

mosi = board.GP7
clk = board.GP6
cs = digitalio.DigitalInOut(board.GP5)
spi = busio.SPI(clk, MOSI=mosi)
leds = bcddigits.BCDDigits(spi, cs, nDigits=16)

leds.brightness(0)
leds.clear_all()

place 8-digit number on display

value = 12345678

leds.show_str(0, "{:8}".format(value))
leds.show()

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

Thank you so, so much again for helping me test this. It seems I forgot to use a bit mask to keep the number(s) being sent fitting within a single byte. The latest code I pushed fixes this. Redownloading from the link should provide the fix.

@bschymanski
Copy link
Author

bschymanski commented Apr 6, 2022

Hi, no problem, i would like to use it afterwards...

and it kind of works... at least it does not give me an error anymore, but the output is not what i would expect, it is not really daisy chained:

This is the code:

import time
import board
import busio
import digitalio

import adafruit_framebuf

from adafruit_max7219 import bcddigits

mosi = board.GP7
clk = board.GP6
cs = digitalio.DigitalInOut(board.GP5)
spi = busio.SPI(clk, MOSI=mosi)
leds = bcddigits.BCDDigits(spi, cs, nDigits=16)


leds.brightness(0)
leds.clear_all()
# place 8-digit number on display
value = 12345678

leds.show_str(0, "11112222")
leds.show_str(8, "33334444")
leds.show()

and the output looks like this:
IMG20220406194939

@tekktrik
Copy link
Member

tekktrik commented Apr 6, 2022

Progress! Let me look into what's going on here, I'm probably not doing the SPI communication correctly. Thanks again for testing!

@Jibun-no-Kage
Copy link

@bschymanski, Post the working code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants