# These pins are used as both analog and digital! XL, XR and YU must be analog # and digital capable. YD just need to be digital ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR, board.TOUCH_YD, board.TOUCH_YU, calibration=((5200, 59000), (5800, 57000)), size=(320, 240)) # Set this to your LIFX personal access token in secrets.py # (to obtain a token, visit: https://cloud.lifx.com/settings) lifx_token = secrets['lifx_token'] # Initialize the LIFX API Helper lifx = adafruit_lifx.LIFX(wifi, lifx_token) # Set these to your LIFX light selector (https://api.developer.lifx.com/docs/selectors) lifx_lights = ['label:Lamp', 'label:Bedroom'] # set default light properties current_light = lifx_lights[0] light_brightness = 1.0 # Make the display context button_group = displayio.Group() board.DISPLAY.show(button_group) # preload the font print('loading font...') font = bitmap_font.load_font("/fonts/Arial-12.bdf") glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: ' font.load_glyphs(glyphs)
# Set up ESP32-S2 and adafruit_requests session wifi.radio.connect(ssid=secrets["ssid"], password=secrets["password"]) pool = socketpool.SocketPool(wifi.radio) http_session = adafruit_requests.Session(pool, ssl.create_default_context()) # Add your LIFX Personal Access token to secrets.py # (to obtain a token, visit: https://cloud.lifx.com/settings) lifx_token = secrets["lifx_token"] # Set this to your LIFX light separator label # https://api.developer.lifx.com/docs/selectors lifx_light = "label:Lamp" # Initialize the LIFX API Client lifx = adafruit_lifx.LIFX(http_session, lifx_token) # List all lights lights = lifx.list_lights() # Turn on the light print("Turning on light...") lifx.toggle_light(lifx_light) # Set the light's brightness to 50% light_brightness = 0.5 lifx.set_brightness(lifx_light, light_brightness) # Cycle the light using the colors of the Python logo colors = ["yellow", "blue", "white"] for color in colors: