当前位置: 首页>>代码示例>>Python>>正文


Python SimpleNamespace.i2c_location方法代码示例

本文整理汇总了Python中types.SimpleNamespace.i2c_location方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleNamespace.i2c_location方法的具体用法?Python SimpleNamespace.i2c_location怎么用?Python SimpleNamespace.i2c_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types.SimpleNamespace的用法示例。


在下文中一共展示了SimpleNamespace.i2c_location方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_measurement

# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import i2c_location [as 别名]
            self.i2c_bus = input_dev.i2c_bus
            self.adc_gain = input_dev.adc_gain
            self.adc = Adafruit_ADS1x15.ADS1115(address=self.i2c_address,
                                                busnum=self.i2c_bus)
        self.running = True

    def get_measurement(self):
        return_dict = measurements_dict.copy()

        for each_measure in self.device_measurements.all():
            if each_measure.is_enabled:
                return_dict[each_measure.channel]['value'] = self.adc.read_adc(
                    each_measure.channel, gain=self.adc_gain) / 10000.0

        return return_dict


if __name__ == "__main__":
    from types import SimpleNamespace
    settings = SimpleNamespace()
    settings.id = 1
    settings.unique_id = '0000-0000'
    settings.i2c_location = '0x48'
    settings.i2c_bus = 1
    settings.adc_gain = 1
    settings.channels = 4
    settings.run_main = True

    measurements = InputModule(settings, run_main=True).next()
    print("Measurements: {}".format(measurements))
开发者ID:ciscomonkey,项目名称:Mycodo,代码行数:32,代码来源:ads1x15.py

示例2: repr

# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import i2c_location [as 别名]
                if (self.is_enabled(2) and
                        self.is_enabled(0) and
                        self.is_enabled(1)):
                    return_dict[2]['value'] = self.tsl._calculate_lux(
                        return_dict[0]['value'], return_dict[1]['value'])

                return return_dict
            except Exception as err:
                if 'saturated' in repr(err):
                    self.logger.error(
                        "Could not obtain measurement: Sensor is saturated. "
                        "Recording value as 65536.")
                    return_dict[0]['value'] = 65536.0
                    return return_dict
                else:
                    self.logger.exception("Error: {}".format(err))


if __name__ == "__main__":
    from types import SimpleNamespace
    settings = SimpleNamespace()
    settings.id = 1
    settings.unique_id = '0000-0000'
    settings.i2c_location = '0x39'
    settings.i2c_bus = 1
    settings.run_main = True

    measurements = InputModule(settings, run_main=True).next()
    print("Measurements: {}".format(measurements))
开发者ID:ciscomonkey,项目名称:Mycodo,代码行数:31,代码来源:tsl2561.py

示例3: SimpleNamespace

# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import i2c_location [as 别名]
                                   channel=each_measure.channel,
                                   gain=self.adc_gain,
                                   resolution=self.adc_resolution)
                return_dict[each_measure.channel]['value'] = adc.convert_and_read()

        # Dummy data for testing
        # import random
        # return_dict[0]['value'] = random.uniform(1.5, 1.9)
        # return_dict[1]['value'] = random.uniform(2.3, 2.5)
        # return_dict[2]['value'] = random.uniform(0.5, 0.6)
        # return_dict[3]['value'] = random.uniform(3.5, 6.2)

        return return_dict


if __name__ == "__main__":
    from types import SimpleNamespace
    settings = SimpleNamespace()
    settings.id = 1
    settings.unique_id='0000-0000'
    settings.i2c_location = '0x68'
    settings.i2c_bus = 1
    settings.adc_gain = 1
    settings.adc_resolution = 12
    settings.channels = 4
    settings.run_main = True

    measurements = InputModule(settings).next()

    print("Measurements: {}".format(measurements))
开发者ID:ciscomonkey,项目名称:Mycodo,代码行数:32,代码来源:mcp342x.py


注:本文中的types.SimpleNamespace.i2c_location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。