2.7. Start with the LVGL GUI Simulation Project

    The GUI simulation can be performed on a PC using Visual Studio.

    Select lvgl-vs-simu, a Visual Studio simulation project, from the Project Builder on the official PikaScript website.

    This project is branched from the official LVGL Visual Studio simulation project.

    Click Generate Project and wait about 1 minute.

    _images/image-20220619174908845.png

    Unzip the project and open LVGL.Simulator.sln

    _images/image-20220619175332172.png

    You can see that the lvgl emulator has been successfully started

    The Python file for running the project is in LVGL.Simulator/pikascript/main.py, and it is recommended to edit the Python file with VSCode.

    _images/image-20220619175630362.png

    The code in main.py is shown below, and the project will run this main.py when it starts

    More sample code

    You can see more sample code in the /pikascript/examples/lvgl folder.

    1. import pika_lvgl as lv
    2. import PikaStdLib
    3. mem = PikaStdLib.MemChecker()
    4. def event_cb_1(evt):
    5. print('in evt1')
    6. def event_cb_2(evt):
    7. print('in evt2')
    8. print('mem used now: %0.2f kB' % (mem.getNow()))
    9. btn1.align(lv.ALIGN.TOP_MID, 0, 10)
    10. btn2 = lv.btn(lv.scr_act())
    11. btn2.align(lv.ALIGN.TOP_MID, 0, 50)
    12. btn1.add_event_cb(event_cb_1, lv.EVENT.CLICKED, 0)
    13. btn2.add_event_cb(event_cb_2, lv.EVENT.CLICKED, 0)

    After replacing main.py, run PikaScript’s pre-compiler

    _images/image-20220619180151300.png

    and then start running

    In this example you can click the button and then view the output.

    _images/image-20220619180255030.png

    If you are prompted for missing functions, you need to manually add the files to be compiled

    Right-click on pikascript/pikascript-api and pikascript/pikascript-lib and click “Include in project”, then recompile.