Skip to content

Commit

Permalink
Added support for Particle devices
Browse files Browse the repository at this point in the history
Only call `Wire.begin()` if not already initialized
  • Loading branch information
bschulz1701 committed Feb 2, 2022
1 parent b7c0ee3 commit 9f33c40
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/MCP3421.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ Distributed as-is; no warranty is given.
MCP3421::MCP3421(int _ADR)
{
ADR = _ADR;
Wire.begin();
#if defined(ARDUINO) && ARDUINO >= 100
Wire.begin();
#elif defined(PARTICLE)
if(!Wire.isEnabled()) Wire.begin(); //Only initialize I2C if not done already //INCLUDE FOR USE WITH PARTICLE
#endif
}

MCP3421::MCP3421(void)
{
ADR = 0x6A; //Use 0x6A as Address by default
Wire.begin();
#if defined(ARDUINO) && ARDUINO >= 100
Wire.begin();
#elif defined(PARTICLE)
if(!Wire.isEnabled()) Wire.begin(); //Only initialize I2C if not done already //INCLUDE FOR USE WITH PARTICLE
#endif
}

int MCP3421::Begin(int _ADR) //Initialize the system in 1x gain, with 12 bit resolution, continuious conversions
Expand Down

0 comments on commit 9f33c40

Please sign in to comment.