lv_barcode.h
API reference for lv_barcode.h
Functions
lv_barcode_set_dark_color
Set the dark color of a barcode object. Only rewrites the palette, so it takes effect before or after the data and never regenerates the bars.
void lv_barcode_set_dark_color(lv_obj_t *obj, lv_color_t color)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
color | lv_color_t | dark color of the barcode |
lv_barcode_set_light_color
Set the light color of a barcode object. Only rewrites the palette, so it takes effect before or after the data and never regenerates the bars.
void lv_barcode_set_light_color(lv_obj_t *obj, lv_color_t color)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
color | lv_color_t | light color of the barcode |
lv_barcode_set_scale
Set the scale of a barcode object, i.e. the pixel width of a single bar. The stored data is re-generated, so this may be called before or after the data.
void lv_barcode_set_scale(lv_obj_t *obj, uint16_t scale)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
scale | uint16_t | scale factor; must be at least 1 |
lv_barcode_set_direction
Set the direction of a barcode object. The stored data is re-generated, so this may be called before or after the data.
void lv_barcode_set_direction(lv_obj_t *obj, lv_dir_t direction)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
direction | lv_dir_t | draw direction (LV_DIR_HOR or LV_DIR_VER) |
lv_barcode_set_tiled
Set the tiled mode of a barcode object. The stored data is re-generated, so this may be called before or after the data.
void lv_barcode_set_tiled(lv_obj_t *obj, bool tiled)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
tiled | bool | true: tiled mode, false: normal mode (default) |
lv_barcode_set_encoding
Set the encoding of a barcode object. The stored data is re-generated, so this may be called before or after the data.
void lv_barcode_set_encoding(lv_obj_t *obj, lv_barcode_encoding_t encoding)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
encoding | lv_barcode_encoding_t | encoding (default is LV_BARCODE_ENCODING_CODE128_GS1) |
lv_barcode_set_update_mode
Set when a change is turned into a new barcode bitmap. Applies to the data and to the scale, direction, tiled mode and encoding; the colors are never affected.
void lv_barcode_set_update_mode(lv_obj_t *obj, lv_barcode_update_mode_t mode)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
mode | lv_barcode_update_mode_t | the mode to use |
Only the fill is deferred. The canvas is resized in the setter in both modes, because the draw pass cannot reallocate it.
Deferred mode expects an explicit lv_barcode_render(), which returns the result. Forgetting it still gives the right bitmap, but the redraw does the work and warns, and no caller is left to see a failure.
Switching back to IMMEDIATE while out of date also regenerates, but this returns void, so a failure is only logged. Render first to get the result.
lv_barcode_get_update_mode
Get when a property change is turned into a new barcode bitmap.
lv_barcode_update_mode_t lv_barcode_get_update_mode(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: lv_barcode_update_mode_t — the update mode currently in use
lv_barcode_get_dark_color
Get the dark color of a barcode object
lv_color_t lv_barcode_get_dark_color(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: lv_color_t — dark color of the barcode
lv_barcode_get_light_color
Get the light color of a barcode object
lv_color_t lv_barcode_get_light_color(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: lv_color_t — light color of the barcode
lv_barcode_get_scale
Get the scale of a barcode object
uint16_t lv_barcode_get_scale(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: uint16_t — scale factor
lv_barcode_get_encoding
Get the encoding of a barcode object
lv_barcode_encoding_t lv_barcode_get_encoding(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to barcode object |
Returns: lv_barcode_encoding_t — encoding
lv_barcode_create
Create an empty barcode (an lv_canvas) object.
lv_obj_t * lv_barcode_create(lv_obj_t *parent)| Name | Type | Description |
|---|---|---|
parent | lv_obj_t * | pointer to a parent widget May be NULL.. When NULL, the widget is created as a screen on the active display. |
Returns: lv_obj_t * — pointer to the created barcode object
lv_barcode_update
Set the data of a barcode object and generate the bitmap. A copy is stored, so a later property change or resize can regenerate it; the properties may be set before or after the data, in any order.
lv_result_t lv_barcode_update(lv_obj_t *obj, const char *data)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
data | const char * | data to display as a NUL terminated string |
Returns: lv_result_t — LV_RESULT_OK: if no error; LV_RESULT_INVALID: on error
Obeys the update mode. In DEFERRED the canvas is only resized here, so the return value reports that resize, not the bars.
lv_barcode_render
(Re)generate the barcode bitmap from the stored data, whether or not anything changed. Needs no data argument, which is how deferred changes are applied.
lv_result_t lv_barcode_render(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: lv_result_t — LV_RESULT_OK: if no error; LV_RESULT_INVALID: on error (e.g. no data set, or the bars do not fit the current object size)
lv_barcode_is_render_valid
Check whether the bitmap is free of a known generation failure. lv_barcode_render(), and lv_barcode_update() in IMMEDIATE mode, return their result directly; the rest cannot - they run in a void setter, the resize handler, or a deferred fill in the draw pass. Use this for those, e.g. after shrinking the object below the size its data needs.
bool lv_barcode_is_render_valid(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to barcode object |
Returns: bool — true: no generation attempt is known to have failed. A change re-arms the Widget, so this is also true while a deferred regeneration is still pending; false: the last generation attempt failed, or no data has been set yet
A failure is not retried every redraw; only a change makes the Widget try again.
Enums
lv_barcode_encoding_t
| Name | Description |
|---|---|
LV_BARCODE_ENCODING_CODE128_GS1 | Code 128 with GS1 encoding. Strips [FCN1] and spaces. |
LV_BARCODE_ENCODING_CODE128_RAW | Code 128 with raw encoding. |
Used by 1 function
lv_barcode_set_encoding— paramencoding
lv_barcode_update_mode_t
Controls when a change is turned into a new barcode bitmap. Applies to the data too. The colors are always a palette-only write, so they are never affected.
| Name | Value | Description |
|---|---|---|
LV_BARCODE_UPDATE_MODE_IMMEDIATE | 0 | Re-generate as soon as a property changes (default) |
LV_BARCODE_UPDATE_MODE_DEFERRED | Only mark the bitmap out of date and re-generate once, on the next redraw |
Used by 1 function
lv_barcode_set_update_mode— parammode
Variables
lv_barcode_class
const lv_obj_class_t lv_barcode_classDependencies
Indirect dependencies
lv_anim.hlv_area.hlv_assert.hlv_bidi.hlv_color_op.hlv_display.hlv_draw.hlv_draw_arc.hlv_draw_blur.hlv_draw_buf.hlv_draw_image.hlv_draw_label.hlv_draw_line.hlv_draw_rect.hlv_draw_triangle.hlv_event.hlv_ext_data.hlv_flex.hlv_font.hlv_fs.hlv_grad.hlv_grid.hlv_group.hlv_image.hlv_image_decoder.hlv_image_dsc.hlv_indev.hlv_layout.hlv_ll.hlv_log.hlv_math.hlv_matrix.hlv_mem.hlv_obj.hlv_obj_class.hlv_obj_draw.hlv_obj_event.hlv_obj_pos.hlv_obj_property.hlv_obj_scroll.hlv_obj_style.hlv_obj_style_gen.hlv_obj_tree.hlv_observer.hlv_palette.hlv_profiler.hlv_profiler_builtin.hlv_sprintf.hlv_string.hlv_style.hlv_style_gen.hlv_symbol_def.hlv_text.hlv_timer.h
Last updated on