File tree Expand file tree Collapse file tree 2 files changed +8
-33
lines changed Expand file tree Collapse file tree 2 files changed +8
-33
lines changed Original file line number Diff line number Diff line change 1
1
#include " TWI.h"
2
2
#include " Driver/BMP085.h"
3
+ #include " assert.h"
3
4
4
5
// Configure: TWI bus manager (software or hardware)
5
6
// #define USE_SOFTWARE_TWI
@@ -23,10 +24,7 @@ void setup()
23
24
while (!Serial);
24
25
25
26
// Start the digital pressure sensor
26
- while (!bmp.begin (BMP085::ULTRA_LOW_POWER)) {
27
- Serial.println (F (" bmp.begin:error" ));
28
- delay (5000 );
29
- }
27
+ ASSERT (bmp.begin (BMP085::ULTRA_LOW_POWER));
30
28
}
31
29
32
30
void loop ()
@@ -37,15 +35,11 @@ void loop()
37
35
Serial.print (' :' );
38
36
39
37
// Sample, calculate and print temperature and pressure
40
- if (bmp.sample ()) {
41
- Serial.print (bmp.temperature () / 10.0 );
42
- Serial.print (F (" C, " ));
43
- Serial.print (bmp.pressure () / 100.0 );
44
- Serial.println (F (" hPa" ));
45
- }
46
- else {
47
- Serial.println (F (" bmp.sample:error" ));
48
- }
38
+ ASSERT (bmp.sample ());
39
+ Serial.print (bmp.temperature () / 10.0 );
40
+ Serial.print (F (" C, " ));
41
+ Serial.print (bmp.pressure () / 100.0 );
42
+ Serial.println (F (" hPa" ));
49
43
50
44
// Periodic execute every two seconds
51
45
delay (2000 - (millis () - start));
Original file line number Diff line number Diff line change 1
1
#include " GPIO.h"
2
2
#include " TWI.h"
3
3
#include " Driver/DS2482.h"
4
+ #include " assert.h"
4
5
5
6
// Configure: Software or Hardware TWI
6
7
// #define USE_SOFTWARE_TWI
@@ -55,26 +56,6 @@ uint8_t one_wire_crc_update(uint8_t crc, uint8_t data)
55
56
return (crc);
56
57
}
57
58
58
- // Check assertion to be true, otherwise print line and expression
59
- #define ASSERT (expr ) \
60
- do { \
61
- if (!(expr)) { \
62
- Serial.print (__LINE__); \
63
- Serial.println (F (" :assert:" #expr)); \
64
- Serial.flush (); \
65
- exit (0 ); \
66
- } \
67
- } while (0 )
68
-
69
-
70
- // Print and evaluate expression
71
- #define TRACE (expr ) \
72
- do { \
73
- Serial.print (#expr " =" ); \
74
- Serial.println (expr); \
75
- } while (0 )
76
-
77
-
78
59
void setup ()
79
60
{
80
61
Serial.begin (57600 );
You can’t perform that action at this time.
0 commit comments