feat(barcode): add none tiled mode (#6462)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
VIFEX
2024-07-10 01:49:36 +08:00
committed by GitHub
parent ba7630ff53
commit ca70164c6b
9 changed files with 125 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -27,6 +27,7 @@ void test_barcode_normal(void)
lv_color_t dark_color = lv_color_black();
lv_color_t light_color = lv_color_white();
uint16_t scale = 2;
lv_result_t res;
lv_barcode_set_dark_color(barcode, dark_color);
lv_barcode_set_light_color(barcode, light_color);
@@ -36,26 +37,35 @@ void test_barcode_normal(void)
TEST_ASSERT_EQUAL_COLOR(lv_barcode_get_light_color(barcode), light_color);
TEST_ASSERT_EQUAL(lv_barcode_get_scale(barcode), scale);
/* Test horizontal mode */
lv_barcode_set_direction(barcode, LV_DIR_HOR);
lv_result_t res = lv_barcode_update(barcode, "https://lvgl.io");
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
lv_image_dsc_t * image_dsc = lv_canvas_get_image(barcode);
TEST_ASSERT_NOT_NULL(image_dsc);
lv_obj_set_size(barcode, image_dsc->header.w, 50);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/barcode_1.png");
lv_barcode_set_direction(barcode, LV_DIR_VER);
lv_obj_set_height(barcode, 50);
res = lv_barcode_update(barcode, "https://lvgl.io");
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/barcode_1.png");
image_dsc = lv_canvas_get_image(barcode);
TEST_ASSERT_NOT_NULL(image_dsc);
lv_obj_set_size(barcode, 50, image_dsc->header.h);
/* Test vertical mode */
lv_barcode_set_direction(barcode, LV_DIR_VER);
lv_obj_set_size(barcode, 50, LV_SIZE_CONTENT);
res = lv_barcode_update(barcode, "https://lvgl.io");
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/barcode_2.png");
/* Test tiled + horizontal mode */
lv_barcode_set_tiled(barcode, true);
lv_barcode_set_direction(barcode, LV_DIR_HOR);
lv_obj_set_size(barcode, LV_SIZE_CONTENT, 50);
res = lv_barcode_update(barcode, "https://lvgl.io");
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/barcode_tiled_1.png");
/* Test tiled + vertical mode */
lv_barcode_set_direction(barcode, LV_DIR_VER);
lv_obj_set_size(barcode, 50, LV_SIZE_CONTENT);
res = lv_barcode_update(barcode, "https://lvgl.io");
TEST_ASSERT_EQUAL(res, LV_RESULT_OK);
TEST_ASSERT_EQUAL_SCREENSHOT("libs/barcode_tiled_2.png");
}
#else