adafruit / Adafruit_CircuitPython_HT16K33

Adafruit CircuitPython driver for the HT16K33, a LED matrix driver IC.
MIT License
41 stars 29 forks source link

Multi #89

Closed Docteh closed 2 years ago

Docteh commented 2 years ago

Hello,

The HT16K33 can drive 8 digits worth of 14 segment displays, so I made my own little board to try that out.

I also took a shot at driving multiple display modules as mentioned in Issue #74 There is a demo video at https://www.youtube.com/watch?v=E5bb6R1FgcE if one is needed.

I'm wishing really really hard that the Continuous Integration passes.

For set_raw_digit() I think that the function should be able to write anywhere on the display even if its "off screen"

import board
import busio
#i2c = busio.I2C(board.SCL, board.SDA)
i2c = busio.I2C(board.IO9, board.IO8)
#from adafruit_ht16k33.segments import Seg14x4
from segments import Seg14x4
import multi_segments
display = multi_segments.Multiple14x4(items=[Seg14x4(i2c,address=0x71),Seg14x4(i2c,address=0x70,chars=6)])
display.marquee('Hello there General Kenobi                ',0.1,loop=False)

# or
display.print('     hi hi hi')
Docteh commented 2 years ago

Got it down to two complaints from pylint

complaints from pylint ``` ************* Module adafruit_ht16k33.multi_segments adafruit_ht16k33/multi_segments.py:81:27: W0613: Unused argument 'decimal' (unused-argument) adafruit_ht16k33/multi_segments.py:1:0: R0801: Similar lines in 2 files ==adafruit_ht16k33.multi_segments:98 ==adafruit_ht16k33.segments:299 def marquee(self, text, delay=0.25, loop=True): """ Automatically scroll the text at the specified delay between characters :param str text: The text to display :param float delay: (optional) The delay in seconds to pause before scrolling to the next character (default=0.25) :param bool loop: (optional) Whether to endlessly loop the text (default=True) """ if isinstance(text, str): self.fill(False) if loop: while True: self._scroll_marquee(text, delay) else: self._scroll_marquee(text, delay) def _scroll_marquee(self, text, delay): """Scroll through the text string once using the delay""" char_is_dot = False for character in text: self.print(character) # Add delay if character is not a dot or more than 2 in a row if character != "." or char_is_dot: sleep(delay) char_is_dot = character == "." self.show() (duplicate-code) ----------------------------------- Your code has been rated at 9.96/10 ```

The first about the unused decimal variable is easy enough: throw it out

Not sure what to do about the reused code complaint, so I'm going to hold for advice on that. I'm surprised it doesn't also complain about _text but maybe its small enough to sneak by.

jepler commented 2 years ago

@kattni requested I review this PR :)

FoamyGuy commented 2 years ago

@Docteh this branch has conflicts with main that will need to be resolved.

Are you interested / willing to do the refactoring that Jepler recommended to use a base class in order to avoid code repetition where possible?

FoamyGuy commented 2 years ago

Closing this for now.

If @Docteh or anyone else who finds this is interested in getting the merge conflicts resolved and refactoring as mentioned in the review this can be re-opened, or a new PR created starting from this code branch