コード例 #1
0
ファイル: common.py プロジェクト: coding-world/Python_DHT
def get_platform():
	"""Return a DHT platform interface for the currently detected platform."""
	plat = platform_detect.platform_detect()
	if plat == platform_detect.RASPBERRY_PI:
		# Check for version 1 or 2 of the pi.
		version = platform_detect.pi_version()
		if version == 1:
			import Python_DHT.Raspberry_Pi as Raspberry_Pi
			return Raspberry_Pi
		elif version == 2:
			import Python_DHT.Raspberry_Pi_2 as Raspberry_Pi_2
			return Raspberry_Pi_2
		else:
			raise RuntimeError('No driver for detected Raspberry Pi version available!')
	elif plat == platform_detect.BEAGLEBONE_BLACK:
		import Python_DHT.Beaglebone_Black as Beaglebone_Black
		return Beaglebone_Black
	else:
		raise RuntimeError('Unknown platform.')
コード例 #2
0
ファイル: common.py プロジェクト: devnet-coding/DHT_Python
def get_platform():
    """Return a DHT platform interface for the currently detected platform."""
    plat = platform_detect.platform_detect()
    if plat == platform_detect.RASPBERRY_PI:
        # Check for version 1 or 2 of the pi.
        version = platform_detect.pi_version()
        if version == 1:
            import Python_DHT.Raspberry_Pi as Raspberry_Pi
            return Raspberry_Pi
        elif version == 2:
            import Python_DHT.Raspberry_Pi_2 as Raspberry_Pi_2
            return Raspberry_Pi_2
        else:
            raise RuntimeError(
                'No driver for detected Raspberry Pi version available!')
    elif plat == platform_detect.BEAGLEBONE_BLACK:
        import Python_DHT.Beaglebone_Black as Beaglebone_Black
        return Beaglebone_Black
    else:
        raise RuntimeError('Unknown platform.')
コード例 #3
0
ファイル: setup.py プロジェクト: devnet-coding/DHT_Python
    platform = platform_detect.RASPBERRY_PI
    pi_version = 1
    sys.argv.remove('--force-pi')
elif '--force-pi2' in sys.argv:
    platform = platform_detect.RASPBERRY_PI
    pi_version = 2
    sys.argv.remove('--force-pi2')
elif '--force-bbb' in sys.argv:
    platform = platform_detect.BEAGLEBONE_BLACK
    sys.argv.remove('--force-bbb')
elif '--force-test' in sys.argv:
    platform = 'TEST'
    sys.argv.remove('--force-test')
else:
    # No explicit platform chosen, detect the current platform.
    platform = platform_detect.platform_detect()

# Pick the right extension to compile based on the platform.
extensions = []
if platform == platform_detect.RASPBERRY_PI:
    # Get the Pi version (1 or 2)
    if pi_version is None:
        pi_version = platform_detect.pi_version()
    # Build the right extension depending on the Pi version.
    if pi_version == 1:
        extensions.append(
            Extension("Python_DHT.Raspberry_Pi_Driver", [
                "source/_Raspberry_Pi_Driver.c", "source/common_dht_read.c",
                "source/Raspberry_Pi/pi_dht_read.c",
                "source/Raspberry_Pi/pi_mmio.c"
            ],
コード例 #4
0
ファイル: setup.py プロジェクト: coding-world/Python_DHT
	platform = platform_detect.RASPBERRY_PI
	pi_version = 1
	sys.argv.remove('--force-pi')
elif '--force-pi2' in sys.argv:
	platform = platform_detect.RASPBERRY_PI
	pi_version = 2
	sys.argv.remove('--force-pi2')
elif '--force-bbb' in sys.argv:
	platform = platform_detect.BEAGLEBONE_BLACK
	sys.argv.remove('--force-bbb')
elif '--force-test' in sys.argv:
	platform = 'TEST'
	sys.argv.remove('--force-test')
else:
	# No explicit platform chosen, detect the current platform.
	platform = platform_detect.platform_detect()

# Pick the right extension to compile based on the platform.
extensions = []
if platform == platform_detect.RASPBERRY_PI:
	# Get the Pi version (1 or 2)
	if pi_version is None:
		pi_version = platform_detect.pi_version()
	# Build the right extension depending on the Pi version.
	if pi_version == 1:
		extensions.append(Extension("Python_DHT.Raspberry_Pi_Driver",
									["source/_Raspberry_Pi_Driver.c", "source/common_dht_read.c", "source/Raspberry_Pi/pi_dht_read.c", "source/Raspberry_Pi/pi_mmio.c"],
									libraries=['rt'],
									extra_compile_args=['-std=gnu99']))
	elif pi_version == 2:
		extensions.append(Extension("Python_DHT.Raspberry_Pi_2_Driver",