Simple test

Ensure your device works with this simple test.

examples/pypixelbuf_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import adafruit_pypixelbuf


class TestBuf(adafruit_pypixelbuf.PixelBuf):
    called = False

    @property
    def n(self):
        return len(self)

    def _transmit(self, buffer):  # pylint: disable=unused-argument
        self.called = True


buf = TestBuf(20, "RGBW", brightness=0.5, auto_write=True)
buf[0] = (1, 2, 3)
buf[1] = (1, 2, 3, 4)
buf[2] = (2, 2, 2)

print(buf[0])
print(buf[0:2])
print(buf[0:2:2])
print(buf.called)