Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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
Beispiel #5
0
 def __init__(self, i2c_bus):
     MockSMBus.__init__(self, i2c_bus)
     self.regs[0x00:0x01] = 0x0f, 0x00
Beispiel #6
0
 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
Beispiel #7
0
 def __init__(self, i2c_bus):
     MockSMBus.__init__(self, i2c_bus)
     self.regs[0xD0] = 0x60  # Fake chip ID
Beispiel #8
0
 def __init__(self, i2c_bus):
     MockSMBus.__init__(self, i2c_bus)
     self.regs[0x0F] = 0x49  # Fake part ID