-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathirSendCMD.py
44 lines (32 loc) · 1.03 KB
/
irSendCMD.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import machine
import utime
import micropython
micropython.alloc_emergency_exception_buf(100)
# how to use:
# # logIrCMD(time list) -> auto save to /buttomCMD.txt:
# from irGetCMD import *
# a = irGetCMD(25) # 25 is GPIO PIN number
# # get irRawCodeListObject
# from irSelectCMD import *
# irCMDList = irSelectCMD(0)
# # pwmObject
# import machine
# irLed = machine.Pin(16, machine.Pin.OUT) # 16 is GPIO PIN number
# irLedPwmObject = machine.PWM(irLed, freq=38000, duty=0)
# # ir send
# irSendCMD(irLedPwmObject, irCMDList, duty=360)
def irSendCMD(pwmObject, ctrlList, duty=360):
pwmObject.deinit()
pwmObject.init()
pwmObject.freq(38000)
pwmObject.duty(0)
utime.sleep_ms(100)
ctrlListLen = len(ctrlList)
for i in range(ctrlListLen):
if i % 2 == 0:
pwmObject.duty(duty)
else:
pwmObject.duty(0)
utime.sleep_us(ctrlList[i])
pwmObject.duty(0)
utime.sleep_ms(100)