🏁 QR Code
The QR Code widget dynamically generates a scannable 2D barcode directly on your HMI. This is essential for mobile pairing, sharing device serial numbers, or directing users to online manuals and support pages.
⚙️ Properties (Props)
The QR Code configuration is defined by the QRCodeWidget interface. The engine renders the matrix in real-time based on the string provided.
| Property | Type | Description |
|---|---|---|
| Text | string | The data to be encoded (URL, plain text, or JSON). |
| Size | number | The pixel dimensions of the square code (e.g., 120x120). |
| ECC Level | Dropdown | L, M, Q, H: Sets the error correction strength (Low to High). |
| Border | number | The thickness of the white "quiet zone" around the code. |
🛠 Error Correction (ECC)
The ecc property determines how much of the code can be damaged or obscured while remaining scannable:
- Level L (7%): Smallest footprint, best for simple URLs on small screens.
- Level M (15%): The standard balance for most industrial HMIs.
- Level Q (25%): Good for environments with high glare or screen scratches.
- Level H (30%): Maximum reliability; allows a logo to be placed in the center.
🎨 Styling for Scannability
In the Inspector Panel, ensure the QR code remains functional:
- Dark Color: Typically black (
#000000). - Light Color: Typically white (
#FFFFFF). - Contrast: Always use a light background and dark foreground. Inverting colors can make the code difficult for some mobile scanners to recognize.
⚡ Runtime API (Lua)
QR codes are most useful when they change based on the specific device state or user session.
-- Generate a QR code for a specific support ticket
local serial = system:get_serial_number()
local url = "[https://support.artok.com/ticket?id=](https://support.artok.com/ticket?id=)" .. serial
qr_support:set_text(url)
-- Update the QR code for WiFi pairing
local wifi_config = "WIFI:S:MyNetwork;T:WPA;P:MyPassword;;"
qr_wifi:set_text(wifi_config)
-- Change the background color (use with caution!)
qr_wifi:set_style_bg_color(0xFFFFFF)
The physical size of the QR code on your hardware display must be large enough for a smartphone camera to focus on. For a standard URL, a minimum size of 80x80 pixels is recommended for reliable scanning.
🚀 Next Steps
- Static Image — Use this if the QR code is a permanent, non-changing link.
- Canvas — Learn how to draw custom overlays on top of your QR code.
- Logic and Events — Learn how to generate unique session tokens via Lua.