Can not compile Arduino sketch with canvas widget

Hello, I´m trying implement canvas widget in to my project, and I can not make it compile.

Compiler is returning this error:

C:\Users\zuzelka.CML\Documents\GitHub\Web_radio\Web_radio\Web_radio.ino: In function 'void setup()':
c:/Users/zuzelka.CML/Dropbox/@Arduino/Arduino/libraries/lvgl/src/draw/lv_draw_buf.h:51:20: error: storage size of 'buf_draw_buff' isn't constant
   51 |     static uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
      |                    ^~~~
C:\Users\zuzelka.CML\Documents\GitHub\Web_radio\Web_radio\Web_radio.ino:425:3: note: in expansion of macro 'LV_DRAW_BUF_DEFINE_STATIC'
  425 |   LV_DRAW_BUF_DEFINE_STATIC(draw_buff, CANVAS_FFT_WIDTH, CANVAS_FFT_HEIGHT, LV_COLOR_FORMAT_RGB565);

What MCU/Processor/Board and compiler are you using?

ESP32-S3 with Arduino & LVGL v9.2.2

What do you want to achieve?

Use canvas widget in my project.

What have you tried so far?

I did look at documentation, look at topics here and issues at Github, but did not find solution to my problem.

Code to reproduce

  /*Create a buffer for the canvas*/
  LV_DRAW_BUF_DEFINE_STATIC(draw_buff, CANVAS_FFT_WIDTH, CANVAS_FFT_HEIGHT, LV_COLOR_FORMAT_RGB565);
  LV_DRAW_BUF_INIT_STATIC(draw_buff);
  // /*Create a canvas and initialize its palette*/
  ui_CanvasFFT = lv_canvas_create(ui_Screen1);
  lv_canvas_set_draw_buf(ui_CanvasFFT, &draw_buff);
  lv_canvas_fill_bg(ui_CanvasFFT, lv_color_hex3(0xccc), LV_OPA_COVER);
  lv_obj_center(ui_CanvasFFT);

  lv_layer_t layer;
  lv_canvas_init_layer(ui_CanvasFFT, &layer);
  lv_canvas_finish_layer(ui_CanvasFFT, &layer);

Whole code of my project can be seen here.

Does anybody encountered similar issue?

Many thanks for any help.

Solved! :slightly_smiling_face:

I did find out that I can not define canvas width via a variable from the graphic library.

#define CANVAS_FFT_WIDTH screenWidth // <- create error
#define CANVAS_FFT_WIDTH 400  // <-this works