return log(x) / log(2)
def truth(v):
+ """Returns a truth value of the given value.
+
+ Allows patterns like: truth(~False) == True
+ the pythonic way is: True is not False
+ while: "True == ~False" returns False an NOT expected"
+
+ in python:
+ ~True == int(-2)
+ ~False == int(-1)
+
+ This returns v if v is a bool, returns False if v is an int and is one of
+ [0, -2], True of bool(v) is True, and False otherwise.
+ """
if isinstance(v, (int, intbv)):
# NB: ~True == -2
# ~False == -1
def __init__(self, interface=ftdi.INTERFACE_A, scl=0, sda=1,
vid=0x0403, pid=0x6011, delay=0.001, timeout=100,
pindir=0xc0, pinstate=0xc0):
- """Bitbanged I2C for use on FT4232H ports C and D.
+ """Bitbanged I2C for use on FT4232H ports C and D. Uses the libftdi
+ python bindings.
interface = [0,1,2,3]
scl/sda = port pin numbers