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
3dcad691
Commit
3dcad691
authored
1 year ago
by
dx
Committed by
q3k
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
move shit to utils
parent
3b4145fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/main.py
+11
-60
11 additions, 60 deletions
python_payload/main.py
python_payload/utils.py
+51
-0
51 additions, 0 deletions
python_payload/utils.py
with
62 additions
and
60 deletions
python_payload/main.py
+
11
−
60
View file @
3dcad691
from
machine
import
Pin
from
machine
import
Pin
from
hardware
import
*
from
hardware
import
*
import
utils
import
time
import
time
import
cap_touch_demo
import
cap_touch_demo
import
melodic_demo
import
melodic_demo
...
@@ -27,9 +28,6 @@ SELECT_TEXT = [
...
@@ -27,9 +28,6 @@ SELECT_TEXT = [
]
]
BACKGROUND_COLOR
=
0
BACKGROUND_COLOR
=
0
GREEN
=
0b0000011111100000
RED
=
0b1111100000000000
BLUE
=
0b0000000000011111
# pin numbers
# pin numbers
# right side: left 37, down 0, right 35
# right side: left 37, down 0, right 35
...
@@ -37,84 +35,37 @@ BLUE = 0b0000000000011111
...
@@ -37,84 +35,37 @@ BLUE = 0b0000000000011111
# NOTE: All except for 0 should be initialized with Pin.PULL_UP
# NOTE: All except for 0 should be initialized with Pin.PULL_UP
# 0 (bootsel) probably not but idk? never tried
# 0 (bootsel) probably not but idk? never tried
def
clear_all_leds
():
for
i
in
range
(
40
):
set_led_rgb
(
i
,
0
,
0
,
0
)
update_leds
()
def
draw_text_big
(
text
,
x
,
y
):
ypos
=
120
+
int
(
len
(
text
)
/
2
)
+
int
(
y
)
xpos
=
120
+
int
(
len
(
text
[
0
])
/
2
)
+
int
(
x
)
for
l
,
line
in
enumerate
(
text
):
for
p
,
pixel
in
enumerate
(
line
):
if
(
pixel
==
'
#
'
):
display_draw_pixel
(
xpos
-
2
*
p
,
ypos
-
2
*
l
,
RED
)
display_draw_pixel
(
xpos
-
2
*
p
,
ypos
-
2
*
l
-
1
,
BLUE
)
display_draw_pixel
(
xpos
-
2
*
p
-
1
,
ypos
-
2
*
l
,
BLUE
)
display_draw_pixel
(
xpos
-
2
*
p
-
1
,
ypos
-
2
*
l
-
1
,
RED
)
def
highlight_bottom_petal
(
num
,
RED
,
GREEN
,
BLUE
):
start
=
4
+
8
*
num
for
i
in
range
(
7
):
set_led_rgb
(((
i
+
start
)
%
40
),
RED
,
GREEN
,
BLUE
)
update_leds
()
def
long_bottom_petal_captouch_blocking
(
num
,
ms
):
if
(
get_captouch
((
num
*
2
)
+
1
)
==
1
):
time
.
sleep_ms
(
ms
)
if
(
get_captouch
((
num
*
2
)
+
1
)
==
1
):
return
True
return
False
def
draw_rect
(
x
,
y
,
w
,
h
,
col
):
for
j
in
range
(
w
):
for
k
in
range
(
h
):
display_draw_pixel
(
x
+
j
,
y
+
k
,
col
)
def
draw_volume_slider
():
global
volume
length
=
96
+
((
volume
-
20
)
*
1.6
)
if
length
>
96
:
length
=
96
if
length
<
0
:
length
=
0
length
=
int
(
length
)
draw_rect
(
70
,
20
,
100
,
10
,
GREEN
)
draw_rect
(
71
,
21
,
98
,
8
,
0
)
draw_rect
(
72
+
96
-
length
,
22
,
length
,
6
,
GREEN
)
def
run_menu
():
def
run_menu
():
global
foreground
global
foreground
display_fill
(
BACKGROUND_COLOR
)
display_fill
(
BACKGROUND_COLOR
)
draw_text_big
(
SELECT_TEXT
,
0
,
0
)
utils
.
draw_text_big
(
SELECT_TEXT
,
0
,
0
)
draw_volume_slider
()
utils
.
draw_volume_slider
(
volume
)
display_update
()
display_update
()
selected_petal
=
None
selected_petal
=
None
selected_module
=
None
selected_module
=
None
for
petal
,
module
in
enumerate
(
MODULES
):
for
petal
,
module
in
enumerate
(
MODULES
):
if
long_bottom_petal_captouch_blocking
(
petal
,
20
):
if
utils
.
long_bottom_petal_captouch_blocking
(
petal
,
20
):
selected_petal
=
petal
selected_petal
=
petal
selected_module
=
module
selected_module
=
module
break
break
if
selected_petal
is
not
None
:
if
selected_petal
is
not
None
:
clear_all_leds
()
utils
.
clear_all_leds
()
highlight_bottom_petal
(
selected_petal
,
55
,
0
,
0
)
utils
.
highlight_bottom_petal
(
selected_petal
,
55
,
0
,
0
)
display_fill
(
BACKGROUND_COLOR
)
display_fill
(
BACKGROUND_COLOR
)
display_update
()
display_update
()
foreground
=
selected_module
.
run
foreground
=
selected_module
.
run
time
.
sleep_ms
(
100
)
time
.
sleep_ms
(
100
)
clear_all_leds
()
utils
.
clear_all_leds
()
selected_module
.
foreground
()
selected_module
.
foreground
()
def
foreground_menu
():
def
foreground_menu
():
clear_all_leds
()
utils
.
clear_all_leds
()
highlight_bottom_petal
(
0
,
0
,
55
,
55
);
utils
.
highlight_bottom_petal
(
0
,
0
,
55
,
55
);
highlight_bottom_petal
(
1
,
55
,
0
,
55
);
utils
.
highlight_bottom_petal
(
1
,
55
,
0
,
55
);
display_fill
(
BACKGROUND_COLOR
)
display_fill
(
BACKGROUND_COLOR
)
draw_text_big
(
SELECT_TEXT
,
0
,
0
)
utils
.
draw_text_big
(
SELECT_TEXT
,
0
,
0
)
display_update
()
display_update
()
def
set_rel_volume
(
vol
):
def
set_rel_volume
(
vol
):
...
...
This diff is collapsed.
Click to expand it.
python_payload/utils.py
0 → 100644
+
51
−
0
View file @
3dcad691
import
time
from
hardware
import
*
RED
=
0b1111100000000000
GREEN
=
0b0000011111100000
BLUE
=
0b0000000000011111
def
clear_all_leds
():
for
i
in
range
(
40
):
set_led_rgb
(
i
,
0
,
0
,
0
)
update_leds
()
def
draw_text_big
(
text
,
x
,
y
):
ypos
=
120
+
int
(
len
(
text
)
/
2
)
+
int
(
y
)
xpos
=
120
+
int
(
len
(
text
[
0
])
/
2
)
+
int
(
x
)
for
l
,
line
in
enumerate
(
text
):
for
p
,
pixel
in
enumerate
(
line
):
if
(
pixel
==
'
#
'
):
display_draw_pixel
(
xpos
-
2
*
p
,
ypos
-
2
*
l
,
RED
)
display_draw_pixel
(
xpos
-
2
*
p
,
ypos
-
2
*
l
-
1
,
BLUE
)
display_draw_pixel
(
xpos
-
2
*
p
-
1
,
ypos
-
2
*
l
,
BLUE
)
display_draw_pixel
(
xpos
-
2
*
p
-
1
,
ypos
-
2
*
l
-
1
,
RED
)
def
highlight_bottom_petal
(
num
,
RED
,
GREEN
,
BLUE
):
start
=
4
+
8
*
num
for
i
in
range
(
7
):
set_led_rgb
(((
i
+
start
)
%
40
),
RED
,
GREEN
,
BLUE
)
update_leds
()
def
long_bottom_petal_captouch_blocking
(
num
,
ms
):
if
(
get_captouch
((
num
*
2
)
+
1
)
==
1
):
time
.
sleep_ms
(
ms
)
if
(
get_captouch
((
num
*
2
)
+
1
)
==
1
):
return
True
return
False
def
draw_rect
(
x
,
y
,
w
,
h
,
col
):
for
j
in
range
(
w
):
for
k
in
range
(
h
):
display_draw_pixel
(
x
+
j
,
y
+
k
,
col
)
def
draw_volume_slider
(
volume
):
length
=
96
+
((
volume
-
20
)
*
1.6
)
if
length
>
96
:
length
=
96
if
length
<
0
:
length
=
0
length
=
int
(
length
)
draw_rect
(
70
,
20
,
100
,
10
,
GREEN
)
draw_rect
(
71
,
21
,
98
,
8
,
0
)
draw_rect
(
72
+
96
-
length
,
22
,
length
,
6
,
GREEN
)
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