Giter Site home page Giter Site logo

lvgl-rclib-rs's Introduction

lvgl-rclib-rs

Provides a RUST api to lvgl/C lib. It supports frame-buffer for embedded devices and GTK emulation for desktop development.

Reference: https://docs.lvgl.io/8/widgets/index.html

Building dependencies

Compiling for frame-buffer

Default driver is frame-buffer, it is typically what is used for embedded devices.

  • Check FBDEV driver is enabled
  • Check EVDEV_NAME=/dev/input/??? is pointing on your mouse/touch-screen
  • Default RUST driver is 'FBDEV' EVDEV_NAME=/dev/input/lvgl should be changed or link to the right input device.
nm /usr/local/lib64/liblv_drivers.so | grep fbdev_init
cargo build

Compiling with GTK emulator

For development and especially for business logic debug with vscode/llgb-gdb, it is far simpler to use GTK than FBDEV.

  • Check GTK driver is enabled
  • Check GTK screen emulator is compile with the right size cmake -DUSE_GTK=1 -DX_RES=1024 Y_RES=600 ..
  • Select GTK by setting USE_GTK=1 environnement variable
nm /usr/local/lib64/liblv_drivers.so | grep gtk_init
USE_GTK=1 cargo build

lvgl-rust-demo

WARNING: if despite of GTK=1 you still get an error as cglue::evdev_init(); not found then either:

  • your lv_driver lib was not compiled with GTK
  • you need to touch build.rs to force _capi-map.rs reconstruction

Testing widget demo panel

cargo test --package lvgl --lib -- test::test_pannel

LVGL demo screen

Rust widget API

Check test-widget.ts for more widget and https://github.com/tux-evse/lvgl-binding-rs for a full example with a integration within lib-afb micro service framework.

Create a label

LvglLabel::new("Label-1", "Tux EvSe UI", 50, 400)
            .set_info("Demo Label widget")
            .set_size(300, 100)
            .set_color(LvglColor::rvb(0, 0, 0))
            .set_background(LvglColor::rvb(0xFF, 0xFF, 0xFF))
            .set_border(3, LvglColor::rvb(0, 0xff, 0))
            .finalize();

Create a button

LvglButton::new("Button-A", "Test-1", 100, 200)
    .set_info("Demo Button 1")
    .set_size(180, 100)
    .finalize();

Using frame-buffer without root privileges

  1. In order to test without admin privileges, you need access to
  • /dev/fb0 generally with 'video' group
  • /dev/input0 usually with 'input' group
  1. find which virtual console hold /dev/fb0 framebuffer
  • switch virtual console with (Alt+Ctrl+F1) (Alt+Ctrl+F2) ...
  • after login check with cat /dev/urandom >/dev/fb0

If your screen is repainted, then you are on /dev/fb0 other wise switch to next virtual console.

Extract a frame-buffer screen cast

Copy framebuffer and transform it yo PNG. If needed crop image to content with gimp.

cp /dev/fb0 > /tmp/screen.data
RESOLUTION="1920x1080"
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s $RESOLUTION -i /tmp/screen.data -f image2 -vcodec png screenshot.png

lvgl-rclib-rs's People

Contributors

fulup-bzh avatar ronan22 avatar

Stargazers

Harrison Chin avatar Eric Pak avatar ZhangJun avatar Kristoffer Peterhänsel avatar Lieven avatar Synchromatic avatar Oleander avatar

Watchers

 avatar Stephane Desneux avatar benierc avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.