|
|
@@ -1,12 +1,22 @@
|
|
|
-#ifndef __DHT_H__
|
|
|
-#define __DHT_H__
|
|
|
+#ifndef DHT_H
|
|
|
+#define DHT_H
|
|
|
#if ARDUINO >= 100
|
|
|
#include "Arduino.h"
|
|
|
#else
|
|
|
#include "WProgram.h"
|
|
|
#endif
|
|
|
|
|
|
-/* DHT library
|
|
|
+// 8 MHz(ish) AVR ---------------------------------------------------------
|
|
|
+#if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL)
|
|
|
+#define COUNT 3
|
|
|
+// 16 MHz(ish) AVR --------------------------------------------------------
|
|
|
+#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L)
|
|
|
+#define COUNT 6
|
|
|
+#else
|
|
|
+#error "CPU SPEED NOT SUPPORTED"
|
|
|
+#endif
|
|
|
+
|
|
|
+/* DHT library
|
|
|
|
|
|
MIT license
|
|
|
written by Adafruit Industries
|
|
|
@@ -20,21 +30,20 @@ written by Adafruit Industries
|
|
|
#define DHT21 21
|
|
|
#define AM2301 21
|
|
|
|
|
|
-class DHT
|
|
|
-{
|
|
|
-private:
|
|
|
- uint8_t data[6];
|
|
|
- uint8_t _pin, _type, _count;
|
|
|
- boolean read(void);
|
|
|
- unsigned long _lastreadtime;
|
|
|
- boolean firstreading;
|
|
|
-
|
|
|
-public:
|
|
|
- DHT(uint8_t pin, uint8_t type, uint8_t count=6);
|
|
|
- void begin(void);
|
|
|
- float readTemperature(bool S=false);
|
|
|
- float convertCtoF(float);
|
|
|
- float readHumidity(void);
|
|
|
-};
|
|
|
+class DHT {
|
|
|
+ private:
|
|
|
+ uint8_t data[6];
|
|
|
+ uint8_t _pin, _type, _count;
|
|
|
+ boolean read(void);
|
|
|
+ unsigned long _lastreadtime;
|
|
|
+ boolean firstreading;
|
|
|
+
|
|
|
+ public:
|
|
|
+ DHT(uint8_t pin, uint8_t type, uint8_t count=COUNT);
|
|
|
+ void begin(void);
|
|
|
+ float readTemperature(bool S=false);
|
|
|
+ float convertCtoF(float);
|
|
|
+ float readHumidity(void);
|
|
|
|
|
|
+};
|
|
|
#endif
|