Barcode

The LVGL Barcode utility enables you to generate Code-128 bar codes. It uses the code128 library by fhunleth.

Edit on GitHub

The LVGL Barcode utility enables you to generate Code-128 bar codes. It uses the code128 library by fhunleth.

Usage

Set LV_USE_BARCODE to 1 in lv_conf.h.

Use lv_barcode_create to create a barcode object, and use lv_barcode_update to generate a barcode.

Call lv_barcode_set_scale to adjust scaling, call lv_barcode_set_dark_color and lv_barcode_set_light_color adjust colors. Call lv_barcode_set_direction to set the bar code's orientation.

By default, LV_BARCODE_ENCODING_CODE128_GS1 encoding is used and strips [FCN1] and spaces. Optionally use lv_barcode_set_encoding to set LV_BARCODE_ENCODING_CODE128_RAW.

After any of a bar code's settings have changed, call lv_barcode_update again to regenerate it.

Notes

  • It is best not to manually set the width of the barcode, because when the width of the Widget is lower than the width of the barcode, the display will be incomplete due to truncation.
  • The scale adjustment can only be an integer multiple, for example, lv_barcode_set_scale(barcode, 2) means 2x scaling.
  • The direction setting can be LV_DIR_HOR or LV_DIR_VER.

Example

Create a Barcode

API

How is this guide?

Last updated on

On this page