From e4abdcdc433b77a0cd883e153139ebec50ab8ce0 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 1 Apr 2022 12:58:59 -0400 Subject: [PATCH 1/5] Update examples to more expected pinout --- examples/max7219_custommatrixtest.py | 9 +++++---- examples/max7219_showbcddigits.py | 9 +++++---- examples/max7219_simpletest.py | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/max7219_custommatrixtest.py b/examples/max7219_custommatrixtest.py index 9b7c7f6..85f3b4e 100644 --- a/examples/max7219_custommatrixtest.py +++ b/examples/max7219_custommatrixtest.py @@ -2,14 +2,15 @@ # SPDX-License-Identifier: MIT import time -from board import TX, RX, A1 +import board import busio import digitalio from adafruit_max7219 import matrices -mosi = TX -clk = RX -cs = digitalio.DigitalInOut(A1) +# You may need to change the chip select board depending on your wiring +mosi = board.MOSI +clk = board.CLK +cs = digitalio.DigitalInOut(board.D4) spi = busio.SPI(clk, MOSI=mosi) diff --git a/examples/max7219_showbcddigits.py b/examples/max7219_showbcddigits.py index cb84981..d1641d2 100644 --- a/examples/max7219_showbcddigits.py +++ b/examples/max7219_showbcddigits.py @@ -3,14 +3,15 @@ import time import random -from board import TX, RX, A1 +import board import busio import digitalio from adafruit_max7219 import bcddigits -mosi = TX -clk = RX -cs = digitalio.DigitalInOut(A1) +# You may need to change the chip select board depending on your wiring +mosi = board.MOSI +clk = board.CLK +cs = digitalio.DigitalInOut(board.D4) spi = busio.SPI(clk, MOSI=mosi) diff --git a/examples/max7219_simpletest.py b/examples/max7219_simpletest.py index 0d4f5df..ba45070 100644 --- a/examples/max7219_simpletest.py +++ b/examples/max7219_simpletest.py @@ -2,14 +2,15 @@ # SPDX-License-Identifier: MIT import time -from board import TX, RX, A1 +import board import busio import digitalio from adafruit_max7219 import matrices -mosi = TX -clk = RX -cs = digitalio.DigitalInOut(A1) +# You may need to change the chip select board depending on your wiring +mosi = board.MOSI +clk = board.CLK +cs = digitalio.DigitalInOut(board.D4) spi = busio.SPI(clk, MOSI=mosi) From 8a4ff66bc8063ad83c6cb33362cbc30a02dbf48b Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 1 Apr 2022 14:42:59 -0400 Subject: [PATCH 2/5] Use board.SPI() instead of busio.SPI --- examples/max7219_custommatrixtest.py | 7 ++----- examples/max7219_showbcddigits.py | 6 ++---- examples/max7219_simpletest.py | 7 ++----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/max7219_custommatrixtest.py b/examples/max7219_custommatrixtest.py index 85f3b4e..786f094 100644 --- a/examples/max7219_custommatrixtest.py +++ b/examples/max7219_custommatrixtest.py @@ -3,17 +3,14 @@ import time import board -import busio import digitalio from adafruit_max7219 import matrices + # You may need to change the chip select board depending on your wiring -mosi = board.MOSI -clk = board.CLK +spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) -spi = busio.SPI(clk, MOSI=mosi) - matrix = matrices.CustomMatrix(spi, cs, 32, 8) while True: print("Cycle Start") diff --git a/examples/max7219_showbcddigits.py b/examples/max7219_showbcddigits.py index d1641d2..87334dc 100644 --- a/examples/max7219_showbcddigits.py +++ b/examples/max7219_showbcddigits.py @@ -8,13 +8,11 @@ import digitalio from adafruit_max7219 import bcddigits + # You may need to change the chip select board depending on your wiring -mosi = board.MOSI -clk = board.CLK +spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) -spi = busio.SPI(clk, MOSI=mosi) - leds = bcddigits.BCDDigits(spi, cs, nDigits=8) while True: # clear display and dim 0 diff --git a/examples/max7219_simpletest.py b/examples/max7219_simpletest.py index ba45070..d444755 100644 --- a/examples/max7219_simpletest.py +++ b/examples/max7219_simpletest.py @@ -3,17 +3,14 @@ import time import board -import busio import digitalio from adafruit_max7219 import matrices + # You may need to change the chip select board depending on your wiring -mosi = board.MOSI -clk = board.CLK +spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) -spi = busio.SPI(clk, MOSI=mosi) - matrix = matrices.Matrix8x8(spi, cs) while True: print("Cycle start") From 2f58be88bf53a1f0450dd959965a8329300dbf1d Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 1 Apr 2022 14:47:33 -0400 Subject: [PATCH 3/5] Remove unused busio import --- examples/max7219_showbcddigits.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/max7219_showbcddigits.py b/examples/max7219_showbcddigits.py index 87334dc..13d01f8 100644 --- a/examples/max7219_showbcddigits.py +++ b/examples/max7219_showbcddigits.py @@ -4,7 +4,6 @@ import time import random import board -import busio import digitalio from adafruit_max7219 import bcddigits From 5008eb987f3a9ab24eaf8095fd00b4847d793d25 Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 1 Apr 2022 15:30:39 -0400 Subject: [PATCH 4/5] Update comment to reference pin instead of board --- examples/max7219_custommatrixtest.py | 2 +- examples/max7219_showbcddigits.py | 2 +- examples/max7219_simpletest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/max7219_custommatrixtest.py b/examples/max7219_custommatrixtest.py index 786f094..2a390f2 100644 --- a/examples/max7219_custommatrixtest.py +++ b/examples/max7219_custommatrixtest.py @@ -7,7 +7,7 @@ from adafruit_max7219 import matrices -# You may need to change the chip select board depending on your wiring +# You may need to change the chip select pin depending on your wiring spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) diff --git a/examples/max7219_showbcddigits.py b/examples/max7219_showbcddigits.py index 13d01f8..b7979aa 100644 --- a/examples/max7219_showbcddigits.py +++ b/examples/max7219_showbcddigits.py @@ -8,7 +8,7 @@ from adafruit_max7219 import bcddigits -# You may need to change the chip select board depending on your wiring +# You may need to change the chip select pin depending on your wiring spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) diff --git a/examples/max7219_simpletest.py b/examples/max7219_simpletest.py index d444755..251967e 100644 --- a/examples/max7219_simpletest.py +++ b/examples/max7219_simpletest.py @@ -7,7 +7,7 @@ from adafruit_max7219 import matrices -# You may need to change the chip select board depending on your wiring +# You may need to change the chip select pin depending on your wiring spi = board.SPI() cs = digitalio.DigitalInOut(board.D4) From c3849b9c5e8cbcc9660d53b2bbb9d04e20f289cb Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 1 Apr 2022 15:30:54 -0400 Subject: [PATCH 5/5] Simplify README examples section --- README.rst | 57 +----------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/README.rst b/README.rst index 986f692..031bedd 100644 --- a/README.rst +++ b/README.rst @@ -56,62 +56,7 @@ To install in a virtual environment in your current project: Usage Example ============= -adafruit_max7219.Matrix8x8 Example ----------------------------------- - -.. code-block:: python - - from adafruit_max7219 import matrices - from board import TX, RX, A2 - import busio - import digitalio - import time - - clk = RX - din = TX - cs = digitalio.DigitalInOut(A2) - - spi = busio.SPI(clk, MOSI=din) - display = matrices.Matrix8x8(spi, cs) - while True: - display.brightness(3) - - display.fill(1) - display.pixel(3, 3) - display.pixel(3, 4) - display.pixel(4, 3) - display.pixel(4, 4) - display.show() - time.sleep(3.0) - - display.clear_all() - s = 'Hello, World!' - for c in range(len(s)*8): - display.fill(0) - display.text(s,-c,0) - display.show() - time.sleep(0.25) - - -adafruit_max7219.BCDDigits Example ----------------------------------- - -.. code-block:: python - - from adafruit_max7219 import bcddigits - from board import TX, RX, A2 - import bitbangio - import digitalio - - clk = RX - din = TX - cs = digitalio.DigitalInOut(A2) - - spi = bitbangio.SPI(clk, MOSI=din) - display = bcddigits.BCDDigits(spi, cs, nDigits=8) - display.clear_all() - display.show_str(0,'{:9.2f}'.format(-1234.56)) - display.show() +See the ``examples/`` folder example uses of this library. Documentation =============