Hi @Jon140244 ,
I am sticking with double level dictionaries at the moment, yes, actually have two of them to handle some of the conflicts as I can’t have identical keys (the ID value) in a dictionary.
Why? because this code will hopefully wind up in the PiicoDev_Unified.py file in the future.
The ‘constants’ and the two dictionaries as at this time
#
# declare "CONSTANTS"
#
__LED_ID = 0x8
__VEML6030_0_ID = 0x10 # CONFLICT
__VEML6040_ID = 0x10 # CONFLICT
__QMC6310_ID = 0x1c # Magnetometer
__LIS3DH_1_ID = 0x18 # Accelerometer - ASW ON
__LIS3DH_0_ID = 0x19 # Accelerometer - ASW OFF
__TRANSCEIVER_ID = 0x1a
__TOUCH_ID = 0x28
__VL53L1X_ID = 0x29
__RFID_ID = 0x2c
__ULTRASONIC_ID = 0x35 # Conflict
__POTENTIOMETER_ID = 0x35 # Conflict
__SSD1306_ID = 0x3c
__BUTTON_ID = 0x42
__SERVO_ID = 0x44
__TMP117_ID = 0x48 # CONFLICT
__VEML6030_1_ID = 0x48 # CONFLICT
__RV3028_ID = 0x52 # RTC
__ENS160_1_ID = 0x52 # ASW on
__ENS160_0_ID = 0x53 # ASW off
__BUZZER_ID = 0x5c
__MS5637_ID = 0x76
__BME280_ID = 0x77
devices_details_list: dict = {
__LED_ID: { # 8. 0x8
'device_name': 'RGB LED Module',
'device_long_name': 'PiicoDev 3x RGB LED Module',
'device_short_name': 'LED'},
__VEML6040_ID: { # 16. 0x10
'device_name': 'Colour Sensor',
'device_long_name': 'PiicoDev VEML6030 Colour Sensor',
'device_short_name': 'VEML6040'},
__LIS3DH_1_ID: { # 24. 0x18
'device_name': 'Accelerometer',
'device_long_name': 'PiicoDev 3-Axis Accelerometer LIS3DH (ASW on)',
'device_short_name': 'LIS3DH (ASW on)'},
__LIS3DH_0_ID: { # 25. 0x19
'device_name': 'Accelerometer',
'device_long_name': 'PiicoDev 3-Axis Accelerometer LIS3DH (ASW off)',
'device_short_name': 'LIS3DH (ASW off)'},
__TRANSCEIVER_ID: { # 26. 0x1A
'device_name': 'Transceiver',
'device_long_name': 'PiicoDev Transceiver 915MHz',
'device_short_name': 'TRANSCEIVER'},
__QMC6310_ID: { # 28. 0x1c
'device_name': 'Magnetometer',
'device_long_name': 'PiicoDev Magnetometer QMC6310',
'device_short_name': 'QMC6310'},
__TOUCH_ID: { # 40. 0x28
'device_name': 'Capacitive Touch Sensor',
'device_long_name': 'PiicoDev Capacitive Touch Sensor',
'device_short_name': 'TOUCH'},
__VL53L1X_ID: { # 41. 0x29
'device_name': 'Laser Distance Sensor',
'device_long_name': 'PiicoDev Laser Distance Sensor VL53L1X',
'device_short_name': 'VL53L1X'},
__RFID_ID: { # 45. 0x2c
'device_name': 'RFID Module',
'device_long_name': 'PiicoDev RFID Module (NFC 13.56MHz)',
'device_short_name': 'RFID'},
__ULTRASONIC_ID: { # 53. 0x35
'device_name': 'Ultrasonic Rangefinder',
'device_long_name': 'PiicoDev Ultrasonic Rangefinder Module',
'device_short_name': 'ULTRASONIC'},
__SSD1306_ID: { # 60. 0x3c
'device_name': 'OLED Module',
'device_long_name': 'PiicoDev OLED Module SSD1306',
'device_short_name': 'SSD1306'},
__BUTTON_ID: { # 66. 0x42
'device_name': 'Button',
'device_long_name': 'PiicoDev Button',
'device_short_name': 'BUTTON'},
__SERVO_ID: { # 68. 0x44
'device_name': 'Servo Driver',
'device_long_name': 'PiicoDev Servo Driver (4 Channel)',
'device_short_name': 'SERVO'},
__TMP117_ID: { # 72. 0x48
'device_name': 'Precision Temperature Sensor',
'device_long_name': 'PiicoDev TMP117 Precision Temperature Sensor',
'device_short_name': 'TMP117'},
__RV3028_ID: { # 82. 0x52
'device_name': 'Real Time Clock',
'device_long_name': 'PiicoDev Real Time Clock (RTC) RV3028',
'device_short_name': 'RV3028'},
__ENS160_0_ID: { # 83. 0x53
'device_name': 'Air Quality Sensor',
'device_long_name': 'PiicoDev Air Quality Sensor ENS160 (ASW off)',
'device_short_name': 'ENS160 (ASW off)'},
__BUZZER_ID: { # 92. 0x5c
'device_name': 'Buzzer Module',
'device_long_name': 'PiicoDev Buzzer Module',
'device_short_name': 'BUZZER'},
__MS5637_ID: { # 118. 0x76
'device_name': 'Pressure Sensor',
'device_long_name': 'PiicoDev Pressure Sensor MS5637',
'device_short_name': 'MS5637'},
__BME280_ID: { # 119. 0x77
'device_name': 'Atmospheric Sensor',
'device_long_name': 'PiicoDev BME280 Atmospheric Sensor',
'device_short_name': 'BME280'},
}
################
## conflicts list
################
devices_details_conf_list: dict = {
__VEML6030_0_ID: { # 16. 0x10
'device_name': 'Ambient Light Sensor',
'device_long_name': 'PiicoDev VEML6030 Ambient Light Sensor (ASW off)',
'device_short_name': 'VEML6030 (ASW off)'},
__POTENTIOMETER_ID: { # 53. 0x35
'device_name': 'Potentiometer',
'device_long_name': 'PiicoDev Potentiometer (Rotary)',
'device_short_name': 'Potentiometer'},
__VEML6030_1_ID: { # 72. 0x48
'device_name': 'Ambient Light Sensor',
'device_long_name': 'PiicoDev VEML6030 Ambient Light Sensor (ASW on)',
'device_short_name': 'VEML6030 (ASW on)'},
__ENS160_1_ID: { # 83. 0x53
'device_name': 'Air Quality Sensor',
'device_long_name': 'PiicoDev Air Quality Sensor ENS160 (ASW on)',
'device_short_name': 'ENS160 (ASW on)'},
}
and some code to do the check and display
def show_what_is_connected():
hit = 0
connected = i2c.scan()
for i in connected:
if i in devices_details_list:
s = devices_details_list[i]['device_long_name']
print(i, hex(i), s)
hit = 1
if i in devices_details_conf_list:
s = devices_details_conf_list[i]['device_long_name']
print(i, hex(i), s, '<<<<< Possible conflict')
hit = 1
if hit == 0:
print('Nothing connected')
Probably will need some ‘polishing’ by those more pythonesk types than me …
Still WIP (recovering from a Scout camp - 3500 Cubs for 5 days/4 nights. ZZzzzzZzz z z)
Murray