Skip to content

Commit 2262ca7

Browse files
committed
2 parents 38a198f + 5a0aa1e commit 2262ca7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/SparkFun_SCD30_Arduino_Library.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ SCD30::SCD30(void)
3333
}
3434

3535
//Initialize the Serial port
36+
#ifdef USE_TEENSY3_I2C_LIB
37+
bool SCD30::begin(i2c_t3 &wirePort, bool autoCalibrate)
38+
#else
3639
bool SCD30::begin(TwoWire &wirePort, bool autoCalibrate)
40+
#endif
3741
{
3842
_i2cPort = &wirePort; //Grab which port the user wants us to use
3943

src/SparkFun_SCD30_Arduino_Library.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@
2828
#ifndef __SparkFun_SCD30_ARDUINO_LIBARARY_H__
2929
#define __SparkFun_SCD30_ARDUINO_LIBARARY_H__
3030

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+
3136
#include "Arduino.h"
37+
#ifdef USE_TEENSY3_I2C_LIB
38+
#include <i2c_t3.h>
39+
#else
3240
#include <Wire.h>
41+
#endif
3342

3443
//The default I2C address for the SCD30 is 0x61.
3544
#define SCD30_ADDRESS 0x61
@@ -52,8 +61,11 @@ class SCD30
5261
SCD30(void);
5362

5463
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
5567
bool begin(TwoWire &wirePort = Wire, bool autoCalibrate=true); //By default use Wire port
56-
68+
#endif
5769
bool beginMeasuring(uint16_t pressureOffset);
5870
bool beginMeasuring(void);
5971

@@ -85,8 +97,11 @@ class SCD30
8597

8698
private:
8799
//Variables
100+
#ifdef USE_TEENSY3_I2C_LIB
101+
i2c_t3 *_i2cPort; //The generic connection to user's chosen I2C hardware
102+
#else
88103
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
89-
104+
#endif
90105
//Global main datums
91106
float co2 = 0;
92107
float temperature = 0;

0 commit comments

Comments
 (0)