class Display: def __init__(self): """ :return: """ self.strand = Strand(leds=38+41+41) def show(self, string): """ :param string: :return: """ parsed = self._parse(string) l = LetterDisplay(parsed[0]) d0 = DigitDisplay(parsed[1]) d1 = DigitDisplay(parsed[3]) pixel_list = [] pixel_list.extend(l.get_pixel_list()) pixel_list.extend(d0.get_pixel_list()) pixel_list.extend(d1.get_pixel_list()) self.strand.show(pixel_list) @staticmethod def _parse(input_str): """ Parse the input string into letters :param input_str: :return tuple: """ if ~isinstance(input_str, str): raise TypeError if len(input_str) != 3: raise ValueError n, d1, d2 = input_str return n, d1, d2
def __init__(self): """ :return: """ self.strand = Strand(leds=38+41+41)