from scs_core.data.json import JSONify from scs_core.gas.ndir.ndir_version import NDIRVersion from scs_host.bus.i2c import I2C from scs_host.sys.host import Host from scs_ndir.gas.ndir.spi_ndir_x1.spi_ndir_x1 import SPINDIRx1 # -------------------------------------------------------------------------------------------------------------------- try: I2C.Sensors.open() ndir = SPINDIRx1(False, Host.ndir_spi_bus(), Host.ndir_spi_device()) print(ndir) print("-") ndir.power_on() version = ndir.version() print("version: %s" % version) print("-") jstr = JSONify.dumps(version) print(jstr) print("-") jdict = json.loads(jstr)
# Interface... interface_conf = InterfaceConf.load(Host) if interface_conf is None: print("InterfaceConf not available.") exit(1) interface = interface_conf.interface() print(interface) # NDIR... conf = NDIRConf("t1f1", 5) print("conf: %s" % conf) ndir = SPINDIRt1f1(interface, Host.ndir_spi_bus(), Host.ndir_spi_device()) print("ndir: %s" % ndir) print("-") ndir.power_on() monitor = NDIRMonitor(ndir, conf) print("monitor: %s" % monitor) firmware = monitor.firmware() print("firmware: %s" % firmware) print("-") monitor.start() for i in range(10):