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
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
c2be6b7a
Commit
c2be6b7a
authored
5 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(spo2): Use IIR filter for offset removal
parent
2db1e62e
Branches
Branches containing commit
No related tags found
1 merge request
!414
SpO2 sensor improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
preload/apps/spo2/__init__.py
+14
-0
14 additions, 0 deletions
preload/apps/spo2/__init__.py
with
14 additions
and
0 deletions
preload/apps/spo2/__init__.py
+
14
−
0
View file @
c2be6b7a
...
...
@@ -23,6 +23,7 @@ class SPO2:
self
.
last_sample
=
0.0
self
.
filtered_value
=
0.0
self
.
source
=
"
Red
"
self
.
average
=
0
def
open
(
self
):
def
callback
(
datasets
):
...
...
@@ -45,7 +46,9 @@ class SPO2:
while
buttons
.
read
(
buttons
.
BOTTOM_RIGHT
):
pass
def
update_history
(
self
,
datasets
):
alpha
=
0.995
for
val
in
datasets
:
"""
if self.source ==
"
Red
"
:
self.avg[self.avg_pos] = val.red
else:
...
...
@@ -63,6 +66,17 @@ class SPO2:
)
self.last_sample = avg_data
self.history.append(self.filtered_value)
"""
#print("%d,%d" % (val.red, val.infrared))
if
self
.
source
==
"
Red
"
:
d
=
val
.
red
else
:
d
=
val
.
infrared
self
.
average
=
alpha
*
self
.
average
+
(
1
-
alpha
)
*
d
d
-=
self
.
average
self
.
history
.
append
(
d
)
# trim old elements
self
.
history
=
self
.
history
[
-
self
.
HISTORY_MAX
:]
...
...
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