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.
Unzip the project and open LVGL.Simulator.sln
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.
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.
import pika_lvgl as lv
import PikaStdLib
mem = PikaStdLib.MemChecker()
def event_cb_1(evt):
print('in evt1')
def event_cb_2(evt):
print('in evt2')
print('mem used now: %0.2f kB' % (mem.getNow()))
btn1.align(lv.ALIGN.TOP_MID, 0, 10)
btn2 = lv.btn(lv.scr_act())
btn2.align(lv.ALIGN.TOP_MID, 0, 50)
btn1.add_event_cb(event_cb_1, lv.EVENT.CLICKED, 0)
btn2.add_event_cb(event_cb_2, lv.EVENT.CLICKED, 0)
After replacing main.py, run PikaScript’s pre-compiler
and then start running
In this example you can click the button and then view the output.
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.