![ARCH](https://shields.microej.com/endpoint?url=https://repository.microej.com/packages/badges/arch_7.16.json)

# Overview

This Abstraction Layer implements a part of the MicroUI Low Level API, described in [LLUI_DISPLAY: Display](https://docs.microej.com/en/latest/VEEPortingGuide/appendix/llapi.html#llui-display-display), [LLUI_INPUT: Input](https://docs.microej.com/en/latest/VEEPortingGuide/appendix/llapi.html#llui-input-input) and [LLUI_LED: LEDs](https://docs.microej.com/en/latest/VEEPortingGuide/appendix/llapi.html#llui-led-leds): the MicroUI and Drawing drawing natives, the display buffer refresh strategies, an images heap allocator and an events logger.
It redirects each drawing to the drawer of the destination: the software drawing of the Graphics Engine by default, or a GPU Abstraction Layer.
See the [MicroUI](https://docs.microej.com/en/latest/VEEPortingGuide/uiCco.html#c-module-microui) section of the MicroEJ documentation.

This Abstraction Layer is tied to the MicroEJ UI Pack: the versions it is compatible with are listed in the [compatibility](https://docs.microej.com/en/latest/VEEPortingGuide/uiReleaseNotes.html#microui-c-module) tables of the documentation.
The badge above gives the oldest MicroEJ Architecture it supports, not the latest one: the [MicroEJ Architecture Compatibility Version](https://docs.microej.com/en/latest/VEEPortingGuide/uiReleaseNotes.html#microej-architecture-compatibility-version) tables list the Architectures of each UI Pack version.

# Usage

1. Add the sources of this Abstraction Layer to the BSP of the VEE Port, in either of these two ways:

   - From the MicroEJ repository: install the `.cco` archive of the version the VEE Port needs, as the [installation guide](https://docs.microej.com/en/latest/VEEPortingGuide/appendix/cmodules.html) describes.
     The headers land in `bsp/vee/port/ui/inc` and the sources in `bsp/vee/port/ui/src`.
   - From GitHub: add the [GitHub repository](https://github.com/MicroEJ/AbstractionLayer-UI) to the BSP of the VEE Port as a git submodule, at the tag of the version the VEE Port needs.
     The VEE Port chooses the folder of the submodule, and either of these two layouts works.
     A flat folder sits beside the other components of the BSP:

     ```sh
     git submodule add https://github.com/MicroEJ/AbstractionLayer-UI.git bsp/vee/port/ui
     git -C bsp/vee/port/ui checkout <version>
     ```

     A folder grouped by domain sits under the folder of the other components of the same domain:

     ```sh
     git submodule add https://github.com/MicroEJ/AbstractionLayer-UI.git bsp/vee/port/ui/UI
     git -C bsp/vee/port/ui/UI checkout <version>
     ```

     The headers then sit in `<folder>/src/main/c/inc` and the sources in `<folder>/src/main/c/src`, where `<folder>` is the folder of the submodule.
     A copy of these sources in the VEE Port repository works as well.

   Then add the folder of the headers to the include paths of the BSP project, and the files of the folder of the sources to its sources.

2. The configuration file [ui_configuration.h](src/main/c/inc/ui_configuration.h) stores the default values of the Abstraction Layer options.
   To change an option, define it in the file `veeport_configuration.h` of the VEE Port, which `ui_configuration.h` includes first.

3. When the VEE Port moves to another version of this Abstraction Layer, follow the [MicroUI migration guide](https://docs.microej.com/en/latest/VEEPortingGuide/uiMigrationGuide.html).

# Requirements

None.

# Validation

This Abstraction Layer is tested on the following boards:

- MIMXRT595-EVK.
- STM32F429I-EVAL.
- STM32U5A9J-DK.
- Linux.

# MISRA Compliance

This Abstraction Layer is MISRA-compliant (MISRA C:2012) with some noted exceptions.
It has been verified with Cppcheck v2.13.
Here is the list of deviations from the MISRA standard:

| Deviation  | Category  | Justification                                                                                               |
|:----------:|:---------:|:----------------------------------------------------------------------------------------------------------- |
| Rule 2.5   | Advisory  | A macro can be defined at API level and not used by the application.                                        |
| Rule 5.9   | Advisory  | The same static function name can be used in several C files.                                               |
| Rule 8.4   | Required  | The compatible declarations are the UI Pack's functions.                                                    |
| Rule 8.7   | Advisory  | The LLAPI functions require external linkage, but cppcheck cannot detect their invocation by the Pack.      |
| Rule 8.9   | Advisory  | The code is clearer with the object defined at file scope.                                                  |
| Rule 10.3  | Required  | The buffer address of a display buffer refresh strategy advances by its stride in bytes, an unsigned value. |
| Rule 10.4  | Required  | The masks of the event decoder macros are signed constants applied to unsigned event data.                  |
| Rule 10.6  | Required  | The format of a custom font or of a custom image is converted to an index.                                  |
| Rule 11.1  | Required  | The event decoder casts an unused function pointer parameter to `void`.                                     |
| Rule 11.3  | Required  | The cast factorizes code, as in many C frameworks.                                                          |
| Rule 11.4  | Advisory  | The best fit allocator of the images heap takes the heap bounds as integers.                                |
| Rule 14.2  | Required  | The loop counter is not incremented at every iteration.                                                     |
| Rule 17.3  | Mandatory | The implicitly declared functions are the UI Pack's functions.                                              |
| Rule 18.4  | Advisory  | Pointer arithmetic can be used in a configurable C library.                                                 |
| Rule 20.7  | Required  | The event decoder passes a macro parameter to another macro, which encloses it in parentheses.              |
| Rule 20.10 | Advisory  | The `#` and `##` operators are used by MicroEJ Architectures.                                               |
| Rule 21.6  | Required  | `UI_DEBUG_PRINT` defaults to `printf`.                                                                      |

# Dependencies

None.

# Changelog

The changes of this Abstraction Layer are listed in the [public changelog of the MicroEJ UI Pack](https://docs.microej.com/en/latest/VEEPortingGuide/uiChangeLog.html), section `C Module MicroUI`.

# Source

- `ui_configuration.h`: the options of the Abstraction Layer.
- `LLUI_PAINTER_impl.c`, `LLDW_PAINTER_impl.c`: the drawing natives of the MicroUI and Drawing libraries.
- `ui_drawing.h`, `ui_drawing.c`: the redirection of the drawing functions to the drawer of the destination.
- `ui_drawing_stub.h`, `ui_drawing_stub.c`: the stubbed drawing functions.
- `ui_font_drawing.h`, `ui_font_drawing.c`, `ui_image_drawing.h`, `ui_image_drawing.c`: the drawing of the fonts and of the images, standard or custom.
- `ui_display_brs.h`, `ui_display_brs.c`, `ui_display_brs_legacy.c`, `ui_display_brs_predraw.c`, `ui_display_brs_single.c`: the display buffer refresh strategies.
- `microui_heap.h`, `LLUI_DISPLAY_HEAP_impl.c`: the best fit allocator of the MicroUI images heap.
- `LLUI_INPUT_LOG_impl.c`, `microui_event_decoder.h`, `microui_event_decoder.c`: the logger of the MicroUI events.
- `ui_rect_util.h`, `ui_rect_util.c`, `ui_rect_collection.h`: the rectangles.
- `ui_color.h`, `ui_util.h`, `ui_log.h`, `ui_trace.h`: the helpers shared by the other files, the logs and the traces.

# Restrictions

None.

---
_Copyright 2020-2026 MicroEJ Corp. All rights reserved._\
_MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms._