Simple Arduino lvgl example using online image converter

Is there a really simple example of displaying an image using lvgl in Arduino using the Online image converter - BMP, JPG or PNG to C array or binary | LVGL? I'm using the image as a variable using the contents from the generated file from the online image converter in LVGL with the output format being a c array.

I have tried following the lvgl docs Images — LVGL documentation, and looked at the GitHub example lvgl/LVGL_Arduino.ino at master · lvgl/lvgl (github.com), but I'm just fighting through error after error and it seems like I'm getting further from basic solution.

I just want to show an image in the device (smart watch screen)...I guess on setup.

My current error is this:

image1.h:253:3: error: expected primary-expression before '.' token
   .header.cf = LV_IMG_CF_TRUE_COLOR,
   ^
image1.h:254:3: error: expected primary-expression before '.' token
   .header.always_zero = 0,
   ^
image1.h:255:3: error: expected primary-expression before '.' token
   .header.reserved = 0,
   ^
image1.h:256:3: error: expected primary-expression before '.' token
   .header.w = 50,
   ^
image1.h:257:3: error: expected primary-expression before '.' token
   .header.h = 50,
   ^
exit status 1
expected primary-expression before '.' token

For this code:

const lv_img_dsc_t icon1 = {
  .header.cf = LV_IMG_CF_TRUE_COLOR,
  .header.always_zero = 0,
  .header.reserved = 0,
  .header.w = 50,
  .header.h = 50,
  .data_size = 2500 * LV_COLOR_SIZE / 8,
  .data = icon1_map,
};

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

You will get far better help if you post your full code.

I think the problem is that the version of C++ supported by the IDE does not support initializing structure fields by name. You should be able to initialize the "lv_img_dsc_t" structure by specifying the field values in order.

const lv_img_dsc_t icon1 = {
  // header
  {
  50, // h
  50, // w
  0, // reserved:2
  0, // always_zero:3
  LV_IMG_CF_TRUE_COLOR, // cf:5
  },
  2500 * LV_COLOR_SIZE / 8, // data_size
  icon1_map // data
};

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.