Skip to content

Commit

Permalink
Merge pull request #63 from makermelissa/main
Browse files Browse the repository at this point in the history
Fixed NEOPIXEL_POWER_INVERTED in use on CP 7.0
  • Loading branch information
makermelissa authored Jul 19, 2021
2 parents 79e7360 + 0c8d464 commit a72f2e3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions adafruit_magtag/peripherals.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ class Peripherals:
def __init__(self):
# Neopixels
self.neopixels = neopixel.NeoPixel(board.NEOPIXEL, 4, brightness=0.3)
self._neopixel_disable = DigitalInOut(board.NEOPIXEL_POWER)
self._neopixel_disable.direction = Direction.OUTPUT
self._neopixel_disable.value = False
try:
self._neopixel_disable = DigitalInOut(board.NEOPIXEL_POWER)
self._neopixel_disable.direction = Direction.OUTPUT
self._neopixel_disable.value = False
except ValueError:
self._neopixel_disable = None

# Battery Voltage
self._batt_monitor = AnalogIn(board.BATTERY)
Expand Down Expand Up @@ -90,7 +93,8 @@ def play_tone(self, frequency, duration):
def deinit(self):
"""Call deinit on all resources to free them"""
self.neopixels.deinit()
self._neopixel_disable.deinit()
if self._neopixel_disable is not None:
self._neopixel_disable.deinit()
self._speaker_enable.deinit()
for button in self.buttons:
button.deinit()
Expand All @@ -107,11 +111,14 @@ def neopixel_disable(self):
"""
Enable or disable the neopixels for power savings
"""
return self._neopixel_disable.value
if self._neopixel_disable is not None:
return self._neopixel_disable.value
return False

@neopixel_disable.setter
def neopixel_disable(self, value):
self._neopixel_disable.value = value
if self._neopixel_disable is not None:
self._neopixel_disable.value = value

@property
def speaker_disable(self):
Expand Down

0 comments on commit a72f2e3

Please sign in to comment.