utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:picraftzero 作者: WayneKeenan 项目源码 文件源码
def i2c_scan(bus_num=1):
    global HAVE_SMBUS
    if not HAVE_SMBUS:
        return []
    bus = smbus.SMBus(bus_num) # 1 indicates /dev/i2c-1
    devices = []
    for device in range(128):
        try:
            bus.read_byte(device)
            logger.info("Found i2c device at addr: {}".format(hex(device)))
            devices.append(device)
        except Exception: # exception if read_byte fails
            pass

    return devices




# Must run some activites on the main thread, e.g. PyGame event polling
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号