Skip to content

Commit

Permalink
More button troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Mar 29, 2024
1 parent fe263e4 commit b0c739d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions neon_phal_plugin_switches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ def on_mic_status(self, message):
msg_type = 'mycroft.mic.unmute'
self.bus.emit(message.reply(msg_type))

def on_button_press(self):
def on_button_press(self, _=None):
LOG.info("Listen button pressed")
if not self.switches.mute_switch.is_active:
self.bus.emit(Message("mycroft.mic.listen"))
else:
self.bus.emit(Message("mycroft.mic.error",
{"error": "mic_sw_muted"}))

def on_button_volup_press(self):
def on_button_volup_press(self, _=None):
LOG.debug("VolumeUp button pressed")
self.bus.emit(Message("mycroft.volume.increase"))

def on_button_voldown_press(self):
def on_button_voldown_press(self, _=None):
LOG.debug("VolumeDown button pressed")
self.bus.emit(Message("mycroft.volume.decrease"))

Expand All @@ -102,7 +102,7 @@ def __init__(self, action_callback: callable,
mute_callback: callable, unmute_callback: callable,
volup_pin: int = 22, voldown_pin: int = 23,
action_pin: int = 24, mute_pin: int = 25,
sw_muted_state: int = 1, sw_pullup: bool = False):
sw_muted_state: int = 1, sw_pullup: bool = True):
"""
Creates an object to manage GPIO switches and callbacks on switch
activity.
Expand Down Expand Up @@ -140,9 +140,12 @@ def setup_gpio(self, pull_up: bool = True):
@param pull_up: If true, pull up switches, else pull down
"""

Button(self.action_pin, pull_up=pull_up).when_activated = self.on_action
Button(self.vol_up_pin, pull_up=pull_up).when_activated = self.on_vol_up
Button(self.vol_dn_pin, pull_up=pull_up).when_activated = self.on_vol_down
act = Button(self.action_pin, pull_up=pull_up)
act.when_activated = self.on_action
vol_up = Button(self.vol_up_pin, pull_up=pull_up)
vol_up.when_activated = self.on_vol_up
vol_down = Button(self.vol_dn_pin, pull_up=pull_up)
vol_down.when_activated = self.on_vol_down

mute_active = True if bool(self._muted) == pull_up else False
self.mute_switch = Button(self.mute_pin, pull_up=None,
Expand Down

0 comments on commit b0c739d

Please sign in to comment.