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()
评论列表
文章目录