blob: 6d654245ff4366f2642e6eca22d92ffb1643c9a0 [file] [log] [blame]
Philip Howardfa09d182013-04-01 21:11:00 +00001%pythoncode %{
2class nes(object):
3 def setupNesJoystick(self,*args):
4 return setupNesJoystick(*args)
5 def readNesJoystick(self,*args):
6 return readNesJoystick(*args)
7
8class Serial(object):
9 device = '/dev/ttyAMA0'
10 baud = 9600
11 serial_id = 0
12 def printf(self,*args):
13 return serialPrintf(self.serial_id,*args)
14 def dataAvail(self,*args):
15 return serialDataAvail(self.serial_id,*args)
16 def getchar(self,*args):
17 return serialGetchar(self.serial_id,*args)
18 def putchar(self,*args):
19 return serialPutchar(self.serial_id,*args)
20 def puts(self,*args):
21 return serialPuts(self.serial_id,*args)
22 def __init__(self,device,baud):
23 self.device = device
24 self.baud = baud
25 self.serial_id = serialOpen(self.device,self.baud)
26 def __del__(self):
27 serialClose(self.serial_id)
28
Philip Howard97a4f512013-04-07 11:06:20 +000029class I2C(object):
30 def setupInterface(self,*args):
31 return wiringPiI2CSetupInterface(*args)
32 def setup(self,*args):
33 return wiringPiI2CSetup(*args)
34 def read(self,*args):
35 return wiringPiI2CRead(*args)
36 def readReg8(self,*args):
Philip Howardf388d582013-12-11 14:37:16 +000037 return wiringPiI2CReadReg8(*args)
Philip Howard97a4f512013-04-07 11:06:20 +000038 def readReg16(self,*args):
39 return wiringPiI2CReadReg16(*args)
Yang Deokgyuf2fc0cc2019-08-27 18:48:54 +090040 def readBlock(self,*args):
41 return wiringPiI2CReadBlock(*args)
Philip Howard97a4f512013-04-07 11:06:20 +000042 def write(self,*args):
43 return wiringPiI2CWrite(*args)
44 def writeReg8(self,*args):
45 return wiringPiI2CWriteReg8(*args)
46 def writeReg16(self,*args):
47 return wiringPiI2CWriteReg16(*args)
Yang Deokgyuf2fc0cc2019-08-27 18:48:54 +090048 def writeBlock(self,*args):
49 return wiringPiI2CWriteBlock(*args)
Philip Howard97a4f512013-04-07 11:06:20 +000050
Philip Howardfa09d182013-04-01 21:11:00 +000051class GPIO(object):
52 WPI_MODE_PINS = 0
53 WPI_MODE_GPIO = 1
54 WPI_MODE_GPIO_SYS = 2
55 WPI_MODE_PHYS = 3
56 WPI_MODE_PIFACE = 4
57 WPI_MODE_UNINITIALISED = -1
58
59 INPUT = 0
60 OUTPUT = 1
61 PWM_OUTPUT = 2
62 GPIO_CLOCK = 3
63
64 LOW = 0
65 HIGH = 1
66
67 PUD_OFF = 0
68 PUD_DOWN = 1
69 PUD_UP = 2
70
71 PWM_MODE_MS = 0
72 PWM_MODE_BAL = 1
73
74 INT_EDGE_SETUP = 0
75 INT_EDGE_FALLING = 1
76 INT_EDGE_RISING = 2
77 INT_EDGE_BOTH = 3
78
79 LSBFIRST = 0
80 MSBFIRST = 1
81
82 MODE = 0
83 def __init__(self,pinmode=0):
84 self.MODE=pinmode
85 if pinmode==self.WPI_MODE_PINS:
86 wiringPiSetup()
87 if pinmode==self.WPI_MODE_GPIO:
88 wiringPiSetupGpio()
89 if pinmode==self.WPI_MODE_GPIO_SYS:
90 wiringPiSetupSys()
91 if pinmode==self.WPI_MODE_PHYS:
92 wiringPiSetupPhys()
93 if pinmode==self.WPI_MODE_PIFACE:
94 wiringPiSetupPiFace()
95
96 def delay(self,*args):
97 delay(*args)
98 def delayMicroseconds(self,*args):
99 delayMicroseconds(*args)
100 def millis(self):
101 return millis()
102 def micros(self):
103 return micros()
104
105 def piHiPri(self,*args):
106 return piHiPri(*args)
107
108 def piBoardRev(self):
109 return piBoardRev()
110 def wpiPinToGpio(self,*args):
111 return wpiPinToGpio(*args)
Philip Howardfa09d182013-04-01 21:11:00 +0000112 def getAlt(self,*args):
113 return getAlt(*args)
114 def digitalWriteByte(self,*args):
115 return digitalWriteByte(*args)
116
Joshua Yangd955f742019-02-13 14:34:43 +0900117 def setPadDrive(self,*args):
118 return setPadDrive(*args)
119 def getPadDrive(self,*args):
120 return getPadDrive(*args)
121 def getPUPD(self,*args):
122 return getPUPD(*args)
123
Philip Howardfa09d182013-04-01 21:11:00 +0000124 def pwmSetMode(self,*args):
125 pwmSetMode(*args)
126 def pwmSetRange(self,*args):
127 pwmSetRange(*args)
128 def pwmSetClock(self,*args):
129 pwmSetClock(*args)
130 def gpioClockSet(self,*args):
131 gpioClockSet(*args)
132 def pwmWrite(self,*args):
133 pwmWrite(*args)
134
135 def pinMode(self,*args):
136 pinMode(*args)
137
138 def digitalWrite(self,*args):
139 digitalWrite(*args)
140 def digitalRead(self,*args):
141 return digitalRead(*args)
142 def digitalWriteByte(self,*args):
143 digitalWriteByte(*args)
144
145 def analogWrite(self,*args):
146 analogWrite(*args)
147 def analogRead(self,*args):
148 return analogRead(*args)
149
150 def shiftOut(self,*args):
151 shiftOut(*args)
152 def shiftIn(self,*args):
153 return shiftIn(*args)
154
155 def pullUpDnControl(self,*args):
156 return pullUpDnControl(*args)
157
158 def waitForInterrupt(self,*args):
159 return waitForInterrupt(*args)
160 def wiringPiISR(self,*args):
161 return wiringPiISR(*args)
162
163 def softPwmCreate(self,*args):
164 return softPwmCreate(*args)
165 def softPwmWrite(self,*args):
Brett Reinhard76db7e62016-12-16 07:37:29 -0800166 return softPwmWrite(*args)
Philip Howardfa09d182013-04-01 21:11:00 +0000167
168 def softToneCreate(self,*args):
169 return softToneCreate(*args)
170 def softToneWrite(self,*args):
171 return softToneWrite(*args)
172
173 def lcdHome(self,*args):
174 return lcdHome(self,*args)
175 def lcdCLear(self,*args):
176 return lcdClear(self,*args)
177 def lcdSendCommand(self,*args):
178 return lcdSendCommand(self,*args)
179 def lcdPosition(self,*args):
180 return lcdPosition(self,*args)
181 def lcdPutchar(self,*args):
182 return lcdPutchar(self,*args)
183 def lcdPuts(self,*args):
184 return lcdPuts(self,*args)
185 def lcdPrintf(self,*args):
186 return lcdPrintf(self,*args)
187 def lcdInit(self,*args):
188 return lcdInit(self,*args)
Philip Howard77a42442013-08-15 22:32:14 +0100189 def piGlowSetup(self,*args):
190 return piGlowSetup(self,*args)
191 def piGlow1(self,*args):
192 return piGlow1(self,*args)
193 def piGlowLeg(self,*args):
194 return piGlowLeg(self,*args)
195 def piGlowRing(self,*args):
196 return piGlowRing(self,*args)
Philip Howardfa09d182013-04-01 21:11:00 +0000197%}