Skip to content
Snippets Groups Projects
Commit 68731ce2 authored by Václav Jelínek's avatar Václav Jelínek
Browse files

Make esp menu reset smoother

parent bf400d2a
No related branches found
No related tags found
1 merge request!12Major update of menu visuals and example programs
......@@ -49,7 +49,8 @@ def main():
MENU_PROGRAM_NXT_UTZ_IDX = 3
menu_programs_functions_size = len(menu_programs_functions)
menu_list = [0, 0, 0, 0, 0, 0]
menu_list_size = [0, Port.M_COUNT, menu_programs_functions_size, 2, 1, Port.S_COUNT]
MENU_CUBE_TESTS = 3
menu_list_size = [0, Port.M_COUNT, menu_programs_functions_size, MENU_CUBE_TESTS, 1, Port.S_COUNT]
SENSOR_TEST_MENU_PORT_IDX = 5
# Fill framebuffer with battery voltage
......@@ -371,6 +372,9 @@ def main():
elif menu_list[current_menu] == 1:
print("Utility tets")
menu_programs.cube_utility_run(robot)
elif menu_list[current_menu] == 2:
print("Wifi webserver test")
menu_programs.esp_wifi_run(robot, esp_default_name)
robot.deinit_all()
robot_state = 0
menu_debounce = 1
......
# Helper file for importing menu programs
from .cube_gyro_acc import cube_gyro_acc_run
from .cube_utility import cube_utility_run
from .esp_wifi import esp_wifi_run
from .motor import motor_run
from .nxt_light import nxt_light_run
from .nxt_sound import nxt_sound_run
......
'''
Example program for the Open-Cube ESP32 Wi-Fi mode with web server.
Start Wi-Fi acces point on the ESP32 with name 'Open-Cube-Wifi' and password '01234567'.
'''
import utime
import random
from lib.robot_consts import Button
def main():
global robot
counter = 0
indicators = [True, False, True, False, False]
labels = ["1", "test1", "test2", "", "123"]
btn_labels = ["", "up", "", "left", "ok", "right", "", "down", "" ]
run = True
while run:
time = utime.ticks_us()
wifi = robot.esp.wifi()
if wifi:
break
print("Name: ", robot.esp.set_name("Open-Cube-Wifi"))
print("Password: ", robot.esp.set_password("01234567"))
robot.esp.wifi_set_indicators_labels(("1", "", "test2", "test3", "123"))
robot.esp.wifi_set_buttons_labels(btn_labels)
robot.esp.wifi_set_switches_labels(labels)
robot.esp.wifi_set_numbers_labels(("t:", "s:", "v:", "test1:", "", "test2:"))
while run:
utime.sleep(0.1)
if counter % 10 == 0:
robot.esp.wifi_set_indicators(indicators)
robot.esp.wifi_set_numbers((123456789, 0.123456, random.random(), 0.123456, random.random(), 5.2))
indicators = indicators[-1:]+indicators[:-1]
print("Buttons: ", robot.esp.wifi_get_buttons())
print("Switches: ", robot.esp.wifi_get_switches())
counter +=1
buttons = robot.buttons.pressed()
if buttons[Button.LEFT]:
run = False
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment