lvgl

Posted on
  • Hi,

    Has there been an attempt to port LVGL into Espruino?

    It seems like a nice UI library and apparently supports ESP32.

    I've no idea how to port the code over to run under Espruino, but would be interested to learn.

    Has anyone got any experience of this that they could help me with?

    Thanks

  • Sounds like a good idea! I originally read this thinking probably not, but when scouring the internet, it could be possible...

    LVGL has the following system requirements that could be a make-or-break deal:

    • Flash minimum 64 KiB, recommended 180 KiB
    • Memory minimum 2 KiB, recommended 4 KiB

    With the Pixl.js (which would be ideal given that it has a display), it's probably not possible: iirc you're given around 40 KiB to play with when the Espruino firmware/interpreter is installed. With some of the non-Bluetooth boards, I believe that they have a much higher spec, so it probably could fit on a few of the other Espruino products.

    As you say, you'd have to port the code over to Espruino, which would require quite a lot of effort since it's probably a top-down rewrite of over roughly 383,002 source lines of code (according to a Chrome extension I installed for GitHub), so pretty big task. By no means impossible though ─ LVGL would only make up around 14% of the Espruino source code if both codebases were merged!

    I admit that I'm not an expert at writing C myself (more of a JS guy ─ I've only written a bunch of small C programs!), but it sounds like an interesting project for those who have more experience at C. Defo a pl that I want to learn since it's so interesting, anyway!

    One thing that would work is just using Espruino's own UI library ─ I mean, you can't go wrong there! I haven't used it myself (I implemented my own basic UI library for a project I've been working on), but it seems to be somewhat powerful given the limitations of the Espruino hardware. It works on the Espruinos with screens, and that includes the Pixl.js if you have one, as well as some of the other boards.

    Hope this helps!
    -James.

  • 383,002 lines sounds like a lot of effort!

    I figured it might not have needed rewriting as it seems to have been designed to be integrated, and be ported to other languages. I however know almost nothing about whats involved so I think I will gracefully step back from this one!

    Thanks,

    Rob Smart

  • Yeah, it's certainly a lot! Though as you say, the code may be quite modular, and so probably only the code that talks to the hardware would need to be changed a bit.

    There's certainly a lot of files in their codebase, and I'm taking a guess that some of them are related to driving/controlling the hardware peripherals, and then other parts are just code that interface with the hardware-controlling code ─ much like a Hardware Abstraction Layer, or HAL, found in modern operating systems.

    Like you, I don't know about the internals of LVGL, but just making an educated guess here! After all, LVGL is designed for a large range of devices ─ after all, their demos page on their website runs all of the code on the browser and that's a much more different architecture than embedded, so I'm sure that they've made their code so that it works practically anywhere. Seeing that both Espruino and LVGL are written in C, it should be possible to somehow merge the code, and then on the Espruino side of things, expose some of the LVGL API to the JavaScript engine for use in your JS program.

    -James.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

lvgl

Posted by Avatar for Ruprect99 @Ruprect99

Actions