Beispiel #1
0
    def __init__(self, width, height, rst_pin, dc_pin, busy_pin, srcs_pin,
                 cs_pin, spi):
        self.width = width
        self.height = height

        # Setup reset pin.
        self._rst = rst_pin
        if rst_pin != None:
            self._rst.direction = digitalio.Direction.OUTPUT

        # Setup busy pin.
        self._busy = busy_pin
        if busy_pin != None:
            self._busy.direction = digitalio.Direction.INPUT

        # Setup dc pin.
        self._dc = dc_pin
        self._dc.direction = digitalio.Direction.OUTPUT

        # Setup cs pin.
        self._cs = cs_pin
        self._cs.direction = digitalio.Direction.OUTPUT

        self.spi_device = spi

        self.sram = mcp_sram.Adafruit_MCP_SRAM(srcs_pin, spi)
    def __init__(
        self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
    ):  # pylint: disable=too-many-arguments
        self._width = width
        self._height = height

        # Setup reset pin, if we have one
        self._rst = rst_pin
        if rst_pin:
            self._rst.direction = Direction.OUTPUT

        # Setup busy pin, if we have one
        self._busy = busy_pin
        if busy_pin:
            self._busy.direction = Direction.INPUT

        # Setup dc pin (required)
        self._dc = dc_pin
        self._dc.direction = Direction.OUTPUT
        self._dc.value = False

        # Setup cs pin (required)
        self._cs = cs_pin
        self._cs.direction = Direction.OUTPUT
        self._cs.value = True

        # SPI interface (required)
        self.spi_device = spi
        while not self.spi_device.try_lock():
            time.sleep(0.01)
        self.spi_device.configure(baudrate=1000000)  # 1 Mhz
        self.spi_device.unlock()

        self._spibuf = bytearray(1)
        self._single_byte_tx = False

        self.sram = None
        if sramcs_pin:
            self.sram = mcp_sram.Adafruit_MCP_SRAM(sramcs_pin, spi)

        self._buf = bytearray(3)
        self._buffer1_size = self._buffer2_size = 0
        self._buffer1 = self._buffer2 = None
        self._framebuf1 = self._framebuf2 = None
        self._colorframebuf = self._blackframebuf = None
        self._black_inverted = self._color_inverted = True
        self.hardware_reset()