def __init__(self, i2c_bus): MockSMBus.__init__(self, i2c_bus) self.regs[0x86] = 0x09 << 4 # Fake part number self.regs[0x86] |= 0x02 # Fake revision self.regs[0x87] = 0x05 # Fake manufacturer ID self.regs[0x88:0x8C] = [0xff, 0xff, 0xff, 0xff] # ALS CH0 & CH1 self.regs[0x8C] = 0xff # ALS / PS Status self.regs[0x8D] = 0xf0 # Proximity Data (240)
def __init__(self, i2c_bus): """Initialise device mock. :param i2c_bus: i2c bus ID """ MockSMBus.__init__(self, i2c_bus) self.regs[0x40] = 0b001011 # Fake part number self.regs[0x92] = 0xE0 # Fake manufacturer ID colour_data = struct.pack('<HHHH', *BH1745_COLOUR_DATA) colour_data = [ord(x) if type(x) is str else x for x in colour_data] self.regs[0x50:0x50 + 8] = list(colour_data)
def __init__(self, i2c_bus): """Initialise the class. :param i2c_bus: i2c bus ID. """ MockSMBus.__init__(self, i2c_bus) self.status = 0b01 # Fake status register self.ptr = None # Fake register pointer # Virtual registers, thes contain the data actually used self.regs[0x00] = 0x88 # Fake HW type self.regs[0x01] = 0x77 # Fake HW version self.regs[0x02] = 0xFE # Fake FW version MSB (Sub, Minor) self.regs[0x03] = 0xFF # Fake FW version LSB (Minor, Major) self.regs[0x04] = 0x02 # Control Register # Prime the Calibrated Data registers with fake data self.regs[0x14:24] = [ ord(c) if type(c) is str else c for c in struct.pack('>ffffff', *reversed(CALIBRATED_VALUES)) ]
def __init__(self, i2c_bus): MockSMBus.__init__(self, i2c_bus) self.regs[0x86] = 0x09 << 4 # Fake part number self.regs[0x86] |= 0x02 # Fake revision self.regs[0x87] = 0x05 # Fake manufacturer ID
def __init__(self, i2c_bus): MockSMBus.__init__(self, i2c_bus) self.regs[0x00:0x01] = 0x0f, 0x00
def __init__(self, bus): MockSMBus.__init__(self, bus) # Set the uppermost bit of the CONFIG register # to indicate an "inactive/start" status self.regs[1] = 0b10000000
def __init__(self, i2c_bus): MockSMBus.__init__(self, i2c_bus) self.regs[0xD0] = 0x60 # Fake chip ID
def __init__(self, i2c_bus): MockSMBus.__init__(self, i2c_bus) self.regs[0x0F] = 0x49 # Fake part ID