コード例 #1
0
def tx(
):  # _433.tx sends the appropriate remote control codes to the 433MHz transmitter
    tx = _433.tx(pi,
                 gpio=TX,
                 gap=remote[i + 2],
                 t0=remote[i + 3],
                 t1=remote[i + 4])
    for p in range(5):  # send code five times
        tx.send(remote[i])
    tx.cancel()
コード例 #2
0
    def rx_callback(code, bits, gap, t0, t1):
        print str(time.localtime())
        print("code={} bits={} (gap={} t0={} t1={})".format(
            code, bits, gap, t0, t1))

    pi = pigpio.pi()  # Connect to local Pi.

    rx = _433.rx(pi, gpio=RX, callback=rx_callback)

    args = len(sys.argv)

    if args > 1:

        # If the script has arguments they are assumed to codes
        # to be transmitted.

        tx = _433.tx(pi, gpio=TX)

        for i in range(args - 1):
            print("sending {}".format(sys.argv[i + 1]))
            tx.send(int(sys.argv[i + 1]))
            time.sleep(1)

        tx.cancel()  # Cancel the transmitter.

    time.sleep(3600)

    rx.cancel()  # Cancel the receiver.

    pi.stop()  # Disconnect from local Pi.