from machine import Pin
from neopixel import NeoPixel

VERSION = "p03-rgb-v1"
COLORS = {
    "RED": (24, 0, 0),
    "GREEN": (0, 24, 0),
    "BLUE": (0, 0, 24),
}

led = NeoPixel(Pin(48, Pin.OUT), 1)
led[0] = (0, 0, 0)
led.write()

print("[BOOT] P03_RGB_DEMO version=%s gpio=48" % VERSION)
print("[DEBUG] ready colors=RED,GREEN,BLUE")

while True:
    command = input().strip().upper()
    if command in COLORS:
        red, green, blue = COLORS[command]
        led[0] = (red, green, blue)
        led.write()
        print("[RGB] color=%s rgb=%d,%d,%d" % (command, red, green, blue))
    elif command:
        print("[ERROR] unknown_command=%s" % command)
