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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arist
firmware
Commits
f7b5abef
Commit
f7b5abef
authored
5 years ago
by
Arist
Browse files
Options
Downloads
Patches
Plain Diff
test(max86150): MAX86150 Epicardium API
parent
d92965df
Branches
test
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
l0dables/meson.build
+1
-0
1 addition, 0 deletions
l0dables/meson.build
l0dables/spo2/README.md
+5
-0
5 additions, 0 deletions
l0dables/spo2/README.md
l0dables/spo2/main.c
+147
-0
147 additions, 0 deletions
l0dables/spo2/main.c
l0dables/spo2/meson.build
+13
-0
13 additions, 0 deletions
l0dables/spo2/meson.build
with
166 additions
and
0 deletions
l0dables/meson.build
+
1
−
0
View file @
f7b5abef
subdir
(
'lib/'
)
subdir
(
'blinky/'
)
subdir
(
'spo2/'
)
This diff is collapsed.
Click to expand it.
l0dables/spo2/README.md
0 → 100644
+
5
−
0
View file @
f7b5abef
SpO2
======
This l0adable displays a histogram of the MAX86150 red LED level (with DC offset removed)
later versions should be able to calculate the blood oxigen saturation
This diff is collapsed.
Click to expand it.
l0dables/spo2/main.c
0 → 100644
+
147
−
0
View file @
f7b5abef
#include
"epicardium.h"
#include
"max32665.h"
#include
<mxc_delay.h>
#include
<math.h>
#include
<stdio.h>
// #include <stdint.h>
#include
<stdlib.h>
#define WIDTH 160
#define HEIGHT 80
#define Y_OFFSET 36
#define Y_SCALE 35
void
delay_us
(
unsigned
long
delay
)
{
mxc_delay_start
(
delay
);
while
(
mxc_delay_check
())
{
__WFI
();
}
mxc_delay_stop
();
}
/*
* main() is called when l0dable is loaded and executed.
*/
int
main
(
void
)
{
struct
max86150_sensor_config
cfg
=
{
0
};
cfg
.
sample_buffer_len
=
128
;
cfg
.
ppg_sample_rate
=
200
;
int
sensor_stream
=
epic_max86150_enable_sensor
(
&
cfg
,
sizeof
(
cfg
));
struct
max86150_sensor_data
data_buf
[
cfg
.
sample_buffer_len
],
data
;
epic_disp_open
();
double
history
[
WIDTH
];
uint8_t
history_pos
=
0
;
double
history_max
=
0
;
double
history_max_avg
[
10
];
uint8_t
history_max_pos
=
0
;
int32_t
last_sample
=
0
;
double
filtered_value
=
0
;
int32_t
avg
[
10
];
uint8_t
avg_pos
=
0
;
// union disp_framebuffer fb;
// char *str = " ";
for
(;;)
{
int
ret
=
epic_stream_read
(
sensor_stream
,
&
data_buf
,
sizeof
(
data_buf
)
);
if
(
ret
>
0
)
{
for
(
int
i
=
0
;
i
<
ret
;
i
++
)
{
data
=
data_buf
[
i
];
avg
[
avg_pos
]
=
data
.
red
;
if
(
avg_pos
<
9
)
{
avg_pos
++
;
}
else
{
avg_pos
=
0
;
}
int32_t
avg_data
=
0
;
for
(
int
a
=
0
;
a
<
10
;
a
++
)
{
avg_data
+=
avg
[
a
];
}
avg_data
=
avg_data
/
10
;
// DC offset removal
filtered_value
=
0
.
9
*
(
filtered_value
+
(
double
)
avg_data
-
(
double
)
last_sample
);
last_sample
=
avg_data
;
history
[
history_pos
]
=
filtered_value
;
//history[history_pos] = data.red;
if
(
history_pos
<
WIDTH
-
1
)
{
history_pos
++
;
}
else
{
history_pos
=
0
;
}
//delay_us(10000);
}
epic_disp_clear
(
0
);
//sprintf(str, "%10ld", data.red);
//epic_disp_print(10,10,str,0xFFFF,0);
history_max
=
0
;
for
(
int
i
=
0
;
i
<
WIDTH
;
i
++
)
{
if
(
fabs
(
history
[
i
])
>
history_max
)
{
history_max
=
fabs
(
history
[
i
]);
}
}
if
(
history_max
<=
0
)
{
history_max
=
1
;
}
history_max_avg
[
history_max_pos
]
=
history_max
;
if
(
history_max_pos
<
9
)
{
history_max_pos
++
;
}
else
{
history_max_pos
=
0
;
}
history_max
=
0
;
for
(
int
a
=
0
;
a
<
9
;
a
++
)
{
history_max
+=
history_max_avg
[
a
];
}
history_max
=
history_max
/
10
;
int32_t
scale
=
history_max
/
Y_SCALE
+
1
;
for
(
int
i
=
history_pos
;
i
<
WIDTH
+
history_pos
;
i
++
)
{
//epic_disp_pixel(history_pos, HEIGHT-10, 0xFFFF);
if
(
i
<=
WIDTH
)
{
epic_disp_pixel
(
i
-
history_pos
,
(
history
[
i
]
/
scale
)
+
Y_OFFSET
,
0xFFFF
);
}
else
{
epic_disp_pixel
(
i
-
history_pos
,
(
history
[
i
-
WIDTH
]
/
scale
)
+
Y_OFFSET
,
0xFFFF
);
}
}
epic_disp_update
();
}
//mxc_delay(1000);
}
//epic_disp_close();
}
This diff is collapsed.
Click to expand it.
l0dables/spo2/meson.build
0 → 100644
+
13
−
0
View file @
f7b5abef
name
=
'spo2'
elf
=
executable
(
name
+
'.elf'
,
'main.c'
,
build_by_default
:
true
,
dependencies
:
[
l0dable_startup
,
api_caller
],
link_whole
:
[
l0dable_startup_lib
],
link_args
:
[
'-Wl,-Map='
+
meson
.
current_build_dir
()
+
'/'
+
name
+
'.map,-lgcc'
,
],
pie
:
true
,
)
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