コード例 #1
0
            if self.in_code:

                self.in_code = False

                pigpio.set_watchdog(self.gpio, 0)

                if self.edges > 12:

                    self.callback(self.hash_val)


if __name__ == "__main__":

    import time
    import pigpio
    import ir_hasher

    def callback(hash):
        print("hash={}".format(hash))

    pigpio.start()

    ir = ir_hasher.hasher(7, callback, 5)

    print("ctrl c to exit")

    time.sleep(300)

    pigpio.stop()
コード例 #2
0
print("Setting up BNO055")
bno = BNO055(serial_port='/dev/serial0', rst=18)
if not bno.begin():
    raise RuntimeError('Failed to initialize BNO055! Is the sensor connected?')

pixel_pin = board.D12  # NeoPixels connected to BCM 12 pin -- WAS CHANGED FROM 18 TO 12
ORDER = neopixel.GRB

import os
print("Running `sudo pigpiod` to enable IR communcation")
os.system("sudo pigpiod")

print("Initializing Controller")
# Instantiate Remote controller
pi = pigpio.pi()
ir = ir_hasher.hasher(pi, 17, callback, 5)

print("Initializing NeoPixels")
with neopixel.NeoPixel(pixel_pin,
                       num_pixels,
                       brightness=0.4,
                       auto_write=False,
                       pixel_order=ORDER) as pixels:

    key_functionality = {
        'UP': (forward_pulse, {}),
        'DOWN': (forward_pulse, {
            'start': BML
        }),
        'LEFT': (forward_pulse, {
            'start': 24
コード例 #3
0
        def callback(hash):
          #print("hello")
          #print("hash = {}".format(hash))
          if hash in hashes:
             print("key = {} hash = {}".format(hashes[hash], hash))
             try:
                if hashes[hash] == 'Play':
                   x.ctrl_iface.Play()
                   print('Play')
                if hashes[hash] == 'Pause':
                   x.ctrl_iface.Pause()
                   print('Pause')
                if hashes[hash] == 'Next':
                   x.ctrl_iface.Next()
                   print('Next')
                if hashes[hash] == 'Previous':
                   x.ctrl_iface.Previous()
                   print('Previous')
             except Exception as e:
                print(e)
        pi = pigpio.pi()
        ir = ir_hasher.hasher(pi, 4, callback, 5)
        time.sleep(1)
        pi.stop()
        
      else:
            print("search for player...")
            x.load_player(x.bus, x.service, x.hci0_path)
            time.sleep(1)

コード例 #4
0
ファイル: ir_hasher.py プロジェクト: Bahamuttg/pigpio
      1583569525:'0',       1629745313:'rewind',  1666513749:'record',
      1677653754:'c-down',  1825951717:'c-right', 1852412236:'6',
      1894279468:'9',       1904895749:'vol+',    1941947509:'ff',
      2076573637:'0',       2104823531:'back',    2141641957:'home',
      2160787557:'record',  2398525299:'7',       2468117013:'8',
      2476712746:'play',    2574308838:'forward', 2577952149:'4',
      2706654902:'stop',    2829002741:'c-up',    2956097083:'back',
      3112717386:'5',       3263244773:'ff',      3286088195:'pause',
      3363767978:'c-down',  3468076364:'vol-',    3491068358:'stop',
      3593710134:'c-left',  3708232515:'3',       3734134565:'back',
      3766109107:'TV',      3798010010:'play',    3869937700:'menu',
      3872715523:'7',       3885097091:'2',       3895301587:'text',
      3931058739:'mute',    3983900853:'c-right', 4032250885:'4',
      4041913909:'vol+',    4207017660:'9',       4227138677:'back',
      4294027955:'3'}

   def callback(hash):
      if hash in hashes:
         print("key={} hash={}".format(hashes[hash], hash));

   pi = pigpio.pi()

   ir = ir_hasher.hasher(pi, 7, callback, 5)

   print("ctrl c to exit");

   time.sleep(300)

   pi.stop()

コード例 #5
0
    recorded = 1


print('Welcome to Ramils Remote Setuper')
print(
    'This code creates a json dictionary mapping keynames to their IR hashcodes'
)
print(
    'Make sure you have pigpio installed, pigpiod enabled and have ir_hasher ')

print('=' * 30, '\n', 'The default pin for IR receiver is 17')
print('Setting up PI gpios and hasher')

INPUT_PIN = 17
pi = pigpio.pi()
ir = ir_hasher.hasher(pi, INPUT_PIN, callback, 5)

print("Type key name, press ENTER, then press key on remote. Repeat. Succeed.")
print("Empty input to stop")

data = {}
key = input("Type key name: ")
recorded = 0

while key != "":
    print("Press that key")
    while recorded == 0:
        pass
    print('recorded')
    recorded = 0
    key = input("Type next key name: ")