# Path: luma/core/lib.py
# def __spidev__(self):  # pragma: no cover
# def __rpi_gpio__(self):
# def rpi_gpio(Class):
# def spidev(Class):


import errno
import luma.core.error
                import smbus2
                import warnings
from time import sleep
from luma.core import lib
    from pyftdi.spi import SpiController
    from pyftdi.i2c import I2cController
        i = 0
        n = len(data)
        tx_sz = self._transfer_size
        while i < n:
            self._write_bytes(data[i:i + tx_sz])
            i += tx_sz

    def _write_bytes(self, data):
        gpio = self._gpio
        if self._CE:
            gpio.output(self._CE, gpio.LOW)  # Active low

        for byte in data:
            for _ in range(8):
                gpio.output(self._SDA, byte & 0x80)
                gpio.output(self._SCLK, gpio.HIGH)
                byte <<= 1
                gpio.output(self._SCLK, gpio.LOW)

        if self._CE:
            gpio.output(self._CE, gpio.HIGH)

    def cleanup(self):
        """
        Clean up GPIO resources if managed.
        """
        if self._managed:
            self._gpio.cleanup([pin for pin in [self._SCLK, self._SDA, self._CE, self._DC, self._RST] if pin is not None])



# Path: luma/core/lib.py
# def __spidev__(self):  # pragma: no cover
# def __rpi_gpio__(self):
# def rpi_gpio(Class):
# def spidev(Class):


# Path: luma/core/interface/serial.py
import errno
import luma.core.error
                import smbus2
                import warnings
from time import sleep
from luma.core import lib
    from pyftdi.spi import SpiController
    from pyftdi.i2c import I2cController

        i = 0
        n = len(data)
        tx_sz = self._transfer_size
        while i < n:
            self._write_bytes(data[i:i + tx_sz])
            i += tx_sz

    def _write_bytes(self, data):
        gpio = self._gpio
        if self._CE:
            gpio.output(self._CE, gpio.LOW)  # Active low

        for byte in data:
            for _ in range(8):
                gpio.output(self._SDA, byte & 0x80)
                gpio.output(self._SCLK, gpio.HIGH)
                byte <<= 1
                gpio.output(self._SCLK, gpio.LOW)

        if self._CE:
            gpio.output(self._CE, gpio.HIGH)

    def cleanup(self):
        """
        Clean up GPIO resources if managed.
        """
        if self._managed:
            self._gpio.cleanup([pin for pin in [self._SCLK, self._SDA, self._CE, self._DC, self._RST] if pin is not None])



@lib.spidev