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
Daniel Hoffend
firmware
Commits
08f65e56
Commit
08f65e56
authored
5 years ago
by
Daniel Hoffend
Browse files
Options
Downloads
Patches
Plain Diff
make led modes iterable in the python way
parent
5bcdb8a6
No related branches found
No related tags found
No related merge requests found
Pipeline
#3852
passed
5 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
preload/apps/ecg/__init__.py
+18
-19
18 additions, 19 deletions
preload/apps/ecg/__init__.py
with
18 additions
and
19 deletions
preload/apps/ecg/__init__.py
+
18
−
19
View file @
08f65e56
...
...
@@ -6,6 +6,7 @@ import buttons
import
max30001
import
math
import
struct
import
itertools
WIDTH
=
160
HEIGHT
=
80
...
...
@@ -24,11 +25,17 @@ COLOR_MODE_FINGER = [0, 255, 0]
COLOR_MODE_USB
=
[
0
,
0
,
255
]
COLOR_WRITE_FG
=
[
255
,
255
,
255
]
COLOR_WRITE_BG
=
[
255
,
0
,
0
]
LED_FLAG_BAR
=
1
LED_FLAG_PULSE
=
2
current_mode
=
MODE_FINGER
led_mode
=
LED_FLAG_BAR
+
LED_FLAG_PULSE
modes
=
itertools
.
cycle
(
[
({
"
bar
"
,
"
pulse
"
},
{
"
text
"
:
"
Top + Pulse
"
,
"
posx
"
:
0
}),
({},
{
"
text
"
:
"
off
"
,
"
posx
"
:
55
}),
({
"
bar
"
},
{
"
text
"
:
"
Top Only
"
,
"
posx
"
:
25
}),
({
"
pulse
"
},
{
"
text
"
:
"
Pulse Only
"
,
"
posx
"
:
5
}),
]
)
led_mode
=
next
(
modes
)[
0
]
history
=
[]
filebuffer
=
bytearray
()
write
=
0
...
...
@@ -240,21 +247,13 @@ def toggle_pause():
def
toggle_leds
():
global
led_mode
,
disp
,
pause_screen
,
leds
led_mode
=
(
led_mode
+
1
)
%
4
global
led_mode
,
disp
,
pause_screen
,
leds
,
modes
led_mode
,
display_args
=
next
(
modes
)
pause_screen
=
utime
.
time_ms
()
+
250
disp
.
clear
(
COLOR_BACKGROUND
)
disp
.
print
(
"
LEDs
"
,
posx
=
50
,
posy
=
20
,
fg
=
COLOR_TEXT
)
if
not
led_mode
:
disp
.
print
(
"
off
"
,
posx
=
55
,
posy
=
40
,
fg
=
COLOR_TEXT
)
elif
led_mode
==
LED_FLAG_BAR
:
disp
.
print
(
"
Top only
"
,
posx
=
25
,
posy
=
40
,
fg
=
COLOR_TEXT
)
elif
led_mode
==
LED_FLAG_PULSE
:
disp
.
print
(
"
Pulse only
"
,
posx
=
5
,
posy
=
40
,
fg
=
COLOR_TEXT
)
elif
led_mode
==
LED_FLAG_BAR
+
LED_FLAG_PULSE
:
disp
.
print
(
"
Top + Pulse
"
,
posx
=
0
,
posy
=
40
,
fg
=
COLOR_TEXT
)
disp
.
print
(
**
display_args
,
posy
=
40
,
fg
=
COLOR_TEXT
)
disp
.
update
()
leds
.
clear
()
...
...
@@ -265,11 +264,11 @@ def draw_leds(vmin, vmax):
global
pulse
,
samples_since_last_pulse
,
last_pulse_blink
# stop blinking
if
not
led_mode
:
if
not
bool
(
led_mode
)
:
return
# update led bar
if
led_mode
&
LED_FLAG_BAR
:
if
"
bar
"
in
led_mode
:
for
i
in
reversed
(
range
(
6
)):
leds
.
prep_hsv
(
5
+
i
,
COLORS
[
5
+
i
]
if
vmin
<=
0
and
i
<=
vmin
*
-
6
else
(
0
,
0
,
0
)
...
...
@@ -281,13 +280,13 @@ def draw_leds(vmin, vmax):
# blink red on pulse
if
(
led_mode
&
LED_FLAG_PULSE
"
pulse
"
in
led_mode
and
pulse
>
0
and
samples_since_last_pulse
<
last_pulse_blink
):
for
i
in
range
(
4
):
leds
.
prep
(
11
+
i
,
(
255
,
0
,
0
))
elif
led_mode
&
LED_FLAG_PULSE
:
elif
"
pulse
"
in
led_mode
:
for
i
in
range
(
4
):
leds
.
prep
(
11
+
i
,
(
0
,
0
,
0
))
last_pulse_blink
=
samples_since_last_pulse
...
...
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