ó
Ø-]c           @   s’   d  d l  Z  d d l m 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(   iÿÿÿÿNi   (   t   platform_detecti    iþÿÿÿiýÿÿÿiüÿÿÿi   i   c          C   sÉ   t  j  ƒ  }  |  t  j k r– t  j ƒ  } | d k rG d d l m } | S| d k rg d d l m } | S| d k r‡ d d l m } | St d ƒ ‚ n/ |  t  j k r¹ d d l m } | St d ƒ ‚ d	 S(
   sD   Return a DHT platform interface for the currently detected platform.i   (   t   Raspberry_Pii   (   t   Raspberry_Pi_2i   s6   No driver for detected Raspberry Pi version available!(   t   Beaglebone_Blacks   Unknown platform.N(	   R    t   RASPBERRY_PIt
   pi_versiont    R   R   t   RuntimeErrort   BEAGLEBONE_BLACKR   (   t   platt   versionR   R   R   (    (    sB   /home/pi/CrowPi/Drivers/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(    (    sB   /home/pi/CrowPi/Drivers/Adafruit_Python_DHT/Adafruit_DHT/common.pyR   A   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(    (    sB   /home/pi/CrowPi/Drivers/Adafruit_Python_DHT/Adafruit_DHT/common.pyt
   read_retryS   s    

(   R   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   (    (    (    sB   /home/pi/CrowPi/Drivers/Adafruit_Python_DHT/Adafruit_DHT/common.pyt   <module>   s   	