Beispiel #1
0
def main():
    attachedSensors = []
    availableSensors = []
    for device in range(0x20, 0x41):  # look at all possible addresses
        test = TrillLib(1, "none", 256)
        if test.testForI2CDevice(device, 0, 1):  # a device is found
            print("Device found at address", hex(device))
            del test
            test = TrillLib(1, "none", device)  # initialise with valid address
            testType = test.getTypeNumber()
            print("Device identifies as", testType, trillType[testType])
            attachedSensors.append([trillType[testType], device])
            availableSensors.append(testType)
        del test
    print("Final Report")
    print("We found", len(availableSensors), "sensors on the I2C bus")
    print("List of sensor types attached with addresses (decimal) :-")
    print(attachedSensors)
def findSensors():
    global trillSensor, attachedSensors, availableSensors, currentType, addr
    attachedSensors = []
    availableSensors = []
    for device in range(0x20, 0x41):  # look at all possible addresses
        test = TrillLib(1, "none", 256)
        if test.testForI2CDevice(device, 0, 1):  # a device is found
            #print("Device found at address", hex(device))
            del test
            test = TrillLib(1, "none", device)  # initialise with valid address
            testType = test.getTypeNumber()
            #print("Device identifies as", testType, trillType[testType])
            attachedSensors.append([trillType[testType], device])
            availableSensors.append(testType)
        del test
    currentType = availableSensors[0]
    initNewSensor(0, attachedSensors[0][0] in trillType)  # first sensor found
    trillSensor.printDetails()