41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
|
from gc import collect
|
||
|
|
||
|
# All the arguments this method takes are there for one reason: reduce the amount of libraries loaded into the picos memory and thus improving performance
|
||
|
# config: utils.Config object
|
||
|
# btn_mapping: a dict containing the btn mapping for the menu operation (given to the lcdMenu object)
|
||
|
# log: the utils.log function
|
||
|
# lcdMenu: the lcdMenu class (not an object of that class!)
|
||
|
def run(config, btn_mapping, log, lcdMenu):
|
||
|
def lcd_driver_demo():
|
||
|
import demos.lcd_driver_demo as ldd
|
||
|
ldd.run(config.LCD)
|
||
|
del ldd
|
||
|
collect()
|
||
|
return True
|
||
|
def lcd_big_hello():
|
||
|
import demos.lcd_big_hello as lbh
|
||
|
lbh.run(config.LCD)
|
||
|
del lbh
|
||
|
collect()
|
||
|
return True
|
||
|
def input_tests():
|
||
|
import demos.input_tests as it
|
||
|
it.run(serial_output=False)
|
||
|
del it
|
||
|
collect()
|
||
|
return True
|
||
|
demo_menu = lcdMenu(config.LCD, btn_mapping, scroll_direction=True, cycle=True, hide_menu_name=False, name="DEMOS")
|
||
|
demo_programs = [("LCD Demo", lcd_driver_demo),
|
||
|
("Hello world", lcd_big_hello),
|
||
|
("Input tests", input_tests),
|
||
|
("Exit", demo_menu.stop)]
|
||
|
demo_menu.setup(demo_programs) # give it the callback list
|
||
|
demo_menu.run()
|
||
|
return True
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
from utils import Config, log
|
||
|
from lcdMenu import lcdMenu
|
||
|
config = Config()
|
||
|
btn_mapping = {"ok_btn": config.PIN_IN_BTN_1, "next_btn": config.PIN_IN_BTN_2} # the btn mapping for all lcdMenus
|
||
|
run(Config(), btn_mapping, log, lcdMenu)
|