
-Tc           @   s   d  d l  Z  d  d l Z d Z d  Z d Z d Z d Z e e g Z d Z d Z	 d Z
 e e	 e
 g Z d   Z d d	  Z d
 d d d  Z d S(   iNi    iiii   i   c          C   sZ   t  j    }  |  t  j k r+ d d l } | S|  t  j k rJ d d l } | St d   d S(   sD   Return a DHT platform interface for the currently detected platform.iNs   Unknown platform.(   t   platform_detectt   RASPBERRY_PIt   Raspberry_Pit   BEAGLEBONE_BLACKt   Beaglebone_Blackt   RuntimeError(   t   platR   R   (    (    sA   /home/pi/europen/VLHKO/Adafruit_Python_DHT/Adafruit_DHT/common.pyt   get_platform)   s    c         C   sC   |  t  k r t d   n  | d k r3 t   } n  | j |  |  S(   s  Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on 
	specified pin and return a tuple of humidity (as a floating point value
	in percent) and temperature (as a floating point value in Celsius). Note that
	because the sensor requires strict timing to read and Linux is not a real
	time OS, a result is not guaranteed to be returned!  In some cases this will
	return the tuple (None, None) which indicates the function should be retried.
	Also note the DHT sensor cannot be read faster than about once every 2 seconds.
	Platform is an optional parameter which allows you to override the detected
	platform interface--ignore this parameter unless you receive unknown platform
	errors and want to override the detection.
	s.   Expected DHT11, DHT22, or AM2302 sensor value.N(   t   SENSORSt
   ValueErrort   NoneR   t   read(   t   sensort   pint   platform(    (    sA   /home/pi/europen/VLHKO/Adafruit_Python_DHT/Adafruit_DHT/common.pyR   5   s
    i   i   c         C   sb   x[ t  |  D]M } t |  | |  \ } } | d k	 rM | d k	 rM | | f St j |  q Wd S(   s&  Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on 
	specified pin and return a tuple of humidity (as a floating point value
	in percent) and temperature (as a floating point value in Celsius).
	Unlike the read function, this read_retry function will attempt to read
	multiple times (up to the specified max retries) until a good reading can be 
	found. If a good reading cannot be found after the amount of retries, a tuple
	of (None, None) is returned. The delay between retries is by default 2
	seconds, but can be overridden.
	N(   NN(   t   rangeR   R
   t   timet   sleep(   R   R   t   retriest   delay_secondsR   t   it   humidityt   temperature(    (    sA   /home/pi/europen/VLHKO/Adafruit_Python_DHT/Adafruit_DHT/common.pyt
   read_retryG   s    

(   R   R    t   DHT_SUCCESSt   DHT_ERROR_TIMEOUTt   DHT_ERROR_CHECKSUMt   DHT_ERROR_ARGUMENTt   DHT_ERROR_GPIOt   TRANSIENT_ERRORSt   DHT11t   DHT22t   AM2302R   R   R
   R   R   (    (    (    sA   /home/pi/europen/VLHKO/Adafruit_Python_DHT/Adafruit_DHT/common.pyt   <module>   s   	