Simple test

Ensure your device works with this simple test.

examples/ws2801_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4### Based on example from
 5### https://github.com/adafruit/Adafruit_CircuitPython_DotStar/tree/master/examples
 6
 7import time
 8import random
 9import board
10import adafruit_ws2801
11
12### Example for a Feather M4 driving 25 12mm leds
13odata = board.D5
14oclock = board.D6
15numleds = 25
16bright = 1.0
17leds = adafruit_ws2801.WS2801(
18    oclock, odata, numleds, brightness=bright, auto_write=False
19)
20
21######################### HELPERS ##############################
22
23
24# a random color 0 -> 224
25def random_color():
26    return random.randrange(0, 7) * 32
27
28
29######################### MAIN LOOP ##############################
30n_leds = len(leds)
31while True:
32    # fill each led with a random color
33    for idx in range(n_leds):
34        leds[idx] = (random_color(), random_color(), random_color())
35
36    # show all leds in led string
37    leds.show()
38
39    time.sleep(0.25)