Name: U12.eDigitalOut(channel, state, idNum = None, demo = 0, writeD=0) Args: See section 4.5 of the User's Guide Desc: This is a simplified version of DigitalIO that sets/clears the state of one digital output. Also configures the requested pin to
(self, channel, state, idNum = None, demo = 0, writeD=0)
| 2059 | return {"idnum" : self.id, "state" : state} |
| 2060 | |
| 2061 | def eDigitalOut(self, channel, state, idNum = None, demo = 0, writeD=0): |
| 2062 | """ |
| 2063 | Name: U12.eDigitalOut(channel, state, idNum = None, demo = 0, writeD=0) |
| 2064 | Args: See section 4.5 of the User's Guide |
| 2065 | Desc: This is a simplified version of DigitalIO that sets/clears the |
| 2066 | state of one digital output. Also configures the requested pin to |
| 2067 | output and leaves it that way. |
| 2068 | |
| 2069 | >>> import u12 |
| 2070 | >>> d = u12.U12() |
| 2071 | >>> d.eDigitalOut(0, 1) |
| 2072 | {idnum': 1} |
| 2073 | """ |
| 2074 | |
| 2075 | # Check id num |
| 2076 | if idNum is None: |
| 2077 | idNum = self.id |
| 2078 | |
| 2079 | if ON_WINDOWS: |
| 2080 | ljid = ctypes.c_long(idNum) |
| 2081 | |
| 2082 | ecode = staticLib.EDigitalOut(ctypes.byref(ljid), demo, channel, writeD, state) |
| 2083 | |
| 2084 | if ecode != 0: raise U12Exception(ecode) |
| 2085 | |
| 2086 | return {"idnum":ljid.value} |
| 2087 | else: |
| 2088 | oldstate = self.rawDIO() |
| 2089 | |
| 2090 | if writeD: |
| 2091 | if channel > 7: |
| 2092 | channel = channel-8 |
| 2093 | direction = BitField(rawByte = int(oldstate['D15toD8Directions'])) |
| 2094 | direction[7-channel] = 0 |
| 2095 | |
| 2096 | states = BitField(rawByte = int(oldstate['D15toD8States'])) |
| 2097 | states[7-channel] = state |
| 2098 | |
| 2099 | self.rawDIO(D15toD8Directions = direction, D15toD8States = states, UpdateDigital = True) |
| 2100 | |
| 2101 | else: |
| 2102 | direction = BitField(rawByte = int(oldstate['D7toD0Directions'])) |
| 2103 | direction[7-channel] = 0 |
| 2104 | |
| 2105 | states = BitField(rawByte = int(oldstate['D7toD0States'])) |
| 2106 | states[7-channel] = state |
| 2107 | |
| 2108 | self.rawDIO(D7toD0Directions = direction, D7toD0States = states, UpdateDigital = True) |
| 2109 | |
| 2110 | else: |
| 2111 | bf = BitField() |
| 2112 | bf[7-(channel+4)] = 0 |
| 2113 | bf[7-channel] = state |
| 2114 | self.rawDIO(IO3toIO0DirectionsAndStates = bf, UpdateDigital = True) |
| 2115 | |
| 2116 | return {"idnum" : self.id} |
| 2117 | |
| 2118 | def aiSample(self, numChannels, channels, idNum=None, demo=0, stateIOin=0, updateIO=0, ledOn=0, gains=[0, 0, 0, 0], disableCal=0): |
no test coverage detected