mma8451.py 文件源码

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

项目:mma8451 作者: jatinkataria 项目源码 文件源码
def __init__(self, address=DEFAULT_ADDRESS, bus=None,
                 sensor_range=RANGE_4G, data_rate=BW_RATE_400HZ, debug=False):
        if debug:
            logger.setLevel(logging.DEBUG)

        self.i2c_address = address
        if bus is None:
            bus = self.get_pi_revision()
        # bcm2708 doesnt support repeated start bits for i2c messages.
        # set the combined parameter which sends command correctly.
        # **********WARNING*******************
        # axes data seems to have lot of noise and its a hack.

        os.chmod(BCM2708_COMBINED_PARAM_PATH, 666)
        os.system('echo -n 1 > {!s}'.format(BCM2708_COMBINED_PARAM_PATH))

        # ************************************

        self._smbus = smbus.SMBus(bus)
        self.sensor_range = sensor_range
        self.data_rate = data_rate
        self.high_res_mode = OVERSAMPLING_MODE
        self.setup_sensor()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号