Skip to content

Fixed NEOPIXEL_POWER_INVERTED in use on CP 7.0 #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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