framebuffer_qr_writer example

The example demonstrates how to set up a graphical user interface (GUI) in a KasperskyOS-based solution using a set of cross-platform libraries: SDL2 for managing the application window and processing user data input, Nuklear for building the graphical interface, Skia as a graphics rendering engine, and ZXing for generating QR codes.

Example directory in the SDK

The code of the example and build scripts are available at the following path:

/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/framebuffer_qr_writer

List of programs

When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:

Initialization description

The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@‌ ‌format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.

Security policy description

The security.psl file contains a description of a security policy for a KasperskyOS-based solution and is located in the ./einit/src directory. The declarations in the PSL file are provided with comments that explain the purpose of these declarations.

The solution security policy description in this example allows any interaction between different processes and between processes and the kernel. This policy can be used only as a stub during the early stages of a solution development so that the security module does not interfere with interactions. It would be unacceptable to apply such a policy in a real-world KasperskyOS-based solution.

Resources

The ./resources/hdd/etc directory includes the ProggyClean.ttf file, which contains information about the font (name, size, style). This file is used to display text in the graphical user interface.

Operating scenario

The QrWriter program performs the following actions:

  1. Uses the SDL2 library to initialize the video subsystem and create a full-screen application window.
  2. Uses the Skia library to configure the graphics context based on the window surface information received from SDL2.
  3. Uses the Nuklear library to initialize the graphical interface via the nuklear_skia implementation.
  4. In an infinite loop:
    • Handles input: uses SDL2 to poll the system event queue and uses Nuklear to convert events into graphical interface state changes.
    • Renders the graphical interface: uses Nuklear to generate commands for rendering controls in Immediate Mode.
    • Generates a QR code: when the button is clicked, it uses the ZXing library to convert the text into a monochrome bitmap image.
    • Renders a frame: uses the Skia library to execute drawing commands and generate the final image in the frame buffer.
    • Displays on screen: uses SDL2 to update the window surface with the contents of the frame buffer.

Building and running the example

The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.

See Building and running examples section.

Page top