1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

chore: fix warnings

This commit is contained in:
Gabor Kiss-Vamosi 2023-07-15 20:59:41 +02:00
parent 657dfe9615
commit 7b1a363ecb
3 changed files with 31 additions and 30 deletions

View File

@ -1,42 +1,45 @@
#include "../../lv_examples.h" #include "../../lv_examples.h"
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES && 0 #if LV_USE_CANVAS && LV_BUILD_EXAMPLES
#define CANVAS_WIDTH 50 #define CANVAS_WIDTH 80
#define CANVAS_HEIGHT 50 #define CANVAS_HEIGHT 40
/** /**
* Create a transparent canvas with Chroma keying and indexed color format (palette). * Create a transparent canvas with transparency
*/ */
void lv_example_canvas_2(void) void lv_example_canvas_2(void)
{ {
/*Create a button to better see the transparency*/ lv_obj_set_style_bg_color(lv_scr_act(), lv_palette_lighten(LV_PALETTE_RED, 5), 0);
lv_btn_create(lv_scr_act());
/*Create a buffer for the canvas*/ /*Create a buffer for the canvas*/
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT)]; static uint8_t cbuf[CANVAS_WIDTH * CANVAS_HEIGHT * 4];
/*Create a canvas and initialize its palette*/ /*Create a canvas and initialize its palette*/
lv_obj_t * canvas = lv_canvas_create(lv_scr_act()); lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_I1); lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
lv_canvas_set_palette(canvas, 0, lv_color_to32(LV_COLOR_CHROMA_KEY)); lv_obj_center(canvas);
lv_canvas_set_palette(canvas, 1, lv_color_to32(lv_palette_main(LV_PALETTE_RED)));
/*Create colors with the indices of the palette*/
lv_color_t c0;
lv_color_t c1;
lv_color_set_int(&c0, 0);
lv_color_set_int(&c1, 1);
/*Red background (There is no dedicated alpha channel in indexed images so LV_OPA_COVER is ignored)*/ /*Red background (There is no dedicated alpha channel in indexed images so LV_OPA_COVER is ignored)*/
lv_canvas_fill_bg(canvas, c1, LV_OPA_COVER); lv_canvas_fill_bg(canvas, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_COVER);
/*Create hole on the canvas*/ /*Create hole on the canvas*/
uint32_t x; uint32_t x;
uint32_t y; uint32_t y;
for(y = 10; y < 30; y++) { for(y = 10; y < 20; y++) {
for(x = 5; x < 20; x++) { for(x = 5; x < 75; x++) {
lv_canvas_set_px(canvas, x, y, c0, LV_OPA_COVER); lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_50);
}
}
for(y = 20; y < 30; y++) {
for(x = 5; x < 75; x++) {
lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_20);
}
}
for(y = 30; y < 40; y++) {
for(x = 5; x < 75; x++) {
lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_0);
} }
} }
} }

View File

@ -56,20 +56,18 @@ void lv_example_canvas_6(void);
void lv_example_canvas_7(void); void lv_example_canvas_7(void);
void lv_example_chart_1(void); void lv_example_chart_1(void);
void lv_example_chart_2(void); //void lv_example_chart_2(void);
void lv_example_chart_3(void); //void lv_example_chart_3(void);
void lv_example_chart_4(void); void lv_example_chart_4(void);
void lv_example_chart_5(void); void lv_example_chart_5(void);
void lv_example_chart_6(void); void lv_example_chart_6(void);
void lv_example_chart_7(void); void lv_example_chart_7(void);
void lv_example_chart_8(void); //void lv_example_chart_8(void);
void lv_example_chart_9(void); void lv_example_chart_9(void);
void lv_example_checkbox_1(void); void lv_example_checkbox_1(void);
void lv_example_checkbox_2(void); void lv_example_checkbox_2(void);
void lv_example_colorwheel_1(void);
void lv_example_dropdown_1(void); void lv_example_dropdown_1(void);
void lv_example_dropdown_2(void); void lv_example_dropdown_2(void);
void lv_example_dropdown_3(void); void lv_example_dropdown_3(void);
@ -87,7 +85,7 @@ void lv_example_keyboard_2(void);
void lv_example_label_1(void); void lv_example_label_1(void);
void lv_example_label_2(void); void lv_example_label_2(void);
void lv_example_label_3(void); void lv_example_label_3(void);
void lv_example_label_4(void); //void lv_example_label_4(void);
void lv_example_label_5(void); void lv_example_label_5(void);
void lv_example_led_1(void); void lv_example_led_1(void);
@ -105,7 +103,7 @@ void lv_example_menu_5(void);
void lv_example_meter_1(void); void lv_example_meter_1(void);
void lv_example_meter_2(void); void lv_example_meter_2(void);
void lv_example_meter_3(void); //void lv_example_meter_3(void);
void lv_example_meter_4(void); void lv_example_meter_4(void);
void lv_example_msgbox_1(void); void lv_example_msgbox_1(void);
@ -115,7 +113,7 @@ void lv_example_obj_2(void);
void lv_example_roller_1(void); void lv_example_roller_1(void);
void lv_example_roller_2(void); void lv_example_roller_2(void);
void lv_example_roller_3(void); //void lv_example_roller_3(void);
void lv_example_slider_1(void); void lv_example_slider_1(void);
void lv_example_slider_2(void); void lv_example_slider_2(void);

View File

@ -23,7 +23,7 @@ extern "C" {
#define LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) ((LV_COLOR_DEPTH / 8) * (w) * (h)) #define LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) ((LV_COLOR_DEPTH / 8) * (w) * (h))
#define LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) ((LV_COLOR_DEPTH / 8) * (w) * (h)) #define LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) ((LV_COLOR_DEPTH / 8) * (w) * (h))
#define LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) (LV_COLOR_FORMAT_NATIVE_ALPHA_SIZE * (w) * (h)) #define LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) (_LV_COLOR_NATIVE_WITH_ALPHA_SIZE * (w) * (h))
/*+ 1: to be sure no fractional row*/ /*+ 1: to be sure no fractional row*/
#define LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) (((((w) + 7) / 8) * (h))) #define LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) (((((w) + 7) / 8) * (h)))