|
1 | 1 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries |
2 | 2 | # SPDX-License-Identifier: MIT |
3 | 3 |
|
| 4 | +from os import getenv |
4 | 5 | import board |
5 | 6 | import busio |
6 | 7 | from digitalio import DigitalInOut |
7 | 8 | from adafruit_esp32spi import adafruit_esp32spi |
8 | | -from adafruit_esp32spi import adafruit_esp32spi_wifimanager |
| 9 | +from adafruit_esp32spi.adafruit_esp32spi_wifimanager import WiFiManager |
9 | 10 | import neopixel |
10 | 11 |
|
11 | 12 | import adafruit_lifx |
12 | 13 |
|
13 | | -# Get wifi details and more from a secrets.py file |
14 | | -try: |
15 | | - from secrets import secrets |
16 | | -except ImportError: |
17 | | - print("WiFi and API secrets are kept in secrets.py, please add them there!") |
18 | | - raise |
| 14 | +# Get WiFi details, ensure these are setup in settings.toml |
| 15 | +ssid = getenv("CIRCUITPY_WIFI_SSID") |
| 16 | +password = getenv("CIRCUITPY_WIFI_PASSWORD") |
19 | 17 |
|
20 | 18 | # ESP32 SPI |
21 | 19 | esp32_cs = DigitalInOut(board.ESP_CS) |
22 | 20 | esp32_ready = DigitalInOut(board.ESP_BUSY) |
23 | 21 | esp32_reset = DigitalInOut(board.ESP_RESET) |
24 | 22 | spi = busio.SPI(board.SCK, board.MOSI, board.MISO) |
25 | 23 | esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) |
26 | | -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) |
27 | | -wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light) |
| 24 | +status_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) |
| 25 | +wifi = WiFiManager(esp, ssid, password, status_pixel=status_pixel) |
28 | 26 |
|
29 | 27 | # Add your LIFX Personal Access token to secrets.py |
30 | 28 | # (to obtain a token, visit: https://cloud.lifx.com/settings) |
31 | | -lifx_token = secrets["lifx_token"] |
| 29 | +lifx_token = getenv("lifx_token") |
| 30 | + |
| 31 | +if lifx_token is None: |
| 32 | + raise KeyError("Please add your lifx token to settings.toml") |
32 | 33 |
|
33 | 34 | # Set this to your LIFX light separator label |
34 | 35 | # https://api.developer.lifx.com/docs/selectors |
|
0 commit comments