File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ SCD30::SCD30(void)
33
33
}
34
34
35
35
// Initialize the Serial port
36
+ #ifdef USE_TEENSY3_I2C_LIB
37
+ bool SCD30::begin (i2c_t3 &wirePort, bool autoCalibrate)
38
+ #else
36
39
bool SCD30::begin (TwoWire &wirePort, bool autoCalibrate)
40
+ #endif
37
41
{
38
42
_i2cPort = &wirePort; // Grab which port the user wants us to use
39
43
Original file line number Diff line number Diff line change 28
28
#ifndef __SparkFun_SCD30_ARDUINO_LIBARARY_H__
29
29
#define __SparkFun_SCD30_ARDUINO_LIBARARY_H__
30
30
31
+ #define USE_TEENSY3_I2C_LIB
32
+
31
33
#include " Arduino.h"
34
+ #ifdef USE_TEENSY3_I2C_LIB
35
+ #include < i2c_t3.h>
36
+ #else
32
37
#include < Wire.h>
38
+ #endif
33
39
34
40
// The default I2C address for the SCD30 is 0x61.
35
41
#define SCD30_ADDRESS 0x61
@@ -52,8 +58,11 @@ class SCD30
52
58
SCD30 (void );
53
59
54
60
bool begin (bool autoCalibrate) { return begin (Wire, autoCalibrate); }
61
+ #ifdef USE_TEENSY3_I2C_LIB
62
+ bool begin (i2c_t3 &wirePort = Wire, bool autoCalibrate=true ); // By default use Wire port
63
+ #else
55
64
bool begin (TwoWire &wirePort = Wire, bool autoCalibrate=true ); // By default use Wire port
56
-
65
+ # endif
57
66
bool beginMeasuring (uint16_t pressureOffset);
58
67
bool beginMeasuring (void );
59
68
@@ -85,8 +94,11 @@ class SCD30
85
94
86
95
private:
87
96
// Variables
97
+ #ifdef USE_TEENSY3_I2C_LIB
98
+ i2c_t3 *_i2cPort; // The generic connection to user's chosen I2C hardware
99
+ #else
88
100
TwoWire *_i2cPort; // The generic connection to user's chosen I2C hardware
89
-
101
+ # endif
90
102
// Global main datums
91
103
float co2 = 0 ;
92
104
float temperature = 0 ;
You can’t perform that action at this time.
0 commit comments