Skip to content

Commit 5e1507c

Browse files
committed
Updated examples for use with current Particle IDE and Local build
1 parent e62f34b commit 5e1507c

7 files changed

+31
-21
lines changed

firmware/PietteTech_DHT.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/*
22
* FILE: PietteTech_DHT.cpp
3-
* VERSION: 0.3
3+
* VERSION: 0.4
44
* PURPOSE: Spark Interrupt driven lib for DHT sensors
55
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
66
*
77
* S Piette (Piette Technologies) [email protected]
88
* January 2014 Original Spark Port
99
* October 2014 Added support for DHT21/22 sensors
1010
* Improved timing, moved FP math out of ISR
11+
* September 2016 Updated for Particle
1112
*
1213
* Based on adaptation by niesteszeck (github/niesteszeck)
1314
* Based on original DHT11 library (http://playgroudn.adruino.cc/Main/DHT11Lib)
@@ -133,7 +134,7 @@ int PietteTech_DHT::acquire() {
133134
return DHTLIB_ERROR_ACQUIRING;
134135
}
135136

136-
int PietteTech_DHT::acquireAndWait(uint32_t timeout=0) {
137+
int PietteTech_DHT::acquireAndWait(uint32_t timeout) {
137138
acquire();
138139
uint32_t start = millis();
139140
uint32_t wrapper;

firmware/PietteTech_DHT.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/*
22
* FILE: PietteTech_DHT.h
3-
* VERSION: 0.3
3+
* VERSION: 0.4
44
* PURPOSE: Spark Interrupt driven lib for DHT sensors
55
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
66
*
77
* S Piette (Piette Technologies) [email protected]
88
* January 2014 Original Spark Port
99
* October 2014 Added support for DHT21/22 sensors
1010
* Improved timing, moved FP math out of ISR
11+
* September 2016 Updated for Particle
1112
*
1213
* Based on adaptation by niesteszeck (github/niesteszeck)
1314
* Based on original DHT11 library (http://playgroudn.adruino.cc/Main/DHT11Lib)
@@ -27,7 +28,7 @@
2728

2829
#include "application.h"
2930

30-
#define DHTLIB_VERSION "0.3"
31+
#define DHTLIB_VERSION "0.4"
3132

3233
// device types
3334
#define DHT11 11
@@ -65,7 +66,7 @@ class PietteTech_DHT
6566
void begin(uint8_t sigPin, uint8_t dht_type, void (*isrCallback_wrapper)());
6667
void isrCallback();
6768
int acquire();
68-
int acquireAndWait(uint32_t);
69+
int acquireAndWait(uint32_t timeout = 0);
6970
float getCelsius();
7071
float getFahrenheit();
7172
float getKelvin();

firmware/examples/DHT_2sensor.ino firmware/examples/DHT_2sensor.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FILE: DHT_2sensor.ino
3-
* VERSION: 0.3
2+
* FILE: DHT_2sensor.cpp
3+
* VERSION: 0.4
44
* PURPOSE: Example that uses DHT library with two sensors
55
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
66
*
@@ -12,11 +12,13 @@
1212
* January 2014 Original Spark Port
1313
* October 2014 Added support for DHT21/22 sensors
1414
* Improved timing, moved FP math out of ISR
15+
* September 2016 Updated for Particle
1516
*/
1617
// NOTE DHT_REPORT_TIMING requires DHT_DEBUG_TIMING in PietteTech_DHT.h for debugging edge->edge timings
1718
//#define DHT_REPORT_TIMING
1819

19-
#include "PietteTech_DHT/PietteTech_DHT.h"
20+
#include "PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
21+
//#include "PietteTech_DHT.h" // Uncomment if building using CLI
2022

2123
#define DHTTYPEA DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
2224
#define DHTPINA 3 // Digital pin for comunications
@@ -58,6 +60,7 @@ void setup()
5860
Serial.begin(9600);
5961
while (!Serial.available()) {
6062
Serial.println("Press any key to start.");
63+
Particle.process();
6164
delay (1000);
6265
}
6366
Serial.println("DHT Example program using 2 DHT sensors");

firmware/examples/DHT_example.ino firmware/examples/DHT_example.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FILE: DHT_example.ino
3-
* VERSION: 0.3
2+
* FILE: DHT_example.cpp
3+
* VERSION: 0.4
44
* PURPOSE: Example that uses DHT library with two sensors
55
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
66
*
@@ -14,9 +14,11 @@
1414
* January 2014 Original Spark Port
1515
* October 2014 Added support for DHT21/22 sensors
1616
* Improved timing, moved FP math out of ISR
17+
* September 2016 Updated for Particle
1718
*/
1819

19-
#include "PietteTech_DHT/PietteTech_DHT.h"
20+
#include "PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
21+
//#include "PietteTech_DHT.h" // Uncomment if building using CLI
2022

2123
// system defines
2224
#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
@@ -39,6 +41,7 @@ void setup()
3941
Serial.begin(9600);
4042
while (!Serial.available()) {
4143
Serial.println("Press any key to start.");
44+
Particle.process();
4245
delay (1000);
4346
}
4447
Serial.println("DHT Example program using DHT.acquire and DHT.aquiring");

firmware/examples/DHT_simple.ino firmware/examples/DHT_simple.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* FILE: DHT_simple.ino
3-
* VERSION: 0.3
2+
* FILE: DHT_simple.cpp
3+
* VERSION: 0.4
44
* PURPOSE: Example that uses DHT library with two sensors
55
* LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
66
*
@@ -11,13 +11,14 @@
1111
* January 2014 Original Spark Port
1212
* October 2014 Added support for DHT21/22 sensors
1313
* Improved timing, moved FP math out of ISR
14+
* September 2016 Updated for Particle
1415
*/
1516

1617
#include "PietteTech_DHT/PietteTech_DHT.h" // Uncomment if building in IDE
17-
//#include "PietteTech_DHT.h" // Uncommend if building using CLI
18+
//#include "PietteTech_DHT.h" // Uncomment if building using CLI
1819

1920
#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
20-
#define DHTPIN 2 // Digital pin for communications
21+
#define DHTPIN 3 // Digital pin for communications
2122

2223
//declaration
2324
void dht_wrapper(); // must be declared before the lib initialization
@@ -31,6 +32,7 @@ void setup()
3132
Serial.begin(9600);
3233
while (!Serial.available()) {
3334
Serial.println("Press any key to start.");
35+
Particle.process();
3436
delay (1000);
3537
}
3638
Serial.println("DHT Example program using DHT.acquireAndWait");

particle.include

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
firmware/PietteTech_DHT.cpp
2+
firmware/PietteTech_DHT.h
3+
firmware/examples/DHT_simple.cpp
4+
#firmware/examples/DHT_example.cpp
5+
#firmware/examples/DHT_2sensor.cpp
6+

spark.include

-6
This file was deleted.

0 commit comments

Comments
 (0)