You can have multiple screens, for example in an array, and then switch the screens with screen.load_screen(screens[i])
I use it like this
screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xadefeb)
screen.set_screen_brightness(60)
#an array to store screens
screens=[]
now everything (M5Label etc) will be drawn on the current screen.
I end the screen with
screen0 = screen.get_act_screen()
screens.append(screen0)
then start a new screen with
get a new screen
screen1 = screen.get_new_screen()
screen.load_screen(screen1)
then end this screen and so on
screen1 = screen.get_act_screen()
screens.append(screen1)
To switch the screen I use
def getPrevScreen():
global current_screen, screens
lock_obj.acquire()
print('getPrevScreen called')
current_screen-=1
if current_screen < 0 :
current_screen=0
else:
screen.load_screen(screens[current_screen])
lock_obj.release()
pass
def getNextScreen():
global current_screen, screens
lock_obj.acquire()
print('getNextScreen called')
current_screen+=1
if current_screen > len(screens)-1 :
current_screen=len(screens)-1
else:
screen.load_screen(screens[current_screen])
lock_obj.release()
pass
these are called by
def buttonA_wasPressed():
global params
do_beep()
reset_idle_counter()
print('ButtonA pressed')
screen.clean_screen()
screen.load_screen(screen0)
screen.load_screen(screens[0])
getPrevScreen()
_thread.start_new_thread(getPrevScreen, ())
pass
btnA.wasPressed(buttonA_wasPressed)
and
def buttonC_wasPressed():
do_beep()
reset_idle_counter()
print('ButtonC pressed')
screen.clean_screen()
screen.load_screen(screen2)
getNextScreen()
_thread.start_new_thread(getNextScreen, ())
screen.clean_screen()
screen.load_screen(screen1)
screen.load_screen(screens[2])
pass
btnC.wasPressed(buttonC_wasPressed)
The formatting here is terrible, as it reads # for markdown...
I will put my code on github (hjgode) later on
BTW: the UIFlow doc is a mess. They use // in fron of line for a python comment line (needs to be a # in front). And I am missing examples, examples....
Still looking for a complete developer doc for the UIFlow micropython stuff. Some functions are named differently and some just do not work, if you try the micropython basic ones (like for example umqtt.simple, which just crashes as someone forget to implement socket.set_timeout)