diff --git a/examples/layouts/flex/lv_example_flex_1.c b/examples/layouts/flex/lv_example_flex_1.c index 52c2653185..45c76d5b31 100644 --- a/examples/layouts/flex/lv_example_flex_1.c +++ b/examples/layouts/flex/lv_example_flex_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES /** * A simple row and a column layout with flexbox diff --git a/examples/layouts/flex/lv_example_flex_2.c b/examples/layouts/flex/lv_example_flex_2.c index 3b45de1e92..ac0cf9aab7 100644 --- a/examples/layouts/flex/lv_example_flex_2.c +++ b/examples/layouts/flex/lv_example_flex_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES /** * Arrange items in rows with wrap and place the items to get even space around them. diff --git a/examples/layouts/flex/lv_example_flex_3.c b/examples/layouts/flex/lv_example_flex_3.c index f8a3726af0..a608397a8f 100644 --- a/examples/layouts/flex/lv_example_flex_3.c +++ b/examples/layouts/flex/lv_example_flex_3.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES /** * Use a built in flex layout and demonstrate flex grow. diff --git a/examples/layouts/flex/lv_example_flex_4.c b/examples/layouts/flex/lv_example_flex_4.c index 2dd33e5ffa..73403a8c7d 100644 --- a/examples/layouts/flex/lv_example_flex_4.c +++ b/examples/layouts/flex/lv_example_flex_4.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES /** * Reverse the order of flex items diff --git a/examples/layouts/flex/lv_example_flex_5.c b/examples/layouts/flex/lv_example_flex_5.c index fcf2db8f59..96a84a26ac 100644 --- a/examples/layouts/flex/lv_example_flex_5.c +++ b/examples/layouts/flex/lv_example_flex_5.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES static void row_gap_anim(lv_obj_t * obj, lv_anim_value_t v) { diff --git a/examples/layouts/flex/lv_example_flex_6.c b/examples/layouts/flex/lv_example_flex_6.c index d5d2694869..474aa22fd9 100644 --- a/examples/layouts/flex/lv_example_flex_6.c +++ b/examples/layouts/flex/lv_example_flex_6.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_FLEX +#if LV_USE_FLEX && LV_BUILD_EXAMPLES /** * RTL base direction changes order of the items. diff --git a/examples/layouts/grid/lv_example_grid_1.c b/examples/layouts/grid/lv_example_grid_1.c index a24828875c..b671257236 100644 --- a/examples/layouts/grid/lv_example_grid_1.c +++ b/examples/layouts/grid/lv_example_grid_1.c @@ -1,7 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID - +#if LV_USE_GRID && LV_BUILD_EXAMPLES /** * A simple grid diff --git a/examples/layouts/grid/lv_example_grid_2.c b/examples/layouts/grid/lv_example_grid_2.c index a7ef3d1c38..5581c7aef8 100644 --- a/examples/layouts/grid/lv_example_grid_2.c +++ b/examples/layouts/grid/lv_example_grid_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID +#if LV_USE_GRID && LV_BUILD_EXAMPLES /** diff --git a/examples/layouts/grid/lv_example_grid_3.c b/examples/layouts/grid/lv_example_grid_3.c index a5972e2bed..f7a411eb47 100644 --- a/examples/layouts/grid/lv_example_grid_3.c +++ b/examples/layouts/grid/lv_example_grid_3.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID +#if LV_USE_GRID && LV_BUILD_EXAMPLES /** * Demonstrate grid's "free unit" diff --git a/examples/layouts/grid/lv_example_grid_4.c b/examples/layouts/grid/lv_example_grid_4.c index e8486aa562..b98b68a3ec 100644 --- a/examples/layouts/grid/lv_example_grid_4.c +++ b/examples/layouts/grid/lv_example_grid_4.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID +#if LV_USE_GRID && LV_BUILD_EXAMPLES /** * Demonstrate track placement diff --git a/examples/layouts/grid/lv_example_grid_5.c b/examples/layouts/grid/lv_example_grid_5.c index 2cf6ffc6e6..4c4dccc670 100644 --- a/examples/layouts/grid/lv_example_grid_5.c +++ b/examples/layouts/grid/lv_example_grid_5.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID +#if LV_USE_GRID && LV_BUILD_EXAMPLES static void row_gap_anim(lv_obj_t * obj, lv_anim_value_t v) { @@ -12,7 +11,7 @@ static void column_gap_anim(lv_obj_t * obj, lv_anim_value_t v) lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v); } /** - * Demonstrate margin in grid + * Demonstrate column and row gap */ void lv_example_grid_5(void) { diff --git a/examples/layouts/grid/lv_example_grid_6.c b/examples/layouts/grid/lv_example_grid_6.c index 93e2faa196..e6ec344483 100644 --- a/examples/layouts/grid/lv_example_grid_6.c +++ b/examples/layouts/grid/lv_example_grid_6.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_GRID +#if LV_USE_GRID && LV_BUILD_EXAMPLES /** * Demonstrate RTL direction on grid diff --git a/examples/widgets/arc/lv_example_arc_1.c b/examples/widgets/arc/lv_example_arc_1.c index d361d872f3..8abb4b51cc 100644 --- a/examples/widgets/arc/lv_example_arc_1.c +++ b/examples/widgets/arc/lv_example_arc_1.c @@ -1,6 +1,6 @@ #include "../../../lvgl.h" -#if LV_USE_ARC +#if LV_USE_ARC && LV_BUILD_EXAMPLES void lv_example_arc_1(void) { diff --git a/examples/widgets/arc/lv_example_arc_2.c b/examples/widgets/arc/lv_example_arc_2.c index 7fd9a1a1d0..8c9d05013e 100644 --- a/examples/widgets/arc/lv_example_arc_2.c +++ b/examples/widgets/arc/lv_example_arc_2.c @@ -1,5 +1,6 @@ #include "../../../lvgl.h" -#if LV_USE_ARC + +#if LV_USE_ARC && LV_BUILD_EXAMPLES /** * An `lv_task` to call periodically to set the angles of the arc diff --git a/examples/widgets/bar/lv_example_bar_1.c b/examples/widgets/bar/lv_example_bar_1.c index 4608351536..b2bd803472 100644 --- a/examples/widgets/bar/lv_example_bar_1.c +++ b/examples/widgets/bar/lv_example_bar_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES void lv_example_bar_1(void) { diff --git a/examples/widgets/bar/lv_bar_example_2.c b/examples/widgets/bar/lv_example_bar_2.c similarity index 96% rename from examples/widgets/bar/lv_bar_example_2.c rename to examples/widgets/bar/lv_example_bar_2.c index ce93913571..d9dc910b23 100644 --- a/examples/widgets/bar/lv_bar_example_2.c +++ b/examples/widgets/bar/lv_example_bar_2.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES /** * Example of styling the bar diff --git a/examples/widgets/bar/lv_example_bar_3.c b/examples/widgets/bar/lv_example_bar_3.c index 6cad55570e..4012ba0000 100644 --- a/examples/widgets/bar/lv_example_bar_3.c +++ b/examples/widgets/bar/lv_example_bar_3.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES static void set_temp(lv_obj_t * bar, int32_t temp) { diff --git a/examples/widgets/bar/lv_example_bar_4.c b/examples/widgets/bar/lv_example_bar_4.c index 4ddf719873..32193d9495 100644 --- a/examples/widgets/bar/lv_example_bar_4.c +++ b/examples/widgets/bar/lv_example_bar_4.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES /** * Bar with stripe pattern and ranged value diff --git a/examples/widgets/bar/lv_example_bar_5.c b/examples/widgets/bar/lv_example_bar_5.c index 6f37c8d4a7..a5a5735b8d 100644 --- a/examples/widgets/bar/lv_example_bar_5.c +++ b/examples/widgets/bar/lv_example_bar_5.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES /** * Bar with LTR and RTL base direction diff --git a/examples/widgets/bar/lv_example_bar_6.c b/examples/widgets/bar/lv_example_bar_6.c index 031c50469f..f9695d8101 100644 --- a/examples/widgets/bar/lv_example_bar_6.c +++ b/examples/widgets/bar/lv_example_bar_6.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_BAR +#if LV_USE_BAR && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * obj, lv_event_t e) { diff --git a/examples/widgets/btn/lv_example_btn_1.c b/examples/widgets/btn/lv_example_btn_1.c index bd12ff4b31..fefd615a03 100644 --- a/examples/widgets/btn/lv_example_btn_1.c +++ b/examples/widgets/btn/lv_example_btn_1.c @@ -1,14 +1,13 @@ #include "../../../lvgl.h" -#include -#if LV_USE_BTN +#if LV_USE_BTN && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_CLICKED) { - printf("Clicked\n"); + LV_LOG_USER("Clicked\n"); } else if(event == LV_EVENT_VALUE_CHANGED) { - printf("Toggled\n"); + LV_LOG_USER("Toggled\n"); } } diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c index d8cebf0a87..426fa5e252 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_BTNMATRIX +#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { @@ -8,7 +7,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) uint32_t id = lv_btnmatrix_get_active_btn(obj); const char * txt = lv_btnmatrix_get_btn_text(obj, id); - printf("%s was pressed\n", txt); + LV_LOG_USER("%s was pressed\n", txt); } } diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c index 387d68eff2..f54a5738f6 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_BTNMATRIX +#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES void event_cb(lv_obj_t * obj, lv_event_t e) diff --git a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c index 38a258e137..871e367356 100644 --- a/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c +++ b/examples/widgets/btnmatrix/lv_example_btnmatrix_3.c @@ -1,7 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_BTNMATRIX - +#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * obj, lv_event_t e) { diff --git a/examples/widgets/calendar/lv_example_calendar_1.c b/examples/widgets/calendar/lv_example_calendar_1.c index 8f39ea0f12..e39728cfee 100644 --- a/examples/widgets/calendar/lv_example_calendar_1.c +++ b/examples/widgets/calendar/lv_example_calendar_1.c @@ -1,14 +1,12 @@ #include "../../../lvgl.h" -#include - -#if LV_USE_CALENDAR +#if LV_USE_CALENDAR && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { lv_calendar_date_t date; if(lv_calendar_get_pressed_date(obj, &date)) { - printf("Clicked date: %02d.%02d.%d\n", date.day, date.month, date.year); + LV_LOG_USER("Clicked date: %02d.%02d.%d\n", date.day, date.month, date.year); } } } diff --git a/examples/widgets/canvas/lv_example_canvas_1.c b/examples/widgets/canvas/lv_example_canvas_1.c index c54c72829b..e3c451a3a9 100644 --- a/examples/widgets/canvas/lv_example_canvas_1.c +++ b/examples/widgets/canvas/lv_example_canvas_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CANVAS +#if LV_USE_CANVAS && LV_BUILD_EXAMPLES #define CANVAS_WIDTH 200 diff --git a/examples/widgets/canvas/lv_example_canvas_2.c b/examples/widgets/canvas/lv_example_canvas_2.c index 9ea0a6d8dc..19c0141b37 100644 --- a/examples/widgets/canvas/lv_example_canvas_2.c +++ b/examples/widgets/canvas/lv_example_canvas_2.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CANVAS +#if LV_USE_CANVAS && LV_BUILD_EXAMPLES #define CANVAS_WIDTH 50 #define CANVAS_HEIGHT 50 diff --git a/examples/widgets/chart/lv_example_chart_1.c b/examples/widgets/chart/lv_example_chart_1.c index 9947cc1a08..8838b616ff 100644 --- a/examples/widgets/chart/lv_example_chart_1.c +++ b/examples/widgets/chart/lv_example_chart_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CHART +#if LV_USE_CHART && LV_BUILD_EXAMPLES void lv_example_chart_1(void) { diff --git a/examples/widgets/chart/lv_example_chart_2.c b/examples/widgets/chart/lv_example_chart_2.c index 693b34cbde..62ebc43a0a 100644 --- a/examples/widgets/chart/lv_example_chart_2.c +++ b/examples/widgets/chart/lv_example_chart_2.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CHART +#if LV_USE_CHART && LV_DRAW_COMPLEX && LV_BUILD_EXAMPLES static lv_obj_t * chart1; static lv_chart_series_t * ser1; diff --git a/examples/widgets/chart/lv_example_chart_3.c b/examples/widgets/chart/lv_example_chart_3.c index bf92818df3..a49af647c9 100644 --- a/examples/widgets/chart/lv_example_chart_3.c +++ b/examples/widgets/chart/lv_example_chart_3.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CHART +#if LV_USE_CHART && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * chart, lv_event_t e) { diff --git a/examples/widgets/chart/lv_example_chart_4.c b/examples/widgets/chart/lv_example_chart_4.c index ce93314551..6d411e4119 100644 --- a/examples/widgets/chart/lv_example_chart_4.c +++ b/examples/widgets/chart/lv_example_chart_4.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_CHART +#if LV_USE_CHART && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * chart, lv_event_t e) @@ -15,7 +15,7 @@ static void event_cb(lv_obj_t * chart, lv_event_t e) int32_t id = lv_chart_get_pressed_point(chart); if(id < 0) return; - printf("Selected point %d\n", id); + LV_LOG_USER("Selected point %d\n", id); lv_chart_series_t * ser = lv_chart_get_series_next(chart, NULL); while(ser) { diff --git a/examples/widgets/checkbox/lv_example_checkbox_1.c b/examples/widgets/checkbox/lv_example_checkbox_1.c index 65281508a7..85dc349d98 100644 --- a/examples/widgets/checkbox/lv_example_checkbox_1.c +++ b/examples/widgets/checkbox/lv_example_checkbox_1.c @@ -1,13 +1,12 @@ #include "../../../lvgl.h" -#include -#if LV_USE_CHECKBOX +#if LV_USE_CHECKBOX && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { const char * txt = lv_checkbox_get_text(obj); const char * state = lv_obj_get_state(obj) & LV_STATE_CHECKED ? "Checked" : "Unchecked"; - printf("%s: %s\n", txt, state); + LV_LOG_USER("%s: %s\n", txt, state); } } diff --git a/examples/widgets/colorwheel/lv_example_colorwheel_1.c b/examples/widgets/colorwheel/lv_example_colorwheel_1.c index ff6d748c33..5b098cc6a5 100644 --- a/examples/widgets/colorwheel/lv_example_colorwheel_1.c +++ b/examples/widgets/colorwheel/lv_example_colorwheel_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_COLORWHEEL +#if LV_USE_COLORWHEEL && LV_BUILD_EXAMPLES void lv_example_colorwheel_1(void) { diff --git a/examples/widgets/dropdown/lv_example_dropdown_1.c b/examples/widgets/dropdown/lv_example_dropdown_1.c index 6d0db2801a..6d1c4fdf95 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_1.c +++ b/examples/widgets/dropdown/lv_example_dropdown_1.c @@ -1,14 +1,12 @@ #include "../../../lvgl.h" -#include -#if LV_USE_DROPDOWN - +#if LV_USE_DROPDOWN && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { char buf[32]; lv_dropdown_get_selected_str(obj, buf, sizeof(buf)); - printf("Option: %s\n", buf); + LV_LOG_USER("Option: %s\n", buf); } } diff --git a/examples/widgets/dropdown/lv_example_dropdown_2.c b/examples/widgets/dropdown/lv_example_dropdown_2.c index 69cf9b1fe6..1be861b97f 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_2.c +++ b/examples/widgets/dropdown/lv_example_dropdown_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_DROPDOWN +#if LV_USE_DROPDOWN && LV_BUILD_EXAMPLES /** diff --git a/examples/widgets/dropdown/lv_example_dropdown_3.c b/examples/widgets/dropdown/lv_example_dropdown_3.c index dcfda19ced..1b03985668 100644 --- a/examples/widgets/dropdown/lv_example_dropdown_3.c +++ b/examples/widgets/dropdown/lv_example_dropdown_3.c @@ -1,7 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_DROPDOWN - +#if LV_USE_DROPDOWN && LV_BUILD_EXAMPLES /** * Create a menu from a drop-down list and show some drop-down list features and styling diff --git a/examples/widgets/img/lv_example_img_1.c b/examples/widgets/img/lv_example_img_1.c index 9241ee7faa..0990f270b4 100644 --- a/examples/widgets/img/lv_example_img_1.c +++ b/examples/widgets/img/lv_example_img_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_IMG +#if LV_USE_IMG && LV_BUILD_EXAMPLES /* Find the image here: https://github.com/lvgl/lv_examples/tree/master/assets */ LV_IMG_DECLARE(img_cogwheel_argb); diff --git a/examples/widgets/img/lv_example_img_2.c b/examples/widgets/img/lv_example_img_2.c index 93b6ff9ed9..632d853113 100644 --- a/examples/widgets/img/lv_example_img_2.c +++ b/examples/widgets/img/lv_example_img_2.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_IMG +#if LV_USE_IMG && LV_BUILD_EXAMPLES static lv_obj_t * create_slider(lv_color_t color); static void slider_event_cb(lv_obj_t * slider, lv_event_t event); diff --git a/examples/widgets/img/lv_example_img_3.c b/examples/widgets/img/lv_example_img_3.c index 9d83fc36d9..4f9f8303fd 100644 --- a/examples/widgets/img/lv_example_img_3.c +++ b/examples/widgets/img/lv_example_img_3.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_IMG +#if LV_USE_IMG && LV_BUILD_EXAMPLES LV_IMG_DECLARE(img_cogwheel_argb); diff --git a/examples/widgets/img/lv_example_img_4.c b/examples/widgets/img/lv_example_img_4.c index 73b5888740..526fdd9112 100644 --- a/examples/widgets/img/lv_example_img_4.c +++ b/examples/widgets/img/lv_example_img_4.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_IMG +#if LV_USE_IMG && LV_BUILD_EXAMPLES LV_IMG_DECLARE(img_skew_strip); diff --git a/examples/widgets/imgbtn/lv_example_imgbtn_1.c b/examples/widgets/imgbtn/lv_example_imgbtn_1.c index f4c10c3152..29a3fb904a 100644 --- a/examples/widgets/imgbtn/lv_example_imgbtn_1.c +++ b/examples/widgets/imgbtn/lv_example_imgbtn_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" - -#if LV_USE_IMGBTN +#if LV_USE_IMGBTN && LV_BUILD_EXAMPLES void lv_example_imgbtn_1(void) { diff --git a/examples/widgets/keyboard/lv_example_keyboard_1.c b/examples/widgets/keyboard/lv_example_keyboard_1.c index dacecf19d4..a6cf5e1ad3 100644 --- a/examples/widgets/keyboard/lv_example_keyboard_1.c +++ b/examples/widgets/keyboard/lv_example_keyboard_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_KEYBOARD - +#if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES static void ta_event_cb(lv_obj_t * ta, lv_event_t e) { diff --git a/examples/widgets/label/lv_example_label_1.c b/examples/widgets/label/lv_example_label_1.c index 6e5a541b5d..519cc1b054 100644 --- a/examples/widgets/label/lv_example_label_1.c +++ b/examples/widgets/label/lv_example_label_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_LABEL +#if LV_USE_LABEL && LV_BUILD_EXAMPLES /** * Show line wrap, re-color, line align and text scrolling. diff --git a/examples/widgets/label/lv_example_label_2.c b/examples/widgets/label/lv_example_label_2.c index 28c42d5d32..95b15a50c0 100644 --- a/examples/widgets/label/lv_example_label_2.c +++ b/examples/widgets/label/lv_example_label_2.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_LABEL +#if LV_USE_LABEL && LV_BUILD_EXAMPLES /** * Create a fake text shadow diff --git a/examples/widgets/led/lv_example_led_1.c b/examples/widgets/led/lv_example_led_1.c index 7462d8047a..b6de77206c 100644 --- a/examples/widgets/led/lv_example_led_1.c +++ b/examples/widgets/led/lv_example_led_1.c @@ -1,6 +1,9 @@ #include "../../../lvgl.h" -#if LV_USE_LED +#if LV_USE_LED && LV_BUILD_EXAMPLES +/** + * Create LED's with different brightness and color + */ void lv_example_led_1(void) { /*Create a LED and switch it OFF*/ @@ -11,7 +14,8 @@ void lv_example_led_1(void) /*Copy the previous LED and set a brightness*/ lv_obj_t * led2 = lv_led_create(lv_scr_act()); lv_obj_align(led2, NULL, LV_ALIGN_CENTER, 0, 0); - lv_led_set_bright(led2, 150); + lv_led_set_brightness(led2, 150); + lv_led_set_color(led2, LV_COLOR_RED); /*Copy the previous LED and switch it ON*/ lv_obj_t * led3 = lv_led_create(lv_scr_act()); diff --git a/examples/widgets/line/lv_example_line_1.c b/examples/widgets/line/lv_example_line_1.c index a81f840c56..64c6f3afad 100644 --- a/examples/widgets/line/lv_example_line_1.c +++ b/examples/widgets/line/lv_example_line_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_LINE +#if LV_USE_LINE && LV_BUILD_EXAMPLES void lv_example_line_1(void) { diff --git a/examples/widgets/list/lv_example_list_1.c b/examples/widgets/list/lv_example_list_1.c index bc2017a228..ba6301262e 100644 --- a/examples/widgets/list/lv_example_list_1.c +++ b/examples/widgets/list/lv_example_list_1.c @@ -1,11 +1,10 @@ #include "../../../lvgl.h" -#include -#if LV_USE_LIST +#if LV_USE_LIST && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_CLICKED) { - printf("Clicked: %s\n", lv_list_get_btn_text(obj)); + LV_LOG_USER("Clicked: %s\n", lv_list_get_btn_text(obj)); } } void lv_list_example_1(void) diff --git a/examples/widgets/meter/lv_example_meter_1.c b/examples/widgets/meter/lv_example_meter_1.c index c0a0dee929..814c9e218a 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_METER +#if LV_USE_METER && LV_BUILD_EXAMPLES static lv_obj_t * meter; diff --git a/examples/widgets/meter/lv_example_meter_2.c b/examples/widgets/meter/lv_example_meter_2.c index 1e2e89d8ca..8707d377ae 100644 --- a/examples/widgets/meter/lv_example_meter_2.c +++ b/examples/widgets/meter/lv_example_meter_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_METER +#if LV_USE_METER && LV_BUILD_EXAMPLES static lv_obj_t * meter; diff --git a/examples/widgets/meter/lv_example_meter_3.c b/examples/widgets/meter/lv_example_meter_3.c index dd3ee0aa72..8b7fab20bb 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_METER +#if LV_USE_METER && LV_BUILD_EXAMPLES static lv_obj_t * meter; diff --git a/examples/widgets/meter/lv_example_meter_4.c b/examples/widgets/meter/lv_example_meter_4.c index f1c3bf62e2..c1c84f9866 100644 --- a/examples/widgets/meter/lv_example_meter_4.c +++ b/examples/widgets/meter/lv_example_meter_4.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_METER +#if LV_USE_METER && LV_BUILD_EXAMPLES /** * Create a pie chart diff --git a/examples/widgets/msgbox/lv_example_msgbox_1.c b/examples/widgets/msgbox/lv_example_msgbox_1.c index 472d462145..dccd4570f4 100644 --- a/examples/widgets/msgbox/lv_example_msgbox_1.c +++ b/examples/widgets/msgbox/lv_example_msgbox_1.c @@ -1,11 +1,10 @@ #include "../../../lvgl.h" -#include -#if LV_USE_MSGBOX +#if LV_USE_MSGBOX && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { - printf("Button: %s\n", lv_msgbox_get_active_btn_text(obj)); + LV_LOG_USER("Button: %s\n", lv_msgbox_get_active_btn_text(obj)); } } diff --git a/examples/widgets/msgbox/lv_example_msgbox_2.c b/examples/widgets/msgbox/lv_example_msgbox_2.c deleted file mode 100644 index 4275e8cd32..0000000000 --- a/examples/widgets/msgbox/lv_example_msgbox_2.c +++ /dev/null @@ -1,94 +0,0 @@ -//#include "../../../lvgl.h" -//#if LV_USE_MSGBOX -// -//static void mbox_event_cb(lv_obj_t *obj, lv_event_t evt); -//static void btn_event_cb(lv_obj_t *btn, lv_event_t evt); -//static void opa_anim(void * bg, lv_anim_value_t v); -// -//static lv_obj_t *mbox, *info; -//static lv_style_t style_modal; -// -//static const char welcome_info[] = "Welcome to the modal message box demo!\n" -// "Press the button to display a message box."; -// -//static const char in_msg_info[] = "Notice that you cannot touch " -// "the button again while the message box is open."; -// -//void lv_example_msgbox_2(void) -//{ -// lv_style_init(&style_modal); -// lv_style_set_bg_color(&style_modal, LV_STATE_DEFAULT, LV_COLOR_BLACK); -// -// /* Create a button, then set its position and event callback */ -// lv_obj_t *btn = lv_btn_create(lv_scr_act(), NULL); -// lv_obj_set_size(btn, 200, 60); -// lv_obj_set_event_cb(btn, btn_event_cb); -// lv_obj_align(btn, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 20); -// -// /* Create a label on the button */ -// lv_obj_t *label = lv_label_create(btn, NULL); -// lv_label_set_text(label, "Display a message box!"); -// -// /* Create an informative label on the screen */ -// info = lv_label_create(lv_scr_act(), NULL); -// lv_label_set_text(info, welcome_info); -// lv_label_set_long_mode(info, LV_LABEL_LONG_BREAK); /* Make sure text will wrap */ -// lv_obj_set_width(info, LV_HOR_RES - 10); -// lv_obj_align(info, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 5, -5); -// -//} -// -//static void mbox_event_cb(lv_obj_t *obj, lv_event_t evt) -//{ -// if(evt == LV_EVENT_DELETE && obj == mbox) { -// /* Delete the parent modal background */ -// lv_obj_del_async(lv_obj_get_parent(mbox)); -// mbox = NULL; /* happens before object is actually deleted! */ -// lv_label_set_text(info, welcome_info); -// } else if(evt == LV_EVENT_VALUE_CHANGED) { -// /* A button was clicked */ -// lv_msgbox_start_auto_close(mbox, 0); -// } -//} -// -//static void btn_event_cb(lv_obj_t *btn, lv_event_t evt) -//{ -// if(evt == LV_EVENT_CLICKED) { -// /* Create a full-screen background */ -// -// /* Create a base object for the modal background */ -// lv_obj_t *obj = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_reset_style_list(obj, LV_OBJ_PART_MAIN); -// lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &style_modal); -// lv_obj_set_pos(obj, 0, 0); -// lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES); -// -// static const char * btns2[] = {"Ok", "Cancel", ""}; -// -// /* Create the message box as a child of the modal background */ -// mbox = lv_msgbox_create(obj, NULL); -// lv_msgbox_add_btns(mbox, btns2); -// lv_msgbox_set_text(mbox, "Hello world!"); -// lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); -// lv_obj_set_event_cb(mbox, mbox_event_cb); -// -// /* Fade the message box in with an animation */ -// lv_anim_t a; -// lv_anim_init(&a); -// lv_anim_set_var(&a, obj); -// lv_anim_set_time(&a, 500); -// lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_50); -// lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)opa_anim); -// lv_anim_start(&a); -// -// lv_label_set_text(info, in_msg_info); -// lv_obj_align(info, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 5, -5); -// } -//} -// -//static void opa_anim(void * bg, lv_anim_value_t v) -//{ -// lv_obj_set_style_local_bg_opa(bg, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); -//} -// -//#endif diff --git a/examples/widgets/obj/lv_example_obj_1.c b/examples/widgets/obj/lv_example_obj_1.c index b7f8d29ee7..4f2d75fffd 100644 --- a/examples/widgets/obj/lv_example_obj_1.c +++ b/examples/widgets/obj/lv_example_obj_1.c @@ -1,21 +1,22 @@ -//#include "../../../lvgl.h" -// -//void lv_example_obj_1(void) -//{ -// lv_obj_t * obj1; -// obj1 = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_set_size(obj1, 100, 50); -// lv_obj_align(obj1, NULL, LV_ALIGN_CENTER, -60, -30); -// -// static lv_style_t style_shadow; -// lv_style_init(&style_shadow); -// lv_style_set_shadow_width(&style_shadow, LV_STATE_DEFAULT, 10); -// lv_style_set_shadow_spread(&style_shadow, LV_STATE_DEFAULT, 5); -// lv_style_set_shadow_color(&style_shadow, LV_STATE_DEFAULT, LV_COLOR_BLUE); -// -// /*Copy the previous object (drag is already enabled)*/ -// lv_obj_t * obj3; -// obj3 = lv_obj_create(lv_scr_act(), NULL); -// lv_obj_add_style(obj3, LV_OBJ_PART_MAIN, &style_shadow); -// lv_obj_align(obj3, NULL, LV_ALIGN_CENTER, 60, 30); -//} +#include "../../../lvgl.h" +#if LV_BUILD_EXAMPLES + +void lv_example_obj_1(void) +{ + lv_obj_t * obj1; + obj1 = lv_obj_create(lv_scr_act(), NULL); + lv_obj_set_size(obj1, 100, 50); + lv_obj_align(obj1, NULL, LV_ALIGN_CENTER, -60, -30); + + static lv_style_t style_shadow; + lv_style_init(&style_shadow); + lv_style_set_shadow_width(&style_shadow, 10); + lv_style_set_shadow_spread(&style_shadow, 5); + lv_style_set_shadow_color(&style_shadow, LV_COLOR_BLUE); + + lv_obj_t * obj3; + obj3 = lv_obj_create(lv_scr_act(), NULL); + lv_obj_add_style(obj3, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow); + lv_obj_align(obj3, NULL, LV_ALIGN_CENTER, 60, 30); +} +#endif diff --git a/examples/widgets/roller/lv_example_roller_1.c b/examples/widgets/roller/lv_example_roller_1.c index d0b03be8ac..2639109cf5 100644 --- a/examples/widgets/roller/lv_example_roller_1.c +++ b/examples/widgets/roller/lv_example_roller_1.c @@ -1,13 +1,12 @@ #include "../../../lvgl.h" -#include -#if LV_USE_ROLLER +#if LV_USE_ROLLER && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { char buf[32]; lv_roller_get_selected_str(obj, buf, sizeof(buf)); - printf("Selected month: %s\n", buf); + LV_LOG_USER("Selected month: %s\n", buf); } } diff --git a/examples/widgets/roller/lv_roller_example_2.c b/examples/widgets/roller/lv_roller_example_2.c index db3cf308fc..d37d740913 100644 --- a/examples/widgets/roller/lv_roller_example_2.c +++ b/examples/widgets/roller/lv_roller_example_2.c @@ -1,13 +1,12 @@ #include "../../../lvgl.h" -#include -#if LV_USE_ROLLER +#if LV_USE_ROLLER && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { char buf[32]; lv_roller_get_selected_str(obj, buf, sizeof(buf)); - printf("Selected value: %s\n", buf); + LV_LOG_USER("Selected value: %s\n", buf); } } diff --git a/examples/widgets/slider/lv_example_slider_1.c b/examples/widgets/slider/lv_example_slider_1.c index 2991d846ae..b8b17634e2 100644 --- a/examples/widgets/slider/lv_example_slider_1.c +++ b/examples/widgets/slider/lv_example_slider_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_SLIDER +#if LV_USE_SLIDER && LV_BUILD_EXAMPLES static void slider_event_cb(lv_obj_t * slider, lv_event_t event); static lv_obj_t * slider_label; diff --git a/examples/widgets/slider/lv_example_slider_2.c b/examples/widgets/slider/lv_example_slider_2.c index 093408c003..463f59f554 100644 --- a/examples/widgets/slider/lv_example_slider_2.c +++ b/examples/widgets/slider/lv_example_slider_2.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_SLIDER +#if LV_USE_SLIDER && LV_BUILD_EXAMPLES static void slider_event_cb(lv_obj_t * slider, lv_event_t event); diff --git a/examples/widgets/slider/lv_example_slider_3.c b/examples/widgets/slider/lv_example_slider_3.c index 57e8e628e2..007c6a7596 100644 --- a/examples/widgets/slider/lv_example_slider_3.c +++ b/examples/widgets/slider/lv_example_slider_3.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_SLIDER +#if LV_USE_SLIDER && LV_BUILD_EXAMPLES static void slider_event_cb(lv_obj_t * slider, lv_event_t event); diff --git a/examples/widgets/spinbox/lv_example_spinbox_1.c b/examples/widgets/spinbox/lv_example_spinbox_1.c index c19cf33945..8ae5ff6a48 100644 --- a/examples/widgets/spinbox/lv_example_spinbox_1.c +++ b/examples/widgets/spinbox/lv_example_spinbox_1.c @@ -1,6 +1,5 @@ #include "../../../lvgl.h" -#include -#if LV_USE_SPINBOX +#if LV_USE_SPINBOX && LV_BUILD_EXAMPLES static lv_obj_t * spinbox; diff --git a/examples/widgets/spinner/lv_example_spinner_1.c b/examples/widgets/spinner/lv_example_spinner_1.c index 7182ea25df..43af3cdc5f 100644 --- a/examples/widgets/spinner/lv_example_spinner_1.c +++ b/examples/widgets/spinner/lv_example_spinner_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_SPINNER +#if LV_USE_SPINNER && LV_BUILD_EXAMPLES void lv_example_spinner_1(void) { diff --git a/examples/widgets/switch/lv_example_switch_1.c b/examples/widgets/switch/lv_example_switch_1.c index 1dfe34651a..26ecc20c7a 100644 --- a/examples/widgets/switch/lv_example_switch_1.c +++ b/examples/widgets/switch/lv_example_switch_1.c @@ -1,11 +1,10 @@ #include "../../../lvgl.h" -#include -#if LV_USE_SWITCH +#if LV_USE_SWITCH && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { - printf("State: %s\n", lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off"); + LV_LOG_USER("State: %s\n", lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off"); } } diff --git a/examples/widgets/table/lv_example_table_1.c b/examples/widgets/table/lv_example_table_1.c index c2c12ddbda..b0321d5a76 100644 --- a/examples/widgets/table/lv_example_table_1.c +++ b/examples/widgets/table/lv_example_table_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_TABLE +#if LV_USE_TABLE && LV_BUILD_EXAMPLES static void event_cb(lv_obj_t * obj, lv_event_t e) { diff --git a/examples/widgets/tabview/lv_example_tabview_1.c b/examples/widgets/tabview/lv_example_tabview_1.c index d96816de89..178d64ab63 100644 --- a/examples/widgets/tabview/lv_example_tabview_1.c +++ b/examples/widgets/tabview/lv_example_tabview_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_TABVIEW +#if LV_USE_TABVIEW && LV_BUILD_EXAMPLES void lv_example_tabview_1(void) { diff --git a/examples/widgets/textarea/lv_example_textarea_1.c b/examples/widgets/textarea/lv_example_textarea_1.c index 99e2ad6edf..56642824b0 100644 --- a/examples/widgets/textarea/lv_example_textarea_1.c +++ b/examples/widgets/textarea/lv_example_textarea_1.c @@ -1,32 +1,38 @@ #include "../../../lvgl.h" -#include -#if LV_USE_TEXTAREA +#if LV_USE_TEXTAREA && LV_BUILD_EXAMPLES -lv_obj_t * ta1; -lv_obj_t * ta2; -static void event_handler(lv_obj_t * obj, lv_event_t event) +static void btnm_event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_VALUE_CHANGED) { - printf("Value: %s\n", lv_textarea_get_text(obj)); - } - else if(event == LV_EVENT_LONG_PRESSED_REPEAT) { - /*For simple test: Long press the Text are to add the text below*/ - const char * txt = "\n\nYou can scroll it if the text is long enough.\n"; - static uint16_t i = 0; - if(txt[i] != '\0') { - lv_textarea_add_char(ta1, txt[i]); - i++; - } + lv_obj_t * ta = lv_event_get_user_data(); + const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_active_btn(obj)); + + if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) lv_textarea_del_char(ta); + else if(strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) lv_textarea_add_char(ta, '\n'); + else lv_textarea_add_text(ta, txt); + } } void lv_example_textarea_1(void) { - ta1 = lv_textarea_create(lv_scr_act(), NULL); - lv_obj_align(ta1, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); - lv_textarea_set_text(ta1, "A text in a Text Area"); /*Set an initial text*/ - lv_obj_add_event_cb(ta1, event_handler, NULL); + lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL); + lv_textarea_set_one_line(ta, true); + lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/ + + static const char * btnm_map[] = {"1", "2", "3", "\n", + "4", "5", "6", "\n", + "7", "8", "9", "\n", + LV_SYMBOL_BACKSPACE, "0", LV_SYMBOL_NEW_LINE}; + + lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL); + lv_obj_set_size(btnm, 200, 150); + lv_obj_align(btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10); + lv_obj_add_event_cb(btnm, btnm_event_handler, ta); + lv_obj_clear_flag(btnm, LV_OBJ_FLAG_CLICK_FOCUSABLE); /*To keep the text area focused on button clicks*/ + lv_btnmatrix_set_map(btnm, btnm_map); } #endif diff --git a/examples/widgets/textarea/lv_example_textarea_2.c b/examples/widgets/textarea/lv_example_textarea_2.c index c78806c33c..c09ef2ddf5 100644 --- a/examples/widgets/textarea/lv_example_textarea_2.c +++ b/examples/widgets/textarea/lv_example_textarea_2.c @@ -1,62 +1,58 @@ -//#include "../../../lvgl.h" -//#include -//#if LV_USE_TEXTAREA && LV_USE_KEYBOARD -// -//static void ta_event_cb(lv_obj_t * ta, lv_event_t event); -// -//static lv_obj_t * kb; -// -//void lv_example_textarea_2(void) -//{ -// /* Create the password box */ -// lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act(), NULL); -// lv_textarea_set_text(pwd_ta, ""); -// lv_textarea_set_pwd_mode(pwd_ta, true); -// lv_textarea_set_one_line(pwd_ta, true); -// lv_textarea_set_cursor_hidden(pwd_ta, true); -// lv_obj_set_width(pwd_ta, LV_HOR_RES / 2 - 20); -// lv_obj_set_pos(pwd_ta, 5, 20); -// lv_obj_set_event_cb(pwd_ta, ta_event_cb); -// -// /* Create a label and position it above the text box */ -// lv_obj_t * pwd_label = lv_label_create(lv_scr_act(), NULL); -// lv_label_set_text(pwd_label, "Password:"); -// lv_obj_align(pwd_label, pwd_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); -// -// /* Create the one-line mode text area */ -// lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act(), pwd_ta); -// lv_textarea_set_pwd_mode(oneline_ta, false); -// lv_textarea_set_cursor_hidden(oneline_ta, true); -// lv_obj_align(oneline_ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20); -// -// -// /* Create a label and position it above the text box */ -// lv_obj_t * oneline_label = lv_label_create(lv_scr_act(), NULL); -// lv_label_set_text(oneline_label, "Text:"); -// lv_obj_align(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); -// -// /* Create a keyboard */ -// kb = lv_keyboard_create(lv_scr_act(), NULL); -// lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2); -// -// lv_keyboard_set_textarea(kb, pwd_ta); /* Focus it on one of the text areas to start */ -// lv_keyboard_set_cursor_manage(kb, true); /* Automatically show/hide cursors on text areas */ -//} -// -//static void ta_event_cb(lv_obj_t * ta, lv_event_t event) -//{ -// if(event == LV_EVENT_CLICKED) { -// /* Focus on the clicked text area */ -// if(kb != NULL) -// lv_keyboard_set_textarea(kb, ta); -// } -// -// else if(event == LV_EVENT_INSERT) { -// const char * str = lv_event_get_data(); -// if(str[0] == '\n') { -// printf("Ready\n"); -// } -// } -//} -// -//#endif +#include "../../../lvgl.h" +#if LV_USE_TEXTAREA && LV_USE_KEYBOARD && LV_BUILD_EXAMPLES + +static void ta_event_cb(lv_obj_t * ta, lv_event_t event); + +static lv_obj_t * kb; + +void lv_example_textarea_2(void) +{ + /* Create the password box */ + lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act(), NULL); + lv_textarea_set_text(pwd_ta, ""); + lv_textarea_set_pwd_mode(pwd_ta, true); + lv_textarea_set_one_line(pwd_ta, true); + lv_obj_set_width(pwd_ta, LV_HOR_RES / 2 - 20); + lv_obj_set_pos(pwd_ta, 5, 20); + lv_obj_add_event_cb(pwd_ta, ta_event_cb, NULL); + + /* Create a label and position it above the text box */ + lv_obj_t * pwd_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(pwd_label, "Password:"); + lv_obj_align(pwd_label, pwd_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); + + /* Create the one-line mode text area */ + lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act(), pwd_ta); + lv_textarea_set_pwd_mode(oneline_ta, false); + lv_obj_align(oneline_ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20); + + + /* Create a label and position it above the text box */ + lv_obj_t * oneline_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(oneline_label, "Text:"); + lv_obj_align(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0); + + /* Create a keyboard */ + kb = lv_keyboard_create(lv_scr_act()); + lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2); + + lv_keyboard_set_textarea(kb, pwd_ta); /* Focus it on one of the text areas to start */ +} + +static void ta_event_cb(lv_obj_t * ta, lv_event_t event) +{ + if(event == LV_EVENT_CLICKED) { + /* Focus on the clicked text area */ + if(kb != NULL) + lv_keyboard_set_textarea(kb, ta); + } + + else if(event == LV_EVENT_INSERT) { + const char * str = lv_event_get_param(); + if(str[0] == '\n') { + LV_LOG_USER("Ready\n"); + } + } +} + +#endif diff --git a/examples/widgets/textarea/lv_example_textarea_3.c b/examples/widgets/textarea/lv_example_textarea_3.c index 33bbeac403..cf0a4c6ddd 100644 --- a/examples/widgets/textarea/lv_example_textarea_3.c +++ b/examples/widgets/textarea/lv_example_textarea_3.c @@ -1,44 +1,43 @@ -//#include "../../../lvgl.h" -//#include -//#if LV_USE_TEXTAREA && LV_USE_KEYBOARD -// -//static void ta_event_cb(lv_obj_t * ta, lv_event_t event); -// -//static lv_obj_t * kb; -// -///** -// * Automatically format text like a clock. E.g. "12:34" -// * Add the ':' automatically. -// */ -//void lv_example_textarea_3(void) -//{ -// /* Create the text area */ -// lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL); -// lv_obj_set_event_cb(ta, ta_event_cb); -// lv_textarea_set_accepted_chars(ta, "0123456789:"); -// lv_textarea_set_max_length(ta, 5); -// lv_textarea_set_one_line(ta, true); -// lv_textarea_set_text(ta, ""); -// -// /* Create a keyboard*/ -// kb = lv_keyboard_create(lv_scr_act(), NULL); -// lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2); -// lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUM); -// lv_keyboard_set_textarea(kb, ta); -//} -// -//static void ta_event_cb(lv_obj_t * ta, lv_event_t event) -//{ -// if(event == LV_EVENT_VALUE_CHANGED) { -// const char * txt = lv_textarea_get_text(ta); -// if(txt[0] >= '0' && txt[0] <= '9' && -// txt[1] >= '0' && txt[1] <= '9' && -// txt[2] != ':') -// { -// lv_textarea_set_cursor_pos(ta, 2); -// lv_textarea_add_char(ta, ':'); -// } -// } -//} -// -//#endif +#include "../../../lvgl.h" +#if LV_USE_TEXTAREA && LV_USE_KEYBOARD && LV_BUILD_EXAMPLES + +static void ta_event_cb(lv_obj_t * ta, lv_event_t event); + +static lv_obj_t * kb; + +/** + * Automatically format text like a clock. E.g. "12:34" + * Add the ':' automatically. + */ +void lv_example_textarea_3(void) +{ + /* Create the text area */ + lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL); + lv_obj_add_event_cb(ta, ta_event_cb, NULL); + lv_textarea_set_accepted_chars(ta, "0123456789:"); + lv_textarea_set_max_length(ta, 5); + lv_textarea_set_one_line(ta, true); + lv_textarea_set_text(ta, ""); + + /* Create a keyboard*/ + kb = lv_keyboard_create(lv_scr_act()); + lv_obj_set_size(kb, LV_HOR_RES, LV_VER_RES / 2); + lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER); + lv_keyboard_set_textarea(kb, ta); +} + +static void ta_event_cb(lv_obj_t * ta, lv_event_t event) +{ + if(event == LV_EVENT_VALUE_CHANGED) { + const char * txt = lv_textarea_get_text(ta); + if(txt[0] >= '0' && txt[0] <= '9' && + txt[1] >= '0' && txt[1] <= '9' && + txt[2] != ':') + { + lv_textarea_set_cursor_pos(ta, 2); + lv_textarea_add_char(ta, ':'); + } + } +} + +#endif diff --git a/examples/widgets/tileview/lv_example_tileview_1.c b/examples/widgets/tileview/lv_example_tileview_1.c index 01ce1c9c36..2bbf769dcc 100644 --- a/examples/widgets/tileview/lv_example_tileview_1.c +++ b/examples/widgets/tileview/lv_example_tileview_1.c @@ -1,5 +1,5 @@ #include "../../../lvgl.h" -#if LV_USE_TILEVIEW +#if LV_USE_TILEVIEW && LV_BUILD_EXAMPLES /** * Create a 2x2 tile view and allow scrolling only in an "L" shape. diff --git a/examples/widgets/win/lv_example_win_1.c b/examples/widgets/win/lv_example_win_1.c index a8bbd61dd4..1f6fb87246 100644 --- a/examples/widgets/win/lv_example_win_1.c +++ b/examples/widgets/win/lv_example_win_1.c @@ -1,12 +1,11 @@ #include "../../../lvgl.h" -#include -#if LV_USE_WIN +#if LV_USE_WIN && LV_BUILD_EXAMPLES static void event_handler(lv_obj_t * obj, lv_event_t event) { if(event == LV_EVENT_CLICKED) { - printf("Button: %d\n", lv_obj_get_child_id(obj)); + LV_LOG_USER("Button: %d\n", lv_obj_get_child_id(obj)); } } diff --git a/lv_conf_template.h b/lv_conf_template.h index c5e26c3c81..e360df2dda 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -15,6 +15,7 @@ #include + /*==================== COLOR SETTINGS *====================*/ @@ -102,12 +103,38 @@ * 0: to disable caching */ #define LV_IMG_CACHE_DEF_SIZE 0 +/*------------- + * GPU + *-----------*/ + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D +/*Must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h" */ +#define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif + +/* Use NXP's PXP GPU iMX RTxxx platforms */ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP +/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + * */ +#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif + +/* Use NXP's VG-Lite GPU iMX RTxxx platforms */ +#define LV_USE_GPU_NXP_VG_LITE 0 + /*------------- * Logging *-----------*/ /*Enable the log module*/ -#define LV_USE_LOG 0 +#define LV_USE_LOG 1 #if LV_USE_LOG /* How important log should be added: @@ -120,7 +147,7 @@ /* 1: Print the log with 'printf'; * 0: User need to register a callback with `lv_log_register_print_cb()`*/ -# define LV_LOG_PRINTF 0 +# define LV_LOG_PRINTF 1 #endif /*LV_USE_LOG*/ /*------------- @@ -129,25 +156,23 @@ /* Enable asserts if an operation is failed or an invalid data is found. * If LV_USE_LOG is enabled an error message will be printed on failure*/ -#define LV_USE_ASSERT 1 -#if LV_USE_ASSERT - #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended) */ #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ -#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ -#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ -#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow) */ +#define LV_USE_ASSERT_STYLE 1 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 1 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 1 /*Check the object's type and existence (e.g. not deleted). (Slow) */ /*Add a custom handler when assert happens e.g. to restart the MCU*/ #define LV_ASSERT_HANDLER_INCLUDE #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ -#endif /*LV_USE_ASSERT*/ - /*------------- * Others *-----------*/ +/*1: Show CPU usage and FPS count in the right bottom corner*/ +#define LV_USE_PERF_MONITOR 0 + /*Change the built in (v)snprintf functions*/ #define LV_SPRINTF_CUSTOM 0 #if LV_SPRINTF_CUSTOM @@ -250,30 +275,27 @@ typedef void * lv_user_data_t; /*Pixel perfect monospace fonts * http://pelulamu.net/unscii/ */ -#define LV_FONT_UNSCII_8 0 -#define LV_FONT_UNSCII_16 0 +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 /* Optionally declare custom fonts here. * You can use these fonts as default font too and they will be available globally. * E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2) */ #define LV_FONT_CUSTOM_DECLARE -/*Always set a default font*/ -#define LV_FONT_DEFAULT &lv_font_montserrat_14 - /* Enable handling large font and/or fonts with a lot of characters. * The limit depends on the font size, font face and bpp. * Compiler error will be triggered if a font needs it.*/ #define LV_FONT_FMT_TXT_LARGE 0 /* Enables/disables support for compressed fonts. */ -#define LV_USE_FONT_COMPRESSED 1 +#define LV_USE_FONT_COMPRESSED 0 /* Enable subpixel rendering */ -#define LV_USE_FONT_SUBPX 1 +#define LV_USE_FONT_SUBPX 0 #if LV_USE_FONT_SUBPX /* Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ -#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ #endif /*================= @@ -308,7 +330,7 @@ typedef void * lv_user_data_t; /* Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. * The direction will be processed according to the Unicode Bidirectioanl Algorithm: * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ -#define LV_USE_BIDI 1 +#define LV_USE_BIDI 0 #if LV_USE_BIDI /* Set the default direction. Supported values: * `LV_BIDI_DIR_LTR` Left-to-Right @@ -322,6 +344,24 @@ typedef void * lv_user_data_t; #define LV_USE_ARABIC_PERSIAN_CHARS 0 +/*================== + * THEME USAGE + *================*/ +/*Set the very basic the attributes*/ +#define LV_THEME_COLOR_PRIMARY lv_color_hex(0x01a2b1) +#define LV_THEME_COLOR_SECONDARY lv_color_hex(0x44d1b6) +#define LV_THEME_FONT_SMALL &lv_font_montserrat_14 +#define LV_THEME_FONT_NORMAL &lv_font_montserrat_14 +#define LV_THEME_FONT_LARGE &lv_font_montserrat_14 +#define LV_THEME_FONT_EXTRA_LARGE &lv_font_montserrat_14 + +/* An external include file required to see the theme init function. + * Relative to "lv_core/lv_obj" */ +#define LV_THEME_INIT_INCLUDE "../extra/themes/lv_themes.h" + +/* Set a theme initialization function */ +#define LV_THEME_INIT lv_theme_default_init + /*================== * WIDGET USAGE *================*/ @@ -379,33 +419,45 @@ typedef void * lv_user_data_t; /*----------- * Widgets *----------*/ -#define LV_USE_CALENDAR 0 -#define LV_USE_CALENDAR_HEADER_ARROW 0 +#define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +# if LV_CALENDAR_WEEK_STARTS_MONDAY +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} +# else +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} +# endif -#define LV_USE_COLORWHEEL 0 +# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} +# define LV_USE_CALENDAR_HEADER_ARROW 1 +#endif /*LV_USE_CALENDAR*/ -#define LV_USE_KEYBOARD 0 +#define LV_USE_COLORWHEEL 1 -#define LV_USE_LED 0 +#define LV_USE_IMGBTN 1 -#define LV_USE_LIST 0 +#define LV_USE_KEYBOARD 1 -#define LV_USE_MSGBOX 0 +#define LV_USE_LED 1 -#define LV_USE_SPINBOX 0 +#define LV_USE_LIST 1 -#define LV_USE_SPINNER 0 +#define LV_USE_MSGBOX 1 -#define LV_USE_TABVIEW 0 +#define LV_USE_SPINBOX 1 -#define LV_USE_TILEVIEW 0 +#define LV_USE_SPINNER 1 -#define LV_USE_WIN 0 +#define LV_USE_TABVIEW 1 + +#define LV_USE_TILEVIEW 1 + +#define LV_USE_WIN 1 /*----------- * Themes *----------*/ -/* Use the default theme. If not used a custom theme needs be assigned to the display.*/ +/* A simple, impressive and very complete theme */ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT /* 1: Light mode; 0: Dark mode*/ @@ -428,14 +480,6 @@ typedef void * lv_user_data_t; /*Enable the examples to be built with the library*/ #define LV_BUILD_EXAMPLES 1 -/*================== - * Non-user section - *==================*/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -# define _CRT_SECURE_NO_WARNINGS -#endif - /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ diff --git a/lvgl.mk b/lvgl.mk index 1479c217a8..d85ae1c07f 100644 --- a/lvgl.mk +++ b/lvgl.mk @@ -3,6 +3,6 @@ include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal/lv_hal.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets/lv_widgets.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font/lv_font.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc/lv_misc.mk -include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes/lv_themes.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw/lv_draw.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu/lv_gpu.mk +include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra/extra.mk diff --git a/scripts/lv_conf_checker.py b/scripts/lv_conf_checker.py index d520042081..43508bc130 100755 --- a/scripts/lv_conf_checker.py +++ b/scripts/lv_conf_checker.py @@ -114,34 +114,16 @@ fout.write( /*If running without lv_conf.h add typdesf with default value*/ #if defined(LV_CONF_SKIP) - /* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ - typedef int16_t lv_coord_t; -# if LV_USE_ANIMATION - /*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ - typedef void * lv_anim_user_data_t; -# endif - -# if LV_USE_GROUP - typedef void * lv_group_user_data_t; -# endif - -# if LV_USE_FILESYSTEM - typedef void * lv_fs_drv_user_data_t; -# endif - - typedef void * lv_img_decoder_user_data_t; - - typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ - typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ - - typedef void * lv_font_user_data_t; - -# if LV_USE_USER_DATA +# if LV_USE_USER_DATA typedef void * lv_obj_user_data_t; -# endif +# endif -#endif +# if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ +# define _CRT_SECURE_NO_WARNINGS +# endif + +#endif /*defined(LV_CONF_SKIP)*/ #endif /*LV_CONF_INTERNAL_H*/ ''' diff --git a/src/extra/extra.mk b/src/extra/extra.mk new file mode 100644 index 0000000000..f2e18e7664 --- /dev/null +++ b/src/extra/extra.mk @@ -0,0 +1 @@ +CSRCS += $(shell find -L ../src/extra -name \*.c) diff --git a/src/extra/widgets/colorwheel/lv_colorwheel.c b/src/extra/widgets/colorwheel/lv_colorwheel.c index dc3fc76f7a..681a2e5955 100644 --- a/src/extra/widgets/colorwheel/lv_colorwheel.c +++ b/src/extra/widgets/colorwheel/lv_colorwheel.c @@ -260,12 +260,12 @@ static void draw_disc_grad(lv_obj_t * obj, const lv_area_t * mask) uint16_t i; lv_coord_t cir_w = lv_obj_get_style_arc_width(obj, LV_PART_MAIN); - /* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */ +#if LV_DRAW_COMPLEX + /* Mask outer and inner ring of widget to tidy up ragged edges of lines while drawing outer ring */ lv_draw_mask_radius_param_t mask_out_param; lv_draw_mask_radius_init(&mask_out_param, &obj->coords, LV_RADIUS_CIRCLE, false); int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); - lv_area_t mask_area; lv_area_copy(&mask_area, &obj->coords); mask_area.x1 += cir_w; @@ -276,25 +276,30 @@ static void draw_disc_grad(lv_obj_t * obj, const lv_area_t * mask) lv_draw_mask_radius_init(&mask_in_param, &mask_area, LV_RADIUS_CIRCLE, true); int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, 0); - /* The inner line ends will be masked out. + /* The inner and outer line ends will be masked out. * So make lines a little bit longer because the masking makes a more even result */ - lv_coord_t cir_w_extra = cir_w + line_dsc.width; + lv_coord_t cir_w_extra = line_dsc.width; +#else + lv_coord_t cir_w_extra = 0; +#endif for(i = 0; i <= 360; i += LV_CPICKER_DEF_QF) { line_dsc.color = angle_to_mode_color(obj, i); lv_point_t p[2]; - p[0].x = cx + ((r + line_dsc.width) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[0].y = cy + ((r + line_dsc.width) * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); - p[1].x = cx + ((r - cir_w_extra) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); - p[1].y = cy + ((r - cir_w_extra) * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT); + p[0].x = cx + ((r + cir_w_extra) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[0].y = cy + ((r + cir_w_extra) * lv_trigo_cos(i) >> LV_TRIGO_SHIFT); + p[1].x = cx + ((r - cir_w - cir_w_extra) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT); + p[1].y = cy + ((r - cir_w - cir_w_extra) * lv_trigo_cos(i) >> LV_TRIGO_SHIFT); lv_draw_line(&p[0], &p[1], mask, &line_dsc); } + +#if LV_DRAW_COMPLEX lv_draw_mask_remove_id(mask_out_id); lv_draw_mask_remove_id(mask_in_id); - +#endif } static void draw_knob(lv_obj_t * obj, const lv_area_t * mask) diff --git a/src/extra/widgets/led/lv_led.c b/src/extra/widgets/led/lv_led.c index 2fa827cbac..acf1d81381 100644 --- a/src/extra/widgets/led/lv_led.c +++ b/src/extra/widgets/led/lv_led.c @@ -81,7 +81,7 @@ void lv_led_set_color(lv_obj_t * led, lv_color_t color) * @param led pointer to a LED object * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light) */ -void lv_led_set_bright(lv_obj_t * obj, uint8_t bright) +void lv_led_set_brightness(lv_obj_t * obj, uint8_t bright) { /*Set the brightness*/ lv_led_t * led = (lv_led_t *) obj; @@ -102,7 +102,7 @@ void lv_led_set_bright(lv_obj_t * obj, uint8_t bright) */ void lv_led_on(lv_obj_t * led) { - lv_led_set_bright(led, LV_LED_BRIGHT_MAX); + lv_led_set_brightness(led, LV_LED_BRIGHT_MAX); } /** @@ -111,7 +111,7 @@ void lv_led_on(lv_obj_t * led) */ void lv_led_off(lv_obj_t * led) { - lv_led_set_bright(led, LV_LED_BRIGHT_MIN); + lv_led_set_brightness(led, LV_LED_BRIGHT_MIN); } /** diff --git a/src/extra/widgets/tabview/lv_tabview.c b/src/extra/widgets/tabview/lv_tabview.c index d3bcdd2e59..9640348f43 100644 --- a/src/extra/widgets/tabview/lv_tabview.c +++ b/src/extra/widgets/tabview/lv_tabview.c @@ -92,7 +92,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) } } tabview->map = new_map; - lv_btnmatrix_set_map(btns, new_map); + lv_btnmatrix_set_map(btns, (const char **)new_map); lv_mem_free(old_map); lv_btnmatrix_set_btn_ctrl_all(btns, LV_BTNMATRIX_CTRL_CHECKABLE | LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT); @@ -179,7 +179,7 @@ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o lv_btnmatrix_set_one_checked(btnm, true); tabview->map = lv_mem_alloc(sizeof(const char *)); tabview->map[0] = ""; - lv_btnmatrix_set_map(btnm, tabview->map); + lv_btnmatrix_set_map(btnm, (const char **)tabview->map); lv_obj_add_event_cb(btnm, btns_event_cb, NULL); lv_obj_add_flag(btnm, LV_OBJ_FLAG_EVENT_BUBBLE); diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 9553d7dc66..abd8da699f 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -51,6 +51,7 @@ #include + /*==================== COLOR SETTINGS *====================*/ @@ -258,6 +259,62 @@ # endif #endif +/*------------- + * GPU + *-----------*/ + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#ifndef LV_USE_GPU_STM32_DMA2D +# ifdef CONFIG_LV_USE_GPU_STM32_DMA2D +# define LV_USE_GPU_STM32_DMA2D CONFIG_LV_USE_GPU_STM32_DMA2D +# else +# define LV_USE_GPU_STM32_DMA2D 0 +# endif +#endif +#if LV_USE_GPU_STM32_DMA2D +/*Must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h" */ +#ifndef LV_GPU_DMA2D_CMSIS_INCLUDE +# ifdef CONFIG_LV_GPU_DMA2D_CMSIS_INCLUDE +# define LV_GPU_DMA2D_CMSIS_INCLUDE CONFIG_LV_GPU_DMA2D_CMSIS_INCLUDE +# else +# define LV_GPU_DMA2D_CMSIS_INCLUDE +# endif +#endif +#endif + +/* Use NXP's PXP GPU iMX RTxxx platforms */ +#ifndef LV_USE_GPU_NXP_PXP +# ifdef CONFIG_LV_USE_GPU_NXP_PXP +# define LV_USE_GPU_NXP_PXP CONFIG_LV_USE_GPU_NXP_PXP +# else +# define LV_USE_GPU_NXP_PXP 0 +# endif +#endif +#if LV_USE_GPU_NXP_PXP +/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + * */ +#ifndef LV_USE_GPU_NXP_PXP_AUTO_INIT +# ifdef CONFIG_LV_USE_GPU_NXP_PXP_AUTO_INIT +# define LV_USE_GPU_NXP_PXP_AUTO_INIT CONFIG_LV_USE_GPU_NXP_PXP_AUTO_INIT +# else +# define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +# endif +#endif +#endif + +/* Use NXP's VG-Lite GPU iMX RTxxx platforms */ +#ifndef LV_USE_GPU_NXP_VG_LITE +# ifdef CONFIG_LV_USE_GPU_NXP_VG_LITE +# define LV_USE_GPU_NXP_VG_LITE CONFIG_LV_USE_GPU_NXP_VG_LITE +# else +# define LV_USE_GPU_NXP_VG_LITE 0 +# endif +#endif + /*------------- * Logging *-----------*/ @@ -267,7 +324,7 @@ # ifdef CONFIG_LV_USE_LOG # define LV_USE_LOG CONFIG_LV_USE_LOG # else -# define LV_USE_LOG 0 +# define LV_USE_LOG 1 # endif #endif #if LV_USE_LOG @@ -292,7 +349,7 @@ # ifdef CONFIG_LV_LOG_PRINTF # define LV_LOG_PRINTF CONFIG_LV_LOG_PRINTF # else -# define LV_LOG_PRINTF 0 +# define LV_LOG_PRINTF 1 # endif #endif #endif /*LV_USE_LOG*/ @@ -303,15 +360,6 @@ /* Enable asserts if an operation is failed or an invalid data is found. * If LV_USE_LOG is enabled an error message will be printed on failure*/ -#ifndef LV_USE_ASSERT -# ifdef CONFIG_LV_USE_ASSERT -# define LV_USE_ASSERT CONFIG_LV_USE_ASSERT -# else -# define LV_USE_ASSERT 1 -# endif -#endif -#if LV_USE_ASSERT - #ifndef LV_USE_ASSERT_NULL # ifdef CONFIG_LV_USE_ASSERT_NULL # define LV_USE_ASSERT_NULL CONFIG_LV_USE_ASSERT_NULL @@ -330,21 +378,21 @@ # ifdef CONFIG_LV_USE_ASSERT_STYLE # define LV_USE_ASSERT_STYLE CONFIG_LV_USE_ASSERT_STYLE # else -# define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +# define LV_USE_ASSERT_STYLE 1 /*Check if the styles are properly initialized. (Very fast, recommended)*/ # endif #endif #ifndef LV_USE_ASSERT_MEM_INTEGRITY # ifdef CONFIG_LV_USE_ASSERT_MEM_INTEGRITY # define LV_USE_ASSERT_MEM_INTEGRITY CONFIG_LV_USE_ASSERT_MEM_INTEGRITY # else -# define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +# define LV_USE_ASSERT_MEM_INTEGRITY 1 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ # endif #endif #ifndef LV_USE_ASSERT_OBJ # ifdef CONFIG_LV_USE_ASSERT_OBJ # define LV_USE_ASSERT_OBJ CONFIG_LV_USE_ASSERT_OBJ # else -# define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow) */ +# define LV_USE_ASSERT_OBJ 1 /*Check the object's type and existence (e.g. not deleted). (Slow) */ # endif #endif @@ -364,12 +412,19 @@ # endif #endif -#endif /*LV_USE_ASSERT*/ - /*------------- * Others *-----------*/ +/*1: Show CPU usage and FPS count in the right bottom corner*/ +#ifndef LV_USE_PERF_MONITOR +# ifdef CONFIG_LV_USE_PERF_MONITOR +# define LV_USE_PERF_MONITOR CONFIG_LV_USE_PERF_MONITOR +# else +# define LV_USE_PERF_MONITOR 0 +# endif +#endif + /*Change the built in (v)snprintf functions*/ #ifndef LV_SPRINTF_CUSTOM # ifdef CONFIG_LV_SPRINTF_CUSTOM @@ -757,14 +812,14 @@ # ifdef CONFIG_LV_FONT_UNSCII_8 # define LV_FONT_UNSCII_8 CONFIG_LV_FONT_UNSCII_8 # else -# define LV_FONT_UNSCII_8 0 +# define LV_FONT_UNSCII_8 0 # endif #endif #ifndef LV_FONT_UNSCII_16 # ifdef CONFIG_LV_FONT_UNSCII_16 # define LV_FONT_UNSCII_16 CONFIG_LV_FONT_UNSCII_16 # else -# define LV_FONT_UNSCII_16 0 +# define LV_FONT_UNSCII_16 0 # endif #endif @@ -779,15 +834,6 @@ # endif #endif -/*Always set a default font*/ -#ifndef LV_FONT_DEFAULT -# ifdef CONFIG_LV_FONT_DEFAULT -# define LV_THEME_FONT_NORMAL CONFIG_LV_FONT_DEFAULT -# else -# define LV_THEME_FONT_NORMAL &lv_font_montserrat_14 -# endif -#endif - /* Enable handling large font and/or fonts with a lot of characters. * The limit depends on the font size, font face and bpp. * Compiler error will be triggered if a font needs it.*/ @@ -804,7 +850,7 @@ # ifdef CONFIG_LV_USE_FONT_COMPRESSED # define LV_USE_FONT_COMPRESSED CONFIG_LV_USE_FONT_COMPRESSED # else -# define LV_USE_FONT_COMPRESSED 1 +# define LV_USE_FONT_COMPRESSED 0 # endif #endif @@ -813,7 +859,7 @@ # ifdef CONFIG_LV_USE_FONT_SUBPX # define LV_USE_FONT_SUBPX CONFIG_LV_USE_FONT_SUBPX # else -# define LV_USE_FONT_SUBPX 1 +# define LV_USE_FONT_SUBPX 0 # endif #endif #if LV_USE_FONT_SUBPX @@ -822,7 +868,7 @@ # ifdef CONFIG_LV_FONT_SUBPX_BGR # define LV_FONT_SUBPX_BGR CONFIG_LV_FONT_SUBPX_BGR # else -# define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +# define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ # endif #endif #endif @@ -899,7 +945,7 @@ # ifdef CONFIG_LV_USE_BIDI # define LV_USE_BIDI CONFIG_LV_USE_BIDI # else -# define LV_USE_BIDI 1 +# define LV_USE_BIDI 0 # endif #endif #if LV_USE_BIDI @@ -927,6 +973,72 @@ #endif +/*================== + * THEME USAGE + *================*/ +/*Set the very basic the attributes*/ +#ifndef LV_THEME_COLOR_PRIMARY +# ifdef CONFIG_LV_THEME_COLOR_PRIMARY +# define LV_THEME_COLOR_PRIMARY CONFIG_LV_THEME_COLOR_PRIMARY +# else +# define LV_THEME_COLOR_PRIMARY lv_color_hex(0x01a2b1) +# endif +#endif +#ifndef LV_THEME_COLOR_SECONDARY +# ifdef CONFIG_LV_THEME_COLOR_SECONDARY +# define LV_THEME_COLOR_SECONDARY CONFIG_LV_THEME_COLOR_SECONDARY +# else +# define LV_THEME_COLOR_SECONDARY lv_color_hex(0x44d1b6) +# endif +#endif +#ifndef LV_THEME_FONT_SMALL +# ifdef CONFIG_LV_THEME_FONT_SMALL +# define LV_THEME_FONT_SMALL CONFIG_LV_THEME_FONT_SMALL +# else +# define LV_THEME_FONT_SMALL &lv_font_montserrat_14 +# endif +#endif +#ifndef LV_THEME_FONT_NORMAL +# ifdef CONFIG_LV_THEME_FONT_NORMAL +# define LV_THEME_FONT_NORMAL CONFIG_LV_THEME_FONT_NORMAL +# else +# define LV_THEME_FONT_NORMAL &lv_font_montserrat_14 +# endif +#endif +#ifndef LV_THEME_FONT_LARGE +# ifdef CONFIG_LV_THEME_FONT_LARGE +# define LV_THEME_FONT_LARGE CONFIG_LV_THEME_FONT_LARGE +# else +# define LV_THEME_FONT_LARGE &lv_font_montserrat_14 +# endif +#endif +#ifndef LV_THEME_FONT_EXTRA_LARGE +# ifdef CONFIG_LV_THEME_FONT_EXTRA_LARGE +# define LV_THEME_FONT_EXTRA_LARGE CONFIG_LV_THEME_FONT_EXTRA_LARGE +# else +# define LV_THEME_FONT_EXTRA_LARGE &lv_font_montserrat_14 +# endif +#endif + +/* An external include file required to see the theme init function. + * Relative to "lv_core/lv_obj" */ +#ifndef LV_THEME_INIT_INCLUDE +# ifdef CONFIG_LV_THEME_INIT_INCLUDE +# define LV_THEME_INIT_INCLUDE CONFIG_LV_THEME_INIT_INCLUDE +# else +# define LV_THEME_INIT_INCLUDE "../extra/themes/lv_themes.h" +# endif +#endif + +/* Set a theme initialization function */ +#ifndef LV_THEME_INIT +# ifdef CONFIG_LV_THEME_INIT +# define LV_THEME_INIT CONFIG_LV_THEME_INIT +# else +# define LV_THEME_INIT lv_theme_default_init +# endif +#endif + /*================== * WIDGET USAGE *================*/ @@ -1114,22 +1226,64 @@ # ifdef CONFIG_LV_USE_CALENDAR # define LV_USE_CALENDAR CONFIG_LV_USE_CALENDAR # else -# define LV_USE_CALENDAR 0 +# define LV_USE_CALENDAR 1 +# endif +#endif +#if LV_USE_CALENDAR +#ifndef LV_CALENDAR_WEEK_STARTS_MONDAY +# ifdef CONFIG_LV_CALENDAR_WEEK_STARTS_MONDAY +# define LV_CALENDAR_WEEK_STARTS_MONDAY CONFIG_LV_CALENDAR_WEEK_STARTS_MONDAY +# else +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +# endif +#endif +# if LV_CALENDAR_WEEK_STARTS_MONDAY +#ifndef LV_CALENDAR_DEFAULT_DAY_NAMES +# ifdef CONFIG_LV_CALENDAR_DEFAULT_DAY_NAMES +# define LV_CALENDAR_DEFAULT_DAY_NAMES CONFIG_LV_CALENDAR_DEFAULT_DAY_NAMES +# else +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} +# endif +#endif +# else +#ifndef LV_CALENDAR_DEFAULT_DAY_NAMES +# ifdef CONFIG_LV_CALENDAR_DEFAULT_DAY_NAMES +# define LV_CALENDAR_DEFAULT_DAY_NAMES CONFIG_LV_CALENDAR_DEFAULT_DAY_NAMES +# else +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} +# endif +#endif +# endif + +#ifndef LV_CALENDAR_DEFAULT_MONTH_NAMES +# ifdef CONFIG_LV_CALENDAR_DEFAULT_MONTH_NAMES +# define LV_CALENDAR_DEFAULT_MONTH_NAMES CONFIG_LV_CALENDAR_DEFAULT_MONTH_NAMES +# else +# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} # endif #endif #ifndef LV_USE_CALENDAR_HEADER_ARROW # ifdef CONFIG_LV_USE_CALENDAR_HEADER_ARROW # define LV_USE_CALENDAR_HEADER_ARROW CONFIG_LV_USE_CALENDAR_HEADER_ARROW # else -# define LV_USE_CALENDAR_HEADER_ARROW 0 +# define LV_USE_CALENDAR_HEADER_ARROW 1 # endif #endif +#endif /*LV_USE_CALENDAR*/ #ifndef LV_USE_COLORWHEEL # ifdef CONFIG_LV_USE_COLORWHEEL # define LV_USE_COLORWHEEL CONFIG_LV_USE_COLORWHEEL # else -# define LV_USE_COLORWHEEL 0 +# define LV_USE_COLORWHEEL 1 +# endif +#endif + +#ifndef LV_USE_IMGBTN +# ifdef CONFIG_LV_USE_IMGBTN +# define LV_USE_IMGBTN CONFIG_LV_USE_IMGBTN +# else +# define LV_USE_IMGBTN 1 # endif #endif @@ -1137,7 +1291,7 @@ # ifdef CONFIG_LV_USE_KEYBOARD # define LV_USE_KEYBOARD CONFIG_LV_USE_KEYBOARD # else -# define LV_USE_KEYBOARD 0 +# define LV_USE_KEYBOARD 1 # endif #endif @@ -1145,7 +1299,7 @@ # ifdef CONFIG_LV_USE_LED # define LV_USE_LED CONFIG_LV_USE_LED # else -# define LV_USE_LED 0 +# define LV_USE_LED 1 # endif #endif @@ -1153,7 +1307,7 @@ # ifdef CONFIG_LV_USE_LIST # define LV_USE_LIST CONFIG_LV_USE_LIST # else -# define LV_USE_LIST 0 +# define LV_USE_LIST 1 # endif #endif @@ -1161,7 +1315,7 @@ # ifdef CONFIG_LV_USE_MSGBOX # define LV_USE_MSGBOX CONFIG_LV_USE_MSGBOX # else -# define LV_USE_MSGBOX 0 +# define LV_USE_MSGBOX 1 # endif #endif @@ -1169,7 +1323,7 @@ # ifdef CONFIG_LV_USE_SPINBOX # define LV_USE_SPINBOX CONFIG_LV_USE_SPINBOX # else -# define LV_USE_SPINBOX 0 +# define LV_USE_SPINBOX 1 # endif #endif @@ -1177,7 +1331,7 @@ # ifdef CONFIG_LV_USE_SPINNER # define LV_USE_SPINNER CONFIG_LV_USE_SPINNER # else -# define LV_USE_SPINNER 0 +# define LV_USE_SPINNER 1 # endif #endif @@ -1185,7 +1339,7 @@ # ifdef CONFIG_LV_USE_TABVIEW # define LV_USE_TABVIEW CONFIG_LV_USE_TABVIEW # else -# define LV_USE_TABVIEW 0 +# define LV_USE_TABVIEW 1 # endif #endif @@ -1193,7 +1347,7 @@ # ifdef CONFIG_LV_USE_TILEVIEW # define LV_USE_TILEVIEW CONFIG_LV_USE_TILEVIEW # else -# define LV_USE_TILEVIEW 0 +# define LV_USE_TILEVIEW 1 # endif #endif @@ -1201,14 +1355,14 @@ # ifdef CONFIG_LV_USE_WIN # define LV_USE_WIN CONFIG_LV_USE_WIN # else -# define LV_USE_WIN 0 +# define LV_USE_WIN 1 # endif #endif /*----------- * Themes *----------*/ -/* Use the default theme. If not used a custom theme needs be assigned to the display.*/ +/* A simple, impressive and very complete theme */ #ifndef LV_USE_THEME_DEFAULT # ifdef CONFIG_LV_USE_THEME_DEFAULT # define LV_USE_THEME_DEFAULT CONFIG_LV_USE_THEME_DEFAULT @@ -1267,52 +1421,20 @@ # endif #endif -/*================== - * Non-user section - *==================*/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -#ifndef _CRT_SECURE_NO_WARNINGS -# ifdef CONFIG__CRT_SECURE_NO_WARNINGS -# define _CRT_SECURE_NO_WARNINGS CONFIG__CRT_SECURE_NO_WARNINGS -# else -# define _CRT_SECURE_NO_WARNINGS -# endif -#endif -#endif - /*If running without lv_conf.h add typdesf with default value*/ #if defined(LV_CONF_SKIP) - /* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ - typedef int16_t lv_coord_t; -# if LV_USE_ANIMATION - /*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ - typedef void * lv_anim_user_data_t; -# endif - -# if LV_USE_GROUP - typedef void * lv_group_user_data_t; -# endif - -# if LV_USE_FILESYSTEM - typedef void * lv_fs_drv_user_data_t; -# endif - - typedef void * lv_img_decoder_user_data_t; - - typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ - typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ - - typedef void * lv_font_user_data_t; - -# if LV_USE_USER_DATA +# if LV_USE_USER_DATA typedef void * lv_obj_user_data_t; -# endif +# endif -#endif +# if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ +# define _CRT_SECURE_NO_WARNINGS +# endif + +#endif /*defined(LV_CONF_SKIP)*/ #endif /*LV_CONF_INTERNAL_H*/ diff --git a/src/lv_core/lv_core.mk b/src/lv_core/lv_core.mk index 9900ca9b0f..ca87c12c2f 100644 --- a/src/lv_core/lv_core.mk +++ b/src/lv_core/lv_core.mk @@ -1,16 +1,16 @@ -CSRCS += lv_grid.c +CSRCS += lv_disp.c CSRCS += lv_group.c CSRCS += lv_indev.c CSRCS += lv_indev_scroll.c -CSRCS += lv_disp.c CSRCS += lv_obj.c +CSRCS += lv_obj_class.c CSRCS += lv_obj_pos.c -CSRCS += lv_obj_style.c CSRCS += lv_obj_draw.c CSRCS += lv_obj_scroll.c +CSRCS += lv_obj_style.c +CSRCS += lv_obj_tree.c CSRCS += lv_refr.c -CSRCS += lv_style.c -CSRCS += lv_flex.c +CSRCS += lv_theme.c DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core diff --git a/src/lv_core/lv_disp.c b/src/lv_core/lv_disp.c index 2522d39e69..e21a54b9d4 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -218,8 +218,8 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t /*Be sure both screens are in a normal position*/ lv_obj_set_pos(new_scr, 0, 0); lv_obj_set_pos(lv_scr_act(), 0, 0); -// lv_style_remove_prop(lv_obj_get_local_style(new_scr, LV_PART_MAIN, LV_STATE_DEFAULT), LV_STYLE_OPA); -// lv_style_remove_prop(lv_obj_get_local_style(lv_scr_act(), LV_PART_MAIN, LV_STATE_DEFAULT), LV_STYLE_OPA); + lv_obj_remove_local_style_prop(new_scr, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA); + lv_obj_remove_local_style_prop(lv_scr_act(), LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA); lv_anim_t a_new; lv_anim_init(&a_new); @@ -379,7 +379,7 @@ static void scr_load_anim_start(lv_anim_t * a) static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v) { -// lv_obj_set_style_bg_color(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v); + lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v); } static void scr_anim_ready(lv_anim_t * a) @@ -389,5 +389,5 @@ static void scr_anim_ready(lv_anim_t * a) if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr); d->prev_scr = NULL; d->scr_to_load = NULL; -// lv_style_remove_prop(lv_obj_get_local_style(a->var, LV_PART_MAIN, LV_STATE_DEFAULT), LV_STYLE_OPA); + lv_obj_remove_local_style_prop(a->var, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA); } diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index d38b8389e8..c707c91ca2 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -29,12 +29,6 @@ * TYPEDEFS **********************/ -/********************** - * GLOBAL PROTOTYPES - **********************/ -void lv_indev_scroll_handler(lv_indev_proc_t * proc); -void lv_indev_scroll_throw_handler(lv_indev_proc_t * proc); - /********************** * STATIC PROTOTYPES **********************/ @@ -769,7 +763,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) if(new_obj_searched && proc->types.pointer.last_obj) { proc->types.pointer.scroll_throw_vect.x = 0; proc->types.pointer.scroll_throw_vect.y = 0; - lv_indev_scroll_throw_handler(proc); + _lv_indev_scroll_throw_handler(proc); if(indev_reset_check(proc)) return; } @@ -841,7 +835,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) if(indev_act->proc.wait_until_release) return; - lv_indev_scroll_handler(proc); + _lv_indev_scroll_handler(proc); if(indev_reset_check(proc)) return; indev_gesture(proc); if(indev_reset_check(proc)) return; @@ -923,7 +917,7 @@ static void indev_proc_release(lv_indev_proc_t * proc) /*The reset can be set in the signal function. * In case of reset query ignore the remaining parts.*/ if(scroll_obj) { - lv_indev_scroll_throw_handler(proc); + _lv_indev_scroll_throw_handler(proc); if(indev_reset_check(proc)) return; } } diff --git a/src/lv_core/lv_indev_scroll.c b/src/lv_core/lv_indev_scroll.c index 28614f3aee..80fcf9a98c 100644 --- a/src/lv_core/lv_indev_scroll.c +++ b/src/lv_core/lv_indev_scroll.c @@ -42,11 +42,7 @@ static lv_coord_t elastic_diff(lv_obj_t * obj, lv_coord_t diff, lv_coord_t scrol * GLOBAL FUNCTIONS **********************/ -/** - * Handle scrolling. Called by LVGL during input device processing - * @param proc pointer to an input device's proc field - */ -void lv_indev_scroll_handler(lv_indev_proc_t * proc) +void _lv_indev_scroll_handler(lv_indev_proc_t * proc) { lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj; /*If there is no scroll object yet try to find one*/ @@ -97,11 +93,7 @@ void lv_indev_scroll_handler(lv_indev_proc_t * proc) } -/** - * Handle throwing after scrolling. Called by LVGL during input device processing - * @param proc pointer to an input device's proc field - */ -void lv_indev_scroll_throw_handler(lv_indev_proc_t * proc) +void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc) { lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj; if(scroll_obj == NULL) return; diff --git a/src/lv_core/lv_indev_scroll.h b/src/lv_core/lv_indev_scroll.h index c92e1dac48..5d76ba3760 100644 --- a/src/lv_core/lv_indev_scroll.h +++ b/src/lv_core/lv_indev_scroll.h @@ -27,6 +27,18 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ +/** + * Handle scrolling. Called by LVGL during input device processing + * @param proc pointer to an input device's proc field + */ +void _lv_indev_scroll_handler(lv_indev_proc_t * proc); + +/** + * Handle throwing after scrolling. Called by LVGL during input device processing + * @param proc pointer to an input device's proc field + */ +void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc); + /** * Predict where would a scroll throw end * @param indev pointer to an input device diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 27cbe53eec..d85b442d45 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -59,13 +59,6 @@ typedef struct { const lv_anim_path_t * path; }trans_set_t; -/********************** - * GLOBAL PROTOTYPES - **********************/ -void lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, - lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path); -_lv_style_state_cmp_t lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2); - /********************** * STATIC PROTOTYPES **********************/ @@ -132,7 +125,9 @@ void lv_init(void) _lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t)); _lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t)); - lv_theme_t * th = LV_THEME_INIT + lv_theme_t * th = LV_THEME_INIT(LV_THEME_COLOR_PRIMARY, LV_THEME_COLOR_SECONDARY, + LV_THEME_FONT_SMALL, LV_THEME_FONT_NORMAL, + LV_THEME_FONT_LARGE, LV_THEME_FONT_EXTRA_LARGE); lv_theme_set_act(th); @@ -151,6 +146,15 @@ void lv_init(void) LV_LOG_WARN("The strings has no UTF-8 encoding. Some characters won't be displayed.") } +#if LV_USE_ASSERT_MEM_INTEGRITY + LV_LOG_WARN("Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower") +#endif + +#if LV_USE_ASSERT_OBJ + LV_LOG_WARN("Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower") +#endif + + lv_initialized = true; LV_LOG_INFO("lv_init ready"); } @@ -248,7 +252,7 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param) if(res == LV_RES_OK) { if(lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) && obj->parent) { - lv_res_t res = lv_event_send(obj->parent, event, param); + res = lv_event_send(obj->parent, event, param); if(res != LV_RES_OK) return LV_RES_INV; } } @@ -273,12 +277,7 @@ uint32_t lv_event_register_id(void) return last_id; } -/** - * Nested events can be called and one of them might belong to an object that is being deleted. - * Mark this object's `event_temp_data` deleted to know that it's `lv_event_send` should return `LV_RES_INV` - * @param obj pointer to an obejct to mark as deleted - */ -void lv_event_mark_deleted(lv_obj_t * obj) +void _lv_event_mark_deleted(lv_obj_t * obj) { lv_event_temp_data_t * t = event_temp_data_head; @@ -342,7 +341,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) lv_state_t prev_state = obj->state; obj->state = new_state; - _lv_style_state_cmp_t cmp_res = lv_obj_style_state_compare(obj, prev_state, new_state); + _lv_style_state_cmp_t cmp_res = _lv_obj_style_state_compare(obj, prev_state, new_state); /*If there is no difference in styles there is nothing else to do*/ if(cmp_res == _LV_STYLE_STATE_CMP_SAME) return; @@ -381,7 +380,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) } for(i = 0;i < tsi; i++) { - lv_obj_style_create_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path); + _lv_obj_style_create_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path); } lv_mem_buf_release(ts); diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 80743a3071..9dedc2f586 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -343,6 +343,13 @@ void * lv_event_get_user_data(void); */ uint32_t lv_event_register_id(void); +/** + * Nested events can be called and one of them might belong to an object that is being deleted. + * Mark this object's `event_temp_data` deleted to know that it's `lv_event_send` should return `LV_RES_INV` + * @param obj pointer to an obejct to mark as deleted + */ +void _lv_event_mark_deleted(lv_obj_t * obj); + /** * Send an event to the object * @param obj pointer to an object @@ -506,7 +513,7 @@ bool lv_obj_is_valid(const lv_obj_t * obj); * MACROS **********************/ -#if LV_USE_ASSERT && LV_USE_ASSERT_OBJ +#if LV_USE_ASSERT_OBJ # define LV_ASSERT_OBJ(obj_p, obj_class) \ LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \ LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \ diff --git a/src/lv_core/lv_obj_class.c b/src/lv_core/lv_obj_class.c index 4cbbaa2c43..b995fda54e 100644 --- a/src/lv_core/lv_obj_class.c +++ b/src/lv_core/lv_obj_class.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_obj.h" +#include "lv_theme.h" /********************* * DEFINES @@ -70,7 +71,7 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p return obj; } -void lv_obj_destruct(lv_obj_t * obj) +void _lv_obj_destruct(lv_obj_t * obj) { if(obj->class_p->destructor_cb) obj->class_p->destructor_cb(obj); @@ -79,7 +80,7 @@ void lv_obj_destruct(lv_obj_t * obj) obj->class_p = obj->class_p->base_class; /*Call the base class's destructor too*/ - lv_obj_destruct(obj); + _lv_obj_destruct(obj); } } diff --git a/src/lv_core/lv_obj_class.h b/src/lv_core/lv_obj_class.h index dd3d8d7b59..bfb89a6e5a 100644 --- a/src/lv_core/lv_obj_class.h +++ b/src/lv_core/lv_obj_class.h @@ -60,6 +60,8 @@ typedef struct _lv_obj_class_t{ */ struct _lv_obj_t * lv_obj_create_from_class(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent, const struct _lv_obj_t * copy); +void _lv_obj_destruct(struct _lv_obj_t * obj); + lv_res_t lv_obj_signal_base(const lv_obj_class_t * class_p, struct _lv_obj_t * obj, lv_signal_t sign, void * param); lv_draw_res_t lv_obj_draw_base(const lv_obj_class_t * class_p, struct _lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); diff --git a/src/lv_core/lv_obj_draw.c b/src/lv_core/lv_obj_draw.c index fc2e72603c..5da8df4889 100644 --- a/src/lv_core/lv_obj_draw.c +++ b/src/lv_core/lv_obj_draw.c @@ -174,8 +174,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } if(draw_dsc->bg_img_opa != LV_OPA_TRANSP) { - draw_dsc->img_src = lv_obj_get_style_bg_img_src(obj, part); - if(draw_dsc->img_src) { + draw_dsc->bg_img_src = lv_obj_get_style_bg_img_src(obj, part); + if(draw_dsc->bg_img_src) { draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part); if(draw_dsc->bg_img_opa > LV_OPA_MIN) { draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part); diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c index aadda1411a..5587bb2c4c 100644 --- a/src/lv_core/lv_obj_scroll.c +++ b/src/lv_core/lv_obj_scroll.c @@ -380,7 +380,7 @@ void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en) { lv_obj_t * parent = lv_obj_get_parent(obj); while(parent) { - lv_obj_scroll_to_view(obj, LV_ANIM_ON); + lv_obj_scroll_to_view(obj, anim_en); obj = parent; parent = lv_obj_get_parent(parent); } diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c index 5bbd6f5222..cc88d785b3 100644 --- a/src/lv_core/lv_obj_style.c +++ b/src/lv_core/lv_obj_style.c @@ -136,7 +136,7 @@ void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style /*Shift the styles after `i` by one*/ uint32_t j; - for(j = i; j < obj->style_list.style_cnt - 1 ; j++) { + for(j = i; j < (uint32_t)obj->style_list.style_cnt - 1 ; j++) { obj->style_list.styles[j] = obj->style_list.styles[j + 1]; } @@ -250,7 +250,7 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t stat return lv_style_remove_prop(obj->style_list.styles[i].style, prop); } -void lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, +void _lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path) { trans_t * tr; @@ -306,7 +306,7 @@ void lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_ } } -_lv_style_state_cmp_t lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2) +_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2) { lv_obj_style_list_t * list = &obj->style_list; _lv_style_state_cmp_t res = _LV_STYLE_STATE_CMP_SAME; @@ -971,12 +971,12 @@ static void trans_anim_ready_cb(lv_anim_t * a) static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v) { -// lv_obj_style_set_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v); + lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v); } static void fade_in_anim_ready(lv_anim_t * a) { -// lv_style_remove_prop(_lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE); + lv_obj_remove_local_style_prop(a->var, LV_PART_MAIN,LV_STATE_DEFAULT, LV_STYLE_OPA); } diff --git a/src/lv_core/lv_obj_style.h b/src/lv_core/lv_obj_style.h index 884c6d3cc1..934a6af3f0 100644 --- a/src/lv_core/lv_obj_style.h +++ b/src/lv_core/lv_obj_style.h @@ -157,6 +157,45 @@ void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint32_t */ bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop); +/** + * Used internally to create a style tarnsition + * @param obj + * @param prop + * @param part + * @param prev_state + * @param new_state + * @param time + * @param delay + * @param path + */ +void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state, + lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path); + +/** + * Used internally to compare the appearance of an object in 2 states + * @param obj + * @param state1 + * @param state2 + * @return + */ +_lv_style_state_cmp_t _lv_obj_style_state_compare(struct _lv_obj_t * obj, lv_state_t state1, lv_state_t state2); + +/** + * Fade in an an object and all its children. + * @param obj the object to fade in + * @param time time of fade + * @param delay delay to start the animation + */ +void lv_obj_fade_in(struct _lv_obj_t * obj, uint32_t time, uint32_t delay); + +/** + * Fade out an an object and all its children. + * @param obj the object to fade out + * @param time time of fade + * @param delay delay to start the animation + */ +void lv_obj_fade_out(struct _lv_obj_t * obj, uint32_t time, uint32_t delay); + /********************* * OBJ STYLE GET *********************/ diff --git a/src/lv_core/lv_obj_tree.c b/src/lv_core/lv_obj_tree.c index bf0574a309..8d6561f824 100644 --- a/src/lv_core/lv_obj_tree.c +++ b/src/lv_core/lv_obj_tree.c @@ -25,10 +25,6 @@ * TYPEDEFS **********************/ -/********************** - * GLOBAL PROTOTYPES - **********************/ -void lv_event_mark_deleted(lv_obj_t * obj); void lv_obj_destruct(lv_obj_t * obj); /********************** @@ -269,12 +265,16 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, int32_t id) if(obj->spec_attr == NULL) return NULL; + uint32_t idu; if(id < 0) { id = obj->spec_attr->child_cnt + id; if(id < 0) return NULL; + idu = (uint32_t) id; + } else { + idu = id; } - if(id >= obj->spec_attr->child_cnt) return NULL; + if(idu >= obj->spec_attr->child_cnt) return NULL; else return obj->spec_attr->children[id]; } @@ -331,7 +331,7 @@ static void obj_del_core(lv_obj_t * obj) child = lv_obj_get_child(obj, 0); } - lv_event_mark_deleted(obj); + _lv_event_mark_deleted(obj); /*Remove all style*/ lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/ @@ -355,7 +355,7 @@ static void obj_del_core(lv_obj_t * obj) } /* All children deleted. Now clean up the object specific data*/ - lv_obj_destruct(obj); + _lv_obj_destruct(obj); /*Remove the object from the child list of its parent*/ uint32_t id = lv_obj_get_child_id(obj); diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 40c3e598aa..1df0adfa24 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -11,6 +11,7 @@ #include "lv_draw_mask.h" #include "../lv_misc/lv_math.h" #include "../lv_misc/lv_log.h" +#include "../lv_misc/lv_mem.h" /********************* * DEFINES diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 840f22b8a1..3aa17a3bd5 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -299,9 +299,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co const lv_opa_t * mask, lv_draw_mask_res_t mask_res) { -#if LV_USE_GPU || LV_COLOR_SCREEN_TRANSP lv_disp_t * disp = _lv_refr_get_disp_refreshing(); -#endif /*Get the width of the `disp_area` it will be used to go to the next line*/ int32_t disp_w = lv_area_get_width(disp_area); @@ -335,12 +333,13 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co lv_gpu_stm32_dma2d_fill(disp_buf_first, disp_w, color, draw_area_w, draw_area_h); return; } -#elif LV_USE_GPU +#endif + if(disp->driver.gpu_fill_cb && lv_area_get_size(draw_area) > GPU_SIZE_LIMIT) { disp->driver.gpu_fill_cb(&disp->driver, disp_buf, disp_w, draw_area, color); return; } -#endif + /*Software rendering*/ for(y = 0; y < draw_area_h; y++) { lv_color_fill(disp_buf_first, color, draw_area_w); @@ -393,14 +392,6 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co } /*Masked*/ else { - /*DMA2D could be used here but it's much slower than software rendering*/ -#if LV_USE_GPU_STM32_DMA2D && 0 - if(lv_area_get_size(draw_area) > 240) { - lv_gpu_stm32_dma2d_fill_mask(disp_buf_first, disp_w, color, mask, opa, draw_area_w, draw_area_h); - return; - } -#endif - /*Buffer the result color to avoid recalculating the same color*/ lv_color_t last_dest_color; lv_color_t last_res_color; @@ -693,17 +684,6 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col /*Simple fill (maybe with opacity), no masking*/ if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) { -#if LV_USE_GPU - if(disp->driver.gpu_blend_cb && (lv_area_get_size(draw_area) > GPU_SIZE_LIMIT)) { - for(y = draw_area->y1; y <= draw_area->y2; y++) { - disp->driver.gpu_blend_cb(&disp->driver, disp_buf_first, map_buf_first, draw_area_w, opa); - disp_buf_first += disp_w; - map_buf_first += map_w; - } - return; - } -#endif - if(opa > LV_OPA_MAX) { #if LV_USE_GPU_NXP_PXP if(lv_area_get_size(draw_area) >= LV_GPU_NXP_PXP_BLIT_SIZE_LIMIT) { diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 6d1d58dabb..1a2a7fb102 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -1199,7 +1199,7 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const label_dsc.letter_space = dsc->content_letter_space; label_dsc.line_space = dsc->content_line_space; lv_point_t s; - lv_txt_get_size(&s, dsc->content_text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, + lv_txt_get_size(&s, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE); diff --git a/src/lv_misc/lv_assert.c b/src/lv_misc/lv_assert.c deleted file mode 100644 index c7e5af66f2..0000000000 --- a/src/lv_misc/lv_assert.c +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @file lv_assert.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_assert.h" - -#if LV_USE_ASSERT - -#include "lv_mem.h" -#include - -/********************* - * DEFINES - *********************/ -#ifndef LV_DEBUG_STR_MAX_LENGTH - #define LV_DEBUG_STR_MAX_LENGTH (1024 * 8) -#endif - -#ifndef LV_DEBUG_STR_MAX_REPEAT - #define LV_DEBUG_STR_MAX_REPEAT 8 -#endif -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -bool lv_debug_check_null(const void * p) -{ - if(p) return true; - - return false; -} - -bool lv_debug_check_mem_integrity(void) -{ - return lv_mem_test() == LV_RES_OK ? true : false; -} - -bool lv_debug_check_str(const void * str) -{ - const uint8_t * s = (const uint8_t *)str; - uint8_t last_byte = 0; - uint32_t rep = 0; - uint32_t i; - - for(i = 0; i < LV_DEBUG_STR_MAX_LENGTH && s[i] != '\0'; i++) { - if(s[i] != last_byte) { - last_byte = s[i]; - rep = 1; - } - else if(s[i] > 0x7F) { - rep++; - if(rep > LV_DEBUG_STR_MAX_REPEAT) { - LV_LOG_WARN("lv_debug_check_str: a non-ASCII char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)"); - return false; - } - } - - if(s[i] < 10) { - LV_LOG_WARN("lv_debug_check_str: invalid char in the string (< 10 value)"); - return false; /*Shouldn't occur in strings*/ - } - } - - if(s[i] == '\0') return true; - - LV_LOG_WARN("lv_debug_check_str: string is longer than LV_DEBUG_STR_MAX_LENGTH"); - return false; -} - -void lv_debug_log_error(const char * msg, uint64_t value) -{ - static const char hex[] = "0123456789ABCDEF"; - - size_t msg_len = strlen(msg); - uint32_t value_len = sizeof(unsigned long int); - - if(msg_len < 230) { - char buf[255]; - char * bufp = buf; - - /*Add the function name*/ - lv_memcpy(bufp, msg, msg_len); - bufp += msg_len; - - /*Add value in hey*/ - *bufp = ' '; - bufp ++; - *bufp = '('; - bufp ++; - *bufp = '0'; - bufp ++; - *bufp = 'x'; - bufp ++; - - int8_t i; - for(i = value_len * 2 - 1; i >= 0; i--) { - uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF; - - *bufp = hex[x]; - bufp++; - } - - *bufp = ')'; - bufp ++; - - *bufp = '\0'; - LV_LOG_ERROR(buf); - } - else { - LV_LOG_ERROR(msg); - } -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_ASSERT*/ diff --git a/src/lv_misc/lv_assert.h b/src/lv_misc/lv_assert.h index bc9a160cd5..40dbc09012 100644 --- a/src/lv_misc/lv_assert.h +++ b/src/lv_misc/lv_assert.h @@ -14,8 +14,6 @@ extern "C" { * INCLUDES *********************/ #include "../lv_conf_internal.h" - -#if LV_USE_ASSERT #include /********************* @@ -29,13 +27,6 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ -bool lv_debug_check_null(const void * p); - -bool lv_debug_check_mem_integrity(void); - -bool lv_debug_check_str(const void * str); - -void lv_debug_log_error(const char * msg, uint64_t value); /********************** * MACROS @@ -82,17 +73,6 @@ void lv_debug_log_error(const char * msg, uint64_t value); # define LV_ASSERT_MALLOC_INTEGRIT() #endif -#else /* LV_USE_ASSERT == 0 */ - -#define LV_ASSERT(expr) do{}while(0) -#define LV_ASSERT_MSG(expr, msg) do{}while(0) - -#define LV_ASSERT_NULL(p) -#define LV_ASSERT_MALLOC(p) -#define LV_ASSERT_MALLOC_INTEGRITY() - -#endif /* LV_USE_ASSERT */ - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index b8f48f922f..71ff1b60e4 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -153,8 +153,6 @@ void lv_mem_deinit(void) */ void * lv_mem_alloc(size_t size) { - // printf("alloc: %d\n", size); - if(size == 0) return &zero_mem; /*Round the size up to ALIGN_MASK*/ @@ -229,9 +227,8 @@ void lv_mem_free(const void * data) lv_memset((void *)data, 0xbb, lv_mem_get_size(data)); # endif #endif -// printf("free: %d\n", lv_mem_get_size(data)); -#if LV_MEM_CUSTOM == 0 + #if LV_MEM_CUSTOM == 0 e->header.s.used = 0; static uint32_t defr = 0; diff --git a/src/lv_misc/lv_misc.mk b/src/lv_misc/lv_misc.mk index 0e3992bbeb..66e6c84d60 100644 --- a/src/lv_misc/lv_misc.mk +++ b/src/lv_misc/lv_misc.mk @@ -14,7 +14,6 @@ CSRCS += lv_utils.c CSRCS += lv_async.c CSRCS += lv_printf.c CSRCS += lv_bidi.c -CSRCS += lv_debug.c DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 4c81c77160..56decfb688 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -51,10 +51,8 @@ LV_EXPORT_CONST_INT(LV_IMG_ZOOM_NONE); */ enum { LV_BLEND_MODE_NORMAL, /**< Simply mix according to the opacity value*/ -#if LV_DRAW_COMPLEX LV_BLEND_MODE_ADDITIVE, /**< Add the respective color channels*/ LV_BLEND_MODE_SUBTRACTIVE,/**< Subtract the foreground from the background*/ -#endif }; typedef uint8_t lv_blend_mode_t; @@ -657,7 +655,7 @@ static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value) * MACROS **********************/ -#if LV_USE_ASSERT && LV_USE_ASSERT_STYLE +#if LV_USE_ASSERT_STYLE # define LV_ASSERT_STYLE(style_p) LV_ASSERT_MSG(style_p != NULL, "The style is NULL"); \ LV_ASSERT_MSG(style_p->sentinel == LV_STYLE_SENTINEL_VALUE, "Style is not initialized or corrupted"); #else diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index a345041e62..46186611bf 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -31,7 +31,6 @@ **********************/ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); -static void lv_arc_destructor(lv_obj_t * obj); static lv_draw_res_t lv_arc_draw(lv_obj_t * arc, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param); static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, uint8_t part); @@ -44,7 +43,6 @@ static void value_update(lv_obj_t * arc); **********************/ const lv_obj_class_t lv_arc_class = { .constructor_cb = lv_arc_constructor, - .destructor_cb = lv_arc_destructor, .signal_cb = lv_arc_signal, .draw_cb = lv_arc_draw, .instance_size = sizeof(lv_arc_t), @@ -489,9 +487,7 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t lv_arc_t * arc = (lv_arc_t *)obj; LV_LOG_TRACE("arc create started"); - /*Create the ancestor of arc*/ - - /*Initialize the allocated 'ext' */ + /*Initialize the allocated 'ext' */ arc->rotation = 0; arc->bg_angle_start = 135; arc->bg_angle_end = 45; @@ -533,20 +529,6 @@ static void lv_arc_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t } -static void lv_arc_destructor(lv_obj_t * obj) -{ -// lv_arc_t * arc = obj; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC); -//#if LV_USE_ANIMATION -// lv_anim_del(&arc->cur_value_anim, NULL); -// lv_anim_del(&arc->start_value_anim, NULL); -//#endif -// -// arc->class_p->base_p->destructor(obj); -} - - static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ diff --git a/src/lv_widgets/lv_meter.c b/src/lv_widgets/lv_meter.c index feb5f9da31..c08a930862 100644 --- a/src/lv_widgets/lv_meter.c +++ b/src/lv_widgets/lv_meter.c @@ -349,20 +349,22 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c lv_meter_scale_t * scale; - lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN); - lv_obj_draw_hook_dsc_t hook_dsc; lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area); +#if LV_DRAW_COMPLEX lv_draw_mask_radius_param_t inner_minor_mask; lv_draw_mask_radius_param_t inner_major_mask; lv_draw_mask_radius_param_t outer_mask; +#endif _LV_LL_READ_BACK(&meter->scale_ll, scale) { lv_coord_t r_out = r_edge + scale->r_mod; lv_coord_t r_in_minor = r_out - scale->tick_length; lv_coord_t r_in_major = r_out - scale->tick_major_length; + +#if LV_DRAW_COMPLEX lv_area_t area_inner_minor; area_inner_minor.x1 = p_center.x - r_in_minor; area_inner_minor.y1 = p_center.y - r_in_minor; @@ -386,6 +388,7 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c int16_t outer_mask_id = lv_draw_mask_add(&outer_mask, NULL); int16_t inner_act_mask_id = -1; /*Will be added later*/ +#endif uint32_t minor_cnt = scale->tick_major_nth ? scale->tick_major_nth - 1 : 0xFFFF; for(i = 0; i < scale->tick_cnt; i++) { @@ -396,7 +399,9 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c major = true; } +#if LV_DRAW_COMPLEX inner_act_mask_id = lv_draw_mask_add(major ? &inner_major_mask : &inner_minor_mask, NULL); +#endif int32_t value_of_line = lv_map(i, 0, scale->tick_cnt - 1, scale->min, scale->max); @@ -442,24 +447,40 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c int32_t cos_high = lv_trigo_cos(angle_high + scale->rotation); int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; - lv_point_t p_outer; - /* Use the interpolated values to get the outer x and y coordinates. - * */ - p_outer.x = (int32_t)(((int32_t)cos_mid * (r_out + 5) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x; - p_outer.y = (int32_t)(((int32_t)sin_mid * (r_out + 5) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y; line_dsc.color = line_color; line_dsc.width = line_width; +#if LV_DRAW_COMPLEX + /* Use the interpolated angle to get the outer x and y coordinates. + * Draw a little bit longer lines to be sure the mask will clip them correctly*/ + lv_point_t p_outer; + p_outer.x = (int32_t)(((int32_t)cos_mid * (r_out + line_width) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x; + p_outer.y = (int32_t)(((int32_t)sin_mid * (r_out + line_width) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y; lv_draw_line(&p_outer, &p_center, clip_area, &line_dsc); +#else + /* Use the interpolated angle to get the outer and inner x and y coordinates.*/ + lv_point_t p_outer; + p_outer.x = (int32_t)(((int32_t)cos_mid * (r_out) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x; + p_outer.y = (int32_t)(((int32_t)sin_mid * (r_out) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y; + lv_point_t p_inner; + lv_coord_t r_in = major ? r_in_major : r_in_minor; + p_inner.x = (int32_t)(((int32_t)cos_mid * (r_in) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x; + p_inner.y = (int32_t)(((int32_t)sin_mid * (r_in) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y; + lv_draw_line(&p_outer, &p_inner, clip_area, &line_dsc); +#endif + line_dsc.color = line_color_ori; line_dsc.width = line_width_ori; +#if LV_DRAW_COMPLEX lv_draw_mask_remove_id(inner_act_mask_id); +#endif /*Draw the text*/ if(major) { +#if LV_DRAW_COMPLEX lv_draw_mask_remove_id(outer_mask_id); - +#endif uint32_t r_text = r_in_major - scale->label_gap; lv_point_t p; p.x = (int32_t)(((int32_t)cos_mid * r_text + 127) >> (LV_TRIGO_SHIFT)) + p_center.x; @@ -485,11 +506,15 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c lv_draw_label(&label_cord, clip_area, &label_dsc, hook_dsc.text, NULL); +#if LV_DRAW_COMPLEX outer_mask_id = lv_draw_mask_add(&outer_mask, NULL); +#endif } } +#if LV_DRAW_COMPLEX lv_draw_mask_remove_id(outer_mask_id); +#endif } } diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index f1f12cac16..f377adb498 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -57,7 +57,7 @@ static bool char_is_accepted(lv_obj_t * obj, uint32_t c); static void start_cursor_blink(lv_obj_t * obj); static void refr_cursor_area(lv_obj_t * obj); static void update_cursor_position_on_click(lv_obj_t * obj, lv_signal_t sign, lv_indev_t * click_source); -static lv_res_t insert_handler(lv_obj_t * obj, char * txt); +static lv_res_t insert_handler(lv_obj_t * obj, const char * txt); static void draw_placeholder(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_cursor(lv_obj_t * obj, const lv_area_t * clip_area); @@ -1459,10 +1459,10 @@ static void update_cursor_position_on_click(lv_obj_t * obj, lv_signal_t sign, lv #endif } -static lv_res_t insert_handler(lv_obj_t * obj, char * txt) +static lv_res_t insert_handler(lv_obj_t * obj, const char * txt) { ta_insert_replace = NULL; - lv_event_send(obj, LV_EVENT_INSERT, txt); + lv_event_send(obj, LV_EVENT_INSERT, (char*)txt); if(ta_insert_replace) { if(ta_insert_replace[0] == '\0') return LV_RES_INV; /*Drop this text*/ diff --git a/src/lv_widgets/lv_widgets.mk b/src/lv_widgets/lv_widgets.mk index 7f61474c88..643f1b79e0 100644 --- a/src/lv_widgets/lv_widgets.mk +++ b/src/lv_widgets/lv_widgets.mk @@ -8,16 +8,13 @@ CSRCS += lv_table.c CSRCS += lv_btn.c CSRCS += lv_chart.c CSRCS += lv_canvas.c -CSRCS += lv_gauge.c +CSRCS += lv_meter.c CSRCS += lv_label.c CSRCS += lv_slider.c CSRCS += lv_textarea.c CSRCS += lv_btnmatrix.c CSRCS += lv_img.c -CSRCS += lv_imgbtn.c -CSRCS += lv_linemeter.c CSRCS += lv_switch.c -CSRCS += lv_objmask.c DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets diff --git a/tests/build.py b/tests/build.py index 82969369e2..1c154aa79b 100755 --- a/tests/build.py +++ b/tests/build.py @@ -50,81 +50,37 @@ def build(name, defines): print("---------------------------") minimal_monochrome = { - "LV_DPI":40, - "LV_MEM_SIZE":4*1024, - "LV_HOR_RES_MAX":128, - "LV_VER_RES_MAX":64, "LV_COLOR_DEPTH":1, - "LV_USE_GROUP":0, - "LV_USE_ANIMATION":0, - "LV_ANTIALIAS":0, - "LV_GPU":0, - "LV_USE_FILESYSTEM":0, - "LV_USE_IMG_TRANSFORM":0, - "LV_USE_API_EXTENSION_V6":0, - "LV_USE_USER_DATA":0, - "LV_USE_USER_DATA_FREE":0, + "LV_MEM_SIZE":4 * 1024, + + "LV_DPI_DEF":40, + "LV_DRAW_COMPLEX":0, "LV_USE_LOG":0, - "LV_USE_THEME_EMPTY":0, - "LV_USE_THEME_MATERIAL":0, - "LV_USE_THEME_MONO":1, - "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_mono_init\\\"", - "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", - "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", - "LV_THEME_DEFAULT_FLAG" : "0", - "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_unscii_8\\\"", - "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_unscii_8\\\"", - "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_unscii_8\\\"", - "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", - "LV_LOG_PRINTF":0, - "LV_USE_DEBUG":0, + + "LV_USE_LOG":0, + "LV_USE_ASSERT_NULL":0, - "LV_USE_ASSERT_MEM":0, - "LV_USE_ASSERT_STR":0, + "LV_USE_ASSERT_MALLOC":0, + "LV_USE_ASSERT_MEM_INTEGRITY":0, "LV_USE_ASSERT_OBJ":0, "LV_USE_ASSERT_STYLE":0, - "LV_FONT_MONTSERRAT_12":0, - "LV_FONT_MONTSERRAT_16":0, - "LV_FONT_MONTSERRAT_22":0, - "LV_FONT_MONTSERRAT_28":0, - "LV_FONT_MONTSERRAT_12_SUBPX":0, - "LV_FONT_MONTSERRAT_28_COMPRESSED":0, + + "LV_USE_USER_DATA": 0, + "LV_FONT_UNSCII_8":1, + "LV_USE_BIDI": 0, - "LV_USE_OBJ_REALIGN": 0, - "LV_USE_ARC":0, - "LV_USE_BAR":1, - "LV_USE_BTN":1, - "LV_USE_BTNM":0, - "LV_USE_CALENDAR":0, - "LV_USE_CANVAS":0, - "LV_USE_CHECKBOX":0, - "LV_USE_CHART":0, - "LV_USE_CONT":1, - "LV_USE_CPICKER":0, - "LV_USE_DROPDOWN":0, - "LV_USE_GAUGE":0, - "LV_USE_IMG":1, - "LV_USE_IMGBTN":0, - "LV_USE_KEYBOARD":0, - "LV_USE_LABEL":1, - "LV_USE_LED":0, - "LV_USE_LINE":0, - "LV_USE_LIST":0, - "LV_USE_LINEMETER":0, - "LV_USE_OBJMASK":0, - "LV_USE_MBOX":0, - "LV_USE_PAGE":0, - "LV_USE_SPINNER":0, - "LV_USE_ROLLER":0, - "LV_USE_SLIDER":0, - "LV_USE_SPINBOX":0, - "LV_USE_SWITCH":0, - "LV_USE_TEXTAREA":0, - "LV_USE_TABLE":0, - "LV_USE_TABVIEW":0, - "LV_USE_TILEVIEW":0, - "LV_USE_WIN":0 + "LV_USE_ARABIC_PERSIAN_CHARS":0, + +# "LV_USE_THEME_MONO":1, +# "LV_THEME_DEFAULT_INIT": "\\\"lv_theme_mono_init\\\"", +# "LV_THEME_DEFAULT_COLOR_PRIMARY": "\\\"LV_COLOR_RED\\\"", +# "LV_THEME_DEFAULT_COLOR_SECONDARY": "\\\"LV_COLOR_BLUE\\\"", +# "LV_THEME_DEFAULT_FLAG" : "0", +# "LV_THEME_DEFAULT_FONT_SMALL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_NORMAL" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_SUBTITLE" : "\\\"&lv_font_unscii_8\\\"", +# "LV_THEME_DEFAULT_FONT_TITLE" : "\\\"&lv_font_unscii_8\\\"", } all_obj_minimal_features = { @@ -367,6 +323,6 @@ advanced_features = { } build("Minimal monochrome", minimal_monochrome) -build("All objects, minimal features", all_obj_minimal_features) -build("All objects, all common features", all_obj_all_features) -build("All objects, with advanced features", advanced_features) +#build("All objects, minimal features", all_obj_minimal_features) +#build("All objects, all common features", all_obj_all_features) +#build("All objects, with advanced features", advanced_features) diff --git a/tests/lv_test_conf.h b/tests/lv_test_conf.h index 3fe8148686..9f82636914 100644 --- a/tests/lv_test_conf.h +++ b/tests/lv_test_conf.h @@ -25,15 +25,7 @@ extern "C" { uint32_t custom_tick_get(void); #define LV_TICK_CUSTOM_SYS_TIME_EXPR custom_tick_get() -typedef int16_t lv_coord_t; -typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ -typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ -typedef void * lv_font_user_data_t; -typedef void * lv_obj_user_data_t; -typedef void * lv_anim_user_data_t; -typedef void * lv_group_user_data_t; -typedef void * lv_fs_drv_user_data_t; -typedef void * lv_img_decoder_user_data_t; +typedef void * lv_user_data_t; /********************** * GLOBAL PROTOTYPES