<commit_before>from . spi_driver_base import DriverSPIBase, ChannelOrder


class DriverAPA102(DriverSPIBase):
    """Main driver for APA102 based LED strips on devices like the Raspberry Pi and BeagleBone"""

    def __init__(self, num, c_order=ChannelOrder.RGB, use_py_spi=True,
                 dev="/dev/spidev0.0", SPISpeed=2, open=open):
        super().__init__(num, c_order=c_order, use_py_spi=use_py_spi, dev=dev,
                         SPISpeed=SPISpeed, open=open)

        # APA102 requires latch bytes at the end
        self._latchBytes = (int(num / 64.0) + 1)

    def _render(self, colors, pos):
        super()._render(colors, pos)
        newBuf = [0xFF] * (self.bufByteCount() + self.numLEDs)
        newBuf[1::4] = self._buf[0::3]
        newBuf[2::4] = self._buf[1::3]
        newBuf[3::4] = self._buf[2::3]
        self._buf[:] = [0, 0, 0, 0] + newBuf
        self._buf.extend([0xFF, 0, 0, 0] * self._latchBytes)

MANIFEST = [<commit_msg>Change line endings to Unix.<commit_after>from . spi_driver_base import DriverSPIBase, ChannelOrder


class DriverAPA102(DriverSPIBase):
    """Main driver for APA102 based LED strips on devices like the Raspberry Pi and BeagleBone"""

    def __init__(self, num, c_order=ChannelOrder.RGB, use_py_spi=True,
                 dev="/dev/spidev0.0", SPISpeed=2, open=open):
        super().__init__(num, c_order=c_order, use_py_spi=use_py_spi, dev=dev,
                         SPISpeed=SPISpeed, open=open)

        # APA102 requires latch bytes at the end
        self._latchBytes = (int(num / 64.0) + 1)

    def _render(self, colors, pos):
        super()._render(colors, pos)
        newBuf = [0xFF] * (self.bufByteCount() + self.numLEDs)
        newBuf[1::4] = self._buf[0::3]
        newBuf[2::4] = self._buf[1::3]
        newBuf[3::4] = self._buf[2::3]
        self._buf[:] = [0, 0, 0, 0] + newBuf
        self._buf.extend([0xFF, 0, 0, 0] * self._latchBytes)

MANIFEST = [
{'fraction_non_alphanumeric': 0.13990707279297884, 'fraction_numerical': 0.03820340733092411, 'mean_word_length': 2.8452380952380953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788555', 'n_tokens_mistral': 735, 'n_tokens_neox': 691, 'n_words': 154}