Skip to content

Commit d0abfaf

Browse files
authored
Merge pull request #2248 from evaherrada/internal-led-update
Updated internal LED code to work better with bundler
2 parents 3bb9bc2 + 97c8ca2 commit d0abfaf

File tree

2 files changed

+17
-9
lines changed
  • CircuitPython_Essentials
    • CircuitPython_Internal_RGB_LED_colors
    • CircuitPython_Internal_RGB_LED_rainbow

2 files changed

+17
-9
lines changed

CircuitPython_Essentials/CircuitPython_Internal_RGB_LED_colors/code.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
import board
88

99
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express, and ItsyBitsy M4 Express
10-
import adafruit_dotstar
11-
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
10+
if hasattr(board, "APA102_SCK"):
11+
import adafruit_dotstar
12+
13+
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
1214
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, Circuit Playground Express, QT Py M0
13-
# import neopixel
14-
# led = neopixel.NeoPixel(board.NEOPIXEL, 1)
15+
else:
16+
import neopixel
17+
18+
led = neopixel.NeoPixel(board.NEOPIXEL, 1)
1519

1620
led.brightness = 0.3
1721

CircuitPython_Essentials/CircuitPython_Internal_RGB_LED_rainbow/code.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
import board
88
from rainbowio import colorwheel
99

10-
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express and ItsyBitsy M4 Express
11-
import adafruit_dotstar
12-
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
10+
# For Trinket M0, Gemma M0, ItsyBitsy M0 Express, and ItsyBitsy M4 Express
11+
if hasattr(board, "APA102_SCK"):
12+
import adafruit_dotstar
13+
14+
led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
1315
# For Feather M0 Express, Metro M0 Express, Metro M4 Express, Circuit Playground Express, QT Py M0
14-
# import neopixel
15-
# led = neopixel.NeoPixel(board.NEOPIXEL, 1)
16+
else:
17+
import neopixel
18+
19+
led = neopixel.NeoPixel(board.NEOPIXEL, 1)
1620

1721
led.brightness = 0.3
1822

0 commit comments

Comments
 (0)