Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r 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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
dos
flow3r firmware
Commits
b0c5fb6e
Commit
b0c5fb6e
authored
1 year ago
by
iggy
Committed by
q3k
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
use demo_menu as entrypoint in main and preserve previous main.py
parent
e00ccc6c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/main.py
+1
-126
1 addition, 126 deletions
python_payload/main.py
python_payload/main_orig.py
+126
-0
126 additions, 0 deletions
python_payload/main_orig.py
with
127 additions
and
126 deletions
python_payload/main.py
+
1
−
126
View file @
b0c5fb6e
from
hardware
import
*
import
utils
import
time
import
harmonic_demo
import
melodic_demo
import
demo_worms
import
cap_touch_demo
MODULES
=
[
harmonic_demo
,
melodic_demo
,
demo_worms
,
cap_touch_demo
,
]
CURRENT_APP_RUN
=
None
VOLUME
=
0
ctx
=
None
BACKGROUND_COLOR
=
0
def
run_menu
():
global
CURRENT_APP_RUN
global
ctx
display_fill
(
BACKGROUND_COLOR
)
utils
.
draw_volume_slider
(
ctx
,
VOLUME
)
ctx
.
move_to
(
0
,
0
).
rgb
(
255
,
0
,
255
).
text
(
"
select :3
"
)
display_update
()
selected_petal
=
None
selected_module
=
None
for
petal
,
module
in
enumerate
(
MODULES
):
if
utils
.
long_bottom_petal_captouch_blocking
(
petal
,
20
):
selected_petal
=
petal
selected_module
=
module
break
if
selected_petal
is
not
None
:
utils
.
clear_all_leds
()
utils
.
highlight_bottom_petal
(
selected_petal
,
55
,
0
,
0
)
display_fill
(
BACKGROUND_COLOR
)
display_update
()
CURRENT_APP_RUN
=
selected_module
.
run
time
.
sleep_ms
(
100
)
utils
.
clear_all_leds
()
selected_module
.
foreground
()
def
foreground_menu
():
utils
.
clear_all_leds
()
utils
.
highlight_bottom_petal
(
0
,
0
,
55
,
55
);
utils
.
highlight_bottom_petal
(
1
,
55
,
0
,
55
);
utils
.
highlight_bottom_petal
(
2
,
55
,
55
,
0
);
utils
.
highlight_bottom_petal
(
3
,
0
,
110
,
0
);
display_fill
(
BACKGROUND_COLOR
)
display_update
()
def
set_rel_volume
(
vol
):
global
VOLUME
vol
+=
VOLUME
if
vol
>
20
:
vol
=
20
if
vol
<
-
40
:
vol
=
-
40
VOLUME
=
vol
if
vol
==
-
40
:
#mute
set_global_volume_dB
(
-
90
)
else
:
set_global_volume_dB
(
VOLUME
)
time
.
sleep_ms
(
100
)
def
captouch_cal
():
global
ctx
display_fill
(
0b0000000111100111
)
ctx
.
move_to
(
0
,
0
).
rgb
(
0
,
255
,
0
).
text
(
"
cal
"
)
display_update
()
time
.
sleep_ms
(
500
)
display_fill
(
0b0011100000000111
)
ctx
.
move_to
(
0
,
0
).
rgb
(
0
,
255
,
0
).
text
(
"
cal
"
)
captouch_autocalib
()
while
(
captouch_calibration_active
()):
pass
display_fill
(
0
)
display_update
()
def
main
():
global
CURRENT_APP_RUN
global
ctx
while
not
init_done
():
pass
captouch_autocalib
()
# dry run
while
(
captouch_calibration_active
()):
pass
ctx
=
get_ctx
()
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_baseline
=
ctx
.
MIDDLE
captouch_cal
()
for
module
in
MODULES
:
module
.
init
()
CURRENT_APP_RUN
=
run_menu
foreground_menu
()
set_global_volume_dB
(
VOLUME
)
while
True
:
if
((
get_button
(
1
)
==
2
)
and
(
CURRENT_APP_RUN
==
run_menu
)):
captouch_cal
()
foreground_menu
()
else
:
if
(
get_button
(
0
)
==
2
):
if
CURRENT_APP_RUN
!=
run_menu
:
CURRENT_APP_RUN
=
run_menu
foreground_menu
()
else
:
if
(
get_button
(
0
)
==
1
):
set_rel_volume
(
+
1
)
if
(
get_button
(
0
)
==
-
1
):
set_rel_volume
(
-
1
)
CURRENT_APP_RUN
()
main
()
import
demo_menu
This diff is collapsed.
Click to expand it.
python_payload/main_orig.py
0 → 100644
+
126
−
0
View file @
b0c5fb6e
from
hardware
import
*
import
utils
import
time
import
harmonic_demo
import
melodic_demo
import
demo_worms
import
cap_touch_demo
MODULES
=
[
harmonic_demo
,
melodic_demo
,
demo_worms
,
cap_touch_demo
,
]
CURRENT_APP_RUN
=
None
VOLUME
=
0
ctx
=
None
BACKGROUND_COLOR
=
0
def
run_menu
():
global
CURRENT_APP_RUN
global
ctx
display_fill
(
BACKGROUND_COLOR
)
utils
.
draw_volume_slider
(
ctx
,
VOLUME
)
ctx
.
move_to
(
0
,
0
).
rgb
(
255
,
0
,
255
).
text
(
"
select :3
"
)
display_update
()
selected_petal
=
None
selected_module
=
None
for
petal
,
module
in
enumerate
(
MODULES
):
if
utils
.
long_bottom_petal_captouch_blocking
(
petal
,
20
):
selected_petal
=
petal
selected_module
=
module
break
if
selected_petal
is
not
None
:
utils
.
clear_all_leds
()
utils
.
highlight_bottom_petal
(
selected_petal
,
55
,
0
,
0
)
display_fill
(
BACKGROUND_COLOR
)
display_update
()
CURRENT_APP_RUN
=
selected_module
.
run
time
.
sleep_ms
(
100
)
utils
.
clear_all_leds
()
selected_module
.
foreground
()
def
foreground_menu
():
utils
.
clear_all_leds
()
utils
.
highlight_bottom_petal
(
0
,
0
,
55
,
55
);
utils
.
highlight_bottom_petal
(
1
,
55
,
0
,
55
);
utils
.
highlight_bottom_petal
(
2
,
55
,
55
,
0
);
utils
.
highlight_bottom_petal
(
3
,
0
,
110
,
0
);
display_fill
(
BACKGROUND_COLOR
)
display_update
()
def
set_rel_volume
(
vol
):
global
VOLUME
vol
+=
VOLUME
if
vol
>
20
:
vol
=
20
if
vol
<
-
40
:
vol
=
-
40
VOLUME
=
vol
if
vol
==
-
40
:
#mute
set_global_volume_dB
(
-
90
)
else
:
set_global_volume_dB
(
VOLUME
)
time
.
sleep_ms
(
100
)
def
captouch_cal
():
global
ctx
display_fill
(
0b0000000111100111
)
ctx
.
move_to
(
0
,
0
).
rgb
(
0
,
255
,
0
).
text
(
"
cal
"
)
display_update
()
time
.
sleep_ms
(
500
)
display_fill
(
0b0011100000000111
)
ctx
.
move_to
(
0
,
0
).
rgb
(
0
,
255
,
0
).
text
(
"
cal
"
)
captouch_autocalib
()
while
(
captouch_calibration_active
()):
pass
display_fill
(
0
)
display_update
()
def
main
():
global
CURRENT_APP_RUN
global
ctx
while
not
init_done
():
pass
captouch_autocalib
()
# dry run
while
(
captouch_calibration_active
()):
pass
ctx
=
get_ctx
()
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_baseline
=
ctx
.
MIDDLE
captouch_cal
()
for
module
in
MODULES
:
module
.
init
()
CURRENT_APP_RUN
=
run_menu
foreground_menu
()
set_global_volume_dB
(
VOLUME
)
while
True
:
if
((
get_button
(
1
)
==
2
)
and
(
CURRENT_APP_RUN
==
run_menu
)):
captouch_cal
()
foreground_menu
()
else
:
if
(
get_button
(
0
)
==
2
):
if
CURRENT_APP_RUN
!=
run_menu
:
CURRENT_APP_RUN
=
run_menu
foreground_menu
()
else
:
if
(
get_button
(
0
)
==
1
):
set_rel_volume
(
+
1
)
if
(
get_button
(
0
)
==
-
1
):
set_rel_volume
(
-
1
)
CURRENT_APP_RUN
()
main
()
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