Skip to content

Commit d21b709

Browse files
author
brentru
committed
add an externally defined rgbled status_led to _wifimanager
1 parent 46b4dea commit d21b709

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

adafruit_esp32spi/adafruit_esp32spi_wifimanager.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2):
4242
"""
4343
:param ESP_SPIcontrol esp: The ESP object we are using
4444
:param dict secrets: The WiFi and Adafruit IO secrets dict (See examples)
45-
:param status_pixel: (Optional) The pixel device - A NeoPixel or DotStar (default=None)
46-
:type status_pixel: NeoPixel or DotStar
45+
:param status_pixel: (Optional) The pixel device - A NeoPixel, DotStar,
46+
or RGB LED (default=None)
47+
:type status_pixel: NeoPixel, DotStar, or RGB LED
4748
:param int attempts: (Optional) Failed attempts before resetting the ESP32 (default=2)
4849
"""
4950
# Read the settings
@@ -54,6 +55,9 @@ def __init__(self, esp, secrets, status_pixel=None, attempts=2):
5455
self.attempts = attempts
5556
requests.set_interface(self._esp)
5657
self.statuspix = status_pixel
58+
self._is_rgb_led = False
59+
if hasattr(self.statuspix, 'color'):
60+
self._is_rgb_led = True
5761
self.pixel_status(0)
5862

5963
def reset(self):
@@ -214,13 +218,15 @@ def ip_address(self):
214218

215219
def pixel_status(self, value):
216220
"""
217-
Change Status NeoPixel if it was defined
221+
Change Status NeoPixel/Dotstar/RGBLED if it was defined
218222
219223
:param value: The value to set the Board's status LED to
220224
:type value: int or 3-value tuple
221225
"""
222-
if self.statuspix:
226+
if self.statuspix and not self._is_rgb_led:
223227
self.statuspix.fill(value)
228+
else:
229+
self.statuspix.color = value
224230

225231
def signal_strength(self):
226232
"""

examples/esp32spi_aio_post.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030
"""Use below for Most Boards"""
3131
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
3232
"""Uncomment below for ItsyBitsy M4"""
33-
#status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
33+
# status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
34+
# Uncomment below for an externally defined RGB LED
35+
# import adafruit_rgbled
36+
# from adafruit_esp32spi import PWMOut
37+
# RED_LED = PWMOut.PWMOut(esp, 26)
38+
# GREEN_LED = PWMOut.PWMOut(esp, 27)
39+
# BLUE_LED = PWMOut.PWMOut(esp, 25)
40+
# status_light = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED)
3441
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)
3542

3643
counter = 0

0 commit comments

Comments
 (0)