Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Open-Cube FW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Cube
Open-Cube FW
Commits
cd5e396e
Commit
cd5e396e
authored
5 months ago
by
Václav Jelínek
Browse files
Options
Downloads
Patches
Plain Diff
Center text, add battery constants
parent
21f5508f
No related branches found
Branches containing commit
No related tags found
1 merge request
!12
Major update of menu visuals and example programs
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/menu_display.py
+12
-11
12 additions, 11 deletions
lib/menu_display.py
lib/robot_consts.py
+4
-1
4 additions, 1 deletion
lib/robot_consts.py
with
16 additions
and
12 deletions
lib/menu_display.py
+
12
−
11
View file @
cd5e396e
import
micropython
from
lib.robot_consts
import
BAT_VOLTAGE_MAX
,
BAT_VOLTAGE_MIN
DISPLAY_TITLE_POS
=
18
DISPLAY_PROG_POS
=
42
...
...
@@ -21,7 +22,7 @@ class Menu:
# Fill fr
# amebuffer with battery voltage
def
display_fill_battery
(
robot
,
bat_voltage
):
bat_percentage
=
int
((
bat_voltage
-
6.4
)
/
(
8.4
-
6.4
)
*
20
)
*
5
bat_percentage
=
int
((
bat_voltage
-
BAT_VOLTAGE_MIN
)
/
(
BAT_VOLTAGE_MAX
-
BAT_VOLTAGE_MIN
)
*
20
)
*
5
# Round to
5
bat_percentage
=
100
if
bat_percentage
>
100
else
0
if
bat_percentage
<
0
else
bat_percentage
robot
.
display
.
line
(
0
,
13
,
128
,
13
,
1
)
...
...
@@ -70,7 +71,7 @@ def display_fill_bt_pin(robot, pin, connecting):
def
display_fill_mot_test
(
robot
,
current_motor_test
):
robot
.
display
.
fill
(
0
)
robot
.
display
.
centered_text
(
'
< Motor test >
'
,
DISPLAY_TITLE_POS
,
1
)
robot
.
display
.
centered_text
(
'
M{
}
'
.
format
(
current_motor_test
+
1
)
,
DISPLAY_PROG_POS
,
1
)
robot
.
display
.
centered_text
(
f
'
M
{
current_motor_test
+
1
}
'
,
DISPLAY_PROG_POS
,
1
)
display_fill_arrows
(
robot
)
# Fill framebuffer with sensor test menu
...
...
@@ -81,7 +82,7 @@ def display_fill_sen_test(robot, current_sen_test, sensor_test_menu, sensor_test
robot
.
display
.
centered_text
(
sensor_test_name
,
DISPLAY_PROG_POS
,
1
)
else
:
robot
.
display
.
centered_text
(
'
< Sensor port
'
,
DISPLAY_TITLE_POS
,
1
)
robot
.
display
.
centered_text
(
'
S{
}
'
.
format
(
current_sen_test
+
1
)
,
DISPLAY_PROG_POS
,
1
)
robot
.
display
.
centered_text
(
f
'
S
{
current_sen_test
+
1
}
'
,
DISPLAY_PROG_POS
,
1
)
display_fill_arrows
(
robot
)
# Fill framebuffer with cube test menu
...
...
@@ -98,24 +99,24 @@ def display_fill_arrows(robot):
def
display_fill_fw_version
(
robot
,
fw_version
):
robot
.
display
.
fill
(
0
)
robot
.
display
.
centered_text
(
"
< Firmware >
"
,
DISPLAY_TITLE_POS
,
1
)
robot
.
display
.
centered_text
(
"
Open-Cube
"
,
DISPLAY_PROG_POS
-
4
,
1
)
robot
.
display
.
centered_text
(
fw_version
,
DISPLAY_PROG_POS
+
4
,
1
)
robot
.
display
.
centered_text
(
"
Open-Cube
"
,
DISPLAY_PROG_POS
-
10
,
1
)
robot
.
display
.
centered_text
(
fw_version
,
DISPLAY_PROG_POS
,
1
)
# Show program error on display
def
display_show_error
(
robot
):
robot
.
display
.
fill
(
0
)
robot
.
display
.
text
(
'
Program
'
,
35
,
20
,
1
)
robot
.
display
.
text
(
'
error!
'
,
40
,
30
,
1
)
robot
.
display
.
centered_
text
(
'
Program
'
,
20
,
1
)
robot
.
display
.
centered_
text
(
'
error!
'
,
30
,
1
)
robot
.
display
.
show
()
def
display_show_startup
(
robot
):
robot
.
display
.
fill
(
0
)
robot
.
display
.
text
(
'
Turning
'
,
35
,
20
,
1
)
robot
.
display
.
text
(
'
on
'
,
40
,
30
,
1
)
robot
.
display
.
centered_
text
(
'
Turning
'
,
20
,
1
)
robot
.
display
.
centered_
text
(
'
on
'
,
30
,
1
)
robot
.
display
.
show
()
def
display_show_program
(
robot
):
robot
.
display
.
fill
(
0
)
robot
.
display
.
text
(
'
Program
'
,
35
,
20
,
1
)
robot
.
display
.
text
(
'
running
'
,
40
,
30
,
1
)
robot
.
display
.
centered_
text
(
'
Program
'
,
20
,
1
)
robot
.
display
.
centered_
text
(
'
running
'
,
30
,
1
)
robot
.
display
.
show
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/robot_consts.py
+
4
−
1
View file @
cd5e396e
...
...
@@ -72,8 +72,11 @@ class Color:
WHITE
:
Color
=
const
(
6
)
BROWN
:
Color
=
const
(
7
)
BAT_VOLTAGE_TURNOFF
=
6.3
# Volts
BAT_MEASURE_PERIOD
=
const
(
1000
)
# ms
BAT_VOLTAGE_MAX
=
8.4
BAT_VOLTAGE_MIN
=
6.2
BAT_VOLTAGE_TURNOFF
=
(
BAT_VOLTAGE_MIN
+
0.1
)
# Volts
PCF_CHECK_PERIOD
=
const
(
50
)
# ms
...
...
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