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")
|
|
|
|
expected_bytearray = bytearray([255, 128, 64, 255, 128, 64, 255, 128, 64])
|
|
|
|
actual_bytearray = np.buf
|
2023-10-06 16:27:28 +00:00
|
|
|
print(f'Initial fill: {"passed" if expected_bytearray == actual_bytearray else "failed"}.')
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|
|
|
|
|
|
|
|
print("Change brightness of all pixels.")
|
|
|
|
np.brightness(0.5)
|
|
|
|
expected_bytearray = bytearray([127, 64, 32, 127, 64, 32, 127, 64, 32])
|
|
|
|
actual_bytearray = np.buf
|
2023-10-06 16:27:28 +00:00
|
|
|
print(f'Brightness change: {"passed" if expected_bytearray == actual_bytearray else "failed"}.')
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|
|
|
|
|
|
|
|
print("Get current brightness.")
|
|
|
|
expected_brightness = 0.5
|
|
|
|
actual_brightness = np.brightness()
|
2023-10-06 16:27:28 +00:00
|
|
|
print(f'Brightness get: {"passed" if expected_brightness == actual_brightness else "failed"}.')
|
2023-10-06 15:52:27 +00:00
|
|
|
print()
|