diff --git a/README.rst b/README.rst index 383b1cb..aaa33a7 100644 --- a/README.rst +++ b/README.rst @@ -73,7 +73,6 @@ adafruit_max7219.Matrix8x8 Example spi = busio.SPI(clk, MOSI=din) display = matrices.Matrix8x8(spi, cs) - display.rotation(1) #change display direction while True: display.brightness(3) @@ -125,14 +124,3 @@ Documentation ============= For information on building library documentation, please check out `this guide `_. - - -Additons -============= - -1. Add rotation func - -.. code-block:: python - - matrix = matrices.Matrix8x8(spi, cs) - matrix.rotation(2) diff --git a/adafruit_max7219/matrices.py b/adafruit_max7219/matrices.py index f32c127..955e050 100644 --- a/adafruit_max7219/matrices.py +++ b/adafruit_max7219/matrices.py @@ -6,11 +6,9 @@ `adafruit_max7219.matrices.Matrix8x8` ==================================================== """ -import time from micropython import const from adafruit_max7219 import max7219 - __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MAX7219.git" @@ -28,8 +26,8 @@ class Matrix8x8(max7219.MAX7219): :param ~digitalio.DigitalInOut cs: digital in/out to use as chip select signal """ - def __init__(self, spi, cs, num=1): - super().__init__(8, 8, spi, cs, num=num) + def __init__(self, spi, cs): + super().__init__(8, 8, spi, cs) def init_display(self): for cmd, data in ( @@ -39,7 +37,7 @@ def init_display(self): (_DECODEMODE, 0), (_SHUTDOWN, 1), ): - self._write([cmd, data] * self.num) + self.write_cmd(cmd, data) self.fill(0) self.show() @@ -60,20 +58,3 @@ def clear_all(self): Clears all matrix leds. """ self.fill(0) - - def display_str(self, data, delay=1): - """ - Display string on led matrix by matrix length - - :param str: string that can be of any length. - :param delay: transfer time from one screen to another screen. default value is 1s - - """ - i = -1 - for char in data: - i += 1 - self.fill(0) - self.text(char, 1, 0) - self.show_char_position(i % self.num) - if i % self.num == self.num - 1: - time.sleep(delay) diff --git a/adafruit_max7219/max7219.py b/adafruit_max7219/max7219.py index a665ed7..b0458f6 100644 --- a/adafruit_max7219/max7219.py +++ b/adafruit_max7219/max7219.py @@ -52,8 +52,6 @@ _DIGIT0 = const(1) _INTENSITY = const(10) -MAX7219_REG_NOOP = 0x0 - class MAX7219: """ @@ -68,7 +66,7 @@ class MAX7219: """ def __init__( - self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0, num=1 + self, width, height, spi, cs, *, baudrate=8000000, polarity=0, phase=0 ): self._chip_select = cs @@ -83,7 +81,6 @@ def __init__( self.width = width self.height = height - self.num = num self.init_display() @@ -93,7 +90,6 @@ def init_display(self): def brightness(self, value): """ Controls the brightness of the display. - :param int value: 0->15 dimmest to brightest """ if not 0 <= value <= 15: @@ -112,7 +108,6 @@ def show(self, number=1, t_num=1): def fill(self, bit_value): """ Fill the display buffer. - :param int bit_value: value > 0 set the buffer bit, else clears the buffer bit """ self.framebuf.fill(bit_value) @@ -120,7 +115,6 @@ def fill(self, bit_value): def pixel(self, xpos, ypos, bit_value=None): """ Set one buffer bit - :param xpos: x position to set bit :param ypos: y position to set bit :param int bit_value: value > 0 sets the buffer bit, else clears the buffer bit @@ -159,29 +153,3 @@ def rotation(self, direction): :param direction:set int to change display direction, value 0 (default), 1, 2, 3 """ self.framebuf.rotation = direction - - def _write(self, data): - """ - Send the bytes (which should comprise of alternating command, data values) - over the SPI device. - - :param data: command collections - """ - - self._chip_select.value = False - with self._spi_device as my_spi_device: - my_spi_device.write(bytes(data)) - self._chip_select.value = True - - def show_char_position(self, position=0): - """ - write data to the position that is one of multi led matrix - - :param position: the position of matrix, value begin 0. - - """ - for ypos in range(8): - self._write( - [_DIGIT0 + ypos, self._buffer[ypos]] - + ([MAX7219_REG_NOOP, 0] * (position)) - ) diff --git a/examples/max7219_disaplay_string_multi_matrix.py b/examples/max7219_disaplay_string_multi_matrix.py deleted file mode 100644 index 930b49f..0000000 --- a/examples/max7219_disaplay_string_multi_matrix.py +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries -# SPDX-License-Identifier: MIT - - -import board -import busio -import digitalio -from adafruit_max7219 import matrices - -clk = board.IO4 -din = board.IO2 -cs = digitalio.DigitalInOut(board.IO3) - -spi = busio.SPI(clk, MOSI=din) -display = matrices.Matrix8x8(spi, cs, 4) -display.framebuf.rotation = 1 # rotate screen - -display.clear_all() -while True: - display.display_str("abc7568123456789asdfghj", 2)