
Recall first from Deploying Qt, input, and GPU rendering
- QT_QPA_PLATFORM (or -platform) selects the backend: eglfs renders full-screen with no display server, wayland makes the app a compositor client
- Under eglfs Qt reads evdev devices itself; under Wayland the compositor reads them via libinput and sends wl_touch, wl_pointer, and wl_keyboard events
- A renderer string of llvmpipe means Mesa fell back to CPU rendering; v3d, etnaviv, and panfrost are the hardware drivers
When a small display favors LVGL
3 min readThe Qt lesson covered full GPUs and Wayland; many embedded displays are too small and slow for that, so this lesson asks when LVGL is the right toolkit.
A real display constraint shows up in the Linux framebuffer API. It reports the number of bytes in a scan line separately from the visible resolution because a stored row can include padding. A screen that looks small can therefore require more storage than its width and height alone suggest. A CPU-rendered interface also has to write its pixels somewhere and get them to the panel. These are separate costs. Linux framebuffer API
Start with the interface the operator needs. A controller that shows a reading, reports alarms, and opens a settings screen has a small set of controls. Most of its pixels can stay the same between updates. LVGL is a strong candidate when that interface runs on a microcontroller, or on a Linux board where the UI has a tight memory budget and will draw in software. Its software renderer can run on the CPU, and its partial rendering mode lets you give it a draw buffer smaller than the display. A microcontroller can run the same C-based toolkit with a hardware-specific integration, even without Linux.
On a BeagleBone driving a small panel, the decision depends on the actual panel connection, graphics configuration, and work the CPU already has to do. For a fixed set of controls with occasional updates, LVGL lets the product use a compact UI without requiring a desktop session or a Wayland compositor. A higher-resolution operator console on a Raspberry Pi 4 or 5 may have enough resources for a richer interface. Screen size alone tells you little about how often the contents change, how many pixels an update affects, or whether the product needs desktop integration.
Qt is a good fit when the UI benefits from QML tooling, a larger application framework, or an existing Qt codebase. Qt can also run without a GPU in supported configurations. Compare how the intended screens behave with the rendering backend the product will actually ship. GTK is a good candidate when the product runs in a Linux desktop session and needs conventional windows, desktop integration, or existing GTK components. With LVGL, the team supplies application-specific services and any platform integration outside the widget library. A requirement such as desktop file dialogs or integration with desktop accessibility services can make the broader toolkit a better fit.
A useful decision starts with the most demanding screen the user will actually open. Estimate how much of it changes during a typical interaction and consider what happens while the rest of the product is busy. Check memory headroom, CPU use, and the time from a user action to its visible result. A static status page can run well on hardware that struggles to scroll a long list smoothly. Use both workloads if the product requires both.
How LVGL represents the interface
3 min readLVGL is a library linked into the application. The application creates the interface and decides what it should show. LVGL maintains the widget hierarchy, computes its layout, and draws it. The platform integration provides timing, a way to send pixels to the display, and any input devices the application needs. The C implementation can be built for a Linux process or included in microcontroller firmware. The widget code can often be reused when the platform integration changes.
In LVGL 9, an lv_display is the display object, represented in application code by an lv_display_t * (version 8 called it lv_disp_t). It associates screens with a logical resolution, a pixel format, draw buffers, and a callback that delivers rendered pixels. A screen is a root object in the hierarchy. A display can have several screens, with an active screen for the interface currently shown. The display object identifies where that interface is rendered and how the resulting pixel data leaves LVGL.
The screen contains widgets. A widget is an LVGL object that can display information, accept interaction, or group other objects. Application code generally handles widgets through lv_obj_t * pointers. A label, a button, and a container all belong to the same object system, commonly referred to as lv_obj. Each child has a parent. A temperature screen can contain a status panel, and that panel can contain a label. A settings button can have its own label as a child. This hierarchy lets LVGL place and draw related objects together. A label's text and a button's current state can change while their positions in the hierarchy stay the same.
A set of properties that controls an object's appearance and can affect its layout can specify text color, background, border width, or padding. A widget can have different properties for different states. A pressed settings button might use a different background while keeping the same label. A style can also be shared by several widgets, which is useful when they should have the same appearance.
A theme applies default styles to objects as they are created. It can give all buttons a consistent starting appearance, while the application can adjust the styling of a specific alarm button. The renderer uses the resulting properties and the widget's current state when drawing. For the temperature label, the application supplies the reading, the label holds the text, and styles control how the text appears. Next to it, the settings button can use the theme defaults until the product design calls for a different appearance.
How LVGL draws a change
3 min readWhen the application sets a new reading on the temperature label, LVGL marks an area of the display for redraw. On a refresh, the renderer uses the widget hierarchy, layout, and styles to generate pixels for the affected area. If the new reading is shorter, the old text still has to disappear. Redrawing the region includes the relevant background and the visible objects intersecting that region. A change that affects layout can make a larger area need redraw.
The memory where the renderer stores pixels before they are delivered to the display backend holds the result. In partial rendering mode, LVGL can redraw a large area in smaller chunks that fit the buffer. Each time it has pixels to deliver, LVGL calls the display's flush callback with an area and pixel data. The backend transfers those pixels to the panel or copies them into storage used for display output. If the transfer continues after the callback returns, the backend tells LVGL when it is safe to reuse the buffer.
Consider the storage for a display configured at 320 by 240 pixels with RGB565. RGB565 stores each pixel in 16 bits: five for red, six for green, and five for blue. With tightly packed rows, a buffer for the whole screen needs 320 × 240 × 2 = 153,600 bytes, or 150 KiB. A partial draw buffer large enough for 24 full-width rows needs 320 × 24 × 2 = 15,360 bytes, or 15 KiB, under the same assumptions. Here, 24 rows is a chosen buffer capacity for the calculation. The renderer may use that capacity for areas with other dimensions.
The calculation covers one draw buffer. Widget objects, fonts, images, and any extra drawing buffers also contribute to memory use. On Linux, a backend can still need a full framebuffer for display output even when LVGL draws into a small temporary buffer. With DRM/KMS, a framebuffer supplies pixel data to a display plane. Count any separately allocated display buffers when planning system memory, and account for row padding where the backend requires it. DRM KMS documentation, Linux framebuffer API
A partial buffer reduces the amount of drawing memory needed at one time. If only the temperature label changes, updating the affected region can also reduce rendering and transfer work, depending on what the backend supports. A full-screen transition may still require drawing and sending the entire screen. The CPU cost depends on what has to be drawn, and the transfer time depends on how much pixel data the backend sends and how quickly it can deliver it. Both matter to the operator waiting for the display to respond.
The next lesson, Porting and building LVGL on Linux, puts these pieces into a Linux program and shows how to connect the library to a display backend.
Key takeaways
- LVGL can render in software and can use a draw buffer smaller than the display.
- An LVGL display object associates screens with display configuration, draw buffers, and a way to deliver rendered pixels.
- Widgets hold UI state, styles supply drawing properties, and themes apply default styles.
- The renderer produces pixels, and the display backend delivers them.
Reflect
- Explain to a colleague, in two sentences: choose between LVGL, Qt, and GTK using product requirements and hardware constraints.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Kernel documentationDRM KMS: display pipelines and framebuffers
- Kernel documentationThe Frame Buffer Device API: pixel formats and line length
- LVGL documentationLVGL display overview
- LVGL documentationLVGL objects
Official documentation first. Links checked when the lesson was published.