configuration.py 文件源码

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

项目:pi-topPULSE 作者: pi-top 项目源码 文件源码
def _write_device_state(state):
    """INTERNAL. Send the state bits across the I2C bus"""

    try:
        PTLogger.debug("Connecting to bus...")
        i2c_bus = SMBus(_bus_id)

        state_to_send = 0x0F & state

        PTLogger.debug("Writing new state:    " + _get_bit_string(state_to_send))
        i2c_bus.write_byte_data(_device_addr, 0, state_to_send)

        result = _verify_device_state(state_to_send)

        if result is True:
            PTLogger.debug("OK")
        else:
            PTLogger.warning("Error: New state could not be verified")

        return result

    except:
        PTLogger.warning("Error: There was a problem writing to the device")
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号