# -------------------------------------------------- #
# This file is autogenerated by pioasm; do not edit! #
# -------------------------------------------------- #
import rp2
import time
from rp2 import PIO
from machine import Pin
from time import sleep
sendout = , Pin.OUT);
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def ir_send():
wrap_target()
pull
set x, 31 ; Loop over 32 bits
bitloop:
set pins, 1 ; Drive pin high
out y, 1 [5] ; Shift 1 bit out, and write it to y
nop [5]
jmp !y skip ; Skip the extra delay if the bit was 0
nop [5]
skip:
set sendout, 0 [5]
nop [5]
jmp x-- bitloop ; Jump if x nonzero, and decrement x
wrap()
sm = rp2.StateMachine(0, ir_send, freq=2000, set_base=Pin(2))
adress = 0b00000001
codes = [
0b11000000, # 0
0b11111001, # 1
0b10100100, # 2
0b10110000, # 3
]
def datacombine(codenum):
return (
adress | (adress xor 0xff) << 8
| codes[codenum] << 16
| (codes[codenum] xor 0xff) << 24
)
counter = 0
while True:
code = rand() % 4 ;
sm.put(datacombine(code));
sm.active(1)
counter += 1;
sleep(1);