Skip to content

Commit

Permalink
[init] Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Dec 1, 2020
1 parent a0e3d31 commit 2d50a6e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
class WakeWordLedGpio(MycroftSkill):
def __init__(self):
MycroftSkill.__init__(self)

# By default the skill requires configuration
self.configured = False

def _setup(self):
Expand All @@ -25,15 +27,19 @@ def _setup(self):

self.log.info('PIN mode set to {}'.format(self.pin_mode))

# See https://bit.ly/37pwxIC (Mycroft documentation about skill lifecycle)
def initialize(self):
# Callback when setting changes are detected from home.mycroft.ai
self.settings_change_callback = self.on_websettings_changed
self.on_websettings_changed()

# What to do in case of setting changes detected
def on_websettings_changed(self):
self._setup()
self._run()

def _run(self):
# Run only when the skill is properly configured
if self.configured:
try:
# Setup GPIO
Expand All @@ -50,9 +56,11 @@ def _run(self):
self.log.error('Cannot initialize GPIO - skill will not load')
self.speak_dialog('error.initialize')

# Turn on LED
def _handle_listener_started(self, message):
GPIO.output(self.pin_number, GPIO.HIGH)

# Turn off LED
def _handle_listener_ended(self, message):
GPIO.output(self.pin_number, GPIO.LOW)

Expand Down

0 comments on commit 2d50a6e

Please sign in to comment.