I am studying examples of obtaining gradients
I wanted to get an image on the display in the form of a color wheel
I wrote this code
// Color wheel
void create_color_wheel(void)
{
static lv_style_t style;
lv_style_init(&style);
// Defining colors for the gradient
static lv_color_t grad_colors[2] = {
// LV_COLOR_MAKE(0x9B, 0x18, 0x42), // Violet
// LV_COLOR_MAKE(0x00, 0x00, 0x00), // Black
};
// static lv_color_t grad_colors[3] = {
LV_COLOR_MAKE(0xFF, 0x00, 0x00), // Red
LV_COLOR_MAKE(0xFF, 0x7F, 0x00), // Orange
LV_COLOR_MAKE(0xFF, 0xFF, 0x00), // Yellow
// };
// static lv_color_t grad_colors[7] = {
// LV_COLOR_MAKE(0xFF, 0x00, 0x00), // Red
// LV_COLOR_MAKE(0xFF, 0x7F, 0x00), // Orange
// LV_COLOR_MAKE(0xFF, 0xFF, 0x00), // Yellow
// LV_COLOR_MAKE(0x00, 0xFF, 0x00), // Green
// LV_COLOR_MAKE(0x00, 0x00, 0xFF), // Blue
// LV_COLOR_MAKE(0x4B, 0x00, 0x82), // Dark Blue
// LV_COLOR_MAKE(0x8B, 0x00, 0x8B), // Violet
// };
// Create params of gradient
static lv_grad_dsc_t grad;
lv_grad_init_stops(&grad, grad_colors, NULL, NULL, sizeof(grad_colors) / sizeof(lv_color_t));
// Create radial gradient
lv_grad_radial_init(&grad, LV_GRAD_CENTER, LV_GRAD_CENTER, LV_GRAD_RIGHT, LV_GRAD_BOTTOM, LV_GRAD_EXTEND_PAD);
// Set fradient as fone
lv_style_set_bg_grad(&style, &grad);
// Create an object with a new style
lv_obj_t * obj = lv_obj_create(lv_scr_act()); // Create an object on the active screen
lv_obj_add_style(obj, &style, 0); // Add style
lv_obj_set_size(obj, 400, 400); // Set size
lv_obj_center(obj); // Center the object on the screen
}
But apparently the function
lv_grad_radial_init
does not accept more than two colors.
The code is loaded into the device and it enters a cyclic reboot.
What am I doing wrong?