mpu6050.py 文件源码

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

项目:py-mpu6050 作者: larsks 项目源码 文件源码
def get_sensor_avg(self, samples, softstart=100):
        '''Return the average readings from the sensors over the
        given number of samples.  Discard the first softstart
        samples to give things time to settle.'''
        sample = self.read_sensors()
        counters = [0] * 7

        for i in range(samples + softstart):
            # the sleep here is to ensure we read a new sample
            # each time
            time.sleep_ms(2)

            sample = self.read_sensors()
            if i < softstart:
                continue

            for j, val in enumerate(sample):
                counters[j] += val

        return [x//samples for x in counters]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号