Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chris007
firmware
Commits
5cead188
Commit
5cead188
authored
5 years ago
by
chris007
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring get_data()
parent
5bf43827
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/bme680.c
+14
-21
14 additions, 21 deletions
epicardium/modules/bme680.c
with
14 additions
and
21 deletions
epicardium/modules/bme680.c
+
14
−
21
View file @
5cead188
...
@@ -104,38 +104,31 @@ int epic_bme680_deinit()
...
@@ -104,38 +104,31 @@ int epic_bme680_deinit()
int
epic_bme680_read_sensors
(
struct
bme680_sensor_data
*
data
)
int
epic_bme680_read_sensors
(
struct
bme680_sensor_data
*
data
)
{
{
int8_t
result
=
BME680_OK
;
if
(
!
initialized
)
{
if
(
!
initialized
)
{
LOG_ERR
(
"bme680"
,
"bme680 sensor not initialized"
);
LOG_ERR
(
"bme680"
,
"bme680 sensor not initialized"
);
return
-
1
;
return
-
1
;
}
}
int8_t
result
=
BME680_OK
;
struct
bme680_field_data
raw_data
;
uint16_t
profile_dur
=
0
;
uint16_t
profile_dur
=
0
;
bme680_get_profile_dur
(
&
profile_dur
,
&
bme
);
bme680_get_profile_dur
(
&
profile_dur
,
&
bme
);
if
(
result
==
BME680_OK
)
{
result
=
bme680_set_sensor_mode
(
&
bme
);
/* Trigger a measurement */
result
=
bme680_set_sensor_mode
(
&
bme
);
/* Trigger a measurement */
if
(
result
!=
BME680_OK
)
{
if
(
result
!=
BME680_OK
)
{
LOG_ERR
(
"bme680"
,
LOG_ERR
(
"bme680"
,
"bme680_set_sensor_mode error: %d
\n
"
,
result
);
"bme680_set_sensor_mode error: %d
\n
"
,
result
);
return
-
convert_error
(
result
);
return
-
convert_error
(
result
);
}
}
vTaskDelay
(
pdMS_TO_TICKS
(
vTaskDelay
(
pdMS_TO_TICKS
(
profile_dur
));
/* Wait for the measurement to complete */
profile_dur
));
/* Wait for the measurement to complete */
struct
bme680_field_data
raw_data
;
result
=
bme680_get_sensor_data
(
&
raw_data
,
&
bme
);
result
=
bme680_get_sensor_data
(
&
raw_data
,
&
bme
);
if
(
result
!=
BME680_OK
)
{
if
(
result
!=
BME680_OK
)
{
LOG_ERR
(
"bme680"
,
LOG_ERR
(
"bme680"
,
"bme680_get_sensor_data error: %d
\n
"
,
result
);
"bme680_get_sensor_data error: %d
\n
"
,
result
);
return
-
convert_error
(
result
);
return
-
convert_error
(
result
);
}
}
}
data
->
temperature
=
raw_data
.
temperature
/
100
.
0l
;
data
->
temperature
=
raw_data
.
temperature
/
100
.
0l
;
data
->
humidity
=
raw_data
.
humidity
/
1000
.
0l
;
data
->
humidity
=
raw_data
.
humidity
/
1000
.
0l
;
...
...
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