gc.collect() from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS gc.collect() import board import pulseio import adafruit_dotstar import adafruit_irremote import time # The keyboard object! time.sleep(1) # Sleep for a bit to avoid a race condition on some systems keyboard = Keyboard() keyboard_layout = KeyboardLayoutUS(keyboard) # We're in the US :) led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1) decoder = adafruit_irremote.GenericDecode() pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=100, idle_state=True) # Expected pulse, pasted in from previous recording REPL session: key1_pulses = [0] key2_pulses = [1] print('IR listener') # Fuzzy pulse comparison function: def fuzzy_pulse_compare(pulse1, pulse2, fuzzyness=0.2): if len(pulse1) != len(pulse2): return False for i in range(len(pulse1)):
def __init__(self, debug=False): self.pulsein = pulseio.PulseIn(board.REMOTEIN, maxlen=120, idle_state=True) self.decoder = adafruit_irremote.GenericDecode() self.debug = debug
def __init__(self): self.decoder = adafruit_irremote.GenericDecode() # Measuring IR pulses self.pulsein = pulseio.PulseIn(board.IR_RX, maxlen=200, idle_state=True)
def __init__(self, lock, pin=board.A0, ir_code=[223, 32, 239, 16]): self.lock = lock self.pulsein = pulseio.PulseIn(pin, maxlen=120, idle_state=True) self.decoder = adafruit_irremote.GenericDecode() self.ir_code = ir_code
''' ###################################################### # Import ###################################################### import board import pulseio import adafruit_irremote from jisforjt_cutebot_clue import cutebot, clue ###################################################### # Global Variables ###################################################### pulsein = pulseio.PulseIn(board.D16, maxlen=120, idle_state=True) #Set Infrared (IR) pin decoder = adafruit_irremote.GenericDecode( ) #Set infrared (IR) decoder to Adafruit's generic decoder maxSpeed = 30 ''' Set each of the buttons codes to the codes for your IR remote. To find codes, run the program with all the buttons set to None. Afterwards, press each button and write down its code that you see on the Cluebot below. ''' #Example: button_UP = [120, 85] button_DOWN = [127, 21] button_LEFT = [122, 65] button_RIGHT = [124, 65] button_STOP = [120, 65] button_1 = [127, 109] ''' button_UP = [None] # Set the up button code
def __init__(self, pin): self._pulses = pulseio.PulseIn(pin, maxlen=250, idle_state=True) self._decoder = adafruit_irremote.GenericDecode()