2023-10-06 15:52:27 +00:00
|
|
|
import machine
|
|
|
|
import neopixel
|
|
|
|
|
|
|
|
|
|
|
|
def neopixel_test():
|
|
|
|
np = neopixel.NeoPixel(machine.Pin(1), 3)
|
|
|
|
print("Fill with a color.")
|
|
|
|
np.fill((255, 128, 64))
|
|
|
|
print("Verify the bytes to be written")
|
2023-10-06 16:32:54 +00:00
|
|
|
expected = bytearray([255, 128, 64, 255, 128, 64, 255, 128, 64])
|
|
|
|
actual = np.buf
|
|
|
|
passed = "passed" if expected == actual else "failed"
|
|
|
|
print(f"Initial fill: {passed}.")
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|
|
|
|
|
|
|
|
print("Change brightness of all pixels.")
|
|
|
|
np.brightness(0.5)
|
2023-10-06 16:32:54 +00:00
|
|
|
expected = bytearray([127, 64, 32, 127, 64, 32, 127, 64, 32])
|
|
|
|
actual = np.buf
|
|
|
|
passed = "passed" if expected == actual else "failed"
|
|
|
|
print(f"Brightness change: {passed}.")
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|
|
|
|
|
|
|
|
print("Get current brightness.")
|
2023-10-06 16:32:54 +00:00
|
|
|
expected = 0.5
|
|
|
|
actual = np.brightness()
|
|
|
|
passed = "passed" if expected == actual else "failed"
|
|
|
|
print(f"Brightness get: {passed}.")
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|