grove_i2c_color_sensor.py 文件源码

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

项目:pimaa 作者: outboxafrica 项目源码 文件源码
def __init__(self, bus_number=None):
        """Initialize i2c communication with the sensor and sets default parameters.

        Default parameters: continuous integration (not started) with 12ms cycles, gain 1x, pre-scale 1.

        :param bus_number: the i2c bus number (usually 0 or 1, depending on the hardware). Use the i2cdetect command
        line tool to identify the right bus. If set to None, will use the Raspberry Pi revision number to guess which
        bus to use.
        """
        if bus_number is None:
            # Use Rasbperry Pi revision to choose bus number
            board_revision = RPi.GPIO.RPI_REVISION
            if board_revision == 2 or board_revision == 3:
                bus_number = 1
            else:
                bus_number = 0
        self.bus = smbus.SMBus(bus_number)
        self.use_continuous_integration()
        self.set_gain_and_prescaler(1, 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号