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
bf400d2a
Commit
bf400d2a
authored
5 months ago
by
Václav Jelínek
Browse files
Options
Downloads
Patches
Plain Diff
Make esp menu reset smoother
parent
498289aa
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/cube/esp_config.py
+7
-1
7 additions, 1 deletion
lib/cube/esp_config.py
main/main.py
+19
-13
19 additions, 13 deletions
main/main.py
with
26 additions
and
14 deletions
lib/cube/esp_config.py
+
7
−
1
View file @
bf400d2a
...
...
@@ -249,7 +249,6 @@ class Esp:
response
=
self
.
repeat_cmd
(
Esp
.
COM_BT_PIN
,
50
)
self
.
cmd_stop
()
return
response
utime
.
sleep
(
0.6
)
else
:
return
None
...
...
@@ -269,6 +268,12 @@ class Esp:
self
.
cmd_stop
()
utime
.
sleep
(
0.6
)
return
response
def
set_name_nonblocking
(
self
,
name
:
str
,
timeout
=
50
):
self
.
cmd_start
()
response
=
self
.
repeat_str
(
Esp
.
COM_NAME
,
name
,
timeout
)
self
.
cmd_stop
()
return
response
def
set_password
(
self
,
password
:
str
,
timeout
=
50
):
self
.
cmd_start
()
...
...
@@ -297,6 +302,7 @@ class Esp:
self
.
flush
()
self
.
esp_mode
=
self
.
esp_mode_prev
self
.
pcf_buttons
.
set_pin
(
8
,
True
)
utime
.
sleep
(
0.01
)
def
timeout
(
self
):
self
.
not_responding
+=
1
...
...
This diff is collapsed.
Click to expand it.
main/main.py
+
19
−
13
View file @
bf400d2a
...
...
@@ -85,7 +85,7 @@ def main():
robot
.
display
.
centered_text
(
f
'
{
pin
:
06
d
}
'
,
20
,
1
)
robot
.
display
.
centered_text
(
'
?
'
,
30
,
1
)
robot
.
display
.
text
(
'
no
'
,
10
,
44
,
1
)
robot
.
display
.
centered_text
(
'
ok
'
,
90
,
44
,
1
)
robot
.
display
.
centered_text
(
'
ok
'
,
44
,
1
)
# Fill framebuffer with motor test menu
def
display_fill_mot_test
(
robot
,
current_motor_test
):
...
...
@@ -228,7 +228,7 @@ def main():
bt_pair
=
False
bt_connecting
=
False
button_values
=
robot
.
buttons
.
pressed
()
esp_reset
=
False
display_show_startup
(
robot
)
# Get a list of user programs
...
...
@@ -258,22 +258,26 @@ def main():
# Loop that shows display, controls menu and starts user programs
while
(
True
):
# Connect to and reset ESP32 to BT mode if it is not running
if
not
robot
.
esp
.
running
()
and
counter
%
20
==
0
:
robot
.
esp
.
reset_non_blocking
()
if
robot
.
esp
.
running
()
and
counter
==
1000
:
robot
.
esp
.
set_name
(
esp_default_name
,
100
)
if
not
robot
.
esp
.
running
()
and
counter
%
10
==
0
:
s
=
utime
.
ticks_ms
()
robot
.
esp
.
reset
(
200
)
print
(
"
ESP32 reset time:
"
,
utime
.
ticks_ms
()
-
s
)
esp_reset_counter
=
counter
if
robot
.
esp
.
running
()
and
counter
-
esp_reset_counter
==
10
:
robot
.
esp
.
set_name_nonblocking
(
esp_default_name
,
100
)
print
(
"
ESP BT name:
"
,
esp_default_name
)
bat_voltage
=
robot
.
battery
.
voltage
()
# Get current battery voltage
button_values
=
robot
.
buttons
.
pressed
()
# Get buttons state
# Move menu accordingly to pressed buttons
menu_move_v
,
menu_move_h
,
menu_debounce
,
ok_pressed
=
buttons
(
robot
,
button_values
,
robot_state
,
menu_move_v
,
menu_move_h
,
menu_debounce
)
# Check if buttons were pressed and move menu accordingly
if
not
bt_pair
:
menu_move_v
,
menu_move_h
,
menu_debounce
,
ok_pressed
=
buttons
(
robot
,
button_values
,
robot_state
,
menu_move_v
,
menu_move_h
,
menu_debounce
)
# Check if buttons were pressed and move menu accordingly
if
menu_debounce
==
0
:
if
sensor_test_menu
==
Menu
.
SEN_TEST_PORT
:
if
menu_move_v
!=
0
:
...
...
@@ -312,9 +316,11 @@ def main():
if
ok_pressed
:
robot
.
esp
.
send_pair
()
bt_connecting
=
True
elif
button_values
[
Button
.
LEFT
]:
menu_debounce
=
1
elif
menu_move_h
==
-
1
:
rejected_pin
=
pin
robot
.
esp
.
send_cancel
()
menu_debounce
=
1
elif
current_menu
==
Menu
.
MOT_TEST
:
chosen_motor_port
=
menu_list
[
current_menu
]
...
...
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