File tree 2 files changed +21
-2
lines changed
2 files changed +21
-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
+ // Uncomment the next #define if using an Teensy >= 3 or Teensy LC and want to use the dedicated I2C-Library for it
32
+ // Then you also have to include <i2c_t3.h> on your application instead of <Wire.h>
33
+
34
+ // #define USE_TEENSY3_I2C_LIB
35
+
31
36
#include " Arduino.h"
37
+ #ifdef USE_TEENSY3_I2C_LIB
38
+ #include < i2c_t3.h>
39
+ #else
32
40
#include < Wire.h>
41
+ #endif
33
42
34
43
// The default I2C address for the SCD30 is 0x61.
35
44
#define SCD30_ADDRESS 0x61
@@ -52,8 +61,11 @@ class SCD30
52
61
SCD30 (void );
53
62
54
63
bool begin (bool autoCalibrate) { return begin (Wire, autoCalibrate); }
64
+ #ifdef USE_TEENSY3_I2C_LIB
65
+ bool begin (i2c_t3 &wirePort = Wire, bool autoCalibrate=true ); // By default use Wire port
66
+ #else
55
67
bool begin (TwoWire &wirePort = Wire, bool autoCalibrate=true ); // By default use Wire port
56
-
68
+ # endif
57
69
bool beginMeasuring (uint16_t pressureOffset);
58
70
bool beginMeasuring (void );
59
71
@@ -85,8 +97,11 @@ class SCD30
85
97
86
98
private:
87
99
// Variables
100
+ #ifdef USE_TEENSY3_I2C_LIB
101
+ i2c_t3 *_i2cPort; // The generic connection to user's chosen I2C hardware
102
+ #else
88
103
TwoWire *_i2cPort; // The generic connection to user's chosen I2C hardware
89
-
104
+ # endif
90
105
// Global main datums
91
106
float co2 = 0 ;
92
107
float temperature = 0 ;
You can’t perform that action at this time.
0 commit comments