Thank you for your donation!


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


Instruction Guide IR remote control without LIRC
#3
I used the PiIR library to make a version of your script that barely uses any CPU and is much simpler.  PiIR requires the use of python3, so it can still be used along side your guide except change the references from "python" to "python3".  

Thought I would share it with everyone.

Code:
from piir.io import receive
from piir.decode import decode
import subprocess,piir,sys

# GPIO of IR receiver
pinr = 24

# unique IR snippet (not entire dict) in button press of apple remote
# captured using "test" mode of this script
ok = r"xee\x87\\\xab"
menu = r"xee\x87\x03\xab"
down = r"xee\x87\x0c\xab"
up = r"xee\x87\n\xab"
left = r"xee\x87\t\xab"
right = r"xee\x87\x06\xab"
play = r"xee\x87_\xab"

# if 'test' is entered as argument then only show remote button press codes
# ex: python3 moode_ir_control.py test
# used to capture button press snippets as shown in previous section
if (len(sys.argv) - 1):
    if sys.argv[1] == 'test':
        while True:
            print(decode(receive(pinr)))

while True:
   data = str(decode(receive(pinr)))
   if ok in data:
       subprocess.call(["mpc", "toggle"])
   elif menu in data:
       subprocess.call(["mpc", "stop"])
   elif down in data:
       subprocess.call(["mpc", "seek","-5%"])
   elif up in data:
       subprocess.call(["mpc", "seek","+5%"])
   elif left in data:
       subprocess.call(["mpc", "prev"])
   elif right in data:
       subprocess.call(["mpc", "next"])
Reply


Messages In This Thread
IR remote control without LIRC - by mmcsn - 03-11-2021, 12:00 AM
RE: IR remote control without LIRC - by donutswdad - 04-28-2021, 01:16 AM
RE: IR remote control without LIRC - by Larvitar - 06-08-2021, 09:40 PM
RE: IR remote control without LIRC - by mmcsn - 09-04-2021, 04:15 PM
RE: IR remote control without LIRC - by Pixxel - 10-04-2021, 11:24 AM

Forum Jump: