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
902ade82
Commit
902ade82
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(spo2): Use averaging from TomoStrap
parent
d7b8753d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+13
-10
13 additions, 10 deletions
preload/apps/spo2/__init__.py
with
13 additions
and
10 deletions
preload/apps/spo2/__init__.py
+
13
−
10
View file @
902ade82
...
...
@@ -24,6 +24,7 @@ class SPO2:
self
.
filtered_value
=
0.0
self
.
source
=
"
Red
"
self
.
average
=
0
self
.
prev_w
=
0
def
open
(
self
):
def
callback
(
datasets
):
...
...
@@ -46,13 +47,19 @@ class SPO2:
while
buttons
.
read
(
buttons
.
BOTTOM_RIGHT
):
pass
def
update_history
(
self
,
datasets
):
alpha
=
0.995
alpha
=
0.99
7
5
for
val
in
datasets
:
"""
print
(
"
%d,%d
"
%
(
val
.
red
,
val
.
infrared
))
if
self
.
source
==
"
Red
"
:
self.avg[self.avg_pos]
= val.red
d
=
val
.
red
else
:
self.avg[self.avg_pos] = val.infrared
d
=
val
.
infrared
w
=
d
+
self
.
prev_w
*
0.95
self
.
history
.
append
(
w
-
self
.
prev_w
)
self
.
prev_w
=
w
"""
self.avg[self.avg_pos] = d
if self.avg_pos < 9:
self.avg_pos += 1
...
...
@@ -68,15 +75,11 @@ class SPO2:
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