๐จ Bit Depth (BPP)
In the context of Artok and embedded systems, Bit Depth (Bits Per Pixel) determines how much memory each pixel occupies and how many colors can be displayed simultaneously. Choosing the right BPP is the most important decision for balancing visual quality against hardware constraints.
โ๏ธ Supported Color Depthsโ
Artok supports several standard color formats, configurable within the Project Settings.
| Format | BPP | Max Colors | Best For... |
|---|---|---|---|
| 1-bit | 1 | 2 (Monochrome) | E-Ink displays, OLEDs, and low-power IoT. |
| 8-bit | 8 | 256 (Palette) | Simple icons, navigation menus, and maps. |
| 16-bit | 16 | 65,535 (RGB565) | Most MCU displays (standard for STM32/ESP32). |
| 24-bit | 24 | 16.7 Million | High-end Embedded Linux / Automotive UIs. |
| 32-bit | 32 | 16.7M + Alpha | UIs requiring true transparency and anti-aliasing. |
๐ Memory Math (RAM Usage)โ
To calculate the RAM required for a single full-screen frame buffer, use this formula:
Width ร Height ร (BPP รท 8) = Bytes
Example: 320x240 Display
- 16-bit (RGB565):
320 ร 240 ร 2 = 153,600 Bytes(~150 KB) - 32-bit (ARGB8888):
320 ร 240 ร 4 = 307,200 Bytes(~300 KB)
If you enable "Double Buffering" for tear-free animations, you must multiply the result by 2.
๐จ Transparency and Alphaโ
- Alpha Blending: Requires at least 8-bit alpha (found in 32-bit mode) or 1-bit "chroma keying" (transparent color) in lower BPP modes.
- Anti-aliasing: To have smooth, rounded edges on fonts and circles, the engine needs enough bit depth to calculate "shades" between the object and the background.
๐ Optimization Strategiesโ
If your project is running out of Flash (Storage) or RAM (Memory):
- Reduce Global BPP: Dropping from 32-bit to 16-bit (RGB565) immediately cuts memory usage by 50% with minimal loss in quality for small screens.
- Per-Asset Overrides: The Asset Packer allows you to keep the system at 16-bit but compress simple icons down to 8-bit Indexed or 4-bit Alpha maps.
- Dithering: Enable dithering in the Studio to simulate more colors on low-BPP hardware, reducing "banding" in gradients.
โก Runtime API (Lua)โ
While BPP is usually a build-time setting, you can query the system status in Lua to adjust UI complexity.
-- Check the current system color depth
local depth = system:get_color_depth()
if depth < 16 then
-- Disable complex gradients for low-spec hardware
btn_main:set_style_bg_grad_dir(LV_GRAD_DIR_NONE)
app:notify("Low Color Mode Active")
end
Your physical display controller (LCD Driver) must support the BPP you select. If you set Artok to 32-bit but your screen is wired for 16-bit RGB565, the colors will appear distorted or "inverted."
๐ Next Stepsโ
- Asset Packer โ Learn how to transcode images to match your BPP.
- Custom Fonts โ Anti-aliasing settings for typography.
- Firmware Integration โ Configuring the
LV_COLOR_DEPTHin your C header.