ESP32/websocket driver for displaying LVGL in a browser

I wrote a device driver that uses a websocket to render lvgl on one or more web browsers as well as get mouse/touch input. It’s still a work in progress but can be found on my github: danjulio/lv_port_esp32_web. This is the esp32 demo project with the SPI drivers stripped out and the new driver in place. Released like the original project for your use but with no warranties, etc, etc.


The idea is to be able to use your same code to display on a local LCD or remote web session. Clearly some security issues, etc. apply.

Performance varies a lot with how much lvgl has to redraw and the pixel depth but it seems quite useable with 16-bit pixels and plain backgrounds (it supports 8/16/32-bit pixels).

The driver is a little on the heavy side. Depending on the lvgl_conf.h settings I got a binary in excess of 1MB. You may have to increase the primary application partition size as I’ve done (see the local partitions.csv file and menuconfig setup to use it).


Nice job!
I agree it could be useful for displaying the same GUI both locally and remotely.

While you concentrated on the ESP32, it could also be useful building such driver for Windows/Linux when running lvgl on the OS. Then we could use the browser instead of using SDL.

Oh! What a good idea. This didn’t occur to me because I don’t use the simulator but I agree with your assessment.

I imagine this would be fairly easy to port to linux. I don’t know windows so I can’t speak to that but. Unfortunately at the moment I’m busy with another project but if no one else tackles this then I’ll try to look at it in a few weeks time.

Wouldn’t Emscripten make more sense for that use case? That way no binaries are necessary. WebAssembly is more than fast enough to run LittlevGL directly.

(The demo I linked is definitely not the fastest, but I’m sure that with some optimization it can run much more efficiently.)

Emscripten makes sense when you want to run it entirely on the web page.
But there are other scenarios where you might want to run it as an executable outside the web browser.

For example, when lvgl is used as a visualization library of another project, or in cases you want lvgl to run on a different machine than the browser.
Another example is when using embedded Linux board such as Raspberry Pi and the like

1 Like

Now that links have been fixed: