Simple test

Ensure your device works with this simple test.

examples/pypixelbuf_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import adafruit_pypixelbuf
 5
 6
 7class TestBuf(adafruit_pypixelbuf.PixelBuf):
 8    called = False
 9
10    @property
11    def n(self):
12        return len(self)
13
14    def _transmit(self, buffer):  # pylint: disable=unused-argument
15        self.called = True
16
17
18buf = TestBuf(20, "RGBW", brightness=0.5, auto_write=True)
19buf[0] = (1, 2, 3)
20buf[1] = (1, 2, 3, 4)
21buf[2] = (2, 2, 2)
22
23print(buf[0])
24print(buf[0:2])
25print(buf[0:2:2])
26print(buf.called)