Skip to content

Commit 5b23e85

Browse files
committed
Added exception if running IR example on Bluefruit
1 parent 4e1a326 commit 5b23e85

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

examples/circuitplayground_ir_receive.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
"""THIS EXAMPLE REQUIRES A SEPARATE LIBRARY BE LOADED ONTO YOUR CIRCUITPY DRIVE.
22
This example requires the adafruit_irremote.mpy library.
33
4+
THIS EXAMPLE WORKS WITH CIRCUIT PLAYGROUND EXPRESS ONLY.
5+
46
This example uses the IR receiver found near the center of the board. Works with another Circuit
5-
Playground running the circuitplayground_ir_transmit.py example. The NeoPixels will light up when
6-
the buttons on the TRANSMITTING Circuit Playground are pressed!"""
7+
Playground Express running the circuitplayground_ir_transmit.py example. The NeoPixels will light
8+
up when the buttons on the TRANSMITTING Circuit Playground Express are pressed!"""
79
import pulseio
810
import board
911
import adafruit_irremote
1012
from adafruit_circuitplayground import cp
1113

1214
# Create a 'pulseio' input, to listen to infrared signals on the IR receiver
13-
pulsein = pulseio.PulseIn(board.IR_RX, maxlen=120, idle_state=True)
15+
try:
16+
pulsein = pulseio.PulseIn(board.IR_RX, maxlen=120, idle_state=True)
17+
except AttributeError:
18+
raise NotImplemented("This example does not work with Circuit Playground Bluefruti!")
1419
# Create a decoder that will take pulses and turn them into numbers
1520
decoder = adafruit_irremote.GenericDecode()
1621

examples/circuitplayground_ir_transmit.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
"""THIS EXAMPLE REQUIRES A SEPARATE LIBRARY BE LOADED ONTO YOUR CIRCUITPY DRIVE.
22
This example requires the adafruit_irremote.mpy library.
33
4+
THIS EXAMPLE WORKS WITH CIRCUIT PLAYGROUND EXPRESS ONLY.
5+
46
This example uses the IR transmitter found near the center of the board. Works with another Circuit
5-
Playground running the circuitplayground_ir_receive.py example. Press the buttons to light up the
6-
NeoPixels on the RECEIVING Circuit Playground!"""
7+
Playground Express running the circuitplayground_ir_receive.py example. Press the buttons to light
8+
up the NeoPixels on the RECEIVING Circuit Playground Express!"""
79
import time
810
import pulseio
911
import board
1012
import adafruit_irremote
1113
from adafruit_circuitplayground import cp
1214

1315
# Create a 'pulseio' output, to send infrared signals from the IR transmitter
14-
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
16+
try:
17+
pwm = pulseio.PWMOut(board.IR_TX, frequency=38000, duty_cycle=2 ** 15)
18+
except AttributeError:
19+
raise NotImplementedError("This example does not work with Circuit Playground Bluefruit!")
1520
pulseout = pulseio.PulseOut(pwm)
1621
# Create an encoder that will take numbers and turn them into NEC IR pulses
1722
encoder = adafruit_irremote.GenericTransmit(header=[9500, 4500], one=[550, 550],

0 commit comments

Comments
 (0)