-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathwiringpi_class.py
96 lines (93 loc) · 2.33 KB
/
wiringpi_class.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
HIGH = 1
LOW = 0
MSBFIRST = 1
LSBFIRST = 0
WPI_MODE_PINS = 0
WPI_MODE_GPIO = 1
WPI_MODE_SYS = 2
MODE_PINS = 0
MODE_GPIO = 1
MODE_SYS = 2
INPUT = 0
OUTPUT = 1
PWM_OUTPUT = 2
PUD_OFF = 0
PUD_DOWN = 1
PUD_UP = 2
class nes(object):
def setupNesJoystick(self,*args):
return setupNesJoystick(*args)
def readNesJoystick(self,*args):
return readNesJoystick(*args)
class Serial(object):
device = '/dev/ttyAMA0'
baud = 9600
serial_id = 0
def printf(self,*args):
return serialPrintf(self.serial_id,*args)
def dataAvail(self,*args):
return serialDataAvail(self.serial_id,*args)
def getchar(self,*args):
return serialGetchar(self.serial_id,*args)
def putchar(self,*args):
return serialPutchar(self.serial_id,*args)
def puts(self,*args):
return serialPuts(self.serial_id,*args)
def __init__(self,device,baud):
self.device = device
self.baud = baud
self.serial_id = serialOpen(self.device,self.baud)
def __del__(self):
serialClose(self.serial_id)
class GPIO(object):
HIGH = 1
LOW = 0
MSBFIRST = 1
LSBFIRST = 0
WPI_MODE_PINS = 0
WPI_MODE_GPIO = 1
WPI_MODE_SYS = 2
MODE_PINS = 0
MODE_GPIO = 1
MODE_SYS = 2
INPUT = 0
OUTPUT = 1
PWM_OUTPUT = 2
PUD_OFF = 0
PUD_DOWN = 1
PUD_UP = 2
MODE = 0
def __init__(self,pinmode=0):
self.MODE=pinmode
if pinmode==0:
wiringPiSetup()
elif pinmode==1:
wiringPiSetupGpio()
elif pinmode==2:
wiringPiSetupSys()
def delay(self,*args):
delay(*args)
def delayMicroseconds(self,*args):
delayMicroseconds(*args)
def millis(self):
return millis()
def pinMode(self,*args):
pinMode(*args)
def digitalWrite(self,*args):
digitalWrite(*args)
def pwmWrite(self,*args):
pwmWrite(*args)
def digitalRead(self,*args):
return digitalRead(*args)
def shiftOut(self,*args):
shiftOut(*args)
def shiftOutWithDelay(self,*args):
shiftOutWithDelay(*args)
def shiftIn(self,*args):
return shiftIn(*args)
def pullUpDnControl(self,*args):
return pullUpDnControl(*args)
def softPwmCreate(*args):
return softPwmCrate(*args)
def softPwmWrite(*args):
return sofPwmWrite(*args)