From 0c4ec0f67bc644ce938f03c6c74d65425568156c Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 4 Feb 2022 01:56:49 +0000 Subject: [PATCH] feat/i2c_detect taken from https://github.com/OpenVoiceOS/ovos_utils/pull/11/files#diff-6ef74e4b2ac88ebd6d3681d4534f0a587bf0eb72d4628b1393c4198a47a1b468 --- ovos_PHAL/i2c_detect | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 ovos_PHAL/i2c_detect diff --git a/ovos_PHAL/i2c_detect b/ovos_PHAL/i2c_detect new file mode 100644 index 0000000..b38ebf3 --- /dev/null +++ b/ovos_PHAL/i2c_detect @@ -0,0 +1,49 @@ +import subprocess + + +def is_mycroft_sj201(): + cmd = 'i2cdetect -y -a 1 0x04 0x04 | egrep "(04|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"04" or out == b"UU": + return True + return False + + +def is_respeaker_2mic(): + cmd = 'i2cdetect -y -a 1 0x1a 0x1a | egrep "(1a|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"1a" or out == b"UU": + return True + return False + + +def is_respeaker_4mic(): + cmd = 'i2cdetect -y -a 0x35 0x35 | egrep "(35|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"35" or out == b"UU": + return True + return False + + +def is_respeaker_6mic(): + cmd = 'i2cdetect -y -a 0x3b 0x3b | egrep "(3b|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"3b" or out == b"UU": + return True + return False + + +def is_adafruit(): + cmd = 'i2cdetect -y -a 0x4b 0x4b | egrep "(4b|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"4b" or out == b"UU": + return True + return False + + +def is_texas_tas5806(): + cmd = 'i2cdetect -y -a 0x2f 0x2f | egrep "(2f|UU)" | awk \'{print $2}\'' + out = subprocess.check_output(cmd, shell=True).strip() + if out == b"2f" or out == b"UU": + return True + return False