Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Use hardware momentary switches to control moOde
#58
That would suggest the code is not detecting any change in the pin state. Below is the code block for button 1.

Code:
   if str(row['id']) == '1' and row['enabled'] == '1':
       sw_1_pin = int(row['pin'])
       sw_1_cmd = row['command'].split(',')
       sw_1_cmd = [x.strip() for x in sw_1_cmd]
       GPIO.setup(sw_1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

       def sw_1_event(channel):
           subprocess.call(sw_1_cmd)

       GPIO.add_event_detect(sw_1_pin,
                             GPIO.RISING,
                             callback=sw_1_event,
                             bouncetime=bounce_time)
       print(str(datetime.datetime.now())[:19] + ' sw_1: pin=' +
             str(sw_1_pin) + ', enabled=' + row['enabled'] +
             ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command'])

Pin numbering used is SoC.
https://raspi.tv/2013/rpi-gpio-basics-4-...and-inputs

Code:
# Use SoC pin numbering
GPIO.setmode(GPIO.BCM)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
RE: Use hardware momentary switches to control moOde - by Tim Curtis - 04-12-2020, 02:53 PM

Forum Jump: