import string from compLib.LogstashLogging import logstash_logger from compLib.Spi import Spi, Register LINE_COUNT = 4 CHARS_PER_LINE = 16 class Display(object): """Access the different IR Sensors of the robot """ @staticmethod def write(line: int, text: string): if len(text) > CHARS_PER_LINE: logstash_logger.error(f"Too many characters specified!") return if line <= 0 or line > LINE_COUNT: raise IndexError("Invalid line number specified") to_write = [0] * CHARS_PER_LINE for i in range(len(text)): to_write[i] = ord(text[i]) if line == 1: Spi.write(Register.DISPLAY_LINE_1_C0, CHARS_PER_LINE, to_write) elif line == 2: Spi.write(Register.DISPLAY_LINE_2_C0, CHARS_PER_LINE, to_write) elif line == 3: Spi.write(Register.DISPLAY_LINE_3_C0, CHARS_PER_LINE, to_write) elif line == 4: Spi.write(Register.DISPLAY_LINE_4_C0, CHARS_PER_LINE, to_write) @staticmethod def clear(): for i in range(1, LINE_COUNT + 1): Display.write(i, "")