我试图让 LIRC 在我的代码中运行。我创建了一些测试代码,但收到此错误:
Traceback (most recent call last):
File "ir_remote.py", line 5, in <module>
config = lirc.nextcode()
File "lirc.pyx", line 183, in lirc.nextcode (lirc/lirc.c:2983)
File "lirc.pyx", line 217, in lirc._is_init_or_error (lirc/lirc.c:3472)
lirc.InitError: lirc has not been initialised.
我创建的代码:
#!/usr/bin/python
import lirc, time
import RPi.GPIO as GPIO
config = lirc.nextcode()
sockid = lirc.init(blocking = False)
if config == 'KEY_DOWN':
print 'Red OFF'
if config == 'KEY_UP':
print 'Light Red'
if config == 'KEY_LEFT':
print 'Red'
if config == 'KEY_RIGHT':
print 'Green OFF'
if config == 'KEY_OK':
print 'Light Green'
if config == 'KEY_1':
print 'Green'
if config == 'KEY_2':
print 'Blue OFF'
if config == 'KEY_3':
print 'Light Blue'
if config == 'KEY_4':
print 'BLUE'