Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neOCampus-arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GIS-neOCampus
neOSensor
neOCampus-arduino
Commits
bab6cd9f
Commit
bab6cd9f
authored
3 years ago
by
thiebolt
Browse files
Options
Downloads
Patches
Plain Diff
update
parent
c0be374e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
neosensor/libraries/neocampus_drivers/SCD4x.cpp
+26
-61
26 additions, 61 deletions
neosensor/libraries/neocampus_drivers/SCD4x.cpp
with
26 additions
and
61 deletions
neosensor/libraries/neocampus_drivers/SCD4x.cpp
+
26
−
61
View file @
bab6cd9f
...
...
@@ -42,6 +42,17 @@
const
uint8_t
SCD4x
::
i2c_addrs
[]
=
{
0x69
};
/* declare kind of units */
const
char
*
SCD4x
::
units_co2
=
"ppm"
;
const
char
*
SCD4x
::
units_temp
=
"celsius"
;
const
char
*
SCD4x
::
units_rh
=
"%r.H."
;
/* declare others static vars */
unsigned
long
SCD4x
::
_lastMsRead
=
0
;
uint16_t
SCD4x
::
_co2_sensor
=
(
uint16_t
)(
-
1
);
uint16_t
SCD4x
::
_t_sensor
=
(
uint16_t
)(
-
1
);
uint16_t
SCD4x
::
_rh_sensor
=
(
uint16_t
)(
-
1
);
/**************************************************************************/
/*!
...
...
@@ -79,18 +90,6 @@ SCD4x::SCD4x( scd4xMeasureType_t kindness ) : generic_driver() {
}
/* declare kind of units */
const
char
*
SCD4x
::
units_co2
=
"ppm"
;
const
char
*
SCD4x
::
units_temp
=
"celsius"
;
const
char
*
SCD4x
::
units_rh
=
"%r.H."
;
/* declare others static vars */
unsigned
long
SCD4x
::
_lastMsRead
=
0
;
uint16_t
SCD4x
::
_co2_sensor
=
(
uint16_t
)(
-
1
);
uint16_t
SCD4x
::
_t_sensor
=
(
uint16_t
)(
-
1
);
uint16_t
SCD4x
::
_rh_sensor
=
(
uint16_t
)(
-
1
);
/**************************************************************************/
/*!
@brief send back units
...
...
@@ -156,38 +155,10 @@ void SCD4x::powerON( void )
// device does not feature continuous integration so nothing to start or stop
}
TO
BE
CONTINUED
/**************************************************************************/
/*!
@brief Setups the HW: set resolution of sensor
@note remember that resolution is virtual, we just set integration
timings, proper cmds for datat acquisition ought to get sent.
*/
/**************************************************************************/
bool
SHT3x
::
setResolution
(
sht3xResolution_t
res
)
{
// set integration timeout
if
(
res
==
sht3xResolution_t
::
high_res
)
_integrationTime
=
static_cast
<
uint8_t
>
(
sht3xIntegration_t
::
ms_integrate_high
);
else
if
(
res
==
sht3xResolution_t
::
medium_res
)
_integrationTime
=
static_cast
<
uint8_t
>
(
sht3xIntegration_t
::
ms_integrate_medium
);
else
if
(
res
==
sht3xResolution_t
::
low_res
)
_integrationTime
=
static_cast
<
uint8_t
>
(
sht3xIntegration_t
::
ms_integrate_low
);
else
return
false
;
// add some constant to integration time ...
_integrationTime
+=
(
uint8_t
)
SHT3X_INTEGRATION_TIME_CTE
;
// finish :)
return
true
;
}
/**************************************************************************/
/*!
@brief Reads the 16-bit temperature register and returns the Centigrade
temperature as a float.
@brief Reads the 16-bit [co2|temp|hygro] register and returns as float.
*/
/**************************************************************************/
...
...
@@ -195,36 +166,30 @@ boolean SHT3x::acquire( float *pval )
{
if
(
pval
==
nullptr
)
return
false
;
//
HUMIDITY
if
(
_measureType
==
s
ht3
xMeasureType_t
::
humidity
)
{
return
get
RH
(
pval
);
//
CO2
if
(
_measureType
==
s
cd4
xMeasureType_t
::
co2
)
{
return
get
CO2
(
pval
);
}
// TEMPERATURE
if
(
!
getTemp
(
pval
)
)
{
// error reading value ... too bad
return
false
;
if
(
_measureType
==
scd4xMeasureType_t
::
temperature
)
{
return
getTemp
(
pval
);
}
// [Mar.18] temperature correction for last i2c sensor ... the one
// supposed to get tied to the main board.
#ifdef TEMPERATURE_CORRECTION_LASTI2C
static
uint8_t
_last_i2c
=
(
uint8_t
)
-
1
;
// determine last i2c addr
if
(
_last_i2c
==
(
uint8_t
)
-
1
)
{
_last_i2c
=
i2c_addrs
[(
sizeof
(
i2c_addrs
)
/
sizeof
(
i2c_addrs
[
0
]))
-
1
];
}
// is last sensor ?
if
(
_i2caddr
==
_last_i2c
)
{
*
pval
+=
TEMPERATURE_CORRECTION_LASTI2C
;
log_debug
(
F
(
"
\n
[SHT3x] corrected temperature for i2c=0x"
));
log_debug
(
_i2caddr
,
HEX
);
log_flush
();
// HUMIDITY
if
(
_measureType
==
scd4xMeasureType_t
::
humidity
)
{
return
getRH
(
pval
);
}
#endif
return
true
;
log_warning
(
F
(
"
\n
[SCD4x] unknown MeasureType 0x"
));
log_warning
(
_measureType
,
HEX
);
log_flush
();
return
false
;
}
TO
BE
CONTINUED
/*
* READ sensor's HUMIDITY
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment