Skip to content

Commit

Permalink
Add isConnected member + update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinlyonsrepo committed Dec 4, 2022
1 parent 4bde61c commit b2c7a3b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Supports sensors features:

The Sensor uses I2C for communication's. Data is outputted (eg to a PC) via a USB.
Can be set up for any I2C interface and speed. By default I2C0, GPIO16(SDATA) and GPIO17(SCLK) & 100kHz.
If you want to use the other I2C port (I2C1) in addition to changing in the main.ccp,
The user must change it in library header as well, could not find a way around this.

* i2c_inst_t *i2c = i2c0 to i2c_inst_t *i2c = i2c1


**Files**

Expand Down
4 changes: 4 additions & 0 deletions include/ahtxx/ahtxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class LIB_AHTXX
ASAIR_I2C_SENSOR_e _sensorName;
uint8_t _rawDataBuffer[6] = {AHT10_ERROR, 0, 0, 0, 0, 0};
int16_t returnValue = 0;
bool isConnected = false;

public:
// Constructor
Expand All @@ -76,6 +77,9 @@ class LIB_AHTXX
uint8_t AHT10_getCalibrationBit(bool);
bool AHT10_enableFactoryCalCoeff();
uint8_t AHT10_getBusyBit(bool);

void AHT10_SetIsConnected(bool);
bool AHT10_GetIsConnected(void);
};
#endif

16 changes: 15 additions & 1 deletion src/ahtxx/ahtxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ bool LIB_AHTXX::AHT10_begin()
{
busy_wait_ms(AHT10_POWER_ON_DELAY); //wait for sensor to initialize
AHT10_setNormalMode(); //one measurement+sleep mode
return AHT10_enableFactoryCalCoeff(); //load factory calibration coeff
if (AHT10_enableFactoryCalCoeff()) //load factory calibration coeff
isConnected = true;
else
isConnected = false;
return isConnected;
}


Expand Down Expand Up @@ -289,3 +293,13 @@ void LIB_AHTXX::AHT10_DeInit(i2c_inst_t* i2c_type)
i2c_inst_t *i2c = i2c_type;
i2c_deinit(i2c);
}

void LIB_AHTXX::AHT10_SetIsConnected(bool connected)
{
isConnected = connected;
}

bool LIB_AHTXX::AHT10_GetIsConnected(void)
{
return isConnected;
}

0 comments on commit b2c7a3b

Please sign in to comment.