MCPcopy Create free account
hub / github.com/LabPy/lantz / fromByte

Method fromByte

lantz/drivers/labjack/_internal/u12.py:217–236  ·  view source on GitHub ↗

Name: BitField.fromByte(raw) Args: raw, the raw byte to make the BitField. Desc: Takes a byte, and modifies self to match. >>> bf = BitField() >>> bf.fromByte(123) # Modifies bf in place >>> print bf [ bit7 = 0, bit6 = 1, bit5 = 1, bi

(self, raw)

Source from the content-addressed store, hash-verified

215 self.fromByte(rawByte)
216
217 def fromByte(self, raw):
218 """
219 Name: BitField.fromByte(raw)
220 Args: raw, the raw byte to make the BitField.
221 Desc: Takes a byte, and modifies self to match.
222
223 >>> bf = BitField()
224 >>> bf.fromByte(123) # Modifies bf in place
225 >>> print bf
226 [ bit7 = 0, bit6 = 1, bit5 = 1, bit4 = 1, bit3 = 1, bit2 = 0, bit1 = 1,
227 bit0 = 1 ]
228 """
229 self.rawValue = raw
230 self.rawBits = []
231 self.data = []
232
233 items = min(8, len(self.labelList))
234 for i in reversed(list(range(items))):
235 self.rawBits.append( ((raw >> (i)) & 1) )
236 self.data.append(self.oneLabel if bool(((raw >> (i)) & 1)) else self.zeroLabel)
237
238 def asByte(self):
239 """

Callers 5

__init__Method · 0.95
rawAISampleMethod · 0.95
rawCounterMethod · 0.95
rawCounterPWMDIOMethod · 0.95
rawAIContinuousMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected