|
2 | 2 | # SPDX-License-Identifier: MIT |
3 | 3 |
|
4 | 4 | import time |
| 5 | +from os import getenv |
5 | 6 | import board |
6 | 7 | import busio |
7 | | -from os import getenv |
8 | 8 | from digitalio import DigitalInOut |
9 | 9 | import neopixel |
10 | 10 | from adafruit_esp32spi import adafruit_esp32spi |
|
17 | 17 | # CIRCUITPY_WIFI_ENT_SSID, CIRCUITPY_WIFI_ENT_PASSWORD, |
18 | 18 | # CIRCUITPY_WIFI_ENT_USER, CIRCUITPY_WIFI_ENT_IDENT |
19 | 19 | secrets = {} |
20 | | -for token in ["ssid","password","user","ident"]: |
21 | | - if getenv("CIRCUITPY_WIFI_ENT_"+token.upper()): |
22 | | - secrets[token] = getenv("CIRCUITPY_WIFI_"+token.upper()) |
23 | | -for token in ["aio_username","aio_key"]: |
24 | | - if getenv("CIRCUITPY_"+token.upper()): |
25 | | - secrets[token] = getenv("CIRCUITPY_"+token.upper()) |
26 | | -if secrets == {}: |
| 20 | +for token in ["ssid", "password", "user", "ident"]: |
| 21 | + if getenv("CIRCUITPY_WIFI_ENT_" + token.upper()): |
| 22 | + secrets[token] = getenv("CIRCUITPY_WIFI_" + token.upper()) |
| 23 | +for token in ["aio_username", "aio_key"]: |
| 24 | + if getenv("CIRCUITPY_" + token.upper()): |
| 25 | + secrets[token] = getenv("CIRCUITPY_" + token.upper()) |
| 26 | +if not secrets: |
27 | 27 | try: |
28 | 28 | # Fallback on secrets.py until depreciation is over and option is removed |
29 | 29 | from secrets import secrets # pylint: disable=no-name-in-module |
|
44 | 44 | esp32_reset = DigitalInOut(board.D5) |
45 | 45 |
|
46 | 46 | # Secondary (SCK1) SPI used to connect to WiFi board on Arduino Nano Connect RP2040 |
47 | | -if 'SCK1' in dir(board): |
| 47 | +if "SCK1" in dir(board): |
48 | 48 | spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1) |
49 | 49 | else: |
50 | 50 | spi = busio.SPI(board.SCK, board.MOSI, board.MISO) |
51 | 51 | esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) |
52 | 52 |
|
53 | 53 | """Use below for Most Boards""" |
54 | | -status_light = neopixel.NeoPixel( |
55 | | - board.NEOPIXEL, 1, brightness=0.2 |
56 | | -) |
| 54 | +status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) |
57 | 55 | """Uncomment below for ItsyBitsy M4""" |
58 | 56 | # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) |
59 | 57 | """Uncomment below for an externally defined RGB LED (including Arduino Nano Connect)""" |
|
0 commit comments