Skip to content

Commit efeeff3

Browse files
committed
NEC IR driver and demos now run on ESP32.
1 parent 177087a commit efeeff3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

nec_ir/aremote.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
else:
1616
from machine import Pin
1717

18+
ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
19+
1820
# Save RAM
1921
# from micropython import alloc_emergency_exception_buf
2022
# alloc_emergency_exception_buf(100)
@@ -48,6 +50,8 @@ def __init__(self, pin, callback, extended, *args): # Optional args for callbac
4850
self._times = array('i', (0 for _ in range(_EDGECOUNT + 1))) # +1 for overrun
4951
if platform == 'pyboard':
5052
ExtInt(pin, ExtInt.IRQ_RISING_FALLING, Pin.PULL_NONE, self._cb_pin)
53+
elif ESP32:
54+
pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING))
5155
else:
5256
pin.irq(handler = self._cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING), hard = True)
5357
self._edge = 0

nec_ir/art.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
from sys import platform
1010
import uasyncio as asyncio
11+
ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
12+
1113
if platform == 'pyboard':
1214
from pyb import Pin
13-
elif platform == 'esp8266':
15+
elif platform == 'esp8266' or ESP32:
1416
from machine import Pin, freq
1517
else:
1618
print('Unsupported platform', platform)
@@ -36,6 +38,8 @@ def test():
3638
elif platform == 'esp8266':
3739
freq(160000000)
3840
p = Pin(13, Pin.IN)
41+
elif ESP32:
42+
p = Pin(23, Pin.IN)
3943
ir = NEC_IR(p, cb, True) # Assume r/c uses extended addressing
4044
loop = asyncio.get_event_loop()
4145
loop.run_forever()

nec_ir/art1.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
from sys import platform
1212
import uasyncio as asyncio
13+
ESP32 = platform == 'esp32' or platform == 'esp32_LoBo'
1314
if platform == 'pyboard':
1415
from pyb import Pin, LED
15-
elif platform == 'esp8266':
16+
elif platform == 'esp8266' or ESP32:
1617
from machine import Pin, freq
1718
else:
1819
print('Unsupported platform', platform)
@@ -48,6 +49,10 @@ def test():
4849
p = Pin(13, Pin.IN)
4950
led = Pin(2, Pin.OUT)
5051
led(1)
52+
elif ESP32:
53+
p = Pin(23, Pin.IN)
54+
led = Pin(21, Pin.OUT) # LED with 220Ω series resistor between 3.3V and pin 21
55+
led(1)
5156
ir = NEC_IR(p, cb, True, led) # Assume extended address mode r/c
5257
loop = asyncio.get_event_loop()
5358
loop.run_forever()

0 commit comments

Comments
 (0)