From c444d068f0278e47ca2ca717bd24dcca84833614 Mon Sep 17 00:00:00 2001 From: Kendell R Date: Sat, 20 Feb 2021 08:48:02 -0800 Subject: [PATCH 1/2] Add deinit function This might not be used a lot, but this helps in case you need to just load up one bit, and then load up another. --- adafruit_magtag/peripherals.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/adafruit_magtag/peripherals.py b/adafruit_magtag/peripherals.py index 69c28cf..944b7ef 100755 --- a/adafruit_magtag/peripherals.py +++ b/adafruit_magtag/peripherals.py @@ -86,6 +86,16 @@ def play_tone(self, frequency, duration): pass attempt += 1 self._speaker_enable.value = False + + def deinit(self): + """Call deinit on all resources to free them""" + self.neopixels.deinit() + self._neopixel_disable.deinit() + self._speaker_enable.deinit() + for button in self.buttons: + button.deinit() + self._batt_monitor.deinit() + self._light.deinit() @property def battery(self): From 54c06b5b2177cb31ee215bc28f70285a249a3c3b Mon Sep 17 00:00:00 2001 From: Kendell R Date: Sat, 20 Feb 2021 08:53:40 -0800 Subject: [PATCH 2/2] Update peripherals.py --- adafruit_magtag/peripherals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_magtag/peripherals.py b/adafruit_magtag/peripherals.py index 944b7ef..83e2e03 100755 --- a/adafruit_magtag/peripherals.py +++ b/adafruit_magtag/peripherals.py @@ -86,7 +86,7 @@ def play_tone(self, frequency, duration): pass attempt += 1 self._speaker_enable.value = False - + def deinit(self): """Call deinit on all resources to free them""" self.neopixels.deinit()