Skip to content
Snippets Groups Projects
Commit 04426dcb authored by thiebolt's avatar thiebolt
Browse files

update

parent fe626d56
No related branches found
No related tags found
No related merge requests found
...@@ -42,16 +42,17 @@ ...@@ -42,16 +42,17 @@
const uint8_t SCD4x::i2c_addrs[] = { 0x69 }; const uint8_t SCD4x::i2c_addrs[] = { 0x69 };
/* declare kind of units */ /* [static] declare kind of units */
const char *SCD4x::units_co2 = "ppm"; const char *SCD4x::units_co2 = "ppm";
const char *SCD4x::units_temp = "celsius"; const char *SCD4x::units_temp = "celsius";
const char *SCD4x::units_rh = "%r.H."; const char *SCD4x::units_rh = "%r.H.";
/* declare others static vars */ /* [static] initialize static vars */
unsigned long SCD4x::_lastMsRead = 0; unsigned long SCD4x::_lastMsRead = 0;
uint16_t SCD4x::_co2_sensor = (uint16_t)(-1); uint16_t SCD4x::_co2_sensor = (uint16_t)(-1);
uint16_t SCD4x::_t_sensor = (uint16_t)(-1); uint16_t SCD4x::_t_sensor = (uint16_t)(-1);
uint16_t SCD4x::_rh_sensor = (uint16_t)(-1); uint16_t SCD4x::_rh_sensor = (uint16_t)(-1);
boolean SCD4x::_periodic_measure = false;
/**************************************************************************/ /**************************************************************************/
...@@ -124,15 +125,24 @@ boolean SCD4x::begin( uint8_t addr=-1) { ...@@ -124,15 +125,24 @@ boolean SCD4x::begin( uint8_t addr=-1) {
if( (addr < (uint8_t)(I2C_ADDR_START)) or (addr > (uint8_t)(I2C_ADDR_STOP)) ) return false; if( (addr < (uint8_t)(I2C_ADDR_START)) or (addr > (uint8_t)(I2C_ADDR_STOP)) ) return false;
_i2caddr = addr; _i2caddr = addr;
WARNING: if periodic measurement is already started ==> no others command will be accepted
// check device identity // check device identity
if( !_check_identity(_i2caddr) ) return false; if( !_check_identity(_i2caddr) ) return false;
/* set config: /* set config:
* - nothing to configure * - software reset
* - reset ? * - calibration ?
* - start periodic measurement
*/ */
// define defaults parameters // soft reset
sw_reset( _i2caddr );
// start periodic measurement
TO BE CONTINUED
/* start lastmsg time measurement. /* start lastmsg time measurement.
* This way, we get sure to have at least a first acquisition! */ * This way, we get sure to have at least a first acquisition! */
...@@ -148,10 +158,14 @@ boolean SCD4x::begin( uint8_t addr=-1) { ...@@ -148,10 +158,14 @@ boolean SCD4x::begin( uint8_t addr=-1) {
*/ */
void SCD4x::powerON( void ) void SCD4x::powerON( void )
{ {
// check if device's periodic measurement is not already engaged
if( _periodic_measure ) return;
// select proper command // select proper command
uint16_t _cmd = static_cast<uint16_t>(scd4xCmd_t::read_measurement); uint16_t _cmd = static_cast<uint16_t>(scd4xCmd_t::start_periodic_measurement);
_i2caddr
// device does not feature continuous integration so nothing to start or stop _periodic_measure = true;
} }
/* /*
......
...@@ -149,6 +149,7 @@ class SCD4x : public generic_driver { ...@@ -149,6 +149,7 @@ class SCD4x : public generic_driver {
static uint16_t _co2_sensor; // shared across all instances static uint16_t _co2_sensor; // shared across all instances
static uint16_t _t_sensor; // shared across all instances static uint16_t _t_sensor; // shared across all instances
static uint16_t _rh_sensor; // shared across all instances static uint16_t _rh_sensor; // shared across all instances
static boolean _periodic_measure; // if automatic periodic measurement has been activated
// CRC computation // CRC computation
static const uint8_t _crc8_polynom; // crc P(x)=x^8+x^5+x^4+1 (0x31) 1.00110001, init=0xFF static const uint8_t _crc8_polynom; // crc P(x)=x^8+x^5+x^4+1 (0x31) 1.00110001, init=0xFF
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@brief Declare list of possible I2C addrs @brief Declare list of possible I2C addrs
Note: only one i2c addr !
*/ */
/**************************************************************************/ /**************************************************************************/
const uint8_t SHT3x::i2c_addrs[2] = { 0x44, 0x45 }; const uint8_t SHT3x::i2c_addrs[2] = { 0x44, 0x45 };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment