Compare commits

..

684 Commits

Author SHA1 Message Date
Gabor Kiss-Vamosi
88ad8c341b chore: kick CI to rebuild the docs 2024-04-23 16:00:28 +02:00
embeddedt
a66658ca3c Fix v5 documentation link 2021-07-17 10:59:36 -04:00
embeddedt
0c64ae2ef7 Remove some outdated links 2021-02-26 13:50:57 -05:00
embeddedt
e2147d4be5 Update forum link 2019-06-28 16:02:28 -04:00
Gabor Kiss-Vamosi
22e8ec2b01 Merge pull request #1104 from C47D/fix_group_wrap
[lv_group - v5.3] Init wrap on group creation and fix documentation of wrap setter
2019-06-18 06:07:37 +02:00
C47D
648e2c4f17 [lv_group] Init wrap on group creation and fix documentation of wrap setter 2019-06-17 20:39:40 -05:00
Gabor Kiss-Vamosi
4139cd619b Update README.md 2019-06-11 15:54:13 +02:00
embeddedt
037e828c8a Fix lv_cont_get_fit_height using width instead
Reported in #1075
2019-05-21 09:52:18 -04:00
Gabor Kiss-Vamosi
d658eef2a0 fix typo
lv_font_symbol_30_basic -> lv_font_symbol_30
2019-05-20 15:50:21 +02:00
embeddedt
292ca72c03 Merge pull request #1064 from CrogST/patch-1
Fix swapping of SB and SCRL styles in lv_list_get_style function
2019-05-16 19:41:26 -04:00
CrogST
8273499a8c Error in lv_list_get_style function
SB and SCRL styles were mixed up. Let me now if it is ok.
2019-05-16 14:30:54 +03:00
Gabor Kiss-Vamosi
c8d1413ece Update lv_obj.c 2019-05-15 07:36:00 +02:00
Gabor Kiss-Vamosi
dab545e770 Update lv_canvas.c 2019-05-12 08:21:32 +02:00
Gabor Kiss-Vamosi
8745d16ba9 Update lv_canvas.c 2019-04-24 06:26:42 +02:00
Gabor Kiss-Vamosi
ef0f8b29cf Update lv_txt.c 2019-04-23 15:08:12 +02:00
Gabor Kiss-Vamosi
580d1e111d lv_list: fix lv_list_get_btn_next/prev 2019-04-11 08:11:13 -04:00
Themba Dube
b6df62a62a lv_list: check actual object type instead of relying on signal handler 2019-04-11 08:09:33 -04:00
embeddedt
5f76d98311 Update README.md 2019-04-04 11:27:55 -04:00
Gabor Kiss-Vamosi
bb20b8ca1a rounder_cb bug fix 2019-04-02 05:59:23 +02:00
Gabor Kiss-Vamosi
87d27a5665 Merge pull request #986 from upbeat27/master
lv_ddlist: fix original selected option not restoring on escape
2019-03-27 21:17:16 +01:00
Josh
6468d925ed lv_ddlist: fix original selected option not restoring on escape 2019-03-27 09:23:43 -07:00
embeddedt
c1e98d3f37 Update all-other-issues.md 2019-03-27 10:39:42 -04:00
Gabor Kiss-Vamosi
22f84314a4 Rename bug_report.md to bug-report.md 2019-03-22 21:28:18 +01:00
Themba Dube
03b3070871 Update issue templates 2019-03-22 13:58:19 -04:00
Themba Dube
73ab6b3e2f Add back missing bug report template 2019-03-22 13:57:35 -04:00
embeddedt
2f86a67e71 Add other issues template 2019-03-22 13:28:36 -04:00
embeddedt
1b12ee50bb Merge pull request #976 from littlevgl/issue-templates
Add bug report issue template
2019-03-22 13:28:26 -04:00
embeddedt
ee4e61ed68 Add bug report issue template 2019-03-22 13:23:55 -04:00
Gabor Kiss-Vamosi
98d43daa5d Merge branch 'master' of https://github.com/littlevgl/lvgl 2019-03-13 12:07:37 +01:00
Gabor Kiss-Vamosi
095a159005 lv_tileview_set_tile_act: fix with no animation
It should the position of the scrollable but the size was set
2019-03-13 05:22:55 +01:00
embeddedt
ec6598ccfb Update CONTRIBUTING.md with forum information 2019-03-12 10:35:48 -04:00
embeddedt
c74e48249d Add license information to CONTRIBUTING.md 2019-03-11 09:51:07 -04:00
Gabor Kiss-Vamosi
2eaa579121 lv_ddlist: fix value revert on focus 2019-03-08 15:48:44 +01:00
Gabor Kiss-Vamosi
66e70afbb4 use the obj->top on focus to bring the obj. to the foregorund 2019-03-06 16:13:04 +01:00
Gabor Kiss-Vamosi
9d0f68880a Merge branch 'master' of https://github.com/littlevgl/lvgl 2019-03-05 15:34:36 +01:00
Gabor Kiss-Vamosi
78574541e3 lv_tileview: infinite loop bugfix 2019-03-05 15:32:09 +01:00
Gabor Kiss-Vamosi
b8c6783207 Update README.md 2019-03-03 08:13:13 +01:00
embeddedt
961d8e0350 Merge pull request #922 from amirgon/undef_free
Workaround for stray 'free' macro
2019-03-02 17:37:29 -05:00
Amir Gonnen
6f53e4616a Workaround for stray 'free' macro
Related to littlevgl/lv_binding_micropython#11 'Build error for STM32 port due to 'free()' macro'
2019-03-03 00:12:12 +02:00
Themba Dube
f509d8fa4f Apply ta label size fix from dev-6.0 2019-03-02 11:17:15 -05:00
Gabor Kiss-Vamosi
00ef778c7c Merge branch 'master' of https://github.com/littlevgl/lvgl 2019-02-28 06:56:23 +01:00
Gabor Kiss-Vamosi
fbe838730f lv_btnm: init recolor to 0 2019-02-28 06:56:10 +01:00
Gabor Kiss-Vamosi
b2e07d858b revert placeholder init 2019-02-27 10:10:12 +01:00
Gabor Kiss-Vamosi
dfbcec2f0d lv_ta: init placeholder 2019-02-27 10:09:36 +01:00
Gabor Kiss-Vamosi
65685a0da6 Merge pull request #892 from amirgon/patch-1
Add Micropython feature to README.md
2019-02-24 12:26:42 +01:00
Amir Gonnen
0bab902753 Add Micropython feature
and a short example
2019-02-24 11:20:37 +02:00
embeddedt
a374baa376 Merge pull request #889 from littlevgl/embeddedt-patch-1
Remove semicolons in lv_font_builtin.h
2019-02-22 12:01:49 -05:00
embeddedt
02c95e8fed Remove semicolons in lv_font_builtin.h 2019-02-22 10:09:07 -05:00
Gabor Kiss-Vamosi
56f54d864a Merge pull request #888 from joltwallet/lv_list_remember
lv_list remember
2019-02-22 13:14:28 +01:00
Brian Pugh
465f8fa96a lv_list: lv_list_set_btn_selected: only write ext->last_sel if btn is non-NULL. 2019-02-21 21:40:00 -08:00
Brian Pugh
a7260bbfa9 Revert semicolon removal from f4498fd0. This semicolon is necessary for more natural, less error prone custom font declaration in lv_conf.h 2019-02-21 21:02:18 -08:00
embeddedt
374dfcd60a Merge pull request #884 from littlevgl/revert-836-master
Revert "[#809] Added x axis scrolling feature into lv_page_focus function."
2019-02-21 10:40:01 -05:00
embeddedt
457f667cab Revert "[#809] Added x axis scrolling feature into lv_page_focus function." 2019-02-21 10:39:39 -05:00
embeddedt
4b6e78cf78 Merge pull request #836 from zavovi/master
[#809] Added x axis scrolling feature into lv_page_focus function.
2019-02-21 10:39:31 -05:00
Vilem Zavodny
07e9fc4ccf [#809] Fixed scroll focus when object is out of the page in twi sides. 2019-02-21 10:41:41 +01:00
Gabor Kiss-Vamosi
a39d617ac9 Update stale.yml 2019-02-21 07:35:14 +01:00
embeddedt
be8db0719f Merge pull request #876 from ironiron/master
Remove duplicate semicolons
2019-02-20 16:49:45 -05:00
Rafał Mazurkiewicz
f4498fd0a4 removed unnecessary semicolons 2019-02-20 22:36:56 +01:00
embeddedt
245d81ee92 Update README.md 2019-02-18 13:05:58 -05:00
Themba Dube
d05ec536fd Fix compilation errors when USE_LV_GROUP is 0 2019-02-18 12:17:56 -05:00
Themba Dube
153f16fc05 Merge branch 'master' of github.com:littlevgl/lvgl 2019-02-18 12:16:16 -05:00
Themba Dube
2e0b8e10ae Add missing include to lv_math.c 2019-02-18 12:15:57 -05:00
Gabor Kiss-Vamosi
62195b7cc7 lv_label_draw fix with offset.y 2019-02-18 06:41:02 +01:00
Gabor Kiss-Vamosi
9572c7d4ed lv_imgbtn: bugfix 2019-02-18 05:57:30 +01:00
Gabor Kiss-Vamosi
20282ce89f remove var. declaration in for loop header 2019-02-18 05:57:30 +01:00
Themba Dube
19ea8ac55f Fix compilation error introduced in 1e8ea6b15b 2019-02-17 14:58:10 -05:00
Gabor Kiss-Vamosi
e3bbe0a4fd spinbox fixes 2019-02-15 06:34:30 +01:00
Gabor Kiss-Vamosi
96adbe3827 spinbox fixes 2019-02-15 06:34:30 +01:00
manison
92babea8c8 fix typo in function name 2019-02-13 06:46:08 -05:00
Vilem Zavodny
3425f29130 [#809] Added x axis scrolling feature into lv_page_focus function. 2019-02-13 11:19:47 +01:00
Gabor Kiss-Vamosi
f5b8dd17b8 lv_list_set_selected_btn fix 2019-02-12 22:48:54 +01:00
embeddedt
fabd551e2a Fix error reported by @canardos in lv_imgbtn 2019-02-12 11:03:34 -05:00
Gabor Kiss-Vamosi
2b67dcd2cf Merge pull request #827 from littlevgl/embeddedt-patch-1
Add LV_INDEV_DRAG_THROW checker to lv_conf_templ.h
2019-02-12 16:24:45 +01:00
embeddedt
5addccc270 Merge pull request #828 from littlevgl/embeddedt-patch-2
Fix image source not being copied in lv_imgbtn
2019-02-12 09:15:46 -05:00
embeddedt
9ac933fb9e Fix image source not being copied in lv_imgbtn 2019-02-12 07:04:34 -05:00
embeddedt
44c2397804 Add LV_INDEV_DRAG_THROW checker to lv_conf_templ.h 2019-02-12 07:01:04 -05:00
Gabor Kiss-Vamosi
caa2064c90 lv_spinbox: fixes 2019-02-12 07:55:46 +01:00
Gabor Kiss-Vamosi
6f47dd6522 theme fixes 2019-02-12 07:33:42 +01:00
Gabor Kiss-Vamosi
c71047f359 lv_chart: LV_CHART_VETICAL_LINES fixes 2019-02-12 06:03:06 +01:00
Gabor Kiss-Vamosi
6871e0252a add LV_ATTRIBUTE_MEM_ALIGN option
update lv_conf_chechker.h
2019-02-12 05:42:45 +01:00
Gabor Kiss-Vamosi
56cfcc693a Merge pull request #820 from seyyah/patch-1
Typo: sonething -> something
2019-02-11 11:30:25 +01:00
seyyah
a87f4388e5 Typo: sonething -> something 2019-02-11 13:25:11 +03:00
embeddedt
f686243f64 Add warning about LV_INDEV_DRAG_THROW 2019-02-10 06:53:11 -05:00
embeddedt
d64902b2a5 Add note about LV_INDEV_DRAG_THROW to lv_conf_templ.h 2019-02-10 06:52:17 -05:00
Gabor Kiss-Vamosi
0733885a73 Merge pull request #817 from fpw/bugfix/color-narrowing
Fix gcc narrowing warning
2019-02-10 07:59:10 +01:00
Gabor Kiss-Vamosi
c42f378184 fix image colors in themes 2019-02-10 06:51:28 +01:00
Gabor Kiss-Vamosi
ad74d32f51 fix image colors in themes 2019-02-10 06:51:28 +01:00
Folke Will
321a08b42e Retain formatting 2019-02-09 13:48:09 +01:00
Folke Will
b7d5537961 Fix color narrowing warning 2019-02-09 13:46:29 +01:00
embeddedt
32017ff659 Fix x/y mixup in lv_page.c (fixes #815) 2019-02-08 10:20:05 -05:00
embeddedt
e2c0e58af9 Merge pull request #811 from amirgon/master
Prevent crash when lv_init is called more than once.
2019-02-07 18:25:26 -05:00
embeddedt
1c67d07dc3 Move setting of _lv_initialized and correct formatting
Set _lv_initialized at the end of lv_init.

Correct formatting of "if" statement to be consistent with the rest of the library.
2019-02-07 17:57:06 -05:00
Amir Gonnen
e72589c6d4 Prevent crash when lv_init is called more than once. After the first call, it will do nothing. 2019-02-08 00:03:16 +02:00
Gabor Kiss-Vamosi
b0b1174564 lv_canvas: fix with LV_COLOR_16_SWAP 2019-02-07 10:27:47 +01:00
Gabor Kiss-Vamosi
fb1a7fc0fc Update stale.yml 2019-02-04 15:28:01 +01:00
Gabor Kiss-Vamosi
b5bcede82f Merge pull request #790 from 0xflotus/patch-1
fixed small errors
2019-02-02 04:36:44 +01:00
Gabor Kiss-Vamosi
23dfc37171 Merge pull request #787 from littlevgl/update-version-readme
Change v5.3 to 5.3 in README
2019-02-02 04:23:17 +01:00
0xflotus
148539d242 fixed small errors 2019-02-02 02:26:49 +01:00
Gabor Kiss-Vamosi
b66e8410f6 Update README.md 2019-02-01 22:27:57 +01:00
Themba D
9a272039d3 Change v5.3 to 5.3
When the badge already says 'version' it doesn't make sense to put the 'v' before the version number.
2019-02-01 16:05:46 -05:00
Gabor Kiss-Vamosi
dc69cf82eb Update README.md 2019-02-01 21:53:12 +01:00
Gabor Kiss-Vamosi
17c19fc35a Update README.md 2019-02-01 15:10:59 +01:00
Gabor Kiss-Vamosi
4cd13016d3 Update README.md 2019-02-01 05:44:19 +01:00
Gabor Kiss-Vamosi
84781c62c2 version number to v5.3 2019-02-01 05:09:20 +01:00
Gabor Kiss-Vamosi
378453c954 Merge branch 'dev-5.3' 2019-02-01 05:08:33 +01:00
Gabor Kiss-Vamosi
40709625cc Merge remote-tracking branch 'origin/master' into dev-5.3 2019-02-01 05:04:05 +01:00
Gabor Kiss-Vamosi
77f6844340 add top level lvgl.mk 2019-02-01 05:03:35 +01:00
Gabor Kiss-Vamosi
68083fa15a Update README.md 2019-01-31 21:23:56 +01:00
Gabor Kiss-Vamosi
cbab184002 lv_canvas: restore reverted updates 2019-01-31 21:06:28 +01:00
Gabor Kiss-Vamosi
0819688f50 Revert "lv_canvas: comment update"
This reverts commit 078bc96b77.
2019-01-31 20:24:40 +01:00
Gabor Kiss-Vamosi
6770e1ab32 Revert "lv_canvas: support indexed images"
This reverts commit ed8ec4a4c2.
2019-01-31 20:24:30 +01:00
Gabor Kiss-Vamosi
078bc96b77 lv_canvas: comment update 2019-01-31 19:39:57 +01:00
Gabor Kiss-Vamosi
ed8ec4a4c2 lv_canvas: support indexed images 2019-01-31 19:38:40 +01:00
Gabor Kiss-Vamosi
4fbf1401fa Update README.md 2019-01-31 19:28:09 +01:00
Gabor Kiss-Vamosi
5f2f6b6617 Update README.md 2019-01-31 19:26:39 +01:00
Gabor Kiss-Vamosi
e3c2a7db67 Update README.md 2019-01-31 19:25:41 +01:00
Gabor Kiss-Vamosi
ace5acea0b Update README.md 2019-01-31 19:13:50 +01:00
Gabor Kiss-Vamosi
8511c6b9cf Update README.md 2019-01-31 19:13:26 +01:00
Gabor Kiss-Vamosi
3ef4a73db5 Update README.md 2019-01-31 15:56:52 +01:00
Gabor Kiss-Vamosi
2274ca348b Merge pull request #783 from seyyah/dev-5.3
lv_canvas: lv_canvas_boundary_fill4 function interface enhancement
2019-01-31 15:55:25 +01:00
Gabor Kiss-Vamosi
e9fca9cad6 Update README.md 2019-01-31 15:43:23 +01:00
Gabor Kiss-Vamosi
96eba5f877 Update README.md 2019-01-31 15:42:18 +01:00
seyyah
3db41c327f lv_canvas: update function prototypes 2019-01-31 16:22:07 +03:00
seyyah
6de1ad36dc lv_canvas: merge last commits 2019-01-31 16:15:50 +03:00
seyyah
635ca1ab90 lv_canvas: lv_canvas_boundary_fill4 function interface enhancement 2019-01-31 16:07:59 +03:00
Gabor Kiss-Vamosi
215cdda238 Update README.md 2019-01-31 14:06:54 +01:00
Gabor Kiss-Vamosi
ffbabfc8fe Merge pull request #782 from littlevgl/badges
Get rid of links on badges
2019-01-31 14:03:42 +01:00
Themba D
5a62ac79e9 Merge branch 'master' into badges 2019-01-31 08:02:57 -05:00
Themba D
846a470717 Merge branch 'master' into badges 2019-01-31 08:02:13 -05:00
Gabor Kiss-Vamosi
f6f8f09bce Update README.md 2019-01-31 14:01:56 +01:00
Themba D
6ffd1475c5 Get rid of links on badges 2019-01-31 08:00:46 -05:00
Gabor Kiss-Vamosi
5bbc3e69e9 Update README.md 2019-01-31 14:00:42 +01:00
Gabor Kiss-Vamosi
f1d5e9c4a2 Update README.md 2019-01-31 13:59:53 +01:00
Gabor Kiss-Vamosi
68f25fa999 add_lv_fs_is_ready() 2019-01-31 13:24:02 +01:00
Gabor Kiss-Vamosi
ef7aa132a6 Update README.md 2019-01-31 10:25:08 +01:00
Gabor Kiss-Vamosi
f41ce51bf9 Update README.md 2019-01-31 10:20:11 +01:00
Gabor Kiss-Vamosi
ed38f7dcb5 Merge pull request #780 from amirgon/dev-5.3
lv_label_set_text_id must be declared conditionally
2019-01-31 09:34:34 +01:00
Amir Gonnen
cc77d78d5a lv_label_set_text_id must be declared conditionally otherwise lv_micropython would create a wrapper to an undefined function 2019-01-31 09:39:59 +02:00
Gabor Kiss-Vamosi
159e07a8ea indev_drag bugfix if dragged on a page 2019-01-31 03:17:30 +01:00
Gabor Kiss-Vamosi
cf434828dc Merge pull request #778 from MiSimon/lv_group_key_ascii_codes
Changed LV_GROUP_KEY macros to the corresponding ascii values
2019-01-31 01:21:56 +01:00
MiSimon
649a21ad86 Changed LV_GROUP_KEY macros to the corresponding ascii values 2019-01-31 01:18:04 +01:00
Gabor Kiss-Vamosi
dd5f66e125 inialize _lv_indev_list adn _lv_disp_list in lv_init 2019-01-31 00:25:15 +01:00
Gabor Kiss-Vamosi
c8920b0c06 Update README.md 2019-01-30 23:05:21 +01:00
Gabor Kiss-Vamosi
09bcf9dd12 Update README.md 2019-01-30 22:17:04 +01:00
Gabor Kiss-Vamosi
d1b593be66 Merge pull request #775 from littlevgl/license-origin
Add note about origin of function
2019-01-30 17:05:50 +01:00
Gabor Kiss-Vamosi
3acd6c3cd0 lv_refr: remove unneccesary waiting for flush 2019-01-30 16:13:11 +01:00
Gabor Kiss-Vamosi
aca2a2d428 lv_refr: formatting 2019-01-30 16:07:56 +01:00
Gabor Kiss-Vamosi
d3dc1f8bf1 Merge pull request #772 from amirgon/dev-5.3
bugfix: return int not pointer
2019-01-30 14:09:04 +01:00
Themba D
a91c142b3c Add note about origin of function 2019-01-30 07:02:03 -05:00
Gabor Kiss-Vamosi
fa28cee957 disable multi-lang related functions if USE_LV_MULTI_LANG = 0 2019-01-30 10:49:59 +01:00
Gabor Kiss-Vamosi
93ec0a512a Update README.md 2019-01-30 10:04:03 +01:00
Gabor Kiss-Vamosi
1bf36221f4 Update README.md 2019-01-30 10:00:50 +01:00
Gabor Kiss-Vamosi
0e3f95c1a9 Update README.md 2019-01-30 07:16:43 +01:00
Gabor Kiss-Vamosi
01e2bf2374 Update README.md 2019-01-30 06:37:51 +01:00
Gabor Kiss-Vamosi
34bcab34d8 Update README.md 2019-01-30 06:35:56 +01:00
Gabor Kiss-Vamosi
fceaf167a4 Update README.md 2019-01-29 21:33:18 +01:00
Amir Gonnen
950fb33206 bugfix: return int not pointer 2019-01-29 22:06:36 +02:00
Gabor Kiss-Vamosi
7b23f7a8fd Update README.md 2019-01-29 20:59:14 +01:00
Gabor Kiss-Vamosi
43e852d43a Update README.md 2019-01-29 20:57:46 +01:00
Gabor Kiss-Vamosi
0bef3ab1bf Update README.md 2019-01-29 15:50:29 +01:00
Gabor Kiss-Vamosi
967d3b54a3 Update README.md 2019-01-29 15:46:30 +01:00
Gabor Kiss-Vamosi
ec31125af3 Update README.md 2019-01-29 15:42:59 +01:00
Gabor Kiss-Vamosi
84d44b2487 Update README.md 2019-01-29 15:41:07 +01:00
Gabor Kiss-Vamosi
9f2f89163f Update README.md 2019-01-29 14:15:28 +01:00
Gabor Kiss-Vamosi
d29536673a Update README.md 2019-01-29 14:10:55 +01:00
Gabor Kiss-Vamosi
8283fcc2d7 Update README.md 2019-01-29 14:10:41 +01:00
Gabor Kiss-Vamosi
5e33e5574e Update README.md 2019-01-29 13:51:49 +01:00
Gabor Kiss-Vamosi
dd41f411e6 lv_conf_checker.py handle prerocessor indentations (e.g. # define ...) 2019-01-29 10:28:48 +01:00
Gabor Kiss-Vamosi
92be58d1d8 fix to work without display 2019-01-29 04:58:21 +01:00
Gabor Kiss-Vamosi
fd1e8483a5 multi-lang: fix function names 2019-01-29 04:41:44 +01:00
Gabor Kiss-Vamosi
855dc44e32 solve warings 2019-01-28 16:02:11 +01:00
Gabor Kiss-Vamosi
9185e1c4a6 add GC to lv_conf_templ.h 2019-01-28 16:01:59 +01:00
Gabor Kiss-Vamosi
08007aa4d5 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2019-01-28 15:41:08 +01:00
Gabor Kiss-Vamosi
3b7a468c6a update lv_conf_checker.h 2019-01-28 15:32:50 +01:00
Gabor Kiss-Vamosi
fba3337925 Merge branch 'multi-lang' into dev-5.3 2019-01-28 15:32:12 +01:00
Gabor Kiss-Vamosi
811f3c0834 lv_lang: disable the whole file id USE_LV_MULTI_LANG == 0 2019-01-28 15:18:59 +01:00
Gabor Kiss-Vamosi
31d0a7f3ae lv_mem: add LV_MEM_ADR to set wotk memory address externally 2019-01-28 15:18:59 +01:00
Brian Pugh
4adbdad9b3 Added lv_gc.c to lv_misc.mk 2019-01-28 15:18:59 +01:00
Gabor Kiss-Vamosi
120a431766 lv_slider: reduce bg size if knob_in = 1 too 2019-01-28 15:18:59 +01:00
Brian Pugh
9cecebfe0a lv_sw.c: lv_sw_toggle_anim initial commit 2019-01-28 15:18:59 +01:00
Brian Pugh
514511c15a lv_sw: lv_sw_toggle doc fix 2019-01-28 15:18:59 +01:00
Brian Pugh
610548ba3d lv_sw: lv_sw_toggle initial commit 2019-01-28 15:18:59 +01:00
Amir Gonnen
dd3c65df7a add missing include to stdlib, needed for 'abs' function on integers 2019-01-28 15:18:59 +01:00
seyyah
195a3d3768 lv_canvas: add the function comments to the header file too 2019-01-28 15:18:59 +01:00
seyyah
65236ede89 lv_canvas: add basic drawing functionalities 2019-01-28 15:18:59 +01:00
Amir Gonnen
0e8984d121 Fix compilation errors: comment out unused variables. cast memcpy dest since it's defined as const. 2019-01-28 15:18:59 +01:00
manison
9f84fb1749 replace inclusion of nonstandard header <strings.h> with standard header <string.h> 2019-01-28 15:18:59 +01:00
manison
b6046a8e23 allow disabling text area password char animation without needing to disable all animations 2019-01-28 15:18:59 +01:00
Amir Gonnen
af3cb73fbc Fixed refernce to anim_ll. LV_GC_ROOT must be used for Micropython gc support 2019-01-28 15:18:59 +01:00
Amir Gonnen
c816847a3c remove historic pycparser. It is here before micropython sources moved to another repository and history rewritten 2019-01-28 15:18:59 +01:00
Amir Gonnen
652809d005 restore LV_COLOR_HEX macros and add inline functions in addition to them, not instead of them 2019-01-28 15:18:59 +01:00
Amir Gonnen
8bfa8ff721 lv_colors.h: move OPA macros to enum, move LV_COLOR_HEX macros to inline funcs, this exposes them to Micropython. If enum member is a number (as in OPA), prefix it by underscore to create a valid python attribute. Bugfix: when returning to a struct by value, copy it first. lv_mpy.c renamed to lv_mpy_example.c since the actual lv_mpy.c should be generated by the build script automatically based on current H files and lv_conf.h 2019-01-28 15:18:59 +01:00
Amir Gonnen
a6c89ee54f add '_lv_' prefix to global roots 2019-01-28 15:18:59 +01:00
Amir Gonnen
0935110284 gc: add undescore to roots, arranged lv_mem.c regarding gc defines. Added support to Symbols using the numstr technique of encoding the characters as a number in an enum. Globals: register them directly witout the need for constructor to access them. Updated example code. Updated lv_mpy.c 2019-01-28 15:18:59 +01:00
Amir Gonnen
f5bd68fa77 Enable Micropython gc (Garbage Collection) on lvgl. This is controlled by LV_ENABLE_GC macro defined in lv_conf.h. When enabled, lv_conf.h should also define LV_MEM_CUSTOM_REALLOC, LV_MEM_CUSTOM_GET_SIZE, LV_GC_INCLUDE and LV_GC_ROOT 2019-01-28 15:18:59 +01:00
Amir Gonnen
d44a618169 Initial revision for Mpy extension generation script 2019-01-28 15:18:59 +01:00
neverxie
ae3eca803d [del] extra spaces 2019-01-28 15:18:59 +01:00
Themba D
b087c1153c Merge pull request #770 from manison/patch-typo-ta-add-char
Fix typo in new line char detection
2019-01-28 06:57:29 -05:00
Gabor Kiss-Vamosi
e12a8b06f0 lv_img_set_src_id fix 2019-01-28 09:17:22 +01:00
manison
fce445e464 lv_ta: fixes typo in new line char detection 2019-01-28 08:55:57 +01:00
Gabor Kiss-Vamosi
5bb66ef268 Merge pull request #769 from joltwallet/square_knob
lv_slider: make knob a perfect square (fix 1 pixel error)
2019-01-28 06:33:13 +01:00
Gabor Kiss-Vamosi
eca9245382 lv_mem: add LV_MEM_ADR to set wotk memory address externally 2019-01-28 06:09:06 +01:00
Brian Pugh
aaa969dc8a lv_slider: make knob a perfect square (fix 1 pixel error) 2019-01-27 16:28:55 -08:00
Themba D
28414505bc Merge pull request #767 from joltwallet/lv_gc_mk
Added lv_gc.c to lv_misc.mk
2019-01-27 17:58:56 -05:00
Brian Pugh
ac8ce1f643 Added lv_gc.c to lv_misc.mk 2019-01-27 12:30:25 -08:00
Gabor Kiss-Vamosi
5ed73c1918 lv_slider: reduce bg size if knob_in = 1 too 2019-01-27 07:16:24 +01:00
Themba D
79e973bfeb Merge pull request #762 from joltwallet/sw_toggle
Add lv_sw_toggle() and lv_sw_toggle_anim()
2019-01-26 15:29:32 -05:00
Brian Pugh
64c87e0e4a lv_sw.c: lv_sw_toggle_anim initial commit 2019-01-25 20:17:43 -08:00
Brian Pugh
6af285adb8 lv_sw: lv_sw_toggle doc fix 2019-01-25 17:42:08 -08:00
Brian Pugh
d962e36dbb lv_sw: lv_sw_toggle initial commit 2019-01-25 17:09:59 -08:00
Themba D
7713b5f941 Merge pull request #761 from amirgon/dev-5.3
Dev 5.3  fix compilation errors on lv_mpy
2019-01-25 16:45:03 -05:00
Amir Gonnen
8764388033 Merge remote-tracking branch 'upstream/dev-5.3' into dev-5.3 2019-01-25 23:18:49 +02:00
Gabor Kiss-Vamosi
2ae3733cd9 Merge pull request #752 from manison/patch-disable-pwd-anim
allow disabling text area password char animation without needing to disable all animations
2019-01-25 16:29:34 +01:00
Gabor Kiss-Vamosi
2762222fcc rename multi-lang functions 2019-01-25 16:19:50 +01:00
Amir Gonnen
a337e25fb1 add missing include to stdlib, needed for 'abs' function on integers 2019-01-25 16:01:52 +02:00
seyyah
fe5eab8f9a lv_canvas: add the function comments to the header file too 2019-01-25 14:50:31 +03:00
seyyah
bdb3bb778e erge branch 'dev-5.3' of github.com:seyyah/lvgl into dev-5.3 2019-01-25 14:14:46 +03:00
seyyah
98b6e446f0 lv_canvas: add basic drawing functionalities 2019-01-25 14:14:22 +03:00
Gabor Kiss-Vamosi
c8f5638780 Merge pull request #756 from amirgon/dev-5.3
Fix compilation errors
2019-01-25 08:27:14 +01:00
Amir Gonnen
c6bafdf203 Fix compilation errors: comment out unused variables. cast memcpy dest since it's defined as const. 2019-01-25 00:27:28 +02:00
Themba D
1bbc482f1a Merge pull request #753 from manison/patch-replace-strings-h
Replace nonstandard <strings.h> with standard <string.h> header
2019-01-24 11:02:08 -05:00
manison
a89fc9460b replace inclusion of nonstandard header <strings.h> with standard header <string.h> 2019-01-24 16:36:13 +01:00
manison
fd2e78965c allow disabling text area password char animation without needing to disable all animations 2019-01-24 16:16:19 +01:00
Amir Gonnen
10f3928169 Fixed refernce to anim_ll. LV_GC_ROOT must be used for Micropython gc support 2019-01-24 00:51:46 +02:00
Amir Gonnen
bf01817ab8 remove historic pycparser. It is here before micropython sources moved to another repository and history rewritten 2019-01-24 00:17:37 +02:00
Amir Gonnen
b58e526a0b restore LV_COLOR_HEX macros and add inline functions in addition to them, not instead of them 2019-01-24 00:17:37 +02:00
Amir Gonnen
fe479fe261 lv_colors.h: move OPA macros to enum, move LV_COLOR_HEX macros to inline funcs, this exposes them to Micropython. If enum member is a number (as in OPA), prefix it by underscore to create a valid python attribute. Bugfix: when returning to a struct by value, copy it first. lv_mpy.c renamed to lv_mpy_example.c since the actual lv_mpy.c should be generated by the build script automatically based on current H files and lv_conf.h 2019-01-24 00:17:37 +02:00
Amir Gonnen
473c2276dd add '_lv_' prefix to global roots 2019-01-24 00:14:33 +02:00
Amir Gonnen
1e8ea6b15b gc: add undescore to roots, arranged lv_mem.c regarding gc defines. Added support to Symbols using the numstr technique of encoding the characters as a number in an enum. Globals: register them directly witout the need for constructor to access them. Updated example code. Updated lv_mpy.c 2019-01-24 00:14:33 +02:00
Amir Gonnen
a883f0b39a Enable Micropython gc (Garbage Collection) on lvgl. This is controlled by LV_ENABLE_GC macro defined in lv_conf.h. When enabled, lv_conf.h should also define LV_MEM_CUSTOM_REALLOC, LV_MEM_CUSTOM_GET_SIZE, LV_GC_INCLUDE and LV_GC_ROOT 2019-01-24 00:14:33 +02:00
Amir Gonnen
848939683e Initial revision for Mpy extension generation script 2019-01-24 00:14:33 +02:00
Gabor Kiss-Vamosi
6cd62851bb lv_img multi lang fixes 2019-01-23 15:24:56 +01:00
Gabor Kiss-Vamosi
97b9fce748 lv_img: add multi language support 2019-01-23 15:07:22 +01:00
Gabor Kiss-Vamosi
c18be9809d Merge branch 'dev-5.3' into mixed 2019-01-23 14:44:18 +01:00
Gabor Kiss-Vamosi
68a860b958 lv_lang: minor fixes 2019-01-23 12:30:50 +01:00
Gabor Kiss-Vamosi
a6ead395a0 lv_lang: minor fixes 2019-01-23 12:30:10 +01:00
Gabor Kiss-Vamosi
e0fe252b90 lv_lang: add const return value to the get text function 2019-01-23 12:29:10 +01:00
Gabor Kiss-Vamosi
0a673294c8 add lv_lang.h to lvgl.h 2019-01-23 12:27:54 +01:00
Gabor Kiss-Vamosi
15d08b6692 multi_lang rework: use separate arrays for each language 2019-01-23 12:25:33 +01:00
Gabor Kiss-Vamosi
b500f0c8f3 lv_porting fixes 2019-01-23 12:25:33 +01:00
Gabor Kiss-Vamosi
5c33fb67e5 Merge pull request #748 from neverxie/master
[delete] extra spaces
2019-01-23 09:36:35 +01:00
neverxie
50dc23f42c [del] extra spaces 2019-01-23 13:53:22 +08:00
Gabor Kiss-Vamosi
10b86cea37 lv_anim: add ease_in/out path 2019-01-22 15:52:47 +01:00
Gabor Kiss-Vamosi
7c6d92ec10 Merge pull request #744 from manison/patch-dont-redefine-msvcrt-symbols
don't redefine _CRT_SECURE_NO_WARNINGS symbol if already defined
2019-01-22 13:16:12 +01:00
manison
4a39e2b731 don't redefine _CRT_SECURE_NO_WARNINGS symbol if already defined 2019-01-22 10:31:36 +01:00
Gabor Kiss-Vamosi
ce94a1ad5b editorconfig: remove duplicated insert_final_newline 2019-01-21 07:04:44 +01:00
Gabor Kiss-Vamosi
264f630467 lv_canvas: fix typo 2019-01-20 21:37:56 +01:00
Themba Dube
9711cf9d9a Merge remote-tracking branch 'origin/master' into dev-5.3 2019-01-20 06:52:10 -05:00
Gabor Kiss-Vamosi
a005c62d17 add .editorconfig 2019-01-18 06:59:16 +01:00
Gabor Kiss-Vamosi
7b193a40ef add lv_canvas_mult_buf 2019-01-17 16:24:01 +01:00
Gabor Kiss-Vamosi
6718decbb7 Update README.md 2019-01-17 12:18:09 +01:00
Gabor Kiss-Vamosi
87e262f27a lv_porting fixes 2019-01-16 17:50:57 +01:00
Gabor Kiss-Vamosi
a7207af953 multi_lang: rename functions 2019-01-16 10:01:27 +01:00
Gabor Kiss-Vamosi
d0f42c26cc add multi language support system + lv_label_set_text_multi 2019-01-16 09:57:07 +01:00
Gabor Kiss-Vamosi
6d449962ff lv_canvas: lv_canvas_copy_to_buf 2019-01-16 08:37:18 +01:00
Gabor Kiss-Vamosi
8ddc9f21fe Set LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN default value to 1 to avoide warnings 2019-01-15 15:36:35 +01:00
Gabor Kiss-Vamosi
3ab541949f add lv_canvas.c/h files 2019-01-14 19:39:21 +01:00
Themba D
b9e61de4d2 Merge pull request #724 from turoksama/dev-5.3
Fix an error in get_row_height.
2019-01-14 10:56:02 -05:00
Samuel
38d0e5b6e7 Fix an error in get_row_height.
Fix get_row_height error.
2019-01-14 23:38:28 +08:00
Gabor Kiss-Vamosi
bb4b37c6b3 add new object type: lv_ canvas 2019-01-14 16:03:40 +01:00
Gabor Kiss-Vamosi
6f12166af2 lv_task_handler: revert the addition of return value. See: #708 2019-01-14 15:21:04 +01:00
Gabor Kiss-Vamosi
eec348132f turn LV_OPA_.. defines to enum 2019-01-14 15:08:54 +01:00
Gabor Kiss-Vamosi
623fc13407 lv_table: minor fix for cell_crop 2019-01-14 07:13:09 +01:00
Themba Dube
a3f50c61f9 Merge branch 'master' into dev-5.3 2019-01-13 08:40:59 -05:00
Themba Dube
da01b4dd31 Change 'issue' to 'issue or pull request' in stale.yml 2019-01-13 08:40:38 -05:00
Themba D
ae0ceee8f6 Merge pull request #723 from joltwallet/lv_list_get_btn_index
Get btn index without providing list object
2019-01-13 08:30:09 -05:00
Gabor Kiss-Vamosi
088936e7f8 add return value to lv_task_handler. resolves #708 2019-01-13 07:46:12 +01:00
Gabor Kiss-Vamosi
d76b9c5b17 Merge pull request #721 from joltwallet/long_word_wrap2
Break long words immediately if word is longer than wrap width 2
2019-01-13 06:20:34 +01:00
Gabor Kiss-Vamosi
645eeae16c update lv_porting with file system examples 2019-01-13 05:28:42 +01:00
Brian Pugh
84bcf11d57 retabbed 2019-01-12 14:28:20 -08:00
Themba D
6d8b8a878d Fix documentation links in CONTRIBUTING.md 2019-01-12 17:21:28 -05:00
Brian Pugh
bd30245492 Get btn index without providing list object 2019-01-12 12:08:41 -08:00
Brian Pugh
48cd728693 move LV_TXT_BREAK_LONG defines to lv_conf.h 2019-01-12 10:59:15 -08:00
Brian Pugh
1a4a35f5a1 Change LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN to 0; see discussion #721 2019-01-12 08:44:16 -08:00
Brian Pugh
5b8e2cb6e1 Fixed off by one error for LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 2019-01-12 08:42:37 -08:00
Gabor Kiss-Vamosi
8a3b60e0c5 lv_conf_templ.h: minor fix 2019-01-12 15:23:21 +01:00
Brian Pugh
6c55ba5d31 Fixed characters jumping after character after future break character 2019-01-11 08:57:23 -08:00
Gabor Kiss-Vamosi
440c6415bc lv_table: crop improvements 2019-01-11 17:37:26 +01:00
Gabor Kiss-Vamosi
fcb95272b9 fix typo 2019-01-11 16:46:36 +01:00
Gabor Kiss-Vamosi
ff21f5a590 Merge pull request #712 from joltwallet/get_txt_width_fix
Correctly count text width
2019-01-11 16:42:57 +01:00
Gabor Kiss-Vamosi
ec19c8c87e lv_imgbtn_get_src_middle fix typo 2019-01-11 16:03:40 +01:00
Brian Pugh
d25f0db948 fix SYMBOL_DOWN 2019-01-10 23:11:48 -08:00
Brian Pugh
62d7b3b034 Added pretty breaks for long, but not widht-long words 2019-01-10 19:52:47 -08:00
Brian Pugh
d8aa9bfa1d move define macro to lv_txt.c 2019-01-10 19:07:36 -08:00
Brian Pugh
56fd6d944c Fixed last character from being cutoff 2019-01-10 19:05:19 -08:00
Gabor Kiss-Vamosi
a4d6c628e3 lv_table: add crop poperty 2019-01-10 16:06:20 +01:00
Gabor Kiss-Vamosi
9bbdd5840c Update stale.yml 2019-01-10 06:59:32 +01:00
Gabor Kiss-Vamosi
52bb50550d Merge pull request #713 from joltwallet/roller_visible_row_count_align_fix
Roller visible height fix
2019-01-07 11:31:27 +01:00
Gabor Kiss-Vamosi
1468da5c33 lv_style: revert defult line_space (modified during testing) 2019-01-07 07:17:58 +01:00
Gabor Kiss-Vamosi
d3fab62f8f txt position fixes 2019-01-07 07:06:31 +01:00
Gabor Kiss-Vamosi
c64a7f1f9c Merge pull request #711 from joltwallet/remove_group_ordering
Remove from group before deleting children
2019-01-07 05:58:09 +01:00
Brian Pugh
db219daeda Roller visible 1 should have a full line-width height padding 2019-01-06 19:24:00 -08:00
Brian Pugh
ee2ddf26f3 in roller, set lv_ddlist_set_fix_height 1 text.line_space less than row_cnt 2019-01-06 19:02:29 -08:00
Brian Pugh
ced3903100 reduce redundant width calculations in lv_label 2019-01-06 18:32:26 -08:00
Brian Pugh
b5e40a44b1 lv_draw_label don't add letter_spaces for 0 width characters 2019-01-06 18:24:47 -08:00
Brian Pugh
5f11d67812 remove duplicate lv_txt_get_width code in lv_label 2019-01-06 18:17:24 -08:00
Brian Pugh
4b2cd9030c Correctly count characters. Also remove letter spaces from 0-width characters 2019-01-06 17:49:07 -08:00
Brian Pugh
239ed85889 Remove from group before deleting children 2019-01-06 11:25:10 -08:00
Gabor Kiss-Vamosi
61bb01e06d lv_chart: fix uninitialized variable 2019-01-06 15:38:31 +01:00
Gabor Kiss-Vamosi
666136851c lv_btnm: last row y2 align bugfix 2019-01-06 15:20:06 +01:00
Gabor Kiss-Vamosi
a6714bbe47 Create stale.yml 2019-01-05 23:30:05 +01:00
Gabor Kiss-Vamosi
167e26a243 lv_mbox: use a unique anim end cb to avoid casting 2019-01-05 19:45:05 +01:00
Themba D
7c322c36ed Merge pull request #705 from joltwallet/vdb-fix
single vdb macro fix for get_active and get_inactive
2019-01-05 07:56:23 -05:00
Brian Pugh
752e752dbd single vdb macro fix for get_active and get_inactive 2019-01-04 20:48:34 -08:00
Brian Pugh
ab1a9b41e6 Add a minimum number of characters to print on a super long screen before wrapping it to the next line 2019-01-04 18:43:20 -08:00
Brian Pugh
b7c08e8aed Proper word wrapping taking into account letter_space 2019-01-04 09:10:27 -08:00
Gabor Kiss-Vamosi
9c675a8e82 Merge pull request #700 from joltwallet/list_fix
bug fix: initialize list size to 0; feature: select first added item …
2019-01-04 14:40:15 +01:00
Gabor Kiss-Vamosi
22e1ccdfa9 Merge pull request #699 from joltwallet/lv_group_send_data_returntype
Change lv_group_send_data() return type to lv_res_t
2019-01-04 14:36:30 +01:00
embeddedt
a4bfd51401 Merge branch 'master' into dev-5.3 2019-01-04 08:27:43 -05:00
Themba D
10b648c96e Merge pull request #704 from Fabien-Chouteau/patch-1
lv_hal_tick: Fix typo
2019-01-04 08:26:31 -05:00
Fabien Chouteau
d109f409fb lv_hal_tick: Fix typo 2019-01-04 12:13:33 +01:00
Gabor Kiss-Vamosi
83cadc8abe LV_VDB_TRUE_DOUBLE_BUFFERED: improvements 2019-01-04 08:40:33 +01:00
Gabor Kiss-Vamosi
31d18a21b2 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2019-01-04 08:33:30 +01:00
Gabor Kiss-Vamosi
20150c1418 LV_VDB_TRUE_DOUBLE_BUFFERED: improvements 2019-01-04 08:33:19 +01:00
Gabor Kiss-Vamosi
9610d914e9 lv_tabview: initialize the btn_hide field 2019-01-04 08:32:45 +01:00
Brian Pugh
0a0df60f77 Long word breaking algorithm 2019-01-03 23:17:19 -08:00
Brian Pugh
b4960b19fb bug fix: initialize list size to 0; feature: select first added item to a focused list object 2019-01-03 15:31:03 -08:00
Brian Pugh
3922c18054 Change lv_group_send_data() return type to lv_res_t 2019-01-03 14:57:45 -08:00
Themba Dube
53c19167f3 Merge branch 'master' into dev-5.3 2019-01-03 13:36:02 -05:00
Themba D
20464832da Merge pull request #697 from MCF/warning-preproc-fix
Remove unneeded #warning pre-processor command in lv_vdb.h
2019-01-03 13:35:25 -05:00
Mike Fellows
73ecaefde8 Remove unneeded #warning pre-processor command in lv_vdb.h
That directive breaks non-gcc builds (e.g. for the pc simulator) and is
not very valuable from a user point of view.
2019-01-03 10:31:02 -08:00
Gabor Kiss-Vamosi
2ab274542a Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2019-01-03 18:04:38 +01:00
Gabor Kiss-Vamosi
280cba0c54 fix warnings 2019-01-03 15:57:31 +01:00
Gabor Kiss-Vamosi
bbe78633a2 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2019-01-03 15:51:06 +01:00
Gabor Kiss-Vamosi
c20af89a11 fix warnings 2019-01-03 15:50:55 +01:00
Gabor Kiss-Vamosi
72fa6f092d Merge pull request #696 from littlevgl/embeddedt-patch-1
Fix uninitialized values reported in #695
2019-01-03 15:50:14 +01:00
Themba D
db26a60320 Fix another uninitialized value reported in #695 2019-01-03 07:16:25 -05:00
Themba D
e6126bc218 Fix uninitialized value reported in #695 2019-01-03 07:15:33 -05:00
Gabor Kiss-Vamosi
29200c8814 Merge pull request #691 from Ferruck/fix/limits-error
lv_log: Fix type limits error
2019-01-03 11:19:45 +01:00
Gabor Kiss-Vamosi
5bbb83c68b Merge pull request #693 from joltwallet/dirty_heap
Don't dirty heap if the lv_btn action deletes the button obj
2019-01-03 10:07:34 +01:00
Themba D
8ec482fdbd Coding standard update 2019-01-02 16:13:04 -05:00
Brian Pugh
f2c4aadfe1 Don't dirty heap if the action deletes the button 2019-01-02 15:09:27 -06:00
Philipp Trommler
75f3198c3d lv_log: Fix type limits error
When building LittlevGL with a rather recent compiler (tested with GCC
7.3.1 provided by Arm), `-Wall`, `-Wextra` and `-Werror` activated and
`LV_LOG_LEVEL` set to `LV_LOG_LEVEL_TRACE`, compilation fails due to a
type limits error in lv_log.c

     if(level >= LV_LOG_LEVEL) {
              ^~

because the comparison is always true, since level is a `lv_log_level_t`
(that is a typedef for `uint8_t`) and `LV_LOG_LEVEL_TRACE` equals 0.

Fix that by making `lv_log_level_t` a typedef to `int8_t`.

Fixes #690
2019-01-02 15:18:02 +01:00
Gabor Kiss-Vamosi
d3101f8e96 lv_bar: add symmetric feature to start the indicator from zero 2019-01-01 14:14:17 +01:00
Gabor Kiss-Vamosi
1927a4cf47 lv_table: minor fixes 2019-01-01 13:48:30 +01:00
Gabor Kiss-Vamosi
0bd55a1fa1 lv_table: add 4 CELL styles and horizontal line drawing on '\n' 2019-01-01 13:44:19 +01:00
Gabor Kiss-Vamosi
cda531fc56 lv_circ.c: include lv_circ.h for consistency 2019-01-01 01:34:29 +01:00
Gabor Kiss-Vamosi
8b3786db40 remove unused function declarations 2019-01-01 01:33:18 +01:00
Gabor Kiss-Vamosi
639edca434 fix incosistent function parameter names. See #681 2019-01-01 01:32:16 +01:00
Gabor Kiss-Vamosi
bf43316942 add themes to spinbox, table and tileview 2019-01-01 01:20:14 +01:00
Gabor Kiss-Vamosi
9c7c200048 lv_porting: add display and indev porting skeleton functions 2018-12-31 18:19:38 +01:00
Gabor Kiss-Vamosi
ceab2ac138 lv_gauge: add interpolation for needle between degrees 2018-12-30 22:00:59 +01:00
Gabor Kiss-Vamosi
6322798b61 lv_trigo_sin: bugfix for with 179 degree 2018-12-30 22:00:59 +01:00
Gabor Kiss-Vamosi
a9921c78e8 lv_btnm: drawing bugfix 2018-12-30 15:58:14 +01:00
Gabor Kiss-Vamosi
7ac12cd071 lv_ta: refresh only the cursor area on cursor blink 2018-12-30 15:02:16 +01:00
Gabor Kiss-Vamosi
d7ae21ce85 lv_vdb: add comments 2018-12-29 09:18:58 +01:00
Gabor Kiss-Vamosi
31468efc8e update lv_conf_temp with extra info 2018-12-29 09:12:46 +01:00
Gabor Kiss-Vamosi
f25dec516b add LV_VDB_TRUE_DOUBLE_BUFFERED 2018-12-29 09:12:32 +01:00
Gabor Kiss-Vamosi
8bca90a40b Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-28 18:07:11 +01:00
Gabor Kiss-Vamosi
62b3b2c578 update mk files to use absolute path 2018-12-28 18:06:57 +01:00
Themba Dube
ae68e0a449 Merge branch 'master' into dev-5.3 2018-12-27 12:36:19 -05:00
Gabor Kiss-Vamosi
6536a30b03 Merge pull request #676 from embeddedt/kb_bksp
Change lv_kb delete key to backspace
2018-12-27 18:35:07 +01:00
Themba Dube
0dcaa505fa Replace "Del" key on keyboard with backspace since that is its function 2018-12-27 10:32:05 -05:00
Gabor Kiss-Vamosi
963d91f07d Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-26 23:49:55 +01:00
Gabor Kiss-Vamosi
65cfdd1bf6 lv_table: fix size (add 1 px) 2018-12-26 23:49:41 +01:00
Gabor Kiss-Vamosi
67972f787b Merge pull request #673 from ErichStyger/master
Several typo and spelling fixes
2018-12-26 23:38:57 +01:00
Gabor Kiss-Vamosi
d78c2f0ef5 Merge pull request #661 from tjstyle/master
lv_log: fix warnings
2018-12-26 23:36:15 +01:00
Gabor Kiss-Vamosi
a114a42b74 Update README.md 2018-12-26 23:35:18 +01:00
Gabor Kiss-Vamosi
3e8e94d49c fix warning in lv_anim_path_bounce 2018-12-26 19:31:00 +01:00
Gabor Kiss-Vamosi
fa89846ee3 lv_sw: call action when released 2018-12-26 19:29:17 +01:00
Gabor Kiss-Vamosi
bffa23c4b2 add LV_VERSION_CHECK 2018-12-26 08:24:47 +01:00
Gabor Kiss-Vamosi
d19792289d add LV_BORDER_INTERNAL 2018-12-26 08:24:18 +01:00
Erich Styger
2bfcce40e2 typo and spelling fixes in comments 2018-12-26 07:58:06 +01:00
Erich Styger
9cf4cc1533 Merge pull request #1 from littlevgl/master
Syncing with original repo
2018-12-26 07:42:33 +01:00
Teguh Sobirin
60ee852587 lv_log: fix warnings 2018-12-24 00:49:16 +07:00
Themba Dube
9531f04abf Merge branch 'master' into dev-5.3 2018-12-23 06:40:11 -05:00
Themba Dube
6f5c1ba629 Fix wrong return value of lv_arc_get_angle_end (Closes #663) 2018-12-23 06:38:54 -05:00
Gabor Kiss-Vamosi
4c2df29808 lv_group: do not modify the focused style if the syle_mod function is NULL 2018-12-22 20:41:20 +01:00
Gabor Kiss-Vamosi
bfba1c477f rename bool '..._en' function paramter names to be more consistent 2018-12-22 19:45:55 +01:00
Gabor Kiss-Vamosi
8c74a23ec1 rename lv_line_y_inv to lv_line_y_invert 2018-12-22 19:32:27 +01:00
Gabor Kiss-Vamosi
fd5ca1e52b Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-22 19:08:55 +01:00
Gabor Kiss-Vamosi
f46958bb3f minor fixes 2018-12-22 19:08:40 +01:00
Gabor Kiss-Vamosi
1787b63599 reworks VDB to work with true double buffering 2018-12-22 19:08:03 +01:00
Gabor Kiss-Vamosi
f80c6ab178 Merge pull request #656 from littlevgl/tabview_hide
Add lv_tabview_set_hidden/lv_tabview_get_hidden
2018-12-21 19:10:34 +01:00
Gabor Kiss-Vamosi
7947a991a4 lv_draw_label: optimization 2018-12-21 15:25:45 +01:00
Gabor Kiss-Vamosi
391fda7ba6 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-21 14:35:40 +01:00
Gabor Kiss-Vamosi
19a5f5cd54 minor fixes 2018-12-21 14:35:25 +01:00
Gabor Kiss-Vamosi
8cd0fcefef add lv_table to the makefile 2018-12-20 23:40:52 +01:00
Gabor Kiss-Vamosi
a4a98617c7 lv_table: fix uninitialized new cells 2018-12-20 23:15:29 +01:00
Gabor Kiss-Vamosi
222ef3a76a lv_img: fix memory leak 2018-12-20 22:48:10 +01:00
Themba Dube
4fbfbc3dd7 Add lv_tabview_set_hidden/lv_tabview_get_hidden 2018-12-20 10:07:28 -05:00
Gabor Kiss-Vamosi
693ab86a6c Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-20 00:04:21 +01:00
Gabor Kiss-Vamosi
837cb2b695 add comment to lv_conf_checker.h 2018-12-20 00:04:09 +01:00
Gabor Kiss-Vamosi
cc20e4cb7d add lv_conf_checker.h 2018-12-20 00:01:24 +01:00
Gabor Kiss-Vamosi
789775d8d7 minor fixes 2018-12-20 00:01:05 +01:00
Gabor Kiss-Vamosi
1314eff237 Merge pull request #641 from littlevgl/indev_feedback
Input device feedback API
2018-12-19 20:28:03 +01:00
Gabor Kiss-Vamosi
47f507ff62 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-19 16:35:58 +01:00
Gabor Kiss-Vamosi
e32c35905a lv_img: use style.image.color for texts 2018-12-19 16:35:44 +01:00
Gabor Kiss-Vamosi
61caef8e94 lv_indev_set_cursor: don't enable cursor for LV_INDEV_TYPE_BUTTON 2018-12-18 07:33:55 +01:00
Gabor Kiss-Vamosi
e6c4845983 lv_label: remove space from LV_LABEL_LONG_ROLL/SCROLL anims 2018-12-18 07:25:34 +01:00
Gabor Kiss-Vamosi
e5f449e74f indev feedback: update signal names 2018-12-17 14:54:12 +01:00
Gabor Kiss-Vamosi
93781909bb lv_draw_label: optimization for long texts (uncomment some lines) 2018-12-17 14:34:26 +01:00
Gabor Kiss-Vamosi
60c07120c7 lv_draw_label: optimization for long texts 2018-12-17 14:33:50 +01:00
Themba Dube
4c0cd82d9c Initial lv_indev_set_feedback support 2018-12-16 20:16:48 -05:00
embeddedt
f0aa7abf21 Merge pull request #636 from littlevgl/btnm_recolor
Add ability to recolor btnm and mbox button labels
2018-12-16 09:35:18 -05:00
Themba Dube
35901db2cd Add mbox recoloring support 2018-12-16 09:33:10 -05:00
Gabor Kiss-Vamosi
0fa3fecfe4 Fix ifdef guards around lv_sw animation code 2018-12-16 08:43:35 -05:00
Gabor Kiss-Vamosi
8a0868e2e0 Merge branch 'dev-5.3' into btnm_recolor 2018-12-16 11:33:42 +01:00
Gabor Kiss-Vamosi
59151b375c Merge pull request #633 from upbeat27/dev-5.3
Add wrap enable/disable for lv_group
2018-12-16 09:52:50 +01:00
Gabor Kiss-Vamosi
5e080ad61d Merge pull request #622 from turoksama/dev-5.3
Attempt to fix an LV_BORDER_RIGHT drawing issue.
2018-12-16 08:32:24 +01:00
Themba Dube
ea224d409e Add lv_btnm_set_recolor/lv_btnm_get_recolor 2018-12-15 21:44:44 -05:00
Themba Dube
37761540d0 Fix warning in lv_table.c 2018-12-15 21:26:14 -05:00
Themba Dube
b4d4759383 Merge branch 'master' into dev-5.3 2018-12-15 09:17:49 -05:00
Gabor Kiss-Vamosi
52ffa29ebe lv_kb: bugfix update 2018-12-15 09:16:47 -05:00
Themba Dube
c74f4656fc Fix OK and close button symbols appearing in text area 2018-12-15 09:16:39 -05:00
Josh
92747ec37a Fix missing temporary setting of wrap to 1 2018-12-14 16:02:29 -08:00
Gabor Kiss-Vamosi
3b81dc2a55 lv_kb: bugfix update 2018-12-15 00:11:28 +01:00
Josh
47bdf497b6 Fix lv_group wrap behavior when removing head or tail object from group 2018-12-14 14:24:47 -08:00
Themba Dube
b1712325a7 Fix OK and close button symbols appearing in text area 2018-12-14 16:32:22 -05:00
Josh
9817e050e0 Add wrap enable/disable for lv_group
Allows for controlling whether focus next/prev will wrap at the boundaries, or if they will stop at the boundaries.
2018-12-14 13:05:00 -08:00
Themba Dube
001f788631 Merge remote-tracking branch 'origin/dev-5.3' into embeddedt-dev-5.3 2018-12-14 16:01:58 -05:00
Gabor Kiss-Vamosi
6f1d0ef97b fixes because of sending LV_SIGNAL_PRESSED in LV_GROUP_KEY_ENTER press 2018-12-14 10:33:18 +01:00
Gabor Kiss-Vamosi
964965be9d Merge branch 'table' into dev-5.3 2018-12-13 17:42:14 +01:00
Gabor Kiss-Vamosi
4919f24985 lv_table updates 2018-12-13 17:41:59 +01:00
Gabor Kiss-Vamosi
1e23df926c lv_table updates 2018-12-13 17:38:27 +01:00
Gabor Kiss-Vamosi
dea81daa79 add lv_font_remove 2018-12-13 15:18:06 +01:00
Themba Dube
1ccec72f8c Move ifdef guard around lv_sw_set_anim_time 2018-12-12 20:15:09 -05:00
Themba Dube
bd38e5a7f2 Merge branch 'dev-5.3' into embeddedt-dev-5.3 2018-12-12 20:04:45 -05:00
Gabor Kiss-Vamosi
6c552e8447 ta: fix cursor draw with LV_TXT_UTF8 == 0 2018-12-12 23:45:06 +01:00
Gabor Kiss-Vamosi
86de6f5fbc lv_font: fix typo 2018-12-12 18:55:32 +01:00
Gabor Kiss-Vamosi
a7bc41b528 ddlist and roller delete fix 2018-12-12 09:08:10 +01:00
Samuel
49b136191f Update lv_btnm.c
Attempt to fix an LV_BORDER_RIGHT drawing issue.
2018-12-12 11:30:17 +08:00
Gabor Kiss-Vamosi
e68c3ab725 line draw updates with width = 1 2018-12-11 18:00:48 +01:00
Themba Dube
a2a03d8d53 Merge remote-tracking branch 'origin/master' into dev-5.3 2018-12-11 07:34:09 -05:00
embeddedt
d712a12db1 Merge pull request #619 from mheranco/master
* Swapped two comments in lv_list.c
* Removed unused variables in lv_theme_alien and lv_theme_mono
2018-12-11 07:31:50 -05:00
Martin Herancourt
e60482ca0e minor fixes 2018-12-11 10:21:22 +01:00
Themba Dube
42a8c59886 Handle USE_LV_ANIMATION being disabled in lv_page and lv_sw 2018-12-10 15:35:57 -05:00
embeddedt
b1499cd954 Merge pull request #614 from embeddedt/ddlist_align
Add lv_ddlist_set_align and lv_ddlist_get_align
2018-12-09 20:52:48 -05:00
Themba Dube
f504d01644 Add lv_ddlist_set_align and lv_ddlist_get_align 2018-12-09 20:51:32 -05:00
embeddedt
e084fb022b Merge pull request #607 from aenchevich/dev-5.3
lv_roller_set_align and some minor bug fixes
2018-12-09 20:41:15 -05:00
embeddedt
3fc3c9d0cf Merge pull request #604 from turoksama/dev-5.3
Add ability to have only one button selected on a list at a time
2018-12-09 20:32:42 -05:00
Themba Dube
e5dabf716a Rename btn_single_selected_mode to single_mode 2018-12-09 20:30:36 -05:00
Themba Dube
739b0d4399 Merge branch 'master' into dev-5.3 2018-12-08 10:02:27 -05:00
embeddedt
92d1e5cefd Merge pull request #613 from embeddedt/dev-5.3
Fix compilation error in lv_chart
2018-12-08 10:01:32 -05:00
Themba Dube
429dca127d Fix compilation error in lv_chart 2018-12-08 09:59:56 -05:00
Themba Dube
303f55f3a3 Merge remote-tracking branch 'upstream/dev-5.3' into dev-5.3 2018-12-08 09:31:47 -05:00
Themba Dube
648c3430ef Add bool single_selected_mode to lv_list_ext_t 2018-12-08 09:22:41 -05:00
Alexander
50fe1ba14d lv_roller_set_align / lv_roller_get_align funcs (user can align the Options: left, right or center) 2018-12-07 15:11:24 +02:00
Samuel
c7846c827b Update lv_list.c
Use setter function enable/disable single selected mode.
2018-12-07 15:22:07 +08:00
Samuel
be8d241e06 Update lv_list.h 2018-12-07 15:21:35 +08:00
Gabor Kiss-Vamosi
545b97de65 Update CONTRIBUTING.md 2018-12-06 22:07:35 +01:00
Alexander
64a2a85077 Compilation error fixes 2018-12-05 11:28:16 +02:00
Gabor Kiss-Vamosi
efa9f0a5d1 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-12-05 06:42:57 +01:00
Gabor Kiss-Vamosi
546262df38 add PRESS action handling to keypad indev 2018-12-05 06:42:37 +01:00
Gabor Kiss-Vamosi
6eb9a636d1 Merge branch 'master' into dev-5.3 2018-12-03 14:52:48 +01:00
Gabor Kiss-Vamosi
33f0900ab7 lv_draw_label: inline recolor bugfix 2018-12-03 14:52:06 +01:00
Samuel
cde5f31135 Update lv_list.h 2018-12-03 19:45:47 +08:00
Samuel
7da01d8683 Update lv_list.c 2018-12-03 19:44:58 +08:00
Gabor Kiss-Vamosi
ccea31d3ab Merge branch 'master' into dev-5.3 2018-12-02 16:49:13 +01:00
Gabor Kiss-Vamosi
aebe5c1dfc lv_img_set_src: bugfix 2018-12-02 16:48:50 +01:00
Gabor Kiss-Vamosi
1efd06ef56 Merge pull request #597 from stheil/master
lv_chart: Use circular buffer to avoid memcopy for every new data point
2018-12-02 12:01:59 +01:00
Gabor Kiss-Vamosi
7d7a85c78f lv_chart:fixes 2018-12-02 09:37:24 +01:00
Gabor Kiss-Vamosi
28c4599436 Merge branch 'master' of https://github.com/stheil/lvgl into stheil-master 2018-12-02 09:07:34 +01:00
Themba Dube
7933435ffc Merge remote-tracking branch 'origin/master' into dev-5.3 2018-12-01 09:44:02 -05:00
embeddedt
1baaf560c5 Merge pull request #600 from ukulili/patch-1
Update lv_conf_templ.h
2018-12-01 09:31:42 -05:00
Cabe Lee
0002d6f833 Update lv_conf_templ.h
Modify "# define _CRT_SECURE_NO_WARNINGS" to "#define _CRT_SECURE_NO_WARNINGS";
2018-12-01 17:48:30 +08:00
Gabor Kiss-Vamosi
0c8782c0ff Merge branch 'master' into dev-5.3 2018-11-30 10:05:51 +01:00
Gabor Kiss-Vamosi
23a0b28326 fix warning 2018-11-30 10:05:30 +01:00
Stefan Theil
8e10f79075 lv_chart: Use circular buffer to avoid memcopy for every new data point
This makes the cost of adding a data point independent of array size.
Changing the array size is more complicated, but that will most likely
happen a lot less than adding a data point.
2018-11-29 22:03:56 +01:00
Gabor Kiss-Vamosi
1e19574645 lv_table: fix 2018-11-29 10:02:34 +01:00
Gabor Kiss-Vamosi
e7058e9135 table updates 2018-11-29 08:52:21 +01:00
Gabor Kiss-Vamosi
c1140ec6a7 begin lv_table 2018-11-28 22:02:51 +01:00
Gabor Kiss-Vamosi
47127e9e4e tileview updates 2018-11-28 20:54:23 +01:00
Gabor Kiss-Vamosi
04e42a8d70 Merge pull request #588 from aenchevich/dev-5.3
Fixing C standard related error, formatting lv_conf_templ.h
2018-11-28 14:37:13 +01:00
Alexander
1d7dd0a227 Fixing C standard related error, formatting lv_conf_templ.h 2018-11-26 18:34:37 +02:00
Gabor Kiss-Vamosi
63b86cab2e lv_anim_bounce updates 2018-11-26 15:04:02 +01:00
Gabor Kiss-Vamosi
9bd7847afb Merge branch 'bounce' into dev-5.3 2018-11-26 15:02:29 +01:00
embeddedt
097a0c4a90 Merge pull request #586 from embeddedt/win_drag
Add `lv_win_set_drag` and `lv_win_get_drag`
2018-11-26 07:18:41 -05:00
Gabor Kiss-Vamosi
916c6b3b2f Merge pull request #585 from kisvegabor/tileview
Tileview: new object type
2018-11-26 10:33:48 +01:00
Gabor Kiss-Vamosi
e82638fa03 Merge pull request #569 from littlevgl/imgbtn_update
lv_imgbtn: add tiling (repeated center) feature
2018-11-26 10:33:23 +01:00
Gabor Kiss-Vamosi
dd26bcb22b Merge pull request #576 from kisvegabor/realign
Add realign feature
2018-11-26 10:33:03 +01:00
Themba Dube
47ec7141ac Merge branch 'dev-5.3' into win_drag 2018-11-25 21:34:51 -05:00
Themba Dube
b42cc9f4ad Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-11-25 21:34:38 -05:00
Themba Dube
4bde73d7a9 Add lv_win_set_drag and lv_win_get_drag 2018-11-25 21:31:54 -05:00
Gabor Kiss-Vamosi
a9eb9f9ea5 tileview asn scroll propagation improvments 2018-11-25 19:40:19 +01:00
Gabor Kiss-Vamosi
2cda0fc1fe Merge branch 'page_flash' of https://github.com/kisvegabor/lvgl into tileview 2018-11-25 12:02:28 +01:00
Gabor Kiss-Vamosi
c62cd4dfcb lv_tileview: add the new object type 2018-11-25 12:02:16 +01:00
Gabor Kiss-Vamosi
c37cd19a23 page edge flah updates 2018-11-25 09:54:13 +01:00
Gabor Kiss-Vamosi
dd8f1c7b38 lv_page: add edge flash animation 2018-11-24 20:31:06 +01:00
Gabor Kiss-Vamosi
3785fc4887 lv_line_draw: compensate y2 coordinate if AA is enabled 2018-11-24 19:05:00 +01:00
Gabor Kiss-Vamosi
f6fb219ab2 lv_calendar: day names padding update 2018-11-24 09:38:10 +01:00
Gabor Kiss-Vamosi
6a2b4a81b5 Merge branch 'dev-5.3' of https://github.com/turoksama/lvgl into dev-5.3 2018-11-24 09:31:18 +01:00
Gabor Kiss-Vamosi
15dae7dcbc define LV_ATTRIBUTE_FLUSH_READY as empty if not defined 2018-11-24 07:49:49 +01:00
Gabor Kiss-Vamosi
e8013a4252 Merge branch 'master' into dev-5.3 2018-11-24 07:42:02 +01:00
Gabor Kiss-Vamosi
f6bc6a0bf6 lv_indev: fix warnings 2018-11-24 07:41:18 +01:00
Gabor Kiss-Vamosi
57dc4ed476 lv_anim_bounce path 2018-11-24 07:38:07 +01:00
Gabor Kiss-Vamosi
9d3f6dacb8 Merge pull request #577 from mharizanov/master
Define a custom attribute to `lv_flush_ready` function
2018-11-24 07:28:00 +01:00
Samuel
cc651d0b4c Update lv_calendar.c 2018-11-24 11:11:36 +08:00
Gabor Kiss-Vamosi
f30f3ea8ed realign: fix warnings 2018-11-23 11:35:13 +01:00
Gabor Kiss-Vamosi
f317ff6d43 Merge pull request #578 from littlevgl/embeddedt-use-uintptr_t
Replace uint64_t with uintptr_t in lv_theme.c
2018-11-23 10:07:50 +01:00
embeddedt
d277e80d81 Replace uint64_t with uintptr_t in lv_theme.c
This resolves #574.
2018-11-22 15:04:35 -05:00
mharizanov
cc801277ce Define a custom attribute to lv_flush_ready function 2018-11-22 19:39:01 +02:00
mharizanov
45cf22ebf5 Define a custom attribute to lv_flush_ready function 2018-11-22 19:36:46 +02:00
Gabor Kiss-Vamosi
ce1a1f749a realign: fix typo 2018-11-22 15:19:22 +01:00
Gabor Kiss-Vamosi
d797d10376 add realign feature 2018-11-22 14:59:38 +01:00
Gabor Kiss-Vamosi
e04a3e7fce Merge branch 'master' into dev-5.3 2018-11-22 11:47:56 +01:00
Gabor Kiss-Vamosi
b8009d7c9a Merge pull request #560 from kisvegabor/indev_data_init
lv_indev: init data before calling of indev_read
2018-11-22 11:46:24 +01:00
Themba Dube
be783a65e0 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-11-21 15:01:35 -05:00
Gabor Kiss-Vamosi
6dc8b2f9f7 Merge branch 'AloyseTech-chart_optimize' into dev-5.3 2018-11-21 15:28:28 +01:00
Gabor Kiss-Vamosi
e37846bdcb Merge branch 'chart_optimize' of https://github.com/AloyseTech/lvgl into AloyseTech-chart_optimize 2018-11-21 15:20:08 +01:00
Gabor Kiss-Vamosi
9b4e5e57d6 Merge branch 'dev-5.3' into imgbtn_update 2018-11-21 14:35:51 +01:00
Gabor Kiss-Vamosi
e68969daa6 Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-11-21 14:01:21 +01:00
Gabor Kiss-Vamosi
c584586985 lv_refr/draw: enable the drawing even with body.opa == LV_OPA_TRANSP
E.g. labels don't care with body paramters
2018-11-21 14:00:30 +01:00
embeddedt
c255e4bf8d Merge pull request #553 from embeddedt/animated_switch
Add animations to switch control
2018-11-21 07:58:48 -05:00
embeddedt
c1c7cfd234 Merge pull request #563 from kisvegabor/lv_btnm_api_ext
add lv_btnm_get_pressed
2018-11-21 07:57:29 -05:00
Gabor Kiss-Vamosi
dc436a66cc lv_imgbtn: add tiled option 2018-11-20 17:05:59 +01:00
Gabor Kiss-Vamosi
699f40c9b2 lv_anim: add overshoot path 2018-11-20 14:49:16 +01:00
Gabor Kiss-Vamosi
84d20442a4 Merge branch 'animated_switch' of https://github.com/embeddedt/lvgl into embeddedt-animated_switch 2018-11-20 07:33:53 +01:00
Gabor Kiss-Vamosi
5416c2b778 lv_sw: aniamtion improvements 2018-11-20 07:33:32 +01:00
Themba Dube
5d09a25abc Merge branch 'animated_switch' of github.com:embeddedt/lvgl into animated_switch 2018-11-19 07:42:11 -05:00
Themba Dube
74f8c0e06a Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into animated_switch 2018-11-19 07:40:32 -05:00
Gabor Kiss-Vamosi
892f2be487 add lv_btnm_get_pressed 2018-11-19 07:00:17 +01:00
Gabor Kiss-Vamosi
bf557a1bb0 lv_sw: add comment 2018-11-19 06:35:11 +01:00
Gabor Kiss-Vamosi
073e99e538 lv_indev: init data before calling of indev_read 2018-11-18 11:54:02 +01:00
Themba Dube
ee544893f6 Merge branch 'master' into dev-5.3 2018-11-17 08:02:49 -05:00
embeddedt
2c8cf7d7ea Update README.md 2018-11-17 08:02:11 -05:00
Gabor Kiss-Vamosi
2c74944566 git push origin dev-5.3Merge branch 'AloyseTech-preload-anim' into dev-5.3 2018-11-17 10:49:39 +01:00
Gabor Kiss-Vamosi
042147b010 add LV_PRELOAD_DEF_ANIM to lv_conf_templ.h 2018-11-17 10:48:17 +01:00
Gabor Kiss-Vamosi
0d3cc14c5e Merge branch 'preload-anim' of https://github.com/AloyseTech/lvgl into AloyseTech-preload-anim 2018-11-17 10:44:29 +01:00
Gabor Kiss-Vamosi
07f2e18dfc lv_sw: animation fixes 2018-11-16 18:36:12 +01:00
Gabor Kiss-Vamosi
938819a8b8 lv_sw: simplify animation 2018-11-16 17:42:29 +01:00
AloyseTech
4de708b5ad add api for setting/getting the animation type of preloader 2018-11-15 11:37:00 +01:00
Themba Dube
65d6c82f81 Add off animation and correct initial switch state 2018-11-14 20:24:13 -05:00
Themba Dube
1da612e8a0 Prevent switch from jumping when clicked 2018-11-14 20:20:35 -05:00
Themba Dube
e6214480c4 Very rough prototype of animated switch 2018-11-14 20:11:32 -05:00
Themba Dube
6de61f3f5b Very rough prototype of animated switch 2018-11-14 20:09:09 -05:00
Gabor Kiss-Vamosi
81634d410b fix version number conflict 2018-11-15 00:33:23 +01:00
Gabor Kiss-Vamosi
7528e2a9b2 start v5.2.1-dev 2018-11-15 00:30:42 +01:00
Gabor Kiss-Vamosi
a9a55321c7 fix version number: release v5.2 2018-11-15 00:21:09 +01:00
Gabor Kiss-Vamosi
4cbd8ea8c9 release v5.3 2018-11-15 00:18:45 +01:00
Gabor Kiss-Vamosi
91f250d4d2 lv_conf.h minor formatting 2018-11-15 00:17:12 +01:00
AloyseTech
5102e71e84 add optimized chart drawing for test 2018-11-15 00:01:05 +01:00
AloyseTech
7b9710aa4e Use define to enable or not double animation on preload 2018-11-14 23:01:22 +01:00
AloyseTech
624939f6ba change the second animation range 2018-11-14 17:33:44 +01:00
AloyseTech
16aaa93e76 Better looking preload animation 2018-11-14 17:00:59 +01:00
Gabor Kiss-Vamosi
7897500c1e lv_group: apply lv_group_refocus update again, because it was overwrittetn from the reverted master 2018-11-14 11:27:15 +01:00
Gabor Kiss-Vamosi
64558e138b Merge branch 'master' into dev-5.3 2018-11-14 11:26:06 +01:00
Gabor Kiss-Vamosi
cc995b625b Merge branch 'dev-5.3' of https://github.com/littlevgl/lvgl into dev-5.3 2018-11-14 11:21:09 +01:00
Gabor Kiss-Vamosi
c81d1b5dd0 lv_group: revert accidentally added merge fron dev-5.3 2018-11-14 10:49:09 +01:00
embeddedt
9ae58caadb Merge pull request #540 from turoksama/dev-5.3
[PR] Add a DOWN symbol within ddlist.
2018-11-11 21:09:10 -05:00
Samuel
f2f7681be2 Update lv_ddlist.c 2018-11-12 10:02:29 +08:00
Gabor Kiss-Vamosi
970d8e813a Merge branch 'master' into dev-5.3 2018-11-11 19:56:44 +01:00
Gabor Kiss-Vamosi
4007834f15 minor fixes 2018-11-11 19:56:30 +01:00
Gabor Kiss-Vamosi
96cd245463 lv_ddlist: minor fixes 2018-11-11 15:16:26 +01:00
Samuel
6742d626e7 Update lv_ddlist.c 2018-11-11 10:16:01 +08:00
Gabor Kiss-Vamosi
e1bde8c730 merge master 2018-11-11 00:03:56 +01:00
Gabor Kiss-Vamosi
b44da3c27f lv_group: fix lv_group_remove_obj() if there is only object is the group 2018-11-11 00:02:44 +01:00
Gabor Kiss-Vamosi
8e70d18a32 lv_ddlist: fix arrow area calculation 2018-11-10 09:16:22 +01:00
Gabor Kiss-Vamosi
f6ce901132 Merge branch 'dev-5.3' of https://github.com/turoksama/lvgl into turoksama-dev-5.3 2018-11-10 07:07:05 +01:00
Themba Dube
4637f4085d Fix compilation error in lv_roller 2018-11-09 16:44:26 -05:00
Themba Dube
134b887adc Add getter function for lv_ddlist_set_draw_arrow 2018-11-09 16:37:40 -05:00
Samuel
4a4d7209ba Update lv_ddlist.c 2018-11-09 21:27:36 +08:00
Samuel
e159e1a8bd Update lv_ddlist.c 2018-11-09 20:32:08 +08:00
Samuel
ac9ee5d1f8 Update lv_roller.c 2018-11-09 20:29:59 +08:00
Samuel
54435fce60 Update lv_ddlist.h 2018-11-09 20:27:59 +08:00
Samuel
4092adbe28 Update lv_ddlist.c 2018-11-09 20:25:48 +08:00
Samuel
06f81e8a61 Update lv_conf_templ.h 2018-11-09 20:13:26 +08:00
Gabor Kiss-Vamosi
e94774ccec Merge branch 'dev-5.3' of https://github.com/turoksama/lvgl into turoksama-dev-5.3 2018-11-09 12:36:58 +01:00
Gabor Kiss-Vamosi
a4d950a2f2 lv_anim: add lv_anim_count_running 2018-11-09 12:36:38 +01:00
Gabor Kiss-Vamosi
63bc66c40d lv_page: remove debug printfs 2018-11-09 07:22:38 +01:00
Gabor Kiss-Vamosi
2a053b86bf lv_ta: with ENCODER show cursor only in edit mode 2018-11-09 07:11:20 +01:00
Gabor Kiss-Vamosi
d643219ee8 lv_group: don't edit the first obj in the group, becuase some indev types (e.g. TP) not supports it 2018-11-09 07:10:10 +01:00
Samuel
74015d6d18 Update lv_conf_templ.h 2018-11-08 23:30:13 +08:00
Samuel
224bd55d50 Update lv_roller.c 2018-11-08 23:28:41 +08:00
Samuel
4f51940274 Update lv_ddlist.c 2018-11-08 23:28:04 +08:00
Samuel
d2263c121a Update lv_ddlist.h 2018-11-08 23:27:30 +08:00
Samuel
075f8740d4 Update lv_ddlist.c 2018-11-08 23:26:43 +08:00
Samuel
8fd442531f Update lv_conf_templ.h 2018-11-08 23:24:23 +08:00
Samuel
4f49061084 Update lv_ddlist.c 2018-11-08 22:47:43 +08:00
Samuel
d02cdc2fec Update lv_ddlist.c 2018-11-08 22:46:20 +08:00
Samuel
29a695b4a6 Add files via upload 2018-11-08 22:39:08 +08:00
Gabor Kiss-Vamosi
9504cb8531 Merge branch 'master' into dev-5.3 2018-11-08 06:23:31 +01:00
Gabor Kiss-Vamosi
8a341d78b1 Merge pull request #539 from C47D/fix_lv_btnm_get_style
Fix lv btnm get style (#513)
2018-11-08 06:21:27 +01:00
Carlos
63075b73bd Add missing = in lv_btnm_get_style function 2018-11-07 21:54:51 -06:00
Carlos
2a27c469fe Fix warning in lv_img_src_get_type 2018-11-07 21:54:18 -06:00
Gabor Kiss-Vamosi
b3c159d968 lv_list: add API for scroll propagation 2018-11-07 20:59:03 +01:00
Gabor Kiss-Vamosi
fa25d7c428 lv_page: scroll propagation buf fix 2018-11-07 20:58:36 +01:00
Gabor Kiss-Vamosi
ba769623be lv_page: add scroll propagation feature 2018-11-07 20:41:52 +01:00
Gabor Kiss-Vamosi
82ff19092b lv_spinbox: fix warnings 2018-11-07 20:41:04 +01:00
Gabor Kiss-Vamosi
e5f59799ee lv_list: use 'last_sel' with encoder too 2018-11-07 17:58:19 +01:00
Gabor Kiss-Vamosi
88392f9bd3 Merge branch 'AloyseTech-spinbox' into dev-5.3 2018-11-07 17:52:22 +01:00
Gabor Kiss-Vamosi
0a3621cdee fix typo 2018-11-07 17:48:50 +01:00
Gabor Kiss-Vamosi
7c32c9c6e7 fix conflicts when merging from master 2018-11-07 17:47:50 +01:00
Gabor Kiss-Vamosi
3f059575ee Merge pull request #529 from joltwallet/rem_last_sel
Remember list last selected
2018-11-07 10:18:50 +01:00
AloyseTech
d4fb9b1343 reverse encoder direction (CCW==decrement, CW==increment) 2018-11-06 17:55:11 +01:00
Brian Pugh
9c2b0ac5ea valid action not necessary to save last_sel 2018-11-06 08:23:57 -08:00
Gabor Kiss-Vamosi
5088e903cb Merge pull request #526 from AloyseTech/single-obj-group
Avoid object defocusing in single group object
2018-11-06 17:01:05 +01:00
Gabor Kiss-Vamosi
5e8a6924b6 Merge pull request #535 from C47D/fix_all_5133
Fixes all functions reported in #513 and add a missing semicolon in #531
2018-11-06 16:50:42 +01:00
Gabor Kiss-Vamosi
7c76a46cbc Remove unused code
Co-Authored-By: AloyseTech <AloyseTech@users.noreply.github.com>
2018-11-06 16:42:30 +01:00
Carlos
fbf44f1991 Fixes all functions reported in #513 and add a missing semicolon in #531 2018-11-05 22:21:20 -06:00
Brian Pugh
e37e0079be Set lv_list last_sel to NULL upon creation 2018-11-05 09:33:05 -08:00
Brian Pugh
96c0050cb8 Remember list last selected 2018-11-05 08:46:51 -08:00
AloyseTech
2c7b51ca56 Add left digit padding handling 2018-11-05 14:48:33 +01:00
AloyseTech
d5747a0379 fix set_digit_format 2018-11-05 14:47:30 +01:00
AloyseTech
b0962095f3 Merge branch 'spinbox' of github.com:AloyseTech/lvgl into spinbox 2018-11-05 14:02:13 +01:00
AloyseTech
77162e7784 Avoid object defocusing in signle group object 2018-11-05 13:15:34 +01:00
AloyseTech
6e116d9e59 Add digit padding feature [WIP] 2018-11-05 11:52:21 +01:00
Gabor Kiss-Vamosi
a81b735016 Merge pull request #522 from C47D/Fix_513
Fixes #513
2018-11-04 20:54:03 +01:00
Gabor Kiss-Vamosi
e5464f5be7 spinbox: formatting 2018-11-04 20:21:51 +01:00
Carlos
d86f8a8981 Fixes #513 2018-11-04 12:24:45 -06:00
Gabor Kiss-Vamosi
deb8048da5 lv_draw_vbasic.c: remove unnecessary cast 2018-11-04 16:11:49 +01:00
AloyseTech
a88ad62af3 Add/fix comment 2018-11-03 18:41:06 +01:00
AloyseTech
8cafd07e0a Remove double api, add increment/decrement api 2018-11-03 18:26:59 +01:00
AloyseTech
46309f7333 update spinbox object when int value change 2018-11-03 18:07:25 +01:00
Gabor Kiss-Vamosi
612c618240 minor fixes 2018-11-02 14:21:10 +01:00
Gabor Kiss-Vamosi
e2bbbefb04 Merge branch 'spinbox' of https://github.com/AloyseTech/lvgl into AloyseTech-spinbox 2018-11-02 13:57:00 +01:00
Gabor Kiss-Vamosi
f1b59388bb Merge branch 'chartSerieClear' of https://github.com/AloyseTech/lvgl into AloyseTech-chartSerieClear 2018-11-02 13:37:23 +01:00
Gabor Kiss-Vamosi
c083150072 lv_list: fix warnings 2018-11-02 12:53:36 +01:00
Gabor Kiss-Vamosi
3353a74e1d Merge branch 'master' of https://github.com/fallstool/lvgl into dev-5.3 2018-11-02 12:50:22 +01:00
Gabor Kiss-Vamosi
79b5b0f1fc lv_list: update comments 2018-11-02 12:45:09 +01:00
Gabor Kiss-Vamosi
ed53728010 Merge branch 'master' into dev-5.3 2018-11-02 12:42:51 +01:00
AloyseTech
0fceadc529 add spinbox object to include list in lvgl.h 2018-11-01 19:45:48 +01:00
AloyseTech
404c52e3c2 create spinbox object, derivating lv_ta 2018-11-01 18:48:13 +01:00
AloyseTech
9b5ec3572e move LV_CHART_POINT_DEF to header and define it to LV_COORD_MIN 2018-11-01 18:40:13 +01:00
fallstool
46b4186216 Update lv_list.c
change the code style
2018-11-01 09:58:55 +08:00
AloyseTech
bcf0a42674 Negative chart point not rendered, add function to clear points from a serie 2018-10-30 17:26:26 +01:00
Gabor Kiss-Vamosi
029d0af946 lv_roller: save preserve the touchpad selected value on defucus 2018-10-30 13:46:49 +01:00
Gabor Kiss-Vamosi
f5e397341d lv_ll: fix comment typo 2018-10-30 13:46:49 +01:00
Gabor Kiss-Vamosi
32843f9f91 lv_roller: save preserve the touchpad selected value on defucus 2018-10-30 13:45:29 +01:00
fallstool
6ecd3f1f8a Update lv_list.c 2018-10-30 18:08:38 +08:00
fallstool
17bc493612 Update lv_list.c 2018-10-30 17:05:27 +08:00
fallstool
34f8013465 Update lv_list.h 2018-10-30 17:04:11 +08:00
fallstool
5b05afe948 Update lv_list.c 2018-10-30 16:38:39 +08:00
fallstool
686c6c9033 Update lv_list.h 2018-10-30 16:38:00 +08:00
Gabor Kiss-Vamosi
04239f9287 lv_ll: fix comment typo 2018-10-30 09:18:45 +01:00
fallstool
e163a796b2 Merge pull request #1 from littlevgl/master
merge
2018-10-30 15:16:19 +08:00
Gabor Kiss-Vamosi
63f1bf2d45 Merge pull request #495 from joltwallet/group_refocus_pr_squashed
Group refocus on deletion
2018-10-28 23:51:19 +01:00
Brian Pugh
0e7d25ba85 Group refocus on deletion 2018-10-28 15:44:58 -07:00
Gabor Kiss-Vamosi
b7792f0aa2 updates from dev-5.3 2018-10-28 23:18:22 +01:00
Gabor Kiss-Vamosi
429a188318 minor fixes in symbol fonts 2018-10-28 23:15:32 +01:00
Gabor Kiss-Vamosi
0ff6026df8 improve page focus styling 2018-10-28 23:14:59 +01:00
Gabor Kiss-Vamosi
984b35e2b0 fix version number conflict 2018-10-28 10:30:22 +01:00
Gabor Kiss-Vamosi
fc319a4502 lv_tabview: add lv_res_t return value to prevent tab laoding on LV_RES_INV 2018-10-28 10:29:06 +01:00
Gabor Kiss-Vamosi
4f11ad7adb lv_draw_img: fix buffer size 2018-10-28 09:07:00 +01:00
Gabor Kiss-Vamosi
436c09aa51 lv_ll: fix comment typo 2018-10-27 11:11:24 +02:00
Gabor Kiss-Vamosi
cd3f6340da add rc tag 2018-10-27 11:11:24 +02:00
Gabor Kiss-Vamosi
78428b523f lv_draw_img: fix to draw images with LV_COLOR_DEPTH 1 2018-10-27 11:11:24 +02:00
Gabor Kiss-Vamosi
f259b56e67 LV_GROUP_KEY_BACKSPACE 2018-10-20 00:43:42 +02:00
Gabor Kiss-Vamosi
e0afb3b8b4 Merge branch 'master' into dev-5.3 2018-10-20 00:39:12 +02:00
Gabor Kiss-Vamosi
e2ddaf7577 add rc tag 2018-10-20 00:38:56 +02:00
Gabor Kiss-Vamosi
63b9c5265f lv_draw_img: fix to draw images with LV_COLOR_DEPTH 1 2018-10-18 06:59:41 +02:00
Gabor Kiss-Vamosi
88b8e982b4 lv_task and lv_ll: stability improvents 2018-10-17 14:31:16 +02:00
Gabor Kiss-Vamosi
bf00102f83 lv_ta: cursor type bit size fix 2018-10-17 12:41:30 +02:00
Gabor Kiss-Vamosi
4751cb16c9 minor fixes 2018-10-17 11:27:31 +02:00
Gabor Kiss-Vamosi
c9111563b1 add lv_cont/page_get_width/height 2018-10-17 11:27:31 +02:00
Gabor Kiss-Vamosi
f7d25a8ee9 Merge pull request #465 from fallstool/master
Update lv_ta.h
2018-10-17 11:13:08 +02:00
fallstool
be24c90532 Update lv_ta.h 2018-10-17 14:20:39 +08:00
Gabor Kiss-Vamosi
3c5093f3cb Merge pull request #460 from ali-rostami/master
action functions for calendar object
2018-10-16 16:37:28 +02:00
Ali Rostami
dd7072c875 pressed_date getter deceleration
A declaration added for pressed_date getter function.
2018-10-16 18:04:43 +03:30
Ali Rostami
6610929eaf pressed date getter
A getter function added for pressed_date.
2018-10-16 18:01:57 +03:30
Gabor Kiss-Vamosi
39395465a2 fix version number 2018-10-16 16:08:13 +02:00
Gabor Kiss-Vamosi
071b10f3f4 lv_calendar: add action API + minor fixes 2018-10-16 14:15:54 +02:00
Gabor Kiss-Vamosi
5a8fb4651c Merge branch 'master' of https://github.com/ali-rostami/lvgl into dev-5.3 2018-10-16 14:07:03 +02:00
Gabor Kiss-Vamosi
eab7a961df Merge branch 'master' into dev-5.3 2018-10-16 14:05:32 +02:00
Ali Rostami
23166f43d7 pressed_date initialization
pressed_date inited in create function.
2018-10-16 08:35:09 +03:30
Gabor Kiss-Vamosi
7427e01b60 lv_group related updates mainly with ENCODER indev 2018-10-15 20:12:12 +02:00
Gabor Kiss-Vamosi
7e4187e89a fixes if an object is deleted in its action 2018-10-15 19:33:34 +02:00
Gabor Kiss-Vamosi
603e9336d4 fixes if the freed memory become dirty 2018-10-15 19:00:03 +02:00
Gabor Kiss-Vamosi
03e6b1bff7 lv_group_remove_obj: stop iterating when the obj is found 2018-10-15 18:22:52 +02:00
Gabor Kiss-Vamosi
d833a65d1e lv_ddlist and lv_roller bugfix when deleted while being in a group 2018-10-15 17:29:15 +02:00
Ali Rostami
e315170c8d init action function
In the lv_calendar_create function, I added some lines to init action functions of the calendar.
2018-10-15 18:14:44 +03:30
Gabor Kiss-Vamosi
c444d43fe8 Merge branch 'master' into dev-5.3 2018-10-15 12:44:39 +02:00
Gabor Kiss-Vamosi
c6d8f8ee28 move the bdf_font_converter to the lv_utils repo 2018-10-15 12:44:17 +02:00
Gabor Kiss-Vamosi
108278c4b5 Merge branch 'master' into dev-5.3 2018-10-15 12:38:27 +02:00
Gabor Kiss-Vamosi
556306a269 add lv_page/cont_fit_width/height functions 2018-10-15 12:38:13 +02:00
Ali Rostami
49b1fe421e Update lv_calendar.h 2018-10-14 14:08:43 +03:30
Ali Rostami
def0169dda Update lv_calendar.c 2018-10-14 14:03:51 +03:30
Gabor Kiss-Vamosi
a482132652 lv_bar and lv_slider: fix indicator size at amy value 2018-10-12 21:12:13 +02:00
Gabor Kiss-Vamosi
4cf6a4c22e Merge pull request #458 from BrianPugh/master
BDF Font Converter
2018-10-12 21:05:27 +02:00
Brian Pugh
10dddd85c5 Documentation update 2018-10-12 09:38:31 -07:00
Brian Pugh
fe24ce53b7 initial bdf font converter 2018-10-12 09:35:46 -07:00
Gabor Kiss-Vamosi
0ee104d155 lv_btnm: ignore clicks on inactive buttons 2018-10-12 09:09:10 +02:00
Gabor Kiss-Vamosi
b6b77f4b45 lv_img_color_format_get_px_size fix for true color apha format 2018-10-11 14:23:03 +02:00
Gabor Kiss-Vamosi
0fdfa32d4a set version number 2018-10-09 17:29:12 +02:00
Gabor Kiss-Vamosi
7d1e1e6147 exclude some code when USE_LV_GROUP 0 2018-10-09 15:10:17 +02:00
Gabor Kiss-Vamosi
a4b4ebaf7d Merge pull request #448 from BrianPugh/master
Add monospace font to makefile
2018-10-09 07:15:37 +02:00
Gabor Kiss-Vamosi
4677c5955d lv_conf_templ.h LV_VDB_PX_BPP comment update 2018-10-09 07:06:51 +02:00
Gabor Kiss-Vamosi
ca7f8e66bb Mark this release as release candidate insted 2018-10-09 07:04:47 +02:00
Brian Pugh
0a6151ade9 added monospace to fonts makefile 2018-10-08 09:40:55 -04:00
Brian Pugh
039deed864 Merge remote-tracking branch 'upstream/master' 2018-10-08 09:39:45 -04:00
Gabor Kiss-Vamosi
83cef11a78 lv_roller: fix for focus change in callback function 2018-10-08 07:28:25 +02:00
Gabor Kiss-Vamosi
0825819586 Merge pull request #445 from ErichStyger/master
removed duplicated define in configuration template file
2018-10-06 12:22:35 +02:00
Erich Styger
2d0c21f8a8 removed duplicated define in configuration template file 2018-10-06 10:41:00 +02:00
Brian Pugh
63be4a3dd1 Added mono themes source file to theme submakefile 2018-10-01 19:44:20 -04:00
144 changed files with 11275 additions and 1745 deletions

7
.editorconfig Normal file
View File

@@ -0,0 +1,7 @@
[*.{c,h}]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

View File

@@ -0,0 +1,14 @@
---
name: All other issues
about: Questions and enhancement requests should go to the forum.
title: ''
labels: not-template
assignees: ''
---
# All enhancement requests or questions should be directed to the Forum.
We use GitHub issues for development related discussions.
Please use the [forum](https://forum.littlevgl.com/) to ask questions.

27
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Please provide a small, independent code sample that can be used to reproduce the issue. Ideally this should work in the PC simulator unless the problem is specific to one platform.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.

17
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 21
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- architecture
- pinned
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue or pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

4
.gitignore vendored
View File

@@ -1 +1,3 @@
**/*.o
**/*.o
**/*.swp
**/*.swo

0
.gitmodules vendored Normal file
View File

225
README.md
View File

@@ -1,69 +1,206 @@
# Littlev Graphics Library
<h1 align="center"> LittlevGL - Open-source Embedded GUI Library</h1>
<p align="center">
<a href="https://github.com/littlevgl/lvgl/blob/master/LICENCE.txt"><img src="https://img.shields.io/badge/licence-MIT-blue.svg"></a>
<a href="https://github.com/littlevgl/lvgl/releases/tag/v5.3"><img src="https://img.shields.io/badge/version-5.3-blue.svg"></a>
<br>
<img src="https://user-images.githubusercontent.com/42941056/109342022-428df280-7839-11eb-89f7-a476495f8e9c.gif">
</p>
![LittlevGL cover](https://littlevgl.com/docs/themes/lv_theme_intro.png)
<p align="center">
LittlevGL provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
</p>
**LittlevGL provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint.**
https://littlevgl.com
<h4><a href="https://github.com/lvgl/docs_old/raw/release/v6/en/docs_v5_3.zip">Documentation</a></h4>
## Key features
<!--
<p align="center">
:star: Star the project if you like it! And share with your friends <a href="https://twitter.com/intent/tweet?text=LittlevGL%20is%20a%20free%20and%20open%20source%20embedded%20GUI%20library%20with%20easy-to-use%20graphical%20elements,%20beautiful%20visual%20effects%20and%20low%20memory%20footprint.&url=https://littlevgl.com/&hashtags=littlevgl,embedded,gui,free,opensource"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"></a>
</p>
-->
### Features
* **Powerful building blocks** buttons, charts, lists, sliders, images, etc.
* **Advanced graphics** with animations, anti-aliasing, opacity, smooth scrolling
* **Various input devices** touch pad, mouse, keyboard, encoder, buttons, etc.
* **Multi-language support** with UTF-8 encoding
* **Fully customizable** graphical elements
* **Hardware independent** to use with any microcontroller or display
* **Scalable** to operate with little memory (50 kB Flash, 10 kB RAM)
* **Scalable** to operate with little memory (64 kB Flash, 10 kB RAM)
* **OS, External memory and GPU** supported but not required
* **Single frame buffer** operation even with advances graphical effects
* **Written in C** for maximal compatibility
* **Micropython Binding** exposes [LittlevGL API in Micropython](https://blog.littlevgl.com/2019-02-20/micropython-bindings)
* **Simulator** to develop on PC without embedded hardware
* **Tutorials, examples, themes** for rapid development
* **Documentation** and API references online
## Porting
In the simplest case you need 5 things:
1. Call `lv_tick_inc(x)` every `x` milliseconds in a Timer or Task (`x` should be between 1 and 10)
2. Register a function which can **copy a pixel array** to an area of the screen.
3. Register a function which can **read an input device**. (E.g. touch pad)
4. Copy `lv_conf_templ.h` as `lv_conf.h` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
5. Call `lv_task_handler()` periodically every few milliseconds.
For a detailed description visit https://littlevgl.com/porting
Or check the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
### Supported devices
Basically, every modern controller - which is able to drive a display - is suitable to run LittlevGL. The minimal requirements:
- **16, 32 or 64-bit** microcontroller or processor
- **&gt; 16 MHz** clock speed
- **&gt; 8 kB RAM for static data** and **&gt; 2 KB RAM for dynamic data** (graphical objects)
- **&gt; 64 kB flash** program memory
- **Optionally ~1/10 screen sized memory** for buffered drawing (on 240 × 320, 16-bit colors it's 15 kB)
Just to mention some **platforms**:
- STM32F1, STM32F3, [STM32F4](https://blog.littlevgl.com/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/littlevgl/stm32f746_disco_no_os_sw4stm32)
- Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ
- NXP Kinetis, LPC, iMX
- [Linux frame buffer](https://blog.littlevgl.com/2018-01-03/linux_fb) (/dev/fb)
- [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
- [Espressif ESP32](https://github.com/littlevgl/esp32_ili9431)
- Nordic nrf52
- Quectell M66
### Quick start in a simulator
The easiest way to get started with LittlevGL is to run it in a simulator on your PC without any embedded hardware.
Choose a project with your favourite IDE:
| Eclipse | CodeBlocks | Visual Studio | PlatformIO | Qt Creator |
|-------------|-------------|---------------|-----------|------------|
| [![Eclipse](https://littlevgl.com/logo/ide/eclipse.jpg)](https://github.com/littlevgl/pc_simulator_sdl_eclipse) | [![CodeBlocks](https://littlevgl.com/logo/ide/codeblocks.jpg)](https://github.com/littlevgl/pc_simulator_win_codeblocks) | [![VisualStudio](https://littlevgl.com/logo/ide/visualstudio.jpg)](https://github.com/littlevgl/visual_studio_2017_sdl_x64) | [![PlatformIO](https://littlevgl.com/logo/ide/platformio.jpg)](https://github.com/littlevgl/pc_simulator_sdl_platformio) | [![QtCreator](https://littlevgl.com/logo/ide/qtcreator.jpg)](https://blog.littlevgl.com/2019-01-03/qt-creator) |
| Cross-platform<br>with SDL | Native Windows | Cross-platform<br>with SDL | Cross-platform<br>with SDL | Cross-platform<br>with SDL |
### Porting to an embedded hardware
In the most simple case you need to do these steps:
1. Copy `lv_conf_templ.h` as `lv_conf.h` next to `lvgl` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
2. Call `lv_tick_inc(x)` every `x` milliseconds **in a Timer or Task** (`x` should be between 1 and 10). It is required for the internal timing of LittlevGL. **It's very important that you don't call `lv_task_handler` in the same loop.**
3. Call `lv_init()`
4. Register a function which can **copy a pixel array** to an area of the screen:
```c
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.disp_flush = disp_flush; /*Set your driver function*/
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
{
int32_t x, y;
for(y = y1; y <= y2; y++) {
for(x = x1; x <= x2; x++) {
sep_pixel(x, y, *color_p); /* Put a pixel to the display.*/
color_p++;
}
}
lv_flush_ready(); /* Tell you are ready with the flushing*/
}
```
5. Register a function which can **read an input device**. E.g. for a touch pad:
```c
lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
indev_drv.read = touchpad_read; /*Set your driver function*/
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/
bool touchpad_read(lv_indev_data_t * data)
{
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
/*Save the state and save the pressed coordinate*/
data->state = touchpad_is_pressed() ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
if(data->state == LV_INDEV_STATE_PR) touchpad_get_xy(&last_x, &last_y);
/*Set the coordinates (if released use the last pressed coordinates)*/
data->point.x = last_x;
data->point.y = last_y;
return false; /*Return `false` because we are not buffering and no more data to read*/
}
```
6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task. It will redraw the screen if required, handle input devices etc. **It's very important that you don't call `lv_tick_inc` in the same loop.**
For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
## Project set-up
1. **Clone** or [Download](https://littlevgl.com/download) the lvgl repository: `git clone https://github.com/littlevgl/lvgl.git`
2. **Create project** with your preferred IDE and add the *lvgl* folder
3. Copy **lvgl/lv_conf_templ.h** as **lv_conf.h** next to the *lvgl* folder
4. In the lv_conf.h delete the first `#if 0` and its `#endif`. Leave the default configuration for the first try.
5. In your *main.c*: #include "lvgl/lvgl.h"
6. In your *main function*:
* lvgl_init();
* tick, display and input device initialization (see above)
7. To **test** create a label: `lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);`
8. In the main *while(1)* call `lv_task_handler();` and make a few milliseconds delay (e.g. `my_delay_ms(5);`)
9. Compile the code and load it to your embedded hardware
### Code examples
#### Create a button with a label and assign a click callback
```c
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 100, 50); /*Set its size*/
## PC Simulator
You can test the graphics library in a PC simulator, if you don't have an embedded hardware. The simulator uses [SDL2](https://www.libsdl.org/) library to emulate a display on your monitor and a touch pad with your mouse.
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, btn_action);/*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
There is a pre-configured PC project for **Eclipse CDT** in this repository: https://github.com/littlevgl/pc_simulator
lv_res_t btn_action(lv_obj_t * btn)
{
printf("Clicked\n");
return LV_RES_OK;
}
```
![Simple button with LittelvGL](https://littlevgl.com/github/btn1.gif)
## Related repositories
* PC simulator: https://github.com/littlevgl/pc_simulator
* Projects: https://github.com/littlevgl/lv_projects
* Examples: https://github.com/littlevgl/lv_examples
* Drivers: https://github.com/littlevgl/lv_drivers
#### Modify the styles
```c
static lv_style_t style_btn_rel; /*A variable to store the released style*/
lv_style_copy(&style_btn_rel, &lv_style_plain); /*Initialize from a built-in style*/
style_btn_rel.body.border.color = LV_COLOR_HEX3(0x269);
style_btn_rel.body.border.width = 1;
style_btn_rel.body.main_color = LV_COLOR_HEX3(0xADF);
style_btn_rel.body.grad_color = LV_COLOR_HEX3(0x46B);
style_btn_rel.body.shadow.width = 4;
style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
style_btn_rel.text.color = LV_COLOR_HEX3(0xDEF);
## Screenshots
![TFT material](http://www.gl.littlev.hu/github_res/tft_material.png)
![TFT zen](http://www.gl.littlev.hu/github_res/tft_zen.png)
![TFT alien](http://www.gl.littlev.hu/github_res/tft_alien.png)
![TFT night](http://www.gl.littlev.hu/github_res/tft_night.png)
static lv_style_t style_btn_pr; /*A variable to store the pressed style*/
lv_style_copy(&style_btn_pr, &style_btn_rel); /*Initialize from the released style*/
style_btn_pr.body.border.color = LV_COLOR_HEX3(0x46B);
style_btn_pr.body.main_color = LV_COLOR_HEX3(0x8BD);
style_btn_pr.body.grad_color = LV_COLOR_HEX3(0x24A);
style_btn_pr.body.shadow.width = 2;
style_btn_pr.text.color = LV_COLOR_HEX3(0xBCD);
## Contributing
See [CONTRIBUTING.md](https://github.com/littlevgl/lvgl/blob/master/docs/CONTRIBUTING.md)
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel); /*Set the button's released style*/
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &style_btn_pr); /*Set the button's pressed style*/
```
## Donate
If you are pleased with this graphics library, found it useful, or are happy with the support you got, please help its further development:
![Simple button with LittelvGL](https://littlevgl.com/github/btn2.gif)
#### Enable a fancy effect
```c
/*Add some effects when the button is clicked*/
lv_btn_set_ink_in_time(btn, 300);
lv_btn_set_ink_wait_time(btn, 100);
lv_btn_set_ink_out_time(btn, 300);
```
![Simple button with LittelvGL](https://littlevgl.com/github/btn3.gif)
#### Use LittlevGL from Micropython
```python
# Create a Button and a Label
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")
# Load the screen
lv.scr_load(scr)
```
Check out the [Documentation](https://docs.littlevgl.com/) for more!
### Contributing
To ask questions please use the [Forum](https://forum.littlevgl.com).
FOr development related things (bug reports, feature suggestions) use [GitHub's Issue tracker](https://github.com/littlevgl/lvgl/issues).
You can contribute in several ways:
- **Answer other's question** in the Forum
- **Report and/or fix bugs** using the issue tracker and in Pull-request
- **Suggest and/or implement new features** using the issue tracker and in Pull-request
- **Improve and/or translate the documentation** learn more [here](https://github.com/littlevgl/docs)
- **Write a blog post about your experiences** learn more [here](https://github.com/littlevgl/blog)
- **Upload your project or product as a reference** to [this site](https://blog.littlevgl.com/2018-12-26/references)
Before contributing, please read [CONTRIBUTING.md](https://github.com/littlevgl/lvgl/blob/master/docs/CONTRIBUTING.md).
### Donate
If you are pleased with the library, found it useful, or you are happy with the support you got, please help its further development:
[![Donate](https://littlevgl.com/donate_dir/donate_btn.png)](https://littlevgl.com/donate)

View File

@@ -1,181 +1,103 @@
# Contributing to Littlev Graphics Library
It's glad to see that you are interested in Contributing to LittlevGL!
In this guide you can learn how can you help to develop LittlevGL.
### Table Of Content
* [Who can contribute?](#who-can-contribute)
* [How to report an issue?](#how-to-report-a-bug)
* [How to suggest a feature?](#how-to-suggest-a-feature)
* [How to implement a feature?](#how-to-implement-a-feature)
* [Styling guide](#styling-guide)
## Who can contribute?
As graphical interfaces for embedded systems has an increasing relevance today you also might find important to work with a good graphics library. Now - independently from skills, programming level or any personal attributes - you can influence and help the development of Littlev Graphics Library with:
* Report an issue
* Suggest feature
* Fix an issue
* Implement a feature
* Help with testing bugfixes and new features
Please, take a look at [CODE_OF_CONDUCT](https://github.com/littlevgl/lvgl/blob/master/docs/CODE_OF_CONDUCT.md)
There are few **general rules**
* We use [GitHub's issue tracker](https://github.com/littlevgl/lvgl/issues)
* Be kind and respectful. Starting with "Hi" is always a good idea :)
* If somebody helped you give a feedback.
* One issue should be about one topic. If you have other questions please open a new issue.
* Always create an issue before creating a [Pull request](https://help.github.com/articles/about-pull-requests/) to discuss the idea first
* Create small, "digestible" Pull requests.
* Tell your remarks in a structured way. Use paragraphs and the [Markdown](https://guides.github.com/features/mastering-markdown/) support of GitHub.
* Be sure you are using the latest version (from `master` branch)
* Keep in mind LittlevGL should be and should remain:
- usable on small MCUs as well (think about memory footprint)
- compilable with "non-standard" tools like Arduino (no gcc specific options)
- C compatible (no C++ specific code and features)
- all configuration should be in `lv_conf.h`. (Instead of modifying the library)
- the API clean and easiy to understand
## How to report a bug?
If you found a **simple and straightforward bug** like:
* misspelling (in comments function/variable names or grammatical issues in comments)
* not handled error cases (negative array index, overflow etc)
* anything else which can be fixed locally with a few lines of code
* or defective documentation
then tell:
* where you found the bug (which file/function/variable)
* how can it cause problem
* what is your suggested solution if you have
If you faced with **something more complex** like:
* might be simple but you don't know its origin
* affects a whole file, module or even the architecture
* needs deeper discussion
then please
* tell what do you experience
* tell what do you expect to happen
* tell how to reproduce the issue
* provide a simplified code example (better if can be tested with copy-paste)
* attache your lv_conf.h (if you feel it's important)
* logs and long codes should be attached in a file (instead of copying into a comment)
## How to suggest a feature?
If you have a good and useful idea open issue to tell it! Please note the followings on suggesting new features:
* What the new feature is about?
* Why/Where/In which case is it useful/helpful/relevant?
* Can you mention real life usecases/examples for the use this feature?
* Can you help in implementing it?
Your suggestion can have 4 possible outcomes:
1. This feature is already exists. In this case you will learn how to achieve your goal.
2. You can simply realize it with the current functionality.
3. Although it's a new feature but it would break LittlevGL's platform independent and/or resource minimalist nature.
4. It's really a new feature which would be good to be in LittlevGL. Hurray! In a discussion we figure out the technical details and implementation options. With the knowledge of how to do it somebody can implement the new feature.
Keep in mind if you wouldn't like to do the implementation there is no guarantee that it will be ready in the near future.
However, if you would like to force it, take a look at this page: [Feature request service](http://www.gl.littlev.hu/services#feature)
## How to implement a feature?
In [docs/TODO_MINOR.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_MINOR.md) and [docs/TODO_PATCH.md](https://github.com/littlevgl/lvgl/blob/master/docs/TODO_PATCH.md) you can see some ideas which are waiting for somebody to realize them! If want to deal with a feature from these files, please start an issue and discuss the details.
The new feature should be in a new branch.
## Styling guide
### File format
Use [lv_misc/lv_templ.c](https://github.com/littlevgl/lvgl/blob/master/lv_misc/lv_templ.c) and [lv_misc/lv_templ.h](https://github.com/littlevgl/lvgl/blob/master/lv_misc/lv_templ.h)
### Naming conventions
* Words are separated by '_'
* In variable and function names use only lower case letters (e.g. *height_tmp*)
* In enums and defines use only upper case letters (e.g. *e.g. MAX_LINE_NUM*)
* Global names (API):
* starts with *lv*
* followed by module name: *btn*, *label*, *style* etc.
* followed by the action (for functions): *set*, *get*, *refr* etc.
* closed with the subject: *name*, *size*, *state* etc.
* Typedefs
* prefer `typedef struct` and `typedef enum` instead of `struct name` and `enum name`
* always add a closing *..._t*
* Abbreviations:
* Use abbreviations on public names only if they become longer than 32 characters
* Use only very straightforward (e.g. pos: position) or well-established (e.g. pr: press) abbreviations
### Coding guide
* Functions:
* Try to write function shorter than is 50 lines
* Always shorter than 100 lines (except very straightforwards)
* Variables:
* One line, one declaration (BAD: char x, y;)
* Use `<stdint.h>` (*uint8_t*, *int32_t* etc)
* Declare variables when needed (not all at function start)
* Use the smallest required scope
* Variables in a file (outside functions) are always *static*
* Do not use global variables (use functions to set/get static variables)
### Comments
Before every function have a comment like this:
```c
/**
* Return with the screen of an object
* @param obj pointer to an object
* @return pointer to a screen
*/
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
```
Always use `/* Something */` format and NOT `//Something`
Write readable code to avoid descriptive comments like:
`x++; /* Add 1 to x */`.
The code should show clearly what you are doing.
You should write **why** have you done this:
`x++; /*Because of closing '\0' of the string */`
Short "code summaries" of a few lines are accepted. E.g. `/*Calculate the new coordinates*/`
In comments use \` \` when referring to a variable. E.g. ``/*Update the value of `x_act`*/``
### Formatting
Here is example to show bracket placing and using of white spaces:
```c
/**
* Set a new text for a label. Memory will be allocated to store the text by the label.
* @param label pointer to a label object
* @param text '\0' terminated character string. NULL to refresh with the current text.
*/
void lv_label_set_text(lv_obj_t * label, const char * text)
{ /* Main brackets of functions in new line*/
if(label == NULL) return; /*No bracket only if the command is inline with the if statement*/
lv_obj_inv(label);
lv_label_ext_t * ext = lv_obj_get_ext(label);
/*Comment before a section */
if(text == ext->txt || text == NULL) { /*Bracket of statements start inline*/
lv_label_refr_text(label);
return;
}
...
}
```
Use 4 spaces indentation instead of tab.
You can use **astyle** to format the code. The required config flies are: `docs/astyle_c` and `docs/astyle_h`.
To format the source files:
`$ find . -type f -name "*.c" | xargs astyle --options=docs/astyle_c`
To format the header files:
`$ find . -type f -name "*.h" | xargs astyle --options=docs/astyle_h`
Append `-n` to the end to skip creation of backup file OR use `$ find . -type f -name "*.bak" -delete` (for source file's backups) and `find . -type f -name "*.orig" -delete` (for header file's backups)
**Welcome! It's glad to see that you are interested in contributing to LittlevGL! There are several types of task where you can help to build a better library! Let's see how to get started!**
There are many different possibilities to join the community. If you have some time to work with us I'm sure you will find something that fits you! You can:
- answer other's questions
- report and/or fix bugs
- suggest and/or implement new features
- improve and/or translate the documentation
- write a blog post about your experiences
But first, start with the most Frequently Asked Questions.
## FAQ about contributing
### What license does my code need to be under?
Any code added to LittlevGL must be licensed under [MIT](https://choosealicense.com/licenses/mit/) or another license that is fully compatible. Contributions under other licenses are highly likely to be rejected.
If you borrow code from another project, please make sure to add their copyright notice to your contribution.
### Where do I ask questions, give feedback, or report bugs?
We use the [forum](http://forum.littlevgl.com/) for questions, feature suggestions, and discussions.
We use [GitHub's issue tracker](https://github.com/littlevgl/lvgl/issues) to report bugs.
For both of these there are some rules:
- Be kind and friendly.
- Speak about one thing in one issue.
- Give feedback and close the issue if your question is answered.
- Explain exactly what you experience or expect. _"The button is not working"_ is not enough info to get help.
- For most issues you should send an absolute minimal code example in order to reproduce the issue. Ideally this should be easily usable in the PC simulator.
- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your post.
- If you don't get any answer in a week write a comment like "Can somebody help?". Maybe your issue wasn't noticed.
### How can I send fixes and improvements?
Merging new code happens via Pull Requests. If you are still not familiar with the Pull Requests (PR for short) here is a quick guide about them:
1. **Fork** the [lvgl repository](https://github.com/littlevgl/lvgl). To do this click the "Fork" button in the top right corner. It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/your_name?tab=repositories`)
2. **Clone** the forked repository and add your updates
3. **Create a PR** on the GitHub on the page of you `lvgl` repository(`https://github.com/your_name/lvgl`) by hitting the "New pull request" button
4. **Set the base branch**. It means where you want to merge your update. Bugfixes for the last release go to `master`, new features to the actual `dev-x.y` branch.
5. **Describe** what is in the update. An example code is welcome if applicable.
Some advice:
- If you are not sure about your fix or feature it's better to open an issue first, and discuss the details there.
- Maybe your fix or update won't be perfect at first. Don't be afraid, just improve it and push the new commits. The PR will be updated accordingly.
- If your update needs some extra work it's okay to say: _"I'm busy now and I will improve it soon"_ or _"Sorry, I don't have time to improve it, I hope it helps in this form too"_. So it's better to say don't have time to continue then saying nothing.
- Please read and follow this [guide about the coding style](https://docs.littlevgl.com/#Coding-Style-Guide)
### Where is the documentation?
You can read the documentation here: https://docs.littlevgl.com/
You can edit the documentation here: https://github.com/littlevgl/doc
### Where is the blog?
You can read the blog here: https://blog.littlevgl.com/
You can edit the blog here: https://github.com/littlevgl/blog
## So how and where can I contribute?
### Answering other's questions
It's a great way to contribute to the library if you already use it. Just go the [issue tracker](https://github.com/littlevgl/lvgl/issues), read the titles and if you are already familiar with a topic, don't be shy, and write your suggestion.
### Reporting and/or fixing bugs
For simple bugfixes (typos, missing error handling, fixing a warning) is fine to send a Pull request directly. However, for more complex bugs it's better to open an issue first. In the issue, you should describe how to reproduce the bug and even add the minimal code snippet.
### Suggesting and/or implementing new features
If you have a good idea don't hesitate to share with us. It's even better if you have time to deal with its implementation. Don't be afraid if you still don't know LittlevGL well enough. We will help you to get started.
During the implementation don't forget the [Code style guide](https://docs.littlevgl.com/#Coding-Style-Guide).
### Improving and/or translating the documentation
The documentation of LittlevGL is written in Markdown and available [here](https://github.com/littlevgl/doc) for editing. If you find some parts of the documentation obscure or insufficient just search the related `.md` file, hit the edit icon and add your updates. This way a new Pull request will be generated automatically.
If you can devote more time to improve the documentation you can translate it!
1. Just copy the English `.md` files from the root folder to `locale/LANGUAGE_CODE` (language code is e.g. DE, FR, ES etc)
2. Append the language code the end of files (e.g. Welcome_fr.md)
3. Update the filenames in `_Sidebar.md`
4. Translate the page(s) you want
5. Create a Pull request
### Writing a blog post about your experiences
Have ported LittlevGL to a new platform? Have you created a fancy GUI? Do you know a great trick?
You can share your knowledge on LittelvGL's blog! It's super easy to add your own post:
- Fork and clone the [blog repository](https://github.com/littlevgl/blog)
- Add your post in Markdown to the `_posts` folder.
- Store the images and other resources in a dedicated folder in `assets`
- Create a Pull Request
The blog uses [Jekyll](https://jekyllrb.com/) to convert the `.md` files to a webpage. You can easily [run Jekyll offline](https://jekyllrb.com/docs/) to check your post before creating the Pull request
## Summary
I hope you have taken a liking to contribute to LittelvGL. A helpful and friendly community is waiting for you! :)

655
lv_conf_checker.h Normal file
View File

@@ -0,0 +1,655 @@
/**
* GENERATED FILE, DO NOT EDIT IT!
* @file lv_conf_checker.h
* Make sure all the defines of lv_conf.h have a default value
**/
#ifndef LV_CONF_CHECKER_H
#define LV_CONF_CHECKER_H
/*===================
Dynamic memory
*===================*/
/* Memory size which will be used by the library
* to store the graphical objects and other data */
#ifndef LV_MEM_CUSTOM
#define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/
#endif
#if LV_MEM_CUSTOM == 0
#ifndef LV_MEM_SIZE
# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
#endif
#ifndef LV_MEM_ATTR
# define LV_MEM_ATTR /*Complier prefix for big array declaration*/
#endif
#ifndef LV_MEM_ADR
# define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
#endif
#ifndef LV_MEM_AUTO_DEFRAG
# define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
#endif
#else /*LV_MEM_CUSTOM*/
#ifndef LV_MEM_CUSTOM_INCLUDE
# define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
#endif
#ifndef LV_MEM_CUSTOM_ALLOC
# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
#endif
#ifndef LV_MEM_CUSTOM_FREE
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif
#endif /*LV_MEM_CUSTOM*/
/* Garbage Collector settings
* Used if lvgl is binded to higher language and the memory is managed by that language */
#ifndef LV_ENABLE_GC
#define LV_ENABLE_GC 0
#endif
#if LV_ENABLE_GC != 0
#ifndef LV_MEM_CUSTOM_REALLOC
# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/
#endif
#ifndef LV_MEM_CUSTOM_GET_SIZE
# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/
#endif
#ifndef LV_GC_INCLUDE
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
#endif
#endif /* LV_ENABLE_GC */
/*===================
Graphical settings
*===================*/
/* Horizontal and vertical resolution of the library.*/
#ifndef LV_HOR_RES
#define LV_HOR_RES (480)
#endif
#ifndef LV_VER_RES
#define LV_VER_RES (320)
#endif
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
* (Not so important, you can adjust it to modify default sizes and spaces)*/
#ifndef LV_DPI
#define LV_DPI 100
#endif
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
#ifndef LV_ANTIALIAS
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
#endif
/*Screen refresh period in milliseconds*/
#ifndef LV_REFR_PERIOD
#define LV_REFR_PERIOD 30
#endif
/*-----------------
* VDB settings
*----------------*/
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
* The GUI will be drawn into this buffer first and then
* the buffer will be passed to your `disp_drv.disp_flush` function to
* copy it to your frame buffer.
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
* Learn more: https://docs.littlevgl.com/#Drawing*/
/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES
* Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions
* will be called to draw to the frame buffer directly*/
#ifndef LV_VDB_SIZE
#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10)
#endif
/* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays.
* Special formats are handled with `disp_drv.vdb_wr`)*/
#ifndef LV_VDB_PX_BPP
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */
#endif
/* Place VDB to a specific address (e.g. in external RAM)
* 0: allocate automatically into RAM
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
#ifndef LV_VDB_ADR
#define LV_VDB_ADR 0
#endif
/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
* The flushing should use DMA to write the frame buffer in the background */
#ifndef LV_VDB_DOUBLE
#define LV_VDB_DOUBLE 0
#endif
/* Place VDB2 to a specific address (e.g. in external RAM)
* 0: allocate automatically into RAM
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
#ifndef LV_VDB2_ADR
#define LV_VDB2_ADR 0
#endif
/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen.
* Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display.
* The best if you do in the blank period of you display to avoid tearing effect.
* Requires:
* - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES
* - LV_VDB_DOUBLE = 1
*/
#ifndef LV_VDB_TRUE_DOUBLE_BUFFERED
#define LV_VDB_TRUE_DOUBLE_BUFFERED 0
#endif
/*=================
Misc. setting
*=================*/
/*Input device settings*/
#ifndef LV_INDEV_READ_PERIOD
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
#endif
#ifndef LV_INDEV_POINT_MARKER
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
#endif
#ifndef LV_INDEV_DRAG_LIMIT
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
#endif
#ifndef LV_INDEV_DRAG_THROW
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
#endif
#ifndef LV_INDEV_LONG_PRESS_TIME
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
#endif
#ifndef LV_INDEV_LONG_PRESS_REP_TIME
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
#endif
/*Color settings*/
#ifndef LV_COLOR_DEPTH
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
#endif
#ifndef LV_COLOR_16_SWAP
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
#endif
#ifndef LV_COLOR_SCREEN_TRANSP
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
#endif
#ifndef LV_COLOR_TRANSP
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
#endif
/*Text settings*/
#ifndef LV_TXT_UTF8
#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */
#endif
#ifndef LV_TXT_BREAK_CHARS
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
#endif
/*Feature usage*/
#ifndef USE_LV_ANIMATION
#define USE_LV_ANIMATION 1 /*1: Enable all animations*/
#endif
#ifndef USE_LV_SHADOW
#define USE_LV_SHADOW 1 /*1: Enable shadows*/
#endif
#ifndef USE_LV_GROUP
#define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/
#endif
#ifndef USE_LV_GPU
#define USE_LV_GPU 1 /*1: Enable GPU interface*/
#endif
#ifndef USE_LV_REAL_DRAW
#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/
#endif
#ifndef USE_LV_FILESYSTEM
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/
#endif
#ifndef USE_LV_MULTI_LANG
#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/
#endif
/*Compiler settings*/
#ifndef LV_ATTRIBUTE_TICK_INC
#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */
#endif
#ifndef LV_ATTRIBUTE_TASK_HANDLER
#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/
#endif
#ifndef LV_COMPILER_VLA_SUPPORTED
#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/
#endif
#ifndef LV_COMPILER_NON_CONST_INIT_SUPPORTED
#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 1 /* 1: Initialization with non constant values are supported */
#endif
/*HAL settings*/
#ifndef LV_TICK_CUSTOM
#define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
#endif
#if LV_TICK_CUSTOM == 1
#ifndef LV_TICK_CUSTOM_INCLUDE
#define LV_TICK_CUSTOM_INCLUDE "sonething.h" /*Header for the sys time function*/
#endif
#ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif
#endif /*LV_TICK_CUSTOM*/
/*Log settings*/
#ifndef USE_LV_LOG
#define USE_LV_LOG 1 /*Enable/disable the log module*/
#endif
#if USE_LV_LOG
/* How important log should be added:
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
* LV_LOG_LEVEL_INFO Log important events
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
*/
#ifndef LV_LOG_LEVEL
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
#endif
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
#ifndef LV_LOG_PRINTF
# define LV_LOG_PRINTF 0
#endif
#endif /*USE_LV_LOG*/
/*================
* THEME USAGE
*================*/
#ifndef LV_THEME_LIVE_UPDATE
#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
#endif
#ifndef USE_LV_THEME_TEMPL
#define USE_LV_THEME_TEMPL 0 /*Just for test*/
#endif
#ifndef USE_LV_THEME_DEFAULT
#define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/
#endif
#ifndef USE_LV_THEME_ALIEN
#define USE_LV_THEME_ALIEN 1 /*Dark futuristic theme*/
#endif
#ifndef USE_LV_THEME_NIGHT
#define USE_LV_THEME_NIGHT 1 /*Dark elegant theme*/
#endif
#ifndef USE_LV_THEME_MONO
#define USE_LV_THEME_MONO 1 /*Mono color theme for monochrome displays*/
#endif
#ifndef USE_LV_THEME_MATERIAL
#define USE_LV_THEME_MATERIAL 1 /*Flat theme with bold colors and light shadows*/
#endif
#ifndef USE_LV_THEME_ZEN
#define USE_LV_THEME_ZEN 1 /*Peaceful, mainly light theme */
#endif
#ifndef USE_LV_THEME_NEMO
#define USE_LV_THEME_NEMO 1 /*Water-like theme based on the movie "Finding Nemo"*/
#endif
/*==================
* FONT USAGE
*===================*/
/* More info about fonts: https://docs.littlevgl.com/#Fonts
* To enable a built-in font use 1,2,4 or 8 values
* which will determine the bit-per-pixel. Higher value means smoother fonts */
#ifndef USE_LV_FONT_DEJAVU_10
#define USE_LV_FONT_DEJAVU_10 4
#endif
#ifndef USE_LV_FONT_DEJAVU_10_LATIN_SUP
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4
#endif
#ifndef USE_LV_FONT_DEJAVU_10_CYRILLIC
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4
#endif
#ifndef USE_LV_FONT_SYMBOL_10
#define USE_LV_FONT_SYMBOL_10 4
#endif
#ifndef USE_LV_FONT_DEJAVU_20
#define USE_LV_FONT_DEJAVU_20 4
#endif
#ifndef USE_LV_FONT_DEJAVU_20_LATIN_SUP
#define USE_LV_FONT_DEJAVU_20_LATIN_SUP 4
#endif
#ifndef USE_LV_FONT_DEJAVU_20_CYRILLIC
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 4
#endif
#ifndef USE_LV_FONT_SYMBOL_20
#define USE_LV_FONT_SYMBOL_20 4
#endif
#ifndef USE_LV_FONT_DEJAVU_30
#define USE_LV_FONT_DEJAVU_30 4
#endif
#ifndef USE_LV_FONT_DEJAVU_30_LATIN_SUP
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4
#endif
#ifndef USE_LV_FONT_DEJAVU_30_CYRILLIC
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4
#endif
#ifndef USE_LV_FONT_SYMBOL_30
#define USE_LV_FONT_SYMBOL_30 4
#endif
#ifndef USE_LV_FONT_DEJAVU_40
#define USE_LV_FONT_DEJAVU_40 4
#endif
#ifndef USE_LV_FONT_DEJAVU_40_LATIN_SUP
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4
#endif
#ifndef USE_LV_FONT_DEJAVU_40_CYRILLIC
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4
#endif
#ifndef USE_LV_FONT_SYMBOL_40
#define USE_LV_FONT_SYMBOL_40 4
#endif
#ifndef USE_LV_FONT_MONOSPACE_8
#define USE_LV_FONT_MONOSPACE_8 1
#endif
/* Optionally declare your 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) \
*/
#ifndef LV_FONT_CUSTOM_DECLARE
#define LV_FONT_CUSTOM_DECLARE
#endif
#ifndef LV_FONT_DEFAULT
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
#endif
/*===================
* LV_OBJ SETTINGS
*==================*/
#ifndef LV_OBJ_FREE_NUM_TYPE
#define LV_OBJ_FREE_NUM_TYPE uint32_t /*Type of free number attribute (comment out disable free number)*/
#endif
#ifndef LV_OBJ_FREE_PTR
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
#endif
#ifndef LV_OBJ_REALIGN
#define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
#endif
/*==================
* LV OBJ X USAGE
*================*/
/*
* Documentation of the object types: https://docs.littlevgl.com/#Object-types
*/
/*****************
* Simple object
*****************/
/*Label (dependencies: -*/
#ifndef USE_LV_LABEL
#define USE_LV_LABEL 1
#endif
#if USE_LV_LABEL != 0
#ifndef LV_LABEL_SCROLL_SPEED
# define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
#endif
#endif
/*Image (dependencies: lv_label*/
#ifndef USE_LV_IMG
#define USE_LV_IMG 1
#endif
#if USE_LV_IMG != 0
#ifndef LV_IMG_CF_INDEXED
# define LV_IMG_CF_INDEXED 1 /*Enable indexed (palette) images*/
#endif
#ifndef LV_IMG_CF_ALPHA
# define LV_IMG_CF_ALPHA 1 /*Enable alpha indexed images*/
#endif
#endif
/*Line (dependencies: -*/
#ifndef USE_LV_LINE
#define USE_LV_LINE 1
#endif
/*Arc (dependencies: -)*/
#ifndef USE_LV_ARC
#define USE_LV_ARC 1
#endif
/*******************
* Container objects
*******************/
/*Container (dependencies: -*/
#ifndef USE_LV_CONT
#define USE_LV_CONT 1
#endif
/*Page (dependencies: lv_cont)*/
#ifndef USE_LV_PAGE
#define USE_LV_PAGE 1
#endif
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
#ifndef USE_LV_WIN
#define USE_LV_WIN 1
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#ifndef USE_LV_TABVIEW
#define USE_LV_TABVIEW 1
#endif
# if USE_LV_TABVIEW != 0
#ifndef LV_TABVIEW_ANIM_TIME
# define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
#endif
/*Tileview (dependencies: lv_page) */
#ifndef USE_LV_TILEVIEW
#define USE_LV_TILEVIEW 1
#endif
#if USE_LV_TILEVIEW
#ifndef LV_TILEVIEW_ANIM_TIME
# define LV_TILEVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
#endif
/*************************
* Data visualizer objects
*************************/
/*Bar (dependencies: -)*/
#ifndef USE_LV_BAR
#define USE_LV_BAR 1
#endif
/*Line meter (dependencies: *;)*/
#ifndef USE_LV_LMETER
#define USE_LV_LMETER 1
#endif
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
#ifndef USE_LV_GAUGE
#define USE_LV_GAUGE 1
#endif
/*Chart (dependencies: -)*/
#ifndef USE_LV_CHART
#define USE_LV_CHART 1
#endif
/*Table (dependencies: lv_label)*/
#ifndef USE_LV_TABLE
#define USE_LV_TABLE 1
#endif
#if USE_LV_TABLE
#ifndef LV_TABLE_COL_MAX
# define LV_TABLE_COL_MAX 12
#endif
#endif
/*LED (dependencies: -)*/
#ifndef USE_LV_LED
#define USE_LV_LED 1
#endif
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
#ifndef USE_LV_MBOX
#define USE_LV_MBOX 1
#endif
/*Text area (dependencies: lv_label, lv_page)*/
#ifndef USE_LV_TA
#define USE_LV_TA 1
#endif
#if USE_LV_TA != 0
#ifndef LV_TA_CURSOR_BLINK_TIME
# define LV_TA_CURSOR_BLINK_TIME 400 /*ms*/
#endif
#ifndef LV_TA_PWD_SHOW_TIME
# define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
#endif
#endif
/*Spinbox (dependencies: lv_ta)*/
#ifndef USE_LV_SPINBOX
#define USE_LV_SPINBOX 1
#endif
/*Calendar (dependencies: -)*/
#ifndef USE_LV_CALENDAR
#define USE_LV_CALENDAR 1
#endif
/*Preload (dependencies: lv_arc)*/
#ifndef USE_LV_PRELOAD
#define USE_LV_PRELOAD 1
#endif
#if USE_LV_PRELOAD != 0
#ifndef LV_PRELOAD_DEF_ARC_LENGTH
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#endif
#ifndef LV_PRELOAD_DEF_SPIN_TIME
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
#endif
#ifndef LV_PRELOAD_DEF_ANIM
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#endif
#endif
/*Canvas (dependencies: lv_img)*/
#ifndef USE_LV_CANVAS
#define USE_LV_CANVAS 1
#endif
/*************************
* User input objects
*************************/
/*Button (dependencies: lv_cont*/
#ifndef USE_LV_BTN
#define USE_LV_BTN 1
#endif
#if USE_LV_BTN != 0
#ifndef LV_BTN_INK_EFFECT
# define LV_BTN_INK_EFFECT 1 /*Enable button-state animations - draw a circle on click (dependencies: USE_LV_ANIMATION)*/
#endif
#endif
/*Image Button (dependencies: lv_btn*/
#ifndef USE_LV_IMGBTN
#define USE_LV_IMGBTN 1
#endif
#if USE_LV_IMGBTN
#ifndef LV_IMGBTN_TILED
# define LV_IMGBTN_TILED 0 /*1: The imgbtn requires left, mid and right parts and the width can be set freely*/
#endif
#endif
/*Button matrix (dependencies: -)*/
#ifndef USE_LV_BTNM
#define USE_LV_BTNM 1
#endif
/*Keyboard (dependencies: lv_btnm)*/
#ifndef USE_LV_KB
#define USE_LV_KB 1
#endif
/*Check box (dependencies: lv_btn, lv_label)*/
#ifndef USE_LV_CB
#define USE_LV_CB 1
#endif
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
#ifndef USE_LV_LIST
#define USE_LV_LIST 1
#endif
#if USE_LV_LIST != 0
#ifndef LV_LIST_FOCUS_TIME
# define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
#endif
#endif
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
#ifndef USE_LV_DDLIST
#define USE_LV_DDLIST 1
#endif
#if USE_LV_DDLIST != 0
#ifndef LV_DDLIST_ANIM_TIME
# define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
#endif
#endif
/*Roller (dependencies: lv_ddlist)*/
#ifndef USE_LV_ROLLER
#define USE_LV_ROLLER 1
#endif
#if USE_LV_ROLLER != 0
#ifndef LV_ROLLER_ANIM_TIME
# define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
#endif
#endif
/*Slider (dependencies: lv_bar)*/
#ifndef USE_LV_SLIDER
#define USE_LV_SLIDER 1
#endif
/*Switch (dependencies: lv_slider)*/
#ifndef USE_LV_SW
#define USE_LV_SW 1
#endif
/*************************
* Non-user section
*************************/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#endif
#endif /*LV_CONF_CHECKER_H*/

52
lv_conf_checker.py Normal file
View File

@@ -0,0 +1,52 @@
'''
Generates a chechker file for lv_conf.h from lv_conf_templ.h define all the not defined values
'''
import re
fin = open("lv_conf_templ.h", "r");
fout = open("lv_conf_checker.h", "w");
fout.write(
'/**\n\
* GENERATED FILE, DO NOT EDIT IT!\n\
* @file lv_conf_checker.h\n\
* Make sure all the defines of lv_conf.h have a default value\n\
**/\n\
\n\
#ifndef LV_CONF_CHECKER_H\n\
#define LV_CONF_CHECKER_H\n\
'
)
inlines = fin.read().splitlines();
started = 0
for i in inlines:
if(not started):
if('#define LV_CONF_H' in i):
started = 1
continue
else:
continue
if('/*--END OF LV_CONF_H--*/' in i): break
if(re.search('^ *# *define .*$', i)):
new = re.sub('^ *# *define', '#define ', i)
new = re.sub(' +', ' ', new) #Remove extra white spaces
splitted = new.split(' ')
fout.write('#ifndef ' + splitted[1] + '\n')
fout.write(i + '\n')
fout.write('#endif\n')
else:
fout.write(i + '\n')
fout.write(
'\n\
#endif /*LV_CONF_CHECKER_H*/\n\
')

View File

@@ -11,7 +11,6 @@
#ifndef LV_CONF_H
#define LV_CONF_H
/*===================
Dynamic memory
*===================*/
@@ -20,43 +19,85 @@
* to store the graphical objects and other data */
#define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/
#if LV_MEM_CUSTOM == 0
#define LV_MEM_SIZE (32U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
#define LV_MEM_ATTR /*Complier prefix for big array declaration*/
#define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
# define LV_MEM_ATTR /*Complier prefix for big array declaration*/
# define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
# define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
#else /*LV_MEM_CUSTOM*/
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
#define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
#define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
# define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif /*LV_MEM_CUSTOM*/
/* Garbage Collector settings
* Used if lvgl is binded to higher language and the memory is managed by that language */
#define LV_ENABLE_GC 0
#if LV_ENABLE_GC != 0
# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/
# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
#endif /* LV_ENABLE_GC */
/*===================
Graphical settings
*===================*/
/* Horizontal and vertical resolution of the library.*/
#define LV_HOR_RES (320)
#define LV_VER_RES (240)
#define LV_HOR_RES (480)
#define LV_VER_RES (320)
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
* (Not so important, you can adjust it to modify default sizes and spaces)*/
#define LV_DPI 100
/* Size of VDB (Virtual Display Buffer: the internal graphics buffer).
* Required for buffered drawing, opacity and anti-aliasing
* VDB makes the double buffering, you don't need to deal with it!
* Typical size: ~1/10 screen */
#define LV_VDB_SIZE (30 * LV_HOR_RES) /*Size of VDB in pixel count (1/10 screen size is good for first)*/
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays. (Set `disp_drv->vdb_wr` and `disp_drv->vdb_rd` too)*/
#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing (optional)
* The flushing should use DMA to write the frame buffer in the background*/
#define LV_VDB_DOUBLE 0 /*1: Enable the use of 2 VDBs*/
#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate automatically into RAM; LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`)*/
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
/*Screen refresh settings*/
#define LV_REFR_PERIOD 30 /*Screen refresh period in milliseconds*/
#define LV_INV_FIFO_SIZE 32 /*The average count of objects on a screen */
/*Screen refresh period in milliseconds*/
#define LV_REFR_PERIOD 30
/*-----------------
* VDB settings
*----------------*/
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
* The GUI will be drawn into this buffer first and then
* the buffer will be passed to your `disp_drv.disp_flush` function to
* copy it to your frame buffer.
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
* Learn more: https://docs.littlevgl.com/#Drawing*/
/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES
* Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions
* will be called to draw to the frame buffer directly*/
#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10)
/* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays.
* Special formats are handled with `disp_drv.vdb_wr`)*/
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */
/* Place VDB to a specific address (e.g. in external RAM)
* 0: allocate automatically into RAM
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
#define LV_VDB_ADR 0
/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
* The flushing should use DMA to write the frame buffer in the background */
#define LV_VDB_DOUBLE 0
/* Place VDB2 to a specific address (e.g. in external RAM)
* 0: allocate automatically into RAM
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
#define LV_VDB2_ADR 0
/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen.
* Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display.
* The best if you do in the blank period of you display to avoid tearing effect.
* Requires:
* - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES
* - LV_VDB_DOUBLE = 1
*/
#define LV_VDB_TRUE_DOUBLE_BUFFERED 0
/*=================
Misc. setting
@@ -66,7 +107,7 @@
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%] (must be > 0). Greater value means faster slow-down */
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
@@ -79,25 +120,30 @@
/*Text settings*/
#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
/*Graphics feature usage*/
/*Feature usage*/
#define USE_LV_ANIMATION 1 /*1: Enable all animations*/
#define USE_LV_SHADOW 1 /*1: Enable shadows*/
#define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/
#define USE_LV_GPU 1 /*1: Enable GPU interface*/
#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (required by images*/
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/
#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/
/*Compiler settings*/
#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */
#define LV_ATTRIBUTE_TASK_HANDLER /* Define a custom attribute to `lv_task_handler` function */
#define LV_ATTRIBUTE_MEM_ALIGN /* With size optimization (-Os) the compiler might not align data to 4 or 8 byte boundary. This alignment will be explicitly applied where needed.*/
#define LV_COMPILER_VLA_SUPPORTED 1 /* 1: Variable length array is supported*/
#define LV_COMPILER_NON_CONST_INIT_SUPPORTED 1 /* 1: Initialization with non constant values are supported */
/*HAL settings*/
#define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
#if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/
@@ -111,56 +157,54 @@
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
*/
#define LV_LOG_LEVEL LV_LOG_LEVEL_INFO
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
#define LV_LOG_PRINTF 0
# define LV_LOG_PRINTF 0
#endif /*USE_LV_LOG*/
/*================
* THEME USAGE
*================*/
#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
#define USE_LV_THEME_TEMPL 0 /*Just for test*/
#define USE_LV_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/
#define USE_LV_THEME_ALIEN 0 /*Dark futuristic theme*/
#define USE_LV_THEME_NIGHT 0 /*Dark elegant theme*/
#define USE_LV_THEME_MONO 0 /*Mono color theme for monochrome displays*/
#define USE_LV_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/
#define USE_LV_THEME_ZEN 0 /*Peaceful, mainly light theme */
#define USE_LV_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/
#define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/
#define USE_LV_THEME_ALIEN 1 /*Dark futuristic theme*/
#define USE_LV_THEME_NIGHT 1 /*Dark elegant theme*/
#define USE_LV_THEME_MONO 1 /*Mono color theme for monochrome displays*/
#define USE_LV_THEME_MATERIAL 1 /*Flat theme with bold colors and light shadows*/
#define USE_LV_THEME_ZEN 1 /*Peaceful, mainly light theme */
#define USE_LV_THEME_NEMO 1 /*Water-like theme based on the movie "Finding Nemo"*/
/*==================
* FONT USAGE
*===================*/
/* More info about fonts: https://littlevgl.com/basics#fonts
/* More info about fonts: https://docs.littlevgl.com/#Fonts
* To enable a built-in font use 1,2,4 or 8 values
* which will determine the bit-per-pixel */
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
#define USE_LV_FONT_DEJAVU_10 0
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
#define USE_LV_FONT_SYMBOL_10 0
* which will determine the bit-per-pixel. Higher value means smoother fonts */
#define USE_LV_FONT_DEJAVU_10 4
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4
#define USE_LV_FONT_SYMBOL_10 4
#define USE_LV_FONT_DEJAVU_20 4
#define USE_LV_FONT_DEJAVU_20_LATIN_SUP 0
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 0
#define USE_LV_FONT_DEJAVU_20_LATIN_SUP 4
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 4
#define USE_LV_FONT_SYMBOL_20 4
#define USE_LV_FONT_DEJAVU_30 0
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0
#define USE_LV_FONT_SYMBOL_30 0
#define USE_LV_FONT_DEJAVU_30 4
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4
#define USE_LV_FONT_SYMBOL_30 4
#define USE_LV_FONT_DEJAVU_40 0
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0
#define USE_LV_FONT_SYMBOL_40 0
#define USE_LV_FONT_DEJAVU_40 4
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4
#define USE_LV_FONT_SYMBOL_40 4
#define USE_LV_FONT_MONOSPACE_8 0
#define USE_LV_FONT_MONOSPACE_8 1
/* Optionally declare your custom fonts here.
* You can use these fonts as default font too
@@ -170,6 +214,7 @@
*/
#define LV_FONT_CUSTOM_DECLARE
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
/*===================
@@ -177,12 +222,13 @@
*==================*/
#define LV_OBJ_FREE_NUM_TYPE uint32_t /*Type of free number attribute (comment out disable free number)*/
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
#define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
/*==================
* LV OBJ X USAGE
*================*/
/*
* Documentation of the object types: https://littlevgl.com/object-types
* Documentation of the object types: https://docs.littlevgl.com/#Object-types
*/
/*****************
@@ -192,14 +238,14 @@
/*Label (dependencies: -*/
#define USE_LV_LABEL 1
#if USE_LV_LABEL != 0
#define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
# define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
#endif
/*Image (dependencies: lv_label*/
#define USE_LV_IMG 1
#if USE_LV_IMG != 0
#define LV_IMG_CF_INDEXED 1 /*Enable indexed (palette) images*/
#define LV_IMG_CF_ALPHA 1 /*Enable alpha indexed images*/
# define LV_IMG_CF_INDEXED 1 /*Enable indexed (palette) images*/
# define LV_IMG_CF_ALPHA 1 /*Enable alpha indexed images*/
#endif
/*Line (dependencies: -*/
@@ -223,8 +269,14 @@
/*Tab (dependencies: lv_page, lv_btnm)*/
#define USE_LV_TABVIEW 1
#if USE_LV_TABVIEW != 0
#define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
# if USE_LV_TABVIEW != 0
# define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
/*Tileview (dependencies: lv_page) */
#define USE_LV_TILEVIEW 1
#if USE_LV_TILEVIEW
# define LV_TILEVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
#endif
/*************************
@@ -237,12 +289,18 @@
/*Line meter (dependencies: *;)*/
#define USE_LV_LMETER 1
/*Gauge (dependencies:bar, lmeter)*/
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
#define USE_LV_GAUGE 1
/*Chart (dependencies: -)*/
#define USE_LV_CHART 1
/*Table (dependencies: lv_label)*/
#define USE_LV_TABLE 1
#if USE_LV_TABLE
# define LV_TABLE_COL_MAX 12
#endif
/*LED (dependencies: -)*/
#define USE_LV_LED 1
@@ -252,20 +310,26 @@
/*Text area (dependencies: lv_label, lv_page)*/
#define USE_LV_TA 1
#if USE_LV_TA != 0
#define LV_TA_CURSOR_BLINK_TIME 400 /*ms*/
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
# define LV_TA_CURSOR_BLINK_TIME 400 /*ms*/
# define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
#endif
/*Spinbox (dependencies: lv_ta)*/
#define USE_LV_SPINBOX 1
/*Calendar (dependencies: -)*/
#define USE_LV_CALENDAR 1
/*Preload (dependencies: arc)*/
/*Preload (dependencies: lv_arc)*/
#define USE_LV_PRELOAD 1
#if USE_LV_PRELOAD != 0
#define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
#define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#endif
/*Canvas (dependencies: lv_img)*/
#define USE_LV_CANVAS 1
/*************************
* User input objects
*************************/
@@ -273,11 +337,14 @@
/*Button (dependencies: lv_cont*/
#define USE_LV_BTN 1
#if USE_LV_BTN != 0
#define LV_BTN_INK_EFFECT 1 /*Enable button-state animations - draw a circle on click (dependencies: USE_LV_ANIMATION)*/
# define LV_BTN_INK_EFFECT 1 /*Enable button-state animations - draw a circle on click (dependencies: USE_LV_ANIMATION)*/
#endif
/*Image Button (dependencies: lv_btn*/
#define USE_LV_IMGBTN 1
#if USE_LV_IMGBTN
# define LV_IMGBTN_TILED 0 /*1: The imgbtn requires left, mid and right parts and the width can be set freely*/
#endif
/*Button matrix (dependencies: -)*/
#define USE_LV_BTNM 1
@@ -291,19 +358,19 @@
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
#define USE_LV_LIST 1
#if USE_LV_LIST != 0
#define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
# define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
#endif
/*Drop down list (dependencies: lv_page, lv_label)*/
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
#define USE_LV_DDLIST 1
#if USE_LV_DDLIST != 0
#define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
# define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
#endif
/*Roller (dependencies: lv_ddlist)*/
#define USE_LV_ROLLER 1
#if USE_LV_ROLLER != 0
#define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
# define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
#endif
/*Slider (dependencies: lv_bar)*/
@@ -315,10 +382,22 @@
/*************************
* Non-user section
*************************/
#ifdef _MSC_VER /* Disable warnings for Visual Studio*/
# define _CRT_SECURE_NO_WARNINGS
#if LV_INDEV_DRAG_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#undef LV_INDEV_DRAG_THROW
#define LV_INDEV_DRAG_THROW 1
#endif
#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--*/
/*Be sure every define has a default value*/
#include "lvgl/lv_conf_checker.h"
#endif /*LV_CONF_H*/
#endif /*End of "Content enable"*/

View File

@@ -4,8 +4,9 @@ CSRCS += lv_obj.c
CSRCS += lv_refr.c
CSRCS += lv_style.c
CSRCS += lv_vdb.c
CSRCS += lv_lang.c
DEPPATH += --dep-path lvgl/lv_core
VPATH += :lvgl/lv_core
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_core
VPATH += :$(LVGL_DIR)/lvgl/lv_core
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_core"

View File

@@ -23,6 +23,8 @@
**********************/
static void style_mod_def(lv_style_t * style);
static void style_mod_edit_def(lv_style_t * style);
static void lv_group_refocus(lv_group_t *g);
static void obj_to_foreground(lv_obj_t * obj);
/**********************
* STATIC VARIABLES
@@ -54,6 +56,7 @@ lv_group_t * lv_group_create(void)
group->focus_cb = NULL;
group->click_focus = 1;
group->editing = 0;
group->wrap = 1;
return group;
}
@@ -89,10 +92,10 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
{
if(group == NULL) return;
/*If the object is already in a group and focused then defocuse it*/
/*If the object is already in a group and focused then defocus it*/
if(obj->group_p) {
if(lv_obj_is_focused(obj)) {
lv_group_focus_next(obj->group_p);
lv_group_refocus(obj->group_p);
LV_LOG_INFO("group: assign object to an other group");
}
@@ -107,7 +110,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
/* If the head and the tail is equal then there is only one object in the linked list.
* In this case automatically activate it*/
if(lv_ll_get_head(&group->obj_ll) == next) {
lv_group_focus_next(group);
lv_group_refocus(group);
}
}
@@ -121,8 +124,16 @@ void lv_group_remove_obj(lv_obj_t * obj)
if(g == NULL) return;
if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/
/*Focus on the next object*/
if(*g->obj_focus == obj) {
lv_group_focus_next(g);
/*If this is the only object in the group then focus to nothing.*/
if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
}
/*If there more objects in the group then focus to the next/prev object*/
else {
lv_group_refocus(g);
}
}
/* If the focuses object is still the same then it was the only object in the group but it will be deleted.
@@ -138,6 +149,7 @@ void lv_group_remove_obj(lv_obj_t * obj)
lv_ll_rem(&g->obj_ll, i);
lv_mem_free(i);
obj->group_p = NULL;
break;
}
}
}
@@ -153,6 +165,9 @@ void lv_group_focus_obj(lv_obj_t * obj)
if(g->frozen != 0) return;
/*On defocus edit mode must be leaved*/
lv_group_set_editing(g, false);
lv_obj_t ** i;
LL_READ(g->obj_ll, i) {
if(*i == obj) {
@@ -168,6 +183,9 @@ void lv_group_focus_obj(lv_obj_t * obj)
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
if(g->focus_cb) g->focus_cb(g);
lv_obj_invalidate(*g->obj_focus);
/*If the object or its parent has `top == true` bring it to the foregorund*/
obj_to_foreground(*g->obj_focus);
}
break;
}
@@ -191,7 +209,10 @@ void lv_group_focus_next(lv_group_t * group)
if(group->obj_focus == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
else obj_next = lv_ll_get_next(&group->obj_ll, group->obj_focus);
if(obj_next == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
if(obj_next == NULL) {
if(group->wrap) obj_next = lv_ll_get_head(&group->obj_ll);
else obj_next = lv_ll_get_tail(&group->obj_ll);
}
group->obj_focus = obj_next;
if(group->obj_focus) {
@@ -199,6 +220,9 @@ void lv_group_focus_next(lv_group_t * group)
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);
/*If the object or its parent has `top == true` bring it to the foregorund*/
obj_to_foreground(*group->obj_focus);
}
}
@@ -219,7 +243,10 @@ void lv_group_focus_prev(lv_group_t * group)
if(group->obj_focus == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
else obj_next = lv_ll_get_prev(&group->obj_ll, group->obj_focus);
if(obj_next == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
if(obj_next == NULL) {
if(group->wrap) obj_next = lv_ll_get_tail(&group->obj_ll);
else obj_next = lv_ll_get_head(&group->obj_ll);
}
group->obj_focus = obj_next;
if(group->obj_focus != NULL) {
@@ -227,6 +254,9 @@ void lv_group_focus_prev(lv_group_t * group)
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);
/*If the object or its parent has `top == true` bring it to the foregorund*/
obj_to_foreground(*group->obj_focus);
}
}
@@ -246,13 +276,14 @@ void lv_group_focus_freeze(lv_group_t * group, bool en)
* Send a control character to the focuses object of a group
* @param group pointer to a group
* @param c a character (use LV_GROUP_KEY_.. to navigate)
* @return result of focused object in group.
*/
void lv_group_send_data(lv_group_t * group, uint32_t c)
lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
{
lv_obj_t * act = lv_group_get_focused(group);
if(act == NULL) return;
if(act == NULL) return LV_RES_OK;
act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
return act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
}
/**
@@ -294,8 +325,15 @@ void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
*/
void lv_group_set_editing(lv_group_t * group, bool edit)
{
group->editing = edit ? 1 : 0;
uint8_t en_val = edit ? 1 : 0;
if(en_val == group->editing) return; /*Do not set the same mode again*/
group->editing = en_val;
lv_obj_t * focused = lv_group_get_focused(group);
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
lv_obj_invalidate(focused);
}
@@ -309,6 +347,33 @@ void lv_group_set_click_focus(lv_group_t * group, bool en)
group->click_focus = en ? 1 : 0;
}
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy) {
group->refocus_policy = policy & 0x01;
}
static void lv_group_refocus(lv_group_t *g) {
/*Refocus must temporarily allow wrapping to work correctly*/
uint8_t temp_wrap = g->wrap;
g->wrap = 1;
if(g->refocus_policy == LV_GROUP_REFOCUS_POLICY_NEXT)
lv_group_focus_next(g);
else if(g->refocus_policy == LV_GROUP_REFOCUS_POLICY_PREV)
lv_group_focus_prev(g);
/*Restore wrap property*/
g->wrap = temp_wrap;
}
/**
* Set whether focus next/prev will allow wrapping from first->last or last->first.
* @param group pointer to group
* @param en: true: enable `wrap`
*/
void lv_group_set_wrap(lv_group_t * group, bool en)
{
group->wrap = en ? 1 : 0;
}
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
@@ -320,11 +385,9 @@ lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
lv_style_copy(&group->style_tmp, style);
if(group->editing) {
if(group->style_mod_edit != NULL) group->style_mod_edit(&group->style_tmp);
else style_mod_edit_def(&group->style_tmp);
if(group->style_mod_edit) group->style_mod_edit(&group->style_tmp);
} else {
if(group->style_mod != NULL) group->style_mod(&group->style_tmp);
else style_mod_def(&group->style_tmp);
if(group->style_mod) group->style_mod(&group->style_tmp);
}
return &group->style_tmp;
}
@@ -397,6 +460,17 @@ bool lv_group_get_click_focus(const lv_group_t * group)
return group->click_focus ? true : false;
}
/**
* Get whether focus next/prev will allow wrapping from first->last or last->first object.
* @param group pointer to group
* @param en: true: wrapping enabled; false: wrapping disabled
*/
bool lv_group_get_wrap(lv_group_t * group)
{
if(!group) return false;
return group->wrap ? true : false;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -459,4 +533,23 @@ static void style_mod_edit_def(lv_style_t * style)
}
static void obj_to_foreground(lv_obj_t * obj)
{
/*Search for 'top' attribute*/
lv_obj_t * i = obj;
lv_obj_t * last_top = NULL;
while(i != NULL) {
if(i->top != 0) last_top = i;
i = lv_obj_get_parent(i);
}
if(last_top != NULL) {
/*Move the last_top object to the foreground*/
lv_obj_t * par = lv_obj_get_parent(last_top);
/*After list change it will be the new head*/
lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top);
lv_obj_invalidate(last_top);
}
}
#endif /*USE_LV_GROUP != 0*/

View File

@@ -31,7 +31,8 @@ extern "C" {
#define LV_GROUP_KEY_RIGHT 19 /*0x13*/
#define LV_GROUP_KEY_LEFT 20 /*0x14*/
#define LV_GROUP_KEY_ESC 27 /*0x1B*/
#define LV_GROUP_KEY_DEL 28 /*0x1C*/
#define LV_GROUP_KEY_DEL 127 /*0x7F*/
#define LV_GROUP_KEY_BACKSPACE 8 /*0x08*/
#define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
#define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/
#define LV_GROUP_KEY_PREV 11 /*0x0B, '*/
@@ -56,8 +57,15 @@ typedef struct _lv_group_t
uint8_t frozen :1; /*1: can't focus to new object*/
uint8_t editing :1; /*1: Edit mode, 0: Navigate mode*/
uint8_t click_focus :1; /*1: If an object in a group is clicked by an indev then it will be focused */
uint8_t refocus_policy :1; /*1: Focus prev if focused on deletion. 0: Focus prev if focused on deletion.*/
uint8_t wrap :1; /*1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end of list.*/
} lv_group_t;
typedef enum _lv_group_refocus_policy_t {
LV_GROUP_REFOCUS_POLICY_NEXT = 0,
LV_GROUP_REFOCUS_POLICY_PREV = 1
} lv_group_refocus_policy_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
@@ -116,8 +124,9 @@ void lv_group_focus_freeze(lv_group_t * group, bool en);
* Send a control character to the focuses object of a group
* @param group pointer to a group
* @param c a character (use LV_GROUP_KEY_.. to navigate)
* @return result of focused object in group.
*/
void lv_group_send_data(lv_group_t * group, uint32_t c);
lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c);
/**
* Set a function for a group which will modify the object's style if it is in focus
@@ -140,6 +149,13 @@ void lv_group_set_style_mod_edit_cb(lv_group_t * group, lv_group_style_mod_func_
*/
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
/**
* Set whether the next or previous item in a group is focused if the currently focussed obj is deleted.
* @param group pointer to a group
* @param new refocus policy enum
*/
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy);
/**
* Manually set the current mode (edit or navigate).
* @param group pointer to group
@@ -154,6 +170,13 @@ void lv_group_set_editing(lv_group_t * group, bool edit);
*/
void lv_group_set_click_focus(lv_group_t * group, bool en);
/**
* Set whether focus next/prev will allow wrapping from first->last or last->first object.
* @param group pointer to group
* @param en: true: wrapping enabled; false: wrapping disabled
*/
void lv_group_set_wrap(lv_group_t * group, bool en);
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
@@ -204,6 +227,12 @@ bool lv_group_get_editing(const lv_group_t * group);
*/
bool lv_group_get_click_focus(const lv_group_t * group);
/**
* Get whether focus next/prev will allow wrapping from first->last or last->first object.
* @param group pointer to group
* @param en: true: wrapping enabled; false: wrapping disabled
*/
bool lv_group_get_wrap(lv_group_t * group);
/**********************
* MACROS

View File

@@ -20,6 +20,10 @@
* DEFINES
*********************/
#if LV_INDEV_DRAG_THROW <= 0
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
#endif
/**********************
* TYPEDEFS
**********************/
@@ -136,7 +140,7 @@ void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
*/
void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
{
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return;
if(indev->driver.type != LV_INDEV_TYPE_POINTER) return;
indev->cursor = cur_obj;
lv_obj_set_parent(indev->cursor, lv_layer_sys());
@@ -161,11 +165,21 @@ void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group)
* @param indev pointer to an input device
* @param group point to a group
*/
void lv_indev_set_button_points(lv_indev_t * indev, lv_point_t * points)
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points)
{
if(indev->driver.type == LV_INDEV_TYPE_BUTTON) indev->btn_points = points;
}
/**
* Set feedback callback for indev.
* @param indev pointer to an input device
* @param feedback feedback callback
*/
void lv_indev_set_feedback(lv_indev_t *indev, lv_indev_feedback_t feedback)
{
indev->feedback = feedback;
}
/**
* Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
* @param indev pointer to an input device
@@ -212,6 +226,12 @@ bool lv_indev_is_dragging(const lv_indev_t * indev)
*/
void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
{
if(indev == NULL) {
point->x = 0;
point->y = 0;
return;
}
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) {
point->x = 0;
point->y = 0;
@@ -243,6 +263,16 @@ uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev)
return t;
}
/**
* Get feedback callback for indev.
* @param indev pointer to an input device
* @return feedback callback
*/
lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev)
{
return indev->feedback;
}
/**
* Do nothing until the next release
* @param indev pointer to an input device
@@ -362,6 +392,10 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
if(data->state == LV_INDEV_STATE_PR &&
i->proc.last_state == LV_INDEV_STATE_REL) {
i->proc.pr_timestamp = lv_tick_get();
lv_obj_t * focused = lv_group_get_focused(i->group);
if(focused && data->key == LV_GROUP_KEY_ENTER) {
focused->signal_func(focused, LV_SIGNAL_PRESSED, indev_act);
}
}
/*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) {
@@ -384,11 +418,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
/* Edit mode is not used by KEYPAD devices.
* So leave edit mode if we are in it before focusing on the next/prev object*/
if(data->key == LV_GROUP_KEY_NEXT || data->key == LV_GROUP_KEY_PREV) {
if(lv_group_get_editing(i->group)) {
lv_group_set_editing(i->group, false);
lv_obj_t * focused = lv_group_get_focused(i->group);
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
}
lv_group_set_editing(i->group, false);
}
if(data->key == LV_GROUP_KEY_NEXT) {
@@ -411,6 +441,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.last_state = data->state;
i->proc.last_key = data->key;
#else
(void)data; /*Unused*/
(void)i; /*Unused*/
#endif
}
@@ -462,14 +495,15 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
if(editable) {
i->group->editing = i->group->editing ? 0 : 1;
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/
LV_LOG_INFO("Edit mode changed");
if(focused) lv_obj_invalidate(focused);
if(i->group->obj_ll.head != i->group->obj_ll.tail)
lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/
else if(focused)
focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
}
/*If not editable then just send a long press signal*/
else {
if(focused) focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
if(focused)
focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act);
}
i->proc.long_pr_sent = 1;
}
@@ -486,14 +520,12 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
}
/*An object is being edited and the button is releases. Just send enter */
else if(i->group->editing) {
if(!i->proc.long_pr_sent) lv_group_send_data(i->group, LV_GROUP_KEY_ENTER); /*Ignore long pressed enter release because it comes from mode switch*/
if(!i->proc.long_pr_sent || i->group->obj_ll.head == i->group->obj_ll.tail)
lv_group_send_data(i->group, LV_GROUP_KEY_ENTER); /*Ignore long pressed enter release because it comes from mode switch*/
}
/*If the focused object is editable and now in navigate mode then enter edit mode*/
else if(editable && !i->group->editing && !i->proc.long_pr_sent) {
i->group->editing = i->group->editing ? 0 : 1;
if(focused) focused->signal_func(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again. Some object do something on navigate->edit change*/
LV_LOG_INFO("Edit mode changed (edit)");
if(focused) lv_obj_invalidate(focused);
lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/
}
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
@@ -504,6 +536,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.last_state = data->state;
i->proc.last_key = data->key;
#else
(void)data; /*Unused*/
(void)i; /*Unused*/
#endif
}
@@ -578,7 +613,10 @@ static void indev_proc_press(lv_indev_proc_t * proc)
if(proc->reset_query != 0) return;
}
if(pr_obj != NULL) {
proc->act_obj = pr_obj; /*Save the pressed object*/
proc->last_obj = proc->act_obj; /*Refresh the last_obj*/
if(proc->act_obj != NULL) {
/* Save the time when the obj pressed.
* It is necessary to count the long press time.*/
proc->pr_timestamp = lv_tick_get();
@@ -587,9 +625,11 @@ static void indev_proc_press(lv_indev_proc_t * proc)
proc->drag_in_prog = 0;
proc->drag_sum.x = 0;
proc->drag_sum.y = 0;
proc->vect.x = 0;
proc->vect.y = 0;
/*Search for 'top' attribute*/
lv_obj_t * i = pr_obj;
lv_obj_t * i = proc->act_obj;
lv_obj_t * last_top = NULL;
while(i != NULL) {
if(i->top != 0) last_top = i;
@@ -605,14 +645,11 @@ static void indev_proc_press(lv_indev_proc_t * proc)
}
/*Send a signal about the press*/
pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act);
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESSED, indev_act);
if(proc->reset_query != 0) return;
}
}
proc->act_obj = pr_obj; /*Save the pressed object*/
proc->last_obj = proc->act_obj; /*Refresh the last_obj*/
/*Calculate the vector*/
proc->vect.x = proc->act_point.x - proc->last_point.x;
proc->vect.y = proc->act_point.y - proc->last_point.y;
@@ -684,13 +721,15 @@ static void indev_proc_release(lv_indev_proc_t * proc)
else {
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
}
if(proc->reset_query != 0) return;
/*Handle click focus*/
#if USE_LV_GROUP
/*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/
lv_group_t * act_g = lv_obj_get_group(proc->act_obj);
if(lv_group_get_editing(act_g)) {
lv_group_set_editing(act_g, false);
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/
}
/*Check, if the parent is in a group focus on it.*/
@@ -810,11 +849,12 @@ static void indev_drag(lv_indev_proc_t * state)
if(lv_obj_get_drag(drag_obj) == false) return;
/*If still there is no drag then count the movement*/
if(state->drag_range_out == 0) {
state->drag_sum.x += state->vect.x;
state->drag_sum.y += state->vect.y;
/*Count the movement by drag*/
state->drag_sum.x += state->vect.x;
state->drag_sum.y += state->vect.y;
/*Enough move?*/
if(state->drag_range_out == 0) {
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT) {
@@ -834,6 +874,8 @@ static void indev_drag(lv_indev_proc_t * state)
lv_coord_t prev_x = drag_obj->coords.x1;
lv_coord_t prev_y = drag_obj->coords.y1;
lv_coord_t prev_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
lv_coord_t prev_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
lv_obj_set_pos(drag_obj, act_x + state->vect.x, act_y + state->vect.y);
@@ -848,8 +890,15 @@ static void indev_drag(lv_indev_proc_t * state)
}
/*If the object didn't moved then clear the invalidated areas*/
else {
uint16_t new_inv_buf_size = lv_refr_get_buf_size();
lv_refr_pop_from_buf(new_inv_buf_size - inv_buf_size);
/*In a special case if the object is moved on a page and
* the scrollable has fit == true and the object is dragged of the page then
* while its coordinate is not changing only the parent's size is reduced */
lv_coord_t act_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
if(act_par_w == prev_par_w && act_par_h == prev_par_h) {
uint16_t new_inv_buf_size = lv_refr_get_buf_size();
lv_refr_pop_from_buf(new_inv_buf_size - inv_buf_size);
}
}
}
}
@@ -887,14 +936,19 @@ static void indev_drag_throw(lv_indev_proc_t * state)
if(state->vect.x != 0 ||
state->vect.y != 0) {
/*Get the coordinates and modify them*/
/*Get the coordinates and modify them*/
lv_area_t coords_ori;
lv_obj_get_coords(drag_obj, &coords_ori);
lv_coord_t act_x = lv_obj_get_x(drag_obj) + state->vect.x;
lv_coord_t act_y = lv_obj_get_y(drag_obj) + state->vect.y;
lv_obj_set_pos(drag_obj, act_x, act_y);
lv_area_t coord_new;
lv_obj_get_coords(drag_obj, &coord_new);
/*If non of the coordinates are changed then do not continue throwing*/
if((lv_obj_get_x(drag_obj) != act_x || state->vect.x == 0) &&
(lv_obj_get_y(drag_obj) != act_y || state->vect.y == 0)) {
if((coords_ori.x1 == coord_new.x1 || state->vect.x == 0) &&
(coords_ori.y1 == coord_new.y1 || state->vect.y == 0)) {
state->drag_in_prog = 0;
state->vect.x = 0;
state->vect.y = 0;

View File

@@ -89,7 +89,14 @@ void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group);
* @param indev pointer to an input device
* @param group point to a group
*/
void lv_indev_set_button_points(lv_indev_t *indev, lv_point_t *points);
void lv_indev_set_button_points(lv_indev_t *indev, const lv_point_t *points);
/**
* Set feedback callback for indev.
* @param indev pointer to an input device
* @param feedback feedback callback
*/
void lv_indev_set_feedback(lv_indev_t *indev, lv_indev_feedback_t feedback);
/**
* Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
@@ -125,6 +132,13 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point);
*/
uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev);
/**
* Get feedback callback for indev.
* @param indev pointer to an input device
* @return feedback callback
*/
lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev);
/**
* Do nothing until the next release
* @param indev pointer to an input device

117
lv_core/lv_lang.c Normal file
View File

@@ -0,0 +1,117 @@
/**
* @file lv_lang.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_lang.h"
#if USE_LV_MULTI_LANG
#include "lv_obj.h"
#include "../lv_misc/lv_gc.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void lang_set_core(lv_obj_t * obj);
/**********************
* STATIC VARIABLES
**********************/
static uint8_t lang_act = 0;
static const void * (*get_txt)(uint16_t);
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Change the language
* @param lang_id the id of the
*/
void lv_lang_set(uint8_t lang_id)
{
lang_act = lang_id;
lv_obj_t * i;
LL_READ(LV_GC_ROOT(_lv_scr_ll), i) {
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
lang_set_core(i);
}
lang_set_core(lv_scr_act());
}
/**
* Set a function to get the texts of the set languages from a `txt_id`
* @param fp a function pointer to get the texts
*/
void lv_lang_set_text_func(const void * (*fp)(uint16_t))
{
get_txt = fp;
}
/**
* Use the function set by `lv_lang_set_text_func` to get the `txt_id` text in the set language
* @param txt_id an ID of the text to get
* @return the `txt_id` txt on the set language
*/
const void * lv_lang_get_text(uint16_t txt_id)
{
if(get_txt == NULL) {
LV_LOG_WARN("lv_lang_get_text: text_func is not specified");
return NULL; /*No text_get function specified */
}
if(txt_id == LV_LANG_TXT_ID_NONE) {
LV_LOG_WARN("lv_lang_get_text: attempts to get invalid text ID");
return NULL; /*Invalid txt_id*/
}
return get_txt(txt_id);
}
/**
* Return with ID of the currently selected language
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
*/
uint8_t lv_lang_act(void)
{
return lang_act;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Change the language of the children. (Called recursively)
* @param obj pointer to an object
*/
static void lang_set_core(lv_obj_t * obj)
{
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
lang_set_core(i);
}
}
#endif /*USE_LV_MULTI_LANG*/

74
lv_core/lv_lang.h Normal file
View File

@@ -0,0 +1,74 @@
/**
* @file lv_lang.h
*
*/
#ifndef LV_LANG_H
#define LV_LANG_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#if USE_LV_MULTI_LANG
#include <stdint.h>
/*********************
* DEFINES
*********************/
#define LV_LANG_TXT_ID_NONE 0xFFFF /*Used to not assign any text IDs for a multi-language object.*/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Change the language
* @param lang_id the id of the
*/
void lv_lang_set(uint8_t lang_id);
/**
* Set a function to get the texts of the set languages from a `txt_id`
* @param fp a function pointer to get the texts
*/
void lv_lang_set_text_func(const void * (*fp)(uint16_t));
/**
* Use the function set by `lv_lang_set_text_func` to get the `txt_id` text in the set language
* @param txt_id an ID of the text to get
* @return the `txt_id` txt on the set language
*/
const void * lv_lang_get_text(uint16_t txt_id);
/**
* Return with ID of the currently selected language
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
*/
uint8_t lv_lang_act(void);
/**********************
* MACROS
**********************/
#endif /*USE_LV_MULTI_LANG*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_LANG_H*/

View File

@@ -19,6 +19,11 @@
#include "../lv_misc/lv_ufs.h"
#include <stdint.h>
#include <string.h>
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -33,9 +38,9 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
static void refresh_childen_style(lv_obj_t * obj);
static void refresh_children_style(lv_obj_t * obj);
static void delete_children(lv_obj_t * obj);
static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
@@ -43,11 +48,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
**********************/
static lv_obj_t * def_scr = NULL;
static lv_obj_t * act_scr = NULL;
static lv_obj_t * top_layer = NULL;
static lv_obj_t * sys_layer = NULL;
static lv_ll_t scr_ll; /*Linked list of screens*/
static bool _lv_initialized = false;
/**********************
* MACROS
@@ -62,6 +64,17 @@ static lv_ll_t scr_ll; /*Linked list of screens*/
*/
void lv_init(void)
{
/* Do nothing if already initialized */
if (_lv_initialized)
return;
LV_GC_ROOT(_lv_def_scr) = NULL;
LV_GC_ROOT(_lv_act_scr) = NULL;
LV_GC_ROOT(_lv_top_layer) = NULL;
LV_GC_ROOT(_lv_sys_layer) = NULL;
LV_GC_ROOT(_lv_disp_list) = NULL;
LV_GC_ROOT(_lv_indev_list) = NULL;
LV_LOG_TRACE("lv_init started");
/*Initialize the lv_misc modules*/
@@ -81,30 +94,30 @@ void lv_init(void)
/*Init. the sstyles*/
lv_style_init();
/*Init. the screen refresh system*/
/*Initialize the screen refresh system*/
lv_refr_init();
/*Create the default screen*/
lv_ll_init(&scr_ll, sizeof(lv_obj_t));
def_scr = lv_obj_create(NULL, NULL);
lv_ll_init(&LV_GC_ROOT(_lv_scr_ll), sizeof(lv_obj_t));
LV_GC_ROOT(_lv_def_scr) = lv_obj_create(NULL, NULL);
act_scr = def_scr;
LV_GC_ROOT(_lv_act_scr) = LV_GC_ROOT(_lv_def_scr);
top_layer = lv_obj_create(NULL, NULL);
lv_obj_set_style(top_layer, &lv_style_transp_fit);
LV_GC_ROOT(_lv_top_layer) = lv_obj_create(NULL, NULL);
lv_obj_set_style(LV_GC_ROOT(_lv_top_layer), &lv_style_transp_fit);
sys_layer = lv_obj_create(NULL, NULL);
lv_obj_set_style(sys_layer, &lv_style_transp_fit);
LV_GC_ROOT(_lv_sys_layer) = lv_obj_create(NULL, NULL);
lv_obj_set_style(LV_GC_ROOT(_lv_sys_layer), &lv_style_transp_fit);
/*Refresh the screen*/
lv_obj_invalidate(act_scr);
lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr));
#if LV_INDEV_READ_PERIOD != 0
/*Init the input device handling*/
lv_indev_init();
#endif
_lv_initialized = true;
LV_LOG_INFO("lv_init ready");
}
@@ -127,7 +140,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
if(parent == NULL) {
LV_LOG_TRACE("Screen create started");
new_obj = lv_ll_ins_head(&scr_ll);
new_obj = lv_ll_ins_head(&LV_GC_ROOT(_lv_scr_ll));
lv_mem_assert(new_obj);
if(new_obj == NULL) return NULL;
@@ -141,6 +154,15 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->coords.y2 = LV_VER_RES - 1;
new_obj->ext_size = 0;
/*Init realign*/
#if LV_OBJ_REALIGN
new_obj->realign.align = LV_ALIGN_CENTER;
new_obj->realign.xofs = 0;
new_obj->realign.yofs = 0;
new_obj->realign.base = NULL;
new_obj->realign.auto_realign = 0;
#endif
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
@@ -200,6 +222,14 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_OBJ_DEF_HEIGHT;
new_obj->ext_size = 0;
/*Init realign*/
#if LV_OBJ_REALIGN
new_obj->realign.align = LV_ALIGN_CENTER;
new_obj->realign.xofs = 0;
new_obj->realign.yofs = 0;
new_obj->realign.base = NULL;
new_obj->realign.auto_realign = 0;
#endif
/*Set appearance*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
@@ -248,6 +278,16 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
#if LV_OBJ_FREE_PTR != 0
new_obj->free_ptr = copy->free_ptr;
#endif
/*Copy realign*/
#if LV_OBJ_REALIGN
new_obj->realign.align = copy->realign.align;
new_obj->realign.xofs = copy->realign.xofs;
new_obj->realign.yofs = copy->realign.yofs;
new_obj->realign.base = copy->realign.base;
new_obj->realign.auto_realign = copy->realign.auto_realign;
#endif
/*Set attributes*/
new_obj->click = copy->click;
new_obj->drag = copy->drag;
@@ -255,6 +295,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->drag_parent = copy->drag_parent;
new_obj->hidden = copy->hidden;
new_obj->top = copy->top;
new_obj->opa_scale_en = copy->opa_scale_en;
new_obj->protect = copy->protect;
new_obj->opa_scale = copy->opa_scale;
@@ -268,7 +309,12 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
}
#endif
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
/*Set the same coordinates for non screen objects*/
if(lv_obj_get_parent(copy) != NULL && parent != NULL) {
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
} else {
lv_obj_set_pos(new_obj, 0, 0);
}
LV_LOG_INFO("Object create ready");
}
@@ -322,7 +368,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
/*Remove the object from parent's children list*/
lv_obj_t * par = lv_obj_get_parent(obj);
if(par == NULL) { /*It is a screen*/
lv_ll_rem(&scr_ll, obj);
lv_ll_rem(&LV_GC_ROOT(_lv_scr_ll), obj);
} else {
lv_ll_rem(&(par->child_ll), obj);
}
@@ -360,10 +406,13 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
void lv_obj_clean(lv_obj_t * obj)
{
lv_obj_t * child = lv_obj_get_child(obj, NULL);
lv_obj_t * child_next;
while(child) {
/* Read the next child before deleting the current
* because the next couldn't be read from a deleted (invalid) node*/
child_next = lv_obj_get_child(obj, child);
lv_obj_del(child);
child = lv_obj_get_child(obj, child);
child = child_next;
}
}
@@ -375,7 +424,7 @@ void lv_obj_invalidate(const lv_obj_t * obj)
{
if(lv_obj_get_hidden(obj)) return;
/*Invalidate the object only if it belongs to the 'act_scr'*/
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
if(obj_scr == lv_scr_act() ||
obj_scr == lv_layer_top() ||
@@ -420,9 +469,9 @@ void lv_obj_invalidate(const lv_obj_t * obj)
*/
void lv_scr_load(lv_obj_t * scr)
{
act_scr = scr;
LV_GC_ROOT(_lv_act_scr) = scr;
lv_obj_invalidate(act_scr);
lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr));
}
/*--------------------
@@ -507,7 +556,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
obj->coords.x2 += diff.x;
obj->coords.y2 += diff.y;
refresh_childen_position(obj, diff.x, diff.y);
refresh_children_position(obj, diff.x, diff.y);
/*Inform the object about its new coordinates*/
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
@@ -578,6 +627,11 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
/*Invalidate the new area*/
lv_obj_invalidate(obj);
/*Automatically realign the object if required*/
#if LV_OBJ_REALIGN
if(obj->realign.auto_realign) lv_obj_realign(obj);
#endif
}
/**
@@ -734,6 +788,194 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
new_y -= par_abs_y;
lv_obj_set_pos(obj, new_x, new_y);
#if LV_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align;
obj->realign.xofs = x_mod;
obj->realign.yofs = y_mod;
obj->realign.base = base;
obj->realign.origo_align = 0;
#endif
}
/**
* Align an object to an other object.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
{
lv_coord_t new_x = lv_obj_get_x(obj);
lv_coord_t new_y = lv_obj_get_y(obj);
lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2;
lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2;
if(base == NULL) {
base = lv_obj_get_parent(obj);
}
switch(align) {
case LV_ALIGN_CENTER:
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
break;
case LV_ALIGN_IN_TOP_LEFT:
new_x = -obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_IN_TOP_MID:
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_IN_TOP_RIGHT:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_IN_BOTTOM_LEFT:
new_x = -obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_IN_BOTTOM_MID:
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_IN_BOTTOM_RIGHT:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_IN_LEFT_MID:
new_x = -obj_w_half;
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
break;
case LV_ALIGN_IN_RIGHT_MID:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
break;
case LV_ALIGN_OUT_TOP_LEFT:
new_x = -obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_OUT_TOP_MID:
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_OUT_TOP_RIGHT:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = - obj_h_half;
break;
case LV_ALIGN_OUT_BOTTOM_LEFT:
new_x = -obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_OUT_BOTTOM_MID:
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_OUT_BOTTOM_RIGHT:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_OUT_LEFT_TOP:
new_x = - obj_w_half ;
new_y = - obj_h_half;
break;
case LV_ALIGN_OUT_LEFT_MID:
new_x = - obj_w_half;
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
break;
case LV_ALIGN_OUT_LEFT_BOTTOM:
new_x = - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
case LV_ALIGN_OUT_RIGHT_TOP:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = -obj_h_half;
break;
case LV_ALIGN_OUT_RIGHT_MID:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
break;
case LV_ALIGN_OUT_RIGHT_BOTTOM:
new_x = lv_obj_get_width(base) - obj_w_half;
new_y = lv_obj_get_height(base) - obj_h_half;
break;
}
/*Bring together the coordination system of base and obj*/
lv_obj_t * par = lv_obj_get_parent(obj);
lv_coord_t base_abs_x = base->coords.x1;
lv_coord_t base_abs_y = base->coords.y1;
lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1;
new_x += x_mod + base_abs_x;
new_y += y_mod + base_abs_y;
new_x -= par_abs_x;
new_y -= par_abs_y;
lv_obj_set_pos(obj, new_x, new_y);
#if LV_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align;
obj->realign.xofs = x_mod;
obj->realign.yofs = y_mod;
obj->realign.base = base;
obj->realign.origo_align = 1;
#endif
}
/**
* Realign the object based on the last `lv_obj_align` parameters.
* @param obj pointer to an object
*/
void lv_obj_realign(lv_obj_t * obj)
{
#if LV_OBJ_REALIGN
if(obj->realign.origo_align) lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
else lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
#else
(void) obj;
LV_LOG_WARN("lv_obj_realaign: no effect because LV_OBJ_REALIGN = 0");
#endif
}
/**
* Enable the automatic realign of the object when its size has changed based on the last `lv_obj_align` parameters.
* @param obj pointer to an object
* @param en true: enable auto realign; false: disable auto realign
*/
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en)
{
#if LV_OBJ_REALIGN
obj->realign.auto_realign = en ? 1 : 0;
#else
(void) obj;
(void) en;
LV_LOG_WARN("lv_obj_set_auto_realign: no effect because LV_OBJ_REALIGN = 0");
#endif
}
/*---------------------
@@ -750,11 +992,10 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
obj->style_p = style;
/*Send a signal about style change to every children with NULL style*/
refresh_childen_style(obj);
refresh_children_style(obj);
/*Notify the object about the style change too*/
lv_obj_refresh_style(obj);
}
/**
@@ -777,7 +1018,11 @@ void lv_obj_refresh_style(lv_obj_t * obj)
void lv_obj_report_style_mod(lv_style_t * style)
{
lv_obj_t * i;
LL_READ(scr_ll, i) {
LL_READ(LV_GC_ROOT(_lv_scr_ll), i) {
if(i->style_p == style || style == NULL) {
lv_obj_refresh_style(i);
}
report_style_mod_core(style, i);
}
}
@@ -1070,7 +1315,7 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
*/
lv_obj_t * lv_scr_act(void)
{
return act_scr;
return LV_GC_ROOT(_lv_act_scr);
}
/**
@@ -1079,7 +1324,7 @@ lv_obj_t * lv_scr_act(void)
*/
lv_obj_t * lv_layer_top(void)
{
return top_layer;
return LV_GC_ROOT(_lv_top_layer);
}
/**
@@ -1089,7 +1334,7 @@ lv_obj_t * lv_layer_top(void)
*/
lv_obj_t * lv_layer_sys(void)
{
return sys_layer;
return LV_GC_ROOT(_lv_sys_layer);
}
/**
@@ -1133,13 +1378,15 @@ lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
*/
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
{
lv_obj_t * result = NULL;
if(child == NULL) {
return lv_ll_get_head(&obj->child_ll);
result = lv_ll_get_head(&obj->child_ll);
} else {
return lv_ll_get_next(&obj->child_ll, child);
result = lv_ll_get_next(&obj->child_ll, child);
}
return NULL;
return result;
}
/**
@@ -1151,13 +1398,15 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child)
*/
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
{
lv_obj_t * result = NULL;
if(child == NULL) {
return lv_ll_get_tail(&obj->child_ll);
result = lv_ll_get_tail(&obj->child_ll);
} else {
return lv_ll_get_prev(&obj->child_ll, child);
result = lv_ll_get_prev(&obj->child_ll, child);
}
return NULL;
return result;
}
/**
@@ -1248,6 +1497,21 @@ lv_coord_t lv_obj_get_ext_size(const lv_obj_t * obj)
return obj->ext_size;
}
/**
* Get the automatic realign property of the object.
* @param obj pointer to an object
* @return true: auto realign is enabled; false: auto realign is disabled
*/
bool lv_obj_get_auto_realign(lv_obj_t * obj)
{
#if LV_OBJ_REALIGN
return obj->realign.auto_realign ? true : false;
#else
(void) obj;
return false;
#endif
}
/*-----------------
* Appearance get
*---------------*/
@@ -1341,7 +1605,7 @@ bool lv_obj_get_drag(const lv_obj_t * obj)
}
/**
* Get the drag thow enable attribute of an object
* Get the drag throw enable attribute of an object
* @param obj pointer to an object
* @return true: drag throw is enabled
*/
@@ -1363,7 +1627,7 @@ bool lv_obj_get_drag_parent(const lv_obj_t * obj)
/**
* Get the opa scale enable parameter
* @param obj pointer to an object
* @return true: opa scaling is enabled for this object and all children false: no opa scaling
* @return true: opa scaling is enabled for this object and all children; false: no opa scaling
*/
lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj)
{
@@ -1413,7 +1677,7 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
* @param obj pointer to an object
* @return the signal function
*/
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj)
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj)
{
return obj->signal_func;
}
@@ -1584,6 +1848,14 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_res_t res = LV_RES_OK;
lv_style_t * style = lv_obj_get_style(obj);
lv_indev_t *indev_act = lv_indev_get_act();
if(sign > _LV_SIGNAL_FEEDBACK_SECTION_START && sign < _LV_SIGNAL_FEEDBACK_SECTION_END) {
if(indev_act != NULL && indev_act->feedback != NULL)
indev_act->feedback(indev_act, sign);
}
if(sign == LV_SIGNAL_CHILD_CHG) {
/*Return 'invalid' if the child change signal is not enabled*/
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
@@ -1605,7 +1877,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
* @param x_diff x coordinate shift
* @param y_diff y coordinate shift
*/
static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
{
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
@@ -1614,7 +1886,7 @@ static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord
i->coords.x2 += x_diff;
i->coords.y2 += y_diff;
refresh_childen_position(i, x_diff, y_diff);
refresh_children_position(i, x_diff, y_diff);
}
}
@@ -1628,7 +1900,7 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj)
lv_obj_t * i;
LL_READ(obj->child_ll, i) {
if(i->style_p == style_p || style_p == NULL) {
refresh_childen_style(i);
refresh_children_style(i);
lv_obj_refresh_style(i);
}
@@ -1636,22 +1908,21 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj)
}
}
/**
* Recursively refresh the style of the children. Go deeper until a not NULL style is found
* because the NULL styles are inherited from the parent
* @param obj pointer to an object
*/
static void refresh_childen_style(lv_obj_t * obj)
static void refresh_children_style(lv_obj_t * obj)
{
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child != NULL) {
if(child->style_p == NULL) {
refresh_childen_style(child); /*Check children too*/
refresh_children_style(child); /*Check children too*/
lv_obj_refresh_style(child); /*Notify the child about the style change*/
} else if(child->style_p->glass) {
/*Children with 'glass' parent might be effected if their style == NULL*/
refresh_childen_style(child);
refresh_children_style(child);
}
child = lv_obj_get_child(obj, child);
}
@@ -1666,6 +1937,14 @@ static void delete_children(lv_obj_t * obj)
lv_obj_t * i;
lv_obj_t * i_next;
i = lv_ll_get_head(&(obj->child_ll));
/*Remove from the group; remove before transversing children so that
* the object still has access to all children during the
* LV_SIGNAL_DEFOCUS call*/
#if USE_LV_GROUP
if(obj->group_p != NULL) lv_group_remove_obj(obj);
#endif
while(i != NULL) {
/*Get the next object before delete this*/
i_next = lv_ll_get_next(&(obj->child_ll), i);
@@ -1682,10 +1961,6 @@ static void delete_children(lv_obj_t * obj)
lv_anim_del(obj, NULL);
#endif
/*Delete from the group*/
#if USE_LV_GROUP
if(obj->group_p != NULL) lv_group_remove_obj(obj);
#endif
/* Reset the input devices if
* the currently pressed object is deleted*/

View File

@@ -34,7 +34,7 @@ extern "C" {
/*Error check of lv_conf.h*/
#if LV_HOR_RES == 0 || LV_VER_RES == 0
#error "LittlevGL: LV_HOR_RES and LV_VER_RES must be greater then 0"
#error "LittlevGL: LV_HOR_RES and LV_VER_RES must be greater than 0"
#endif
#if LV_ANTIALIAS > 1
@@ -59,6 +59,7 @@ extern "C" {
#define LV_ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/
#define LV_MAX_ANCESTOR_NUM 8
/**********************
* TYPEDEFS
**********************/
@@ -90,8 +91,10 @@ enum
LV_SIGNAL_CORD_CHG,
LV_SIGNAL_STYLE_CHG,
LV_SIGNAL_REFR_EXT_SIZE,
LV_SIGNAL_LANG_CHG,
LV_SIGNAL_GET_TYPE,
_LV_SIGNAL_FEEDBACK_SECTION_START,
/*Input device related*/
LV_SIGNAL_PRESSED,
LV_SIGNAL_PRESSING,
@@ -106,12 +109,51 @@ enum
LV_SIGNAL_FOCUS,
LV_SIGNAL_DEFOCUS,
LV_SIGNAL_CONTROLL,
_LV_SIGNAL_FEEDBACK_SECTION_END,
LV_SIGNAL_GET_EDITABLE,
};
typedef uint8_t lv_signal_t;
typedef lv_res_t (* lv_signal_func_t) (struct _lv_obj_t * obj, lv_signal_t sign, void * param);
enum
{
LV_ALIGN_CENTER = 0,
LV_ALIGN_IN_TOP_LEFT,
LV_ALIGN_IN_TOP_MID,
LV_ALIGN_IN_TOP_RIGHT,
LV_ALIGN_IN_BOTTOM_LEFT,
LV_ALIGN_IN_BOTTOM_MID,
LV_ALIGN_IN_BOTTOM_RIGHT,
LV_ALIGN_IN_LEFT_MID,
LV_ALIGN_IN_RIGHT_MID,
LV_ALIGN_OUT_TOP_LEFT,
LV_ALIGN_OUT_TOP_MID,
LV_ALIGN_OUT_TOP_RIGHT,
LV_ALIGN_OUT_BOTTOM_LEFT,
LV_ALIGN_OUT_BOTTOM_MID,
LV_ALIGN_OUT_BOTTOM_RIGHT,
LV_ALIGN_OUT_LEFT_TOP,
LV_ALIGN_OUT_LEFT_MID,
LV_ALIGN_OUT_LEFT_BOTTOM,
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
};
typedef uint8_t lv_align_t;
#if LV_OBJ_REALIGN
typedef struct {
const struct _lv_obj_t * base;
lv_coord_t xofs;
lv_coord_t yofs;
lv_align_t align;
uint8_t auto_realign :1;
uint8_t origo_align :1; /*1: the oigo (center of the object) was aligned with `lv_obj_align_origo`*/
}lv_reailgn_t;
#endif
typedef struct _lv_obj_t
{
struct _lv_obj_t * par; /*Pointer to the parent object*/
@@ -144,6 +186,9 @@ typedef struct _lv_obj_t
lv_opa_t opa_scale; /*Scale down the opacity by this factor. Effects all children as well*/
lv_coord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
#if LV_OBJ_REALIGN
lv_reailgn_t realign;
#endif
#ifdef LV_OBJ_FREE_NUM_TYPE
LV_OBJ_FREE_NUM_TYPE free_num; /*Application specific identifier (set it freely)*/
@@ -171,32 +216,6 @@ typedef struct {
const char * type[LV_MAX_ANCESTOR_NUM]; /*[0]: the actual type, [1]: ancestor, [2] #1's ancestor ... [x]: "lv_obj" */
} lv_obj_type_t;
enum
{
LV_ALIGN_CENTER = 0,
LV_ALIGN_IN_TOP_LEFT,
LV_ALIGN_IN_TOP_MID,
LV_ALIGN_IN_TOP_RIGHT,
LV_ALIGN_IN_BOTTOM_LEFT,
LV_ALIGN_IN_BOTTOM_MID,
LV_ALIGN_IN_BOTTOM_RIGHT,
LV_ALIGN_IN_LEFT_MID,
LV_ALIGN_IN_RIGHT_MID,
LV_ALIGN_OUT_TOP_LEFT,
LV_ALIGN_OUT_TOP_MID,
LV_ALIGN_OUT_TOP_RIGHT,
LV_ALIGN_OUT_BOTTOM_LEFT,
LV_ALIGN_OUT_BOTTOM_MID,
LV_ALIGN_OUT_BOTTOM_RIGHT,
LV_ALIGN_OUT_LEFT_TOP,
LV_ALIGN_OUT_LEFT_MID,
LV_ALIGN_OUT_LEFT_BOTTOM,
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
};
typedef uint8_t lv_align_t;
enum
{
LV_ANIM_NONE = 0,
@@ -333,6 +352,28 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h);
*/
void lv_obj_align(lv_obj_t * obj,const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
/**
* Align an object to an other object.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
/**
* Realign the object based on the last `lv_obj_align` parameters.
* @param obj pointer to an object
*/
void lv_obj_realign(lv_obj_t * obj);
/**
* Enable the automatic realign of the object when its size has changed based on the last `lv_obj_align` parameters.
* @param obj pointer to an object
* @param en true: enable auto realign; false: disable auto realign
*/
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en);
/*---------------------
* Appearance set
@@ -412,7 +453,7 @@ void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
* @param obj pointer to an object
* @param en true: enable editing
*/
void lv_obj_set_editable(lv_obj_t * obj, bool en);
//void lv_obj_set_editable(lv_obj_t * obj, bool en);
/**
* Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
@@ -623,6 +664,13 @@ lv_coord_t lv_obj_get_height(const lv_obj_t * obj);
*/
lv_coord_t lv_obj_get_ext_size(const lv_obj_t * obj);
/**
* Get the automatic realign property of the object.
* @param obj pointer to an object
* @return true: auto realign is enabled; false: auto realign is disabled
*/
bool lv_obj_get_auto_realign(lv_obj_t * obj);
/*-----------------
* Appearance get
*---------------*/
@@ -655,7 +703,7 @@ bool lv_obj_get_click(const lv_obj_t * obj);
/**
* Get the top enable attribute of an object
* @param obj pointer to an object
* @return true: the auto top feture is enabled
* @return true: the auto top feature is enabled
*/
bool lv_obj_get_top(const lv_obj_t * obj);
@@ -667,7 +715,7 @@ bool lv_obj_get_top(const lv_obj_t * obj);
bool lv_obj_get_drag(const lv_obj_t * obj);
/**
* Get the drag thow enable attribute of an object
* Get the drag throw enable attribute of an object
* @param obj pointer to an object
* @return true: drag throw is enabled
*/
@@ -680,6 +728,14 @@ bool lv_obj_get_drag_throw(const lv_obj_t * obj);
*/
bool lv_obj_get_drag_parent(const lv_obj_t * obj);
/**
* Get the opa scale enable parameter
* @param obj pointer to an object
* @return true: opa scaling is enabled for this object and all children; false: no opa scaling
*/
lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj);
/**
* Get the opa scale parameter of an object
* @param obj pointer to an object
@@ -707,7 +763,7 @@ bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot);
* @param obj pointer to an object
* @return the signal function
*/
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj);
lv_signal_func_t lv_obj_get_signal_func(const lv_obj_t * obj);
/**
* Get the design function of an object
@@ -764,7 +820,7 @@ void * lv_obj_get_group(const lv_obj_t * obj);
/**
* Tell whether the ohe object is the focused object of a group or not.
* Tell whether the object is the focused object of a group or not.
* @param obj pointer to an object
* @return true: the object is focused, false: the object is not focused or not in a group
*/

View File

@@ -10,12 +10,16 @@
#include "lv_refr.h"
#include "lv_vdb.h"
#include "../lv_hal/lv_hal_tick.h"
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_misc/lv_task.h"
#include "../lv_misc/lv_mem.h"
/*********************
* DEFINES
*********************/
#ifndef LV_INV_FIFO_SIZE
#define LV_INV_FIFO_SIZE 32 /*The average count of objects on a screen */
#endif
/**********************
* TYPEDEFS
@@ -73,9 +77,9 @@ void lv_refr_init(void)
/**
* Redraw the invalidated areas now.
* Normally the redarwing is peridocally executed in `lv_task_handler` but a long blocking process can
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
* this function can be called when the screen shoud be updated.
* this function can be called when the screen should be updated.
*/
void lv_refr_now(void)
{
@@ -184,18 +188,59 @@ static void lv_refr_task(void * param)
uint32_t start = lv_tick_get();
if(lv_disp_get_active() == NULL) {
LV_LOG_TRACE("No display is registered");
return;
}
lv_refr_join_area();
lv_refr_areas();
bool refr_done = false;
if(inv_buf_p != 0) refr_done = true;
memset(inv_buf, 0, sizeof(inv_buf));
inv_buf_p = 0;
/*If refresh happened ...*/
if(inv_buf_p != 0) {
/* In the callback lv_obj_inv can occur
* therefore be sure the inv_buf is cleared prior to it*/
if(refr_done != false) {
/*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/
#if LV_VDB_TRUE_DOUBLE_BUFFERED
lv_vdb_t * vdb_p = lv_vdb_get();
vdb_p->area.x1 = 0;
vdb_p->area.x2 = LV_HOR_RES-1;
vdb_p->area.y1 = 0;
vdb_p->area.y2 = LV_VER_RES - 1;
/*Flush the content of the VDB*/
lv_vdb_flush();
/* With true double buffering the flushing should be only the address change of the current frame buffer
* Wait until the address change is ready and copy the active content to the other frame buffer (new active VDB)
* The changes will be written to the new VDB.*/
lv_vdb_t * vdb_act = lv_vdb_get_active();
lv_vdb_t * vdb_ina = lv_vdb_get_inactive();
uint8_t * buf_act = (uint8_t *) vdb_act->buf;
uint8_t * buf_ina = (uint8_t *) vdb_ina->buf;
uint16_t a;
for(a = 0; a < inv_buf_p; a++) {
if(inv_buf[a].joined == 0) {
lv_coord_t y;
uint32_t start_offs = ((LV_HOR_RES * inv_buf[a].area.y1 + inv_buf[a].area.x1) * LV_VDB_PX_BPP) >> 3;
uint32_t line_length = (lv_area_get_width(&inv_buf[a].area) * LV_VDB_PX_BPP) >> 3;
for(y = inv_buf[a].area.y1; y <= inv_buf[a].area.y2; y++) {
memcpy(buf_act + start_offs, buf_ina + start_offs, line_length);
start_offs += (LV_HOR_RES * LV_VDB_PX_BPP) >> 3;
}
}
}
#endif
/*Clean up*/
memset(inv_buf, 0, sizeof(inv_buf));
inv_buf_p = 0;
/*Call monitor cb if present*/
if(monitor_cb != NULL) {
monitor_cb(lv_tick_elaps(start), px_num);
}
@@ -296,6 +341,8 @@ static void lv_refr_area_no_vdb(const lv_area_t * area_p)
*/
static void lv_refr_area_with_vdb(const lv_area_t * area_p)
{
#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0
/*Calculate the max row num*/
lv_coord_t w = lv_area_get_width(area_p);
lv_coord_t h = lv_area_get_height(area_p);
@@ -312,14 +359,18 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
tmp.x1 = 0;
tmp.x2 = 0;
tmp.y1 = 0;
tmp.y2 = max_row;
lv_coord_t y_tmp = max_row;
lv_coord_t y_tmp = max_row - 1;
do {
tmp.y2 = y_tmp;
round_cb(&tmp);
y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */
} while(lv_area_get_height(&tmp) > max_row && y_tmp != 0);
/*If this height fits into `max_row` then fine*/
if(lv_area_get_height(&tmp) <= max_row) break;
/*Decrement the height of the area until it fits into `max_row` after rounding*/
y_tmp --;
} while(y_tmp != 0);
if(y_tmp == 0) {
LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to small VDB)");
@@ -366,6 +417,14 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
/*Refresh this part too*/
lv_refr_area_part_vdb(area_p);
}
#else
lv_vdb_t * vdb_p = lv_vdb_get();
vdb_p->area.x1 = 0;
vdb_p->area.x2 = LV_HOR_RES-1;
vdb_p->area.y1 = 0;
vdb_p->area.y2 = LV_VER_RES - 1;
lv_refr_area_part_vdb(area_p);
#endif
}
/**
@@ -396,8 +455,12 @@ static void lv_refr_area_part_vdb(const lv_area_t * area_p)
lv_refr_obj_and_children(lv_layer_top(), &start_mask);
lv_refr_obj_and_children(lv_layer_sys(), &start_mask);
/* In true double buffered mode flush only once when all areas were rendered.
* In normal mode flush after every area */
#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0
/*Flush the content of the VDB*/
lv_vdb_flush();
#endif
}
#endif /*LV_VDB_SIZE == 0*/
@@ -514,11 +577,9 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
if(union_ok != false) {
/* Redraw the object */
lv_style_t * style = lv_obj_get_style(obj);
if(style->body.opa != LV_OPA_TRANSP) {
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
//tick_wait_ms(100); /*DEBUG: Wait after every object draw to see the order of drawing*/
}
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
//usleep(5 * 1000); /*DEBUG: Wait after every object draw to see the order of drawing*/
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
lv_obj_get_coords(obj, &obj_area);
@@ -547,8 +608,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
}
/* If all the children are redrawn make 'post draw' design */
if(style->body.opa != LV_OPA_TRANSP) {
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
}
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
}
}

View File

@@ -47,9 +47,9 @@ void lv_refr_init(void);
/**
* Redraw the invalidated areas now.
* Normally the redarwing is peridocally executed in `lv_task_handler` but a long blocking process can
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
* this function can be called when the screen shoud be updated.
* this function can be called when the screen should be updated.
*/
void lv_refr_now(void);

View File

@@ -164,9 +164,10 @@ void lv_style_init(void)
lv_style_btn_rel.body.border.color = LV_COLOR_MAKE(0x0b, 0x19, 0x28);
lv_style_btn_rel.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
lv_style_btn_rel.body.border.opa = LV_OPA_70;
lv_style_btn_rel.text.color = LV_COLOR_MAKE(0xff, 0xff, 0xff);
lv_style_btn_rel.body.shadow.color = LV_COLOR_GRAY;
lv_style_btn_rel.body.shadow.width = 0;
lv_style_btn_rel.text.color = LV_COLOR_MAKE(0xff, 0xff, 0xff);
lv_style_btn_rel.image.color = LV_COLOR_MAKE(0xff, 0xff, 0xff);
/*Button pressed style*/
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));

View File

@@ -31,12 +31,13 @@ extern "C" {
/*Border types (Use 'OR'ed values)*/
enum
{
LV_BORDER_NONE = 0x00,
LV_BORDER_BOTTOM = 0x01,
LV_BORDER_TOP = 0x02,
LV_BORDER_LEFT = 0x04,
LV_BORDER_RIGHT = 0x08,
LV_BORDER_FULL = 0x0F,
LV_BORDER_NONE = 0x00,
LV_BORDER_BOTTOM = 0x01,
LV_BORDER_TOP = 0x02,
LV_BORDER_LEFT = 0x04,
LV_BORDER_RIGHT = 0x08,
LV_BORDER_FULL = 0x0F,
LV_BORDER_INTERNAL = 0x10, /*FOR matrix-like objects (e.g. Button matrix)*/
};
typedef uint8_t lv_border_part_t;
@@ -183,7 +184,7 @@ extern lv_style_t lv_style_pretty_color;
extern lv_style_t lv_style_btn_rel;
extern lv_style_t lv_style_btn_pr;
extern lv_style_t lv_style_btn_tgl_rel;
extern lv_style_t lv_style_btn_tgl_pr;;
extern lv_style_t lv_style_btn_tgl_pr;
extern lv_style_t lv_style_btn_ina;
/**********************

View File

@@ -16,16 +16,17 @@
/*********************
* DEFINES
*********************/
#ifndef LV_ATTRIBUTE_FLUSH_READY
#define LV_ATTRIBUTE_FLUSH_READY
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
/**********************
* TYPEDEFS
**********************/
enum {
LV_VDB_STATE_FREE = 0, /*Not used*/
LV_VDB_STATE_ACTIVE, /*Being used to render*/
LV_VDB_STATE_FLUSH, /*Flushing pixels from it*/
};
typedef uint8_t lv_vdb_state_t;
/**********************
* STATIC PROTOTYPES
@@ -35,24 +36,25 @@ typedef uint8_t lv_vdb_state_t;
* STATIC VARIABLES
**********************/
#if LV_VDB_DOUBLE == 0
/*Simple VDB*/
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
#if LV_VDB_DOUBLE == 0
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb = {.buf = (lv_color_t *)vdb_buf};
# else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/
static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
# endif
#else /*LV_VDB_DOUBLE != 0*/
/*LV_VDB_DOUBLE != 0*/
#else
/*Double VDB*/
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
static uint8_t vdb_active = 0;
# if LV_VDB_ADR == 0
/*If the buffer address is not specified simply allocate it*/
static uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
static LV_ATTRIBUTE_MEM_ALIGN uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}};
# else /*LV_VDB_ADR != 0*/
/*If the buffer address is specified use that address*/
@@ -60,6 +62,8 @@ static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t
# endif
#endif
static volatile bool vdb_flushing = false;
/**********************
* MACROS
**********************/
@@ -75,32 +79,14 @@ static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t
lv_vdb_t * lv_vdb_get(void)
{
#if LV_VDB_DOUBLE == 0
/* Wait until VDB become ACTIVE from FLUSH by the
* user call of 'lv_flush_ready()' in display drivers's flush function*/
while(vdb_state != LV_VDB_STATE_ACTIVE);
/* Wait until VDB is flushing.
* (Until this user calls of 'lv_flush_ready()' in the display drivers's flush function*/
while(vdb_flushing);
if(vdb.buf == (void *)LV_VDB_ADR_INV) {
LV_LOG_ERROR("VDB address is invalid. Use `lv_vdb_set_adr` to set a valid address or use LV_VDB_ADR = 0 in lv_conf.h");
return NULL;
}
return &vdb;
#else
/*If already there is an active do nothing*/
if(vdb_state[0] == LV_VDB_STATE_ACTIVE) return &vdb[0];
if(vdb_state[1] == LV_VDB_STATE_ACTIVE) return &vdb[1];
/*Try to allocate a free VDB*/
if(vdb_state[0] == LV_VDB_STATE_FREE) {
vdb_state[0] = LV_VDB_STATE_ACTIVE;
return &vdb[0];
}
if(vdb_state[1] == LV_VDB_STATE_FREE) {
vdb_state[1] = LV_VDB_STATE_ACTIVE;
return &vdb[1];
}
return NULL; /*There wasn't free VDB (never happen)*/
return &vdb[vdb_active];
#endif
}
@@ -114,23 +100,31 @@ void lv_vdb_flush(void)
LV_LOG_WARN("Invalid VDB pointer");
return;
}
#if LV_VDB_DOUBLE == 0
vdb_state = LV_VDB_STATE_FLUSH; /*User call to 'lv_flush_ready()' will set to ACTIVE 'disp_flush'*/
#else
/* Wait the pending flush before starting this one
* (Don't forget: 'lv_flush_ready()' has to be called when flushing is ready)*/
while(vdb_state[0] == LV_VDB_STATE_FLUSH || vdb_state[1] == LV_VDB_STATE_FLUSH);
/*Turn the active VDB to flushing*/
if(vdb_state[0] == LV_VDB_STATE_ACTIVE) vdb_state[0] = LV_VDB_STATE_FLUSH;
if(vdb_state[1] == LV_VDB_STATE_ACTIVE) vdb_state[1] = LV_VDB_STATE_FLUSH;
#endif
/*Don't start a new flush while the previous is not finished*/
#if LV_VDB_DOUBLE
while(vdb_flushing);
#endif /*LV_VDB_DOUBLE*/
vdb_flushing = true;
/*Flush the rendered content to the display*/
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
}
#if LV_VDB_DOUBLE
/*Make the other VDB active. The content of the current will be kept until the next flush*/
vdb_active++;
vdb_active &= 0x1;
/*If the screen is transparent initialize it when the new VDB is selected*/
# if LV_COLOR_SCREEN_TRANSP
memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES);
# endif /*LV_COLOR_SCREEN_TRANSP*/
#endif /*#if LV_VDB_DOUBLE*/
}
/**
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
@@ -152,31 +146,51 @@ void lv_vdb_set_adr(void * buf1, void * buf2)
/**
* Call in the display driver's 'disp_flush' function when the flushing is finished
*/
void lv_flush_ready(void)
LV_ATTRIBUTE_FLUSH_READY void lv_flush_ready(void)
{
#if LV_VDB_DOUBLE == 0
vdb_state = LV_VDB_STATE_ACTIVE;
vdb_flushing = false;
#if LV_COLOR_SCREEN_TRANSP
/*If the screen is transparent initialize it when the flushing is ready*/
#if LV_VDB_DOUBLE == 0 && LV_COLOR_SCREEN_TRANSP
memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES);
#endif
}
/**
* Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1`
* @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB
*/
lv_vdb_t * lv_vdb_get_active(void)
{
#if LV_VDB_DOUBLE == 0
return &vdb;
#else
if(vdb_state[0] == LV_VDB_STATE_FLUSH) {
#if LV_COLOR_SCREEN_TRANSP
memset(vdb_buf[0], 0x00, LV_VDB_SIZE_IN_BYTES);
return &vdb[vdb_active];
#endif
vdb_state[0] = LV_VDB_STATE_FREE;
}
if(vdb_state[1] == LV_VDB_STATE_FLUSH) {
#if LV_COLOR_SCREEN_TRANSP
memset(vdb_buf[1], 0x00, LV_VDB_SIZE_IN_BYTES);
#endif
vdb_state[1] = LV_VDB_STATE_FREE;
}
}
/**
* Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1`
* @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB
*/
lv_vdb_t * lv_vdb_get_inactive(void)
{
#if LV_VDB_DOUBLE == 0
return &vdb;
#else
return &vdb[(vdb_active + 1) & 0x1];
#endif
}
/**
* Whether the flushing is in progress or not
* @return true: flushing is in progress; false: flushing ready
*/
bool lv_vdb_is_flushing(void)
{
return vdb_flushing;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -31,10 +31,15 @@ extern "C" {
#define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/
#ifndef LV_VDB_PX_BPP
#warning "LV_VDB_PX_BPP is not specified in lv_conf.h. Use the default value (LV_COLOR_SIZE)"
#define LV_VDB_PX_BPP LV_COLOR_SIZE
#define LV_VDB_PX_BPP LV_COLOR_SIZE /* Default is LV_COLOR_SIZE */
#endif
#if LV_VDB_TRUE_DOUBLE_BUFFERED && (LV_VDB_SIZE != LV_HOR_RES * LV_VER_RES || LV_VDB_DOUBLE == 0)
#error "With LV_VDB_TRUE_DOUBLE_BUFFERED: (LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES and LV_VDB_DOUBLE = 1 is required"
#endif
/* The size of VDB in bytes.
* (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes
* (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up.
@@ -79,6 +84,24 @@ void lv_vdb_set_adr(void * buf1, void * buf2);
*/
void lv_flush_ready(void);
/**
* Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1`
* @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB
*/
lv_vdb_t * lv_vdb_get_active(void);
/**
* Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1`
* @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB
*/
lv_vdb_t * lv_vdb_get_inactive(void);
/**
* Whether the flushing is in progress or not
* @return true: flushing is in progress; false: flushing ready
*/
bool lv_vdb_is_flushing(void);
/**********************
* MACROS
**********************/

View File

@@ -8,7 +8,7 @@ CSRCS += lv_draw_img.c
CSRCS += lv_draw_arc.c
CSRCS += lv_draw_triangle.c
DEPPATH += --dep-path lvgl/lv_draw
VPATH += :lvgl/lv_draw
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_draw
VPATH += :$(LVGL_DIR)/lvgl/lv_draw
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_draw"

View File

@@ -147,41 +147,48 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf)
{
uint8_t px_size = 0;
switch(cf) {
case LV_IMG_CF_UNKOWN:
case LV_IMG_CF_RAW:
return 0;
px_size = 0;
break;
case LV_IMG_CF_TRUE_COLOR:
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
return LV_COLOR_SIZE;
px_size = LV_COLOR_SIZE;
break;
case LV_IMG_CF_TRUE_COLOR_ALPHA:
return LV_IMG_PX_SIZE_ALPHA_BYTE;
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3;
break;
case LV_IMG_CF_INDEXED_1BIT:
case LV_IMG_CF_ALPHA_1BIT:
return 1;
px_size = 1;
break;
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_ALPHA_2BIT:
return 2;
px_size = 2;
break;
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_ALPHA_4BIT:
return 4;
px_size = 4;
break;
case LV_IMG_CF_INDEXED_8BIT:
case LV_IMG_CF_ALPHA_8BIT:
return 8;
px_size = 8;
break;
default:
return 0;
px_size = 0;
break;
}
return 0;
return px_size;
}
bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
{
bool is_chroma_keyed = false;
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
case LV_IMG_CF_RAW_CHROMA_KEYED:
@@ -189,17 +196,21 @@ bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
case LV_IMG_CF_INDEXED_2BIT:
case LV_IMG_CF_INDEXED_4BIT:
case LV_IMG_CF_INDEXED_8BIT:
return true;
is_chroma_keyed = true;
break;
default:
return false;
is_chroma_keyed = false;
break;
}
return false;
return is_chroma_keyed;
}
bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
{
bool has_alpha = false;
switch(cf) {
case LV_IMG_CF_TRUE_COLOR_ALPHA:
case LV_IMG_CF_RAW_ALPHA:
@@ -207,12 +218,14 @@ bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
case LV_IMG_CF_ALPHA_2BIT:
case LV_IMG_CF_ALPHA_4BIT:
case LV_IMG_CF_ALPHA_8BIT:
return true;
has_alpha = true;
break;
default:
return false;
has_alpha = false;
break;
}
return false;
return has_alpha;
}
/**
@@ -225,20 +238,25 @@ bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
*/
lv_img_src_t lv_img_src_get_type(const void * src)
{
if(src == NULL) return LV_IMG_SRC_UNKNOWN;
lv_img_src_t img_src_type = LV_IMG_SRC_UNKNOWN;
if(src == NULL) return img_src_type;
const uint8_t * u8_p = src;
/*The first byte shows the type of the image source*/
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
return LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
img_src_type = LV_IMG_SRC_FILE; /*If it's an ASCII character then it's file name*/
} else if(u8_p[0] >= 0x80) {
return LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
img_src_type = LV_IMG_SRC_SYMBOL; /*Symbols begins after 0x7F*/
} else {
return LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
img_src_type = LV_IMG_SRC_VARIABLE; /*`lv_img_dsc_t` is design to the first byte < 0x20*/
}
LV_LOG_WARN("lv_img_src_get_type: unknown image type");
return LV_IMG_SRC_UNKNOWN;
if (LV_IMG_SRC_UNKNOWN == img_src_type) {
LV_LOG_WARN("lv_img_src_get_type: unknown image type");
}
return img_src_type;
}
/**
@@ -305,7 +323,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
lv_coord_t width = lv_area_get_width(&mask_com);
#if LV_COMPILER_VLA_SUPPORTED
uint8_t buf[(lv_area_get_width(&mask_com) * (LV_COLOR_SIZE + 1))];
uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))];
#else
uint8_t buf[LV_HOR_RES * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/
#endif
@@ -469,6 +487,7 @@ static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
decoder_header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
uint32_t pos = ((y * decoder_header.w + x) * px_size) >> 3;
pos += 4; /*Skip the header*/
res = lv_fs_seek(&decoder_file, pos);
if(res != LV_FS_RES_OK) {
LV_LOG_WARN("Built-in image decoder seek failed");

View File

@@ -69,15 +69,36 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
w = p.x;
}
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
/*Init variables for the first line*/
lv_coord_t line_width = 0;
uint32_t line_start = 0;
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
lv_point_t pos;
pos.x = coords->x1;
pos.y = coords->y1;
lv_coord_t x_ofs = 0;
lv_coord_t y_ofs = 0;
if(offset != NULL) {
x_ofs = offset->x;
y_ofs = offset->y;
pos.y += y_ofs;
}
uint32_t line_start = 0;
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
/*Go the first visible line*/
while(pos.y + line_height < mask->y1) {
/*Go to next line*/
line_start = line_end;
line_end += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, w, flag);
pos.y += line_height;
if(txt[line_start] == '\0') return;
}
/*Align to middle*/
if(flag & LV_TXT_FLAG_CENTER) {
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
@@ -102,19 +123,12 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
lv_color_t recolor;
lv_coord_t letter_w;
lv_coord_t x_ofs = 0;
lv_coord_t y_ofs = 0;
if(offset != NULL) {
x_ofs = offset->x;
y_ofs = offset->y;
pos.y += y_ofs;
}
/*Real draw need a background color for higher bpp letter*/
#if LV_VDB_SIZE == 0
lv_rletter_set_background(style->body.main_color);
#endif
/*Write out all lines*/
while(txt[line_start] != '\0') {
if(offset != NULL) {
@@ -126,6 +140,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
uint32_t letter;
while(i < line_end) {
letter = lv_txt_encoded_next(txt, &i);
/*Handle the re-color command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(letter == (uint32_t)LV_TXT_COLOR_CMD[0]) {
@@ -170,7 +185,9 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
letter_fp(&pos, mask, font, letter, color, opa);
letter_w = lv_font_get_width(font, letter);
pos.x += letter_w + style->text.letter_space;
if(letter_w > 0){
pos.x += letter_w + style->text.letter_space;
}
}
/*Go to next line*/
line_start = line_end;
@@ -193,8 +210,9 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
}
/*Go the next line position*/
pos.y += lv_font_get_height(font);
pos.y += style->text.line_space;
pos.y += line_height;
if(pos.y > mask->y2) return;
}
}
@@ -209,28 +227,38 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
*/
static uint8_t hex_char_to_num(char hex)
{
uint8_t result = 0;
if(hex >= '0' && hex <= '9') {
return hex - '0';
result = hex - '0';
}
else {
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
switch(hex) {
case 'A':
result = 10;
break;
case 'B':
result = 11;
break;
case 'C':
result = 12;
break;
case 'D':
result = 13;
break;
case 'E':
result = 14;
break;
case 'F':
result = 15;
break;
default:
result = 0;
break;
}
}
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
switch(hex) {
case 'A':
return 10;
case 'B':
return 11;
case 'C':
return 12;
case 'D':
return 13;
case 'E':
return 14;
case 'F':
return 15;
default:
return 0;
}
return 0;
return result;
}

View File

@@ -46,7 +46,7 @@ typedef struct {
**********************/
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
static void line_init(line_draw_t * line, const lv_point_t * p1, const lv_point_t * p2);
static bool line_next(line_draw_t * line);
static bool line_next_y(line_draw_t * line);
@@ -73,7 +73,7 @@ static bool line_next_x(line_draw_t * line);
* @param opa_scale scale down all opacities by the factor
*/
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
const lv_style_t * style, lv_opa_t opa_scale)
const lv_style_t * style, lv_opa_t opa_scale)
{
if(style->line.width == 0) return;
@@ -127,7 +127,44 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
}
/*Arbitrary skew line*/
else {
line_draw_skew(&main_line, mask, style, opa_scale);
bool dir_ori = false;
#if LV_ANTIALIAS
lv_point_t p_tmp;
if(main_line.hor) {
if(main_line.p1.y < main_line.p2.y) {
dir_ori = true;
p_tmp.x = main_line.p2.x;
p_tmp.y = main_line.p2.y - 1;
line_init(&main_line, &p1, &p_tmp);
main_line.sy = LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/
}
else if(main_line.p1.y > main_line.p2.y) {
dir_ori = false;
p_tmp.x = main_line.p2.x;
p_tmp.y = main_line.p2.y + 1;
line_init(&main_line, &p1, &p_tmp);
main_line.sy = -LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/
}
}
else {
if(main_line.p1.x < main_line.p2.x) {
dir_ori = true;
p_tmp.x = main_line.p2.x - 1;
p_tmp.y = main_line.p2.y;
line_init(&main_line, &p1, &p_tmp);
main_line.sx = LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/
}
else if(main_line.p1.x > main_line.p2.x) {
dir_ori = false;
p_tmp.x = main_line.p2.x + 1;
p_tmp.y = main_line.p2.y;
line_init(&main_line, &p1, &p_tmp);
main_line.sx = -LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/
}
}
#endif
line_draw_skew(&main_line, dir_ori, mask, style, opa_scale);
}
}
@@ -137,7 +174,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
**********************/
static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_coord_t width = style->line.width - 1;
lv_coord_t width_half = width >> 1;
@@ -145,10 +182,10 @@ static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_s
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
lv_area_t act_area;
act_area.x1 = line->p1.x;
act_area.x2 = line->p2.x;
act_area.y1 = line->p1.y - width_half - width_1;
act_area.y2 = line->p2.y + width_half ;
act_area.x1 = main_line->p1.x;
act_area.x2 = main_line->p2.x;
act_area.y1 = main_line->p1.y - width_half - width_1;
act_area.y2 = main_line->p2.y + width_half ;
lv_area_t draw_area;
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
@@ -158,7 +195,7 @@ static void line_draw_hor(line_draw_t * line, const lv_area_t * mask, const lv_s
fill_fp(&draw_area, mask, style->line.color, opa);
}
static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_coord_t width = style->line.width - 1;
lv_coord_t width_half = width >> 1;
@@ -167,10 +204,10 @@ static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_s
lv_area_t act_area;
act_area.x1 = line->p1.x - width_half;
act_area.x2 = line->p2.x + width_half + width_1;
act_area.y1 = line->p1.y;
act_area.y2 = line->p2.y;
act_area.x1 = main_line->p1.x - width_half;
act_area.x2 = main_line->p2.x + width_half + width_1;
act_area.y1 = main_line->p1.y;
act_area.y2 = main_line->p2.y;
lv_area_t draw_area;
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
@@ -180,7 +217,7 @@ static void line_draw_ver(line_draw_t * line, const lv_area_t * mask, const lv_s
fill_fp(&draw_area, mask, style->line.color, opa);
}
static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
{
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
@@ -190,7 +227,7 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
vect_main.y = main_line->p2.y - main_line->p1.y;
if(main_line->hor) {
if(main_line->p1.y < main_line->p2.y) {
if(main_line->p1.y < main_line->p2.y + dir_ori) {
vect_norm.x = - vect_main.y;
vect_norm.y = vect_main.x;
} else {
@@ -198,7 +235,7 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
vect_norm.y = -vect_main.x;
}
} else {
if(main_line->p1.x < main_line->p2.x) {
if(main_line->p1.x < main_line->p2.x + dir_ori) {
vect_norm.x = vect_main.y;
vect_norm.y = - vect_main.x;
} else {
@@ -242,16 +279,12 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
width = i;
#if LV_ANTIALIAS
width--;
#endif
break;
}
line_next(&pattern_line);
}
} else {
pattern[0].x = 0;
pattern[0].y = 0;
}
#if LV_ANTIALIAS
@@ -262,10 +295,22 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
aa_last_corner = 0;
#endif
lv_coord_t x_center_ofs = 0;
lv_coord_t y_center_ofs = 0;
if(width != 0) {
x_center_ofs = pattern[width - 1].x / 2;
y_center_ofs = pattern[width - 1].y / 2;
}
else {
if(main_line->hor && main_line->p1.y >= main_line->p2.y + dir_ori) pattern[0].y --;
if(!main_line->hor && main_line->p1.x >= main_line->p2.x + dir_ori) pattern[0].x --;
}
/* Make the coordinates relative to the center */
for(i = 0; i < width; i++) {
pattern[i].x -= pattern[width - 1].x / 2;
pattern[i].y -= pattern[width - 1].y / 2;
pattern[i].x -= x_center_ofs;
pattern[i].y -= y_center_ofs;
#if LV_ANTIALIAS
if(i != 0) {
if(main_line->hor) {
@@ -273,16 +318,16 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
lv_coord_t seg_w = pattern[i].y - pattern[aa_last_corner].y;
if(main_line->sy < 0) {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w + 1,
seg_w, mask, style->line.color, opa);
seg_w, mask, style->line.color, opa);
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w + 1,
-seg_w, mask, style->line.color, opa);
-seg_w, mask, style->line.color, opa);
} else {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
seg_w, mask, style->line.color, opa);
seg_w, mask, style->line.color, opa);
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
-seg_w, mask, style->line.color, opa);
-seg_w, mask, style->line.color, opa);
}
aa_last_corner = i;
}
@@ -291,16 +336,16 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
lv_coord_t seg_w = pattern[i].x - pattern[aa_last_corner].x;
if(main_line->sx < 0) {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w, mask, style->line.color, opa);
seg_w, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p2.y + pattern[aa_last_corner].y + 1,
-seg_w, mask, style->line.color, opa);
-seg_w, mask, style->line.color, opa);
} else {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w, mask, style->line.color, opa);
seg_w, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
-seg_w, mask, style->line.color, opa);
-seg_w, mask, style->line.color, opa);
}
aa_last_corner = i;
}
@@ -314,39 +359,41 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#if LV_ANTIALIAS
/*Add the last part of anti-aliasing for the perpendicular ending*/
if(main_line->hor) {
lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y;
if(main_line->sy < 0) {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w,
seg_w + main_line->sy, mask, style->line.color, opa);
if(width != 0) { /*Due to rounding error with very thin lines it looks ugly*/
if(main_line->hor) {
lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y;
if(main_line->sy < 0) {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w,
seg_w + main_line->sy, mask, style->line.color, opa);
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w,
-(seg_w + main_line->sy), mask, style->line.color, opa);
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w,
-(seg_w + main_line->sy), mask, style->line.color, opa);
} else {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
seg_w + main_line->sy, mask, style->line.color, opa);
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
-(seg_w + main_line->sy), mask, style->line.color, opa);
}
} else {
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
seg_w + main_line->sy, mask, style->line.color, opa);
lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x;
if(main_line->sx < 0) {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w + main_line->sx, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, main_line->p2.y + pattern[aa_last_corner].y + 1,
-(seg_w + main_line->sx), mask, style->line.color, opa);
} else {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w + main_line->sx, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
-(seg_w + main_line->sx), mask, style->line.color, opa);
}
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
-(seg_w + main_line->sy), mask, style->line.color, opa);
}
} else {
lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x;
if(main_line->sx < 0) {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w + main_line->sx, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, main_line->p2.y + pattern[aa_last_corner].y + 1,
-(seg_w + main_line->sx), mask, style->line.color, opa);
} else {
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
seg_w + main_line->sx, mask, style->line.color, opa);
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
-(seg_w + main_line->sx), mask, style->line.color, opa);
}
}
#endif
@@ -376,7 +423,6 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#endif
volatile lv_point_t prev_p;
prev_p.x = main_line->p1.x;
prev_p.y = main_line->p1.y;
@@ -401,9 +447,9 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#if LV_ANTIALIAS
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
#endif
first_run = false;
@@ -428,9 +474,9 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#if LV_ANTIALIAS
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
#endif
}
/*Rather a vertical line*/
@@ -455,9 +501,9 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#if LV_ANTIALIAS
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
#endif
first_run = false;
@@ -484,9 +530,9 @@ static void line_draw_skew(line_draw_t * main_line, const lv_area_t * mask, cons
#if LV_ANTIALIAS
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
#endif
}
}

View File

@@ -71,7 +71,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
lv_draw_shadow(coords, mask, style, opa_scale);
}
#endif
if(style->body.empty == 0) {
if(style->body.empty == 0 && style->body.opa >= LV_OPA_MIN) {
lv_draw_rect_main_mid(coords, mask, style, opa_scale);
if(style->body.radius != 0) {
@@ -79,7 +79,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
}
}
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE) {
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE && style->body.border.opa >= LV_OPA_MIN) {
lv_draw_rect_border_straight(coords, mask, style, opa_scale);
if(style->body.radius != 0) {

View File

@@ -30,6 +30,10 @@
*********************/
#define VFILL_HW_ACC_SIZE_LIMIT 50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
/**********************
* TYPEDEFS
**********************/
@@ -147,7 +151,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
#if USE_LV_GPU
static lv_color_t color_array_tmp[LV_HOR_RES]; /*Used by 'lv_disp_mem_blend'*/
static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES]; /*Used by 'lv_disp_mem_blend'*/
static lv_coord_t last_width = -1;
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
@@ -445,7 +449,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
lv_coord_t col;
for(row = masked_a.y1; row <= masked_a.y2; row++) {
for(col = 0; col < map_useful_w; col++) {
lv_color_t px_color = (lv_color_t) * ((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
}
map_p += map_width * px_size_byte; /*Next row on the map*/
@@ -483,7 +487,7 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
/*Calculate with the pixel level alpha*/
if(alpha_byte) {
#if LV_COLOR_DEPTH == 8
#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1
px_color.full = px_color_p[0];
#elif LV_COLOR_DEPTH == 16
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
@@ -529,21 +533,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
#else
vdb_buf_tmp[col] = color_mix_2_alpha(vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result);
// if(vdb_buf_tmp[col].alpha == LV_OPA_TRANSP) {
// /* When it is the first visible pixel on the transparent screen
// * simlply use this color and set the pixel opa as backrounds alpha*/
// vdb_buf_tmp[col] = px_color;
// vdb_buf_tmp[col].alpha = opa_result;
// } else {
// /* If already this pixel is already written then for performance reasons
// * don't care with alpha channel
// */
// lv_opa_t bg_opa = vdb_buf_tmp[col].alpha;
// vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
//
// uint16_t opa_tmp = (uint16_t)opa_result + ((bg_opa * (255 - opa_result)) >> 8);
// vdb_buf_tmp[col].alpha = opa_tmp > 0xFF ? 0xFF : opa_tmp ;
// }
#endif
}
}
@@ -680,7 +669,7 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
/*Save the parameters and the result. If they will be asked again don't compute again*/
static lv_opa_t fg_opa_save = 0;
static lv_opa_t bg_opa_save = 0;
static lv_color_t c = {0};
static lv_color_t c = {{0}};
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save) {
fg_opa_save = fg_opa;

View File

@@ -76,12 +76,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
lv_color_t recolor, lv_opa_t recolor_opa);
/**
* Reallocate 'color_map_tmp' to the new hor. res. size. It is used in 'sw_fill'
*/
void lv_vdraw_refresh_temp_arrays(void);
/**********************
* MACROS
**********************/

View File

@@ -125,7 +125,7 @@ void lv_font_builtin_init(void)
#if USE_LV_FONT_DEJAVU_30 != 0
lv_font_add(&lv_font_symbol_30, &lv_font_dejavu_30);
#else
lv_font_add(&lv_font_symbol_30_basic, NULL);
lv_font_add(&lv_font_symbol_30, NULL);
#endif
#endif

View File

@@ -48,74 +48,74 @@ void lv_font_builtin_init(void);
/*10 px */
#if USE_LV_FONT_DEJAVU_10
LV_FONT_DECLARE(lv_font_dejavu_10);
LV_FONT_DECLARE(lv_font_dejavu_10)
#endif
#if USE_LV_FONT_DEJAVU_10_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_10_latin_sup);
LV_FONT_DECLARE(lv_font_dejavu_10_latin_sup)
#endif
#if USE_LV_FONT_DEJAVU_10_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_10_cyrillic);
LV_FONT_DECLARE(lv_font_dejavu_10_cyrillic)
#endif
#if USE_LV_FONT_SYMBOL_10
LV_FONT_DECLARE(lv_font_symbol_10);
LV_FONT_DECLARE(lv_font_symbol_10)
#endif
/*20 px */
#if USE_LV_FONT_DEJAVU_20
LV_FONT_DECLARE(lv_font_dejavu_20);
LV_FONT_DECLARE(lv_font_dejavu_20)
#endif
#if USE_LV_FONT_DEJAVU_20_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_20_latin_sup);
LV_FONT_DECLARE(lv_font_dejavu_20_latin_sup)
#endif
#if USE_LV_FONT_DEJAVU_20_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_20_cyrillic);
LV_FONT_DECLARE(lv_font_dejavu_20_cyrillic)
#endif
#if USE_LV_FONT_SYMBOL_20
LV_FONT_DECLARE(lv_font_symbol_20);
LV_FONT_DECLARE(lv_font_symbol_20)
#endif
/*30 px */
#if USE_LV_FONT_DEJAVU_30
LV_FONT_DECLARE(lv_font_dejavu_30);
LV_FONT_DECLARE(lv_font_dejavu_30)
#endif
#if USE_LV_FONT_DEJAVU_30_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_30_latin_sup);
LV_FONT_DECLARE(lv_font_dejavu_30_latin_sup)
#endif
#if USE_LV_FONT_DEJAVU_30_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_30_cyrillic);
LV_FONT_DECLARE(lv_font_dejavu_30_cyrillic)
#endif
#if USE_LV_FONT_SYMBOL_30
LV_FONT_DECLARE(lv_font_symbol_30);
LV_FONT_DECLARE(lv_font_symbol_30)
#endif
/*40 px */
#if USE_LV_FONT_DEJAVU_40
LV_FONT_DECLARE(lv_font_dejavu_40);
LV_FONT_DECLARE(lv_font_dejavu_40)
#endif
#if USE_LV_FONT_DEJAVU_40_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_40_latin_sup);
LV_FONT_DECLARE(lv_font_dejavu_40_latin_sup)
#endif
#if USE_LV_FONT_DEJAVU_40_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic);
LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic)
#endif
#if USE_LV_FONT_SYMBOL_40
LV_FONT_DECLARE(lv_font_symbol_40);
LV_FONT_DECLARE(lv_font_symbol_40)
#endif
#if USE_LV_FONT_MONOSPACE_8
LV_FONT_DECLARE(lv_font_monospace_8);
LV_FONT_DECLARE(lv_font_monospace_8)
#endif
#ifdef __cplusplus

View File

@@ -2836,13 +2836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_10_glyph_dsc[] = {
};
lv_font_t lv_font_symbol_10 = {
#if LV_TXT_UTF8
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#else
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#endif
.h_px = 10, /*Font height in pixels*/
.glyph_bitmap = lv_font_symbol_10_glyph_bitmap, /*Bitmap of glyphs*/
.glyph_dsc = lv_font_symbol_10_glyph_dsc, /*Description of glyphs*/

View File

@@ -4836,13 +4836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_20_glyph_dsc[] = {
};
lv_font_t lv_font_symbol_20 = {
#if LV_TXT_UTF8
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#else
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#endif
.h_px = 20, /*Font height in pixels*/
.glyph_bitmap = lv_font_symbol_20_glyph_bitmap, /*Bitmap of glyphs*/
.glyph_dsc = lv_font_symbol_20_glyph_dsc, /*Description of glyphs*/

View File

@@ -6835,13 +6835,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_30_glyph_dsc[] = {
#endif
};
lv_font_t lv_font_symbol_30 = {
#if LV_TXT_UTF8
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#else
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#endif
.h_px = 30, /*Font height in pixels*/
.glyph_bitmap = lv_font_symbol_30_glyph_bitmap, /*Bitmap of glyphs*/
.glyph_dsc = lv_font_symbol_30_glyph_dsc, /*Description of glyphs*/

View File

@@ -8836,13 +8836,8 @@ static const lv_font_glyph_dsc_t lv_font_symbol_40_glyph_dsc[] = {
};
lv_font_t lv_font_symbol_40 = {
#if LV_TXT_UTF8
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#else
.unicode_first = LV_SYMBOL_GLYPH_FIRST, /*First Unicode letter in this font*/
.unicode_last = LV_SYMBOL_GLYPH_LAST, /*Last Unicode letter in this font*/
#endif
.h_px = 40, /*Font height in pixels*/
.glyph_bitmap = lv_font_symbol_40_glyph_bitmap, /*Bitmap of glyphs*/
.glyph_dsc = lv_font_symbol_40_glyph_dsc, /*Description of glyphs*/

View File

@@ -15,8 +15,9 @@ CSRCS += lv_font_symbol_10.c
CSRCS += lv_font_symbol_20.c
CSRCS += lv_font_symbol_30.c
CSRCS += lv_font_symbol_40.c
CSRCS += lv_font_monospace_8.c
DEPPATH += --dep-path lvgl/lv_fonts
VPATH += :lvgl/lv_fonts
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_fonts
VPATH += :$(LVGL_DIR)/lvgl/lv_fonts
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_fonts"

View File

@@ -2,7 +2,7 @@ CSRCS += lv_hal_disp.c
CSRCS += lv_hal_indev.c
CSRCS += lv_hal_tick.c
DEPPATH += --dep-path lvgl/lv_hal
VPATH += :lvgl/lv_hal
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_hal
VPATH += :$(LVGL_DIR)/lvgl/lv_hal
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_hal"

View File

@@ -14,6 +14,12 @@
#include "../lv_hal/lv_hal_disp.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -30,7 +36,6 @@
/**********************
* STATIC VARIABLES
**********************/
static lv_disp_t * disp_list = NULL;
static lv_disp_t * active;
/**********************
@@ -81,12 +86,12 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
node->next = NULL;
/* Set first display as active by default */
if(disp_list == NULL) {
disp_list = node;
if(LV_GC_ROOT(_lv_disp_list) == NULL) {
LV_GC_ROOT(_lv_disp_list) = node;
active = node;
lv_obj_invalidate(lv_scr_act());
} else {
disp_list->next = node;
((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next = node;
}
return node;
@@ -120,10 +125,10 @@ lv_disp_t * lv_disp_get_active(void)
lv_disp_t * lv_disp_next(lv_disp_t * disp)
{
if(disp == NULL) {
return disp_list;
return LV_GC_ROOT(_lv_disp_list);
} else {
if(disp_list->next == NULL) return NULL;
else return disp_list->next;
if(((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next == NULL) return NULL;
else return ((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next;
}
}

View File

@@ -10,6 +10,12 @@
*********************/
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -22,7 +28,6 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_indev_t * indev_list = NULL;
/**********************
* STATIC VARIABLES
@@ -70,10 +75,10 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
node->group = NULL;
node->btn_points = NULL;
if(indev_list == NULL) {
indev_list = node;
if(LV_GC_ROOT(_lv_indev_list) == NULL) {
LV_GC_ROOT(_lv_indev_list) = node;
} else {
lv_indev_t * last = indev_list;
lv_indev_t * last = LV_GC_ROOT(_lv_indev_list);
while(last->next)
last = last->next;
@@ -92,7 +97,7 @@ lv_indev_t * lv_indev_next(lv_indev_t * indev)
{
if(indev == NULL) {
return indev_list;
return LV_GC_ROOT(_lv_indev_list);
} else {
if(indev->next == NULL) return NULL;
else return indev->next;
@@ -109,6 +114,9 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
{
bool cont = false;
memset(data, 0, sizeof(lv_indev_data_t));
data->state = LV_INDEV_STATE_REL;
if(indev->driver.read) {
data->user_data = indev->driver.user_data;
@@ -117,7 +125,6 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
LV_LOG_TRACE("idnev read finished");
} else {
LV_LOG_WARN("indev function registered");
memset(data, 0, sizeof(lv_indev_data_t));
}
return cont;

View File

@@ -19,6 +19,7 @@ extern "C" {
#include <stdint.h>
#include "lv_hal.h"
#include "../lv_misc/lv_area.h"
#include "../lv_core/lv_obj.h"
/*********************
* DEFINES
@@ -98,6 +99,9 @@ typedef struct _lv_indev_proc_t {
uint8_t disabled :1;
} lv_indev_proc_t;
struct _lv_indev_t;
typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, lv_signal_t);
struct _lv_obj_t;
struct _lv_group_t;
@@ -106,11 +110,12 @@ struct _lv_group_t;
typedef struct _lv_indev_t {
lv_indev_drv_t driver;
lv_indev_proc_t proc;
lv_indev_feedback_t feedback;
uint32_t last_activity_time;
union {
struct _lv_obj_t *cursor; /*Cursor for LV_INPUT_TYPE_POINTER*/
struct _lv_group_t *group; /*Keypad destination group*/
lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
};
struct _lv_indev_t *next;

View File

@@ -75,7 +75,7 @@ uint32_t lv_tick_get(void)
}
/**
* Get the elapsed milliseconds science a previous time stamp
* Get the elapsed milliseconds since a previous time stamp
* @param prev_tick a previous time stamp (return value of systick_get() )
* @return the elapsed milliseconds since 'prev_tick'
*/

View File

@@ -49,7 +49,7 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period);
uint32_t lv_tick_get(void);
/**
* Get the elapsed milliseconds science a previous time stamp
* Get the elapsed milliseconds since a previous time stamp
* @param prev_tick a previous time stamp (return value of systick_get() )
* @return the elapsed milliseconds since 'prev_tick'
*/

View File

@@ -14,6 +14,12 @@
#include "../lv_hal/lv_hal_tick.h"
#include "lv_task.h"
#include "lv_math.h"
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -34,7 +40,6 @@ static bool anim_ready_handler(lv_anim_t * a);
/**********************
* STATIC VARIABLES
**********************/
static lv_ll_t anim_ll;
static uint32_t last_task_run;
static bool anim_list_changed;
@@ -51,7 +56,7 @@ static bool anim_list_changed;
*/
void lv_anim_init(void)
{
lv_ll_init(&anim_ll, sizeof(lv_anim_t));
lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t));
last_task_run = lv_tick_get();
lv_task_create(anim_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
}
@@ -67,7 +72,7 @@ void lv_anim_create(lv_anim_t * anim_p)
if(anim_p->fp != NULL) lv_anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
/*Add the new animation to the animation linked list*/
lv_anim_t * new_anim = lv_ll_ins_head(&anim_ll);
lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
lv_mem_assert(new_anim);
if(new_anim == NULL) return;
@@ -97,13 +102,13 @@ bool lv_anim_del(void * var, lv_anim_fp_t fp)
lv_anim_t * a;
lv_anim_t * a_next;
bool del = false;
a = lv_ll_get_head(&anim_ll);
a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
while(a != NULL) {
/*'a' might be deleted, so get the next object while 'a' is valid*/
a_next = lv_ll_get_next(&anim_ll, a);
a_next = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
if(a->var == var && (a->fp == fp || fp == NULL)) {
lv_ll_rem(&anim_ll, a);
lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a);
anim_list_changed = true; /*Read by `anim_task`. It need to know if a delete occurred in the linked list*/
del = true;
@@ -115,6 +120,19 @@ bool lv_anim_del(void * var, lv_anim_fp_t fp)
return del;
}
/**
* Get the number of currently running animations
* @return the number of running animations
*/
uint16_t lv_anim_count_running(void)
{
uint16_t cnt = 0;
lv_anim_t * a;
LL_READ(LV_GC_ROOT(_lv_anim_ll), a) cnt++;
return cnt++;
}
/**
* Calculate the time of an animation with a given speed and the start and end values
* @param speed speed of animation in unit/sec
@@ -144,7 +162,6 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
int32_t lv_anim_path_linear(const lv_anim_t * a)
{
/*Calculate the current step*/
uint16_t step;
if(a->time == a->act_time) step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
else step = (a->act_time * LV_ANIM_RESOLUTION) / a->time;
@@ -159,6 +176,53 @@ int32_t lv_anim_path_linear(const lv_anim_t * a)
return new_value;
}
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_in(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = lv_bezier3(t, 0, 1, 1, 1024);
int32_t new_value;
new_value = (int32_t) step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return new_value;
}
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_out(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = lv_bezier3(t, 0, 1023, 1023, 1024);
int32_t new_value;
new_value = (int32_t) step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return new_value;
}
/**
* Calculate the current value of an animation applying an "S" characteristic (cosine)
* @param a pointer to an animation
@@ -183,6 +247,91 @@ int32_t lv_anim_path_ease_in_out(const lv_anim_t * a)
return new_value;
}
/**
* Calculate the current value of an animation with overshoot at the end
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_overshoot(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = lv_bezier3(t, 0, 600, 1300, 1024);
int32_t new_value;
new_value = (int32_t) step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return new_value;
}
/**
* Calculate the current value of an animation with 3 bounces
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_bounce(const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time) t = 1024;
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t diff = (a->end - a->start);
/*3 bounces has 5 parts: 3 down and 2 up. One part is t / 5 long*/
if(t < 408){
/*Go down*/
t = (t * 2500) >> 10; /*[0..1024] range*/
}
else if(t >= 408 && t < 614) {
/*First bounce back*/
t -= 408;
t = t * 5; /*to [0..1024] range*/
t = 1024 - t;
diff = diff / 6;
}
else if(t >= 614 && t < 819) {
/*Fall back*/
t -= 614;
t = t * 5; /*to [0..1024] range*/
diff = diff / 6;
}
else if(t >= 819 && t < 921) {
/*Second bounce back*/
t -= 819;
t = t * 10; /*to [0..1024] range*/
t = 1024 - t;
diff = diff / 16;
}
else if(t >= 921 && t <= 1024) {
/*Fall back*/
t -= 921;
t = t * 10; /*to [0..1024] range*/
diff = diff / 16;
}
if(t > 1024) t = 1024;
int32_t step = lv_bezier3(t, 1024, 1024, 800, 0);
int32_t new_value;
new_value = (int32_t) step * diff;
new_value = new_value >> 10;
new_value = a->end - new_value;
return new_value;
}
/**
* Calculate the current value of an animation applying step characteristic.
* (Set end value on the end of the animation)
@@ -208,12 +357,12 @@ static void anim_task(void * param)
(void)param;
lv_anim_t * a;
LL_READ(anim_ll, a) {
LL_READ(LV_GC_ROOT(_lv_anim_ll), a) {
a->has_run = 0;
}
uint32_t elaps = lv_tick_elaps(last_task_run);
a = lv_ll_get_head(&anim_ll);
a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
while(a != NULL) {
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete happened in `anim_ready_handler`
@@ -241,8 +390,8 @@ static void anim_task(void * param)
/* If the linked list changed due to anim. delete then it's not safe to continue
* the reading of the list from here -> start from the head*/
if(anim_list_changed) a = lv_ll_get_head(&anim_ll);
else a = lv_ll_get_next(&anim_ll, a);
if(anim_list_changed) a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
else a = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
}
last_task_run = lv_tick_get();
@@ -252,7 +401,7 @@ static void anim_task(void * param)
* Called when an animation is ready to do the necessary thinks
* e.g. repeat, play back, delete etc.
* @param a pointer to an animation descriptor
* @return true: animation delete occurred nnd the `anim_ll` has changed
* @return true: animation delete occurred nnd the `LV_GC_ROOT(_lv_anim_ll)` has changed
* */
static bool anim_ready_handler(lv_anim_t * a)
{
@@ -264,8 +413,9 @@ static bool anim_ready_handler(lv_anim_t * a)
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
void (*cb)(void *) = a->end_cb;
void * p = a->var;
lv_ll_rem(&anim_ll, a);
lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a);
anim_list_changed = true;
/* Call the callback function at the end*/
/* Check if an animation is deleted in the cb function

View File

@@ -99,6 +99,12 @@ void lv_anim_create(lv_anim_t * anim_p);
*/
bool lv_anim_del(void * var, lv_anim_fp_t fp);
/**
* Get the number of currently running animations
* @return the number of running animations
*/
uint16_t lv_anim_count_running(void);
/**
* Calculate the time of an animation with a given speed and the start and end values
* @param speed speed of animation in unit/sec
@@ -115,6 +121,19 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
*/
int32_t lv_anim_path_linear(const lv_anim_t *a);
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_in(const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_ease_out(const lv_anim_t * a);
/**
* Calculate the current value of an animation applying an "S" characteristic (cosine)
@@ -123,6 +142,20 @@ int32_t lv_anim_path_linear(const lv_anim_t *a);
*/
int32_t lv_anim_path_ease_in_out(const lv_anim_t *a);
/**
* Calculate the current value of an animation with overshoot at the end
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_overshoot(const lv_anim_t * a);
/**
* Calculate the current value of an animation with 3 bounces
* @param a pointer to an animation
* @return the current value to set
*/
int32_t lv_anim_path_bounce(const lv_anim_t * a);
/**
* Calculate the current value of an animation applying step characteristic.
* (Set end value on the end of the animation)

View File

@@ -8,7 +8,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_area.h"
#include "lv_circ.h"
/*********************
* DEFINES

View File

@@ -57,19 +57,21 @@ extern "C" {
#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80,0x00,0x80)
#define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF,0xA5,0x00)
#define LV_OPA_TRANSP 0
#define LV_OPA_0 0
#define LV_OPA_10 25
#define LV_OPA_20 51
#define LV_OPA_30 76
#define LV_OPA_40 102
#define LV_OPA_50 127
#define LV_OPA_60 153
#define LV_OPA_70 178
#define LV_OPA_80 204
#define LV_OPA_90 229
#define LV_OPA_100 255
#define LV_OPA_COVER 255
enum {
LV_OPA_TRANSP = 0,
LV_OPA_0 = 0,
LV_OPA_10 = 25,
LV_OPA_20 = 51,
LV_OPA_30 = 76,
LV_OPA_40 = 102,
LV_OPA_50 = 127,
LV_OPA_60 = 153,
LV_OPA_70 = 178,
LV_OPA_80 = 204,
LV_OPA_90 = 229,
LV_OPA_100 = 255,
LV_OPA_COVER = 255,
};
#define LV_OPA_MIN 16 /*Opacities below this will be transparent*/
#define LV_OPA_MAX 251 /*Opacities above this will fully cover*/
@@ -390,14 +392,23 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
#endif
#endif
#define LV_COLOR_HEX(c) LV_COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \
((uint32_t)((uint32_t)c >> 8) & 0xFF), \
((uint32_t) c & 0xFF))
#define LV_COLOR_HEX(c) LV_COLOR_MAKE((uint8_t) ((uint32_t)((uint32_t)c >> 16) & 0xFF), \
(uint8_t) ((uint32_t)((uint32_t)c >> 8) & 0xFF), \
(uint8_t) ((uint32_t) c & 0xFF))
/*Usage LV_COLOR_HEX3(0x16C) which means LV_COLOR_HEX(0x1166CC)*/
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
(uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
(uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
static inline lv_color_t lv_color_hex(uint32_t c){
return LV_COLOR_HEX(c);
}
static inline lv_color_t lv_color_hex3(uint32_t c){
return LV_COLOR_HEX3(c);
}
/**

View File

@@ -47,10 +47,9 @@ void lv_font_init(void)
}
/**
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
* @param name name of the font
* @param dsc_get_fp the font descriptor get function
* @param parent add this font as charter set extension of 'parent'
* Add a font to an other to extend the character set.
* @param child the font to add
* @param parent this font will be extended. Using it later will contain the characters from `child`
*/
void lv_font_add(lv_font_t * child, lv_font_t * parent)
{
@@ -64,6 +63,24 @@ void lv_font_add(lv_font_t * child, lv_font_t * parent)
}
/**
* Remove a font from a character set.
* @param child the font to remove
* @param parent remove `child` from here
*/
void lv_font_remove(lv_font_t * child, lv_font_t * parent)
{
if(parent == NULL) return;
if(child == NULL) return;
while(parent->next_page != child) {
parent = parent->next_page; /*Got to the last page and add the new font there*/
}
parent->next_page = child->next_page;
}
/**
* Tells if font which contains `letter` is monospace or not
* @param font_p point to font

View File

@@ -72,12 +72,19 @@ typedef struct _lv_font_struct
void lv_font_init(void);
/**
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
* @param child pointer to a font to join to the 'parent'
* @param parent pointer to a font. 'child' will be joined here
* Add a font to an other to extend the character set.
* @param child the font to add
* @param parent this font will be extended. Using it later will contain the characters from `child`
*/
void lv_font_add(lv_font_t *child, lv_font_t *parent);
/**
* Remove a font from a character set.
* @param child the font to remove
* @param parent remove `child` from here
*/
void lv_font_remove(lv_font_t * child, lv_font_t * parent);
/**
* Tells if font which contains `letter` is monospace or not
* @param font_p point to font

View File

@@ -11,11 +11,24 @@
#include "lv_ll.h"
#include <string.h>
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
*********************/
/* "free" is used as a function pointer (in lv_fs_drv_t).
* We must make sure "free" was not defined to a platform specific
* free function, otherwise compilation would fail.
*/
#ifdef free
#undef free
#endif
/**********************
* TYPEDEFS
**********************/
@@ -30,7 +43,6 @@ static lv_fs_drv_t * lv_fs_get_drv(char letter);
/**********************
* STATIC VARIABLES
**********************/
static lv_ll_t drv_ll;
/**********************
* MACROS
@@ -45,10 +57,24 @@ static lv_ll_t drv_ll;
*/
void lv_fs_init(void)
{
lv_ll_init(&drv_ll, sizeof(lv_fs_drv_t));
lv_ll_init(&LV_GC_ROOT(_lv_drv_ll), sizeof(lv_fs_drv_t));
}
/**
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be returned.
* @param letter letter of the drive
* @return true: drive is ready; false: drive is not ready
*/
bool lv_fs_is_ready(char letter)
{
lv_fs_drv_t * drv = lv_fs_get_drv(letter);
if(drv == NULL) return false; /*An unknown driver in not ready*/
if(drv->ready == NULL) return true; /*Assume the driver is always ready if no handler provided*/
return drv->ready();
}
/**
* Open a file
@@ -449,7 +475,7 @@ void lv_fs_add_drv(lv_fs_drv_t * drv_p)
{
/*Save the new driver*/
lv_fs_drv_t * new_drv;
new_drv = lv_ll_ins_head(&drv_ll);
new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
lv_mem_assert(new_drv);
if(new_drv == NULL) return;
@@ -466,7 +492,7 @@ char * lv_fs_get_letters(char * buf)
lv_fs_drv_t * drv;
uint8_t i = 0;
LL_READ(drv_ll, drv) {
LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
buf[i] = drv->letter;
i++;
}
@@ -520,7 +546,7 @@ char * lv_fs_up(char * path)
if(path[i] == '/' || path[i] == '\\') break;
}
path[i] = '\0';
if(i > 0) path[i] = '\0';
return path;
}
@@ -589,7 +615,7 @@ static lv_fs_drv_t * lv_fs_get_drv(char letter)
{
lv_fs_drv_t * drv;
LL_READ(drv_ll, drv) {
LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
if(drv->letter == letter) {
return drv;
}

View File

@@ -113,6 +113,13 @@ void lv_fs_init(void);
*/
void lv_fs_add_drv(lv_fs_drv_t * drv_p);
/**
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be returned.
* @param letter letter of the drive
* @return true: drive is ready; false: drive is not ready
*/
bool lv_fs_is_ready(char letter);
/**
* Open a file
* @param file_p pointer to a lv_fs_file_t variable

40
lv_misc/lv_gc.c Normal file
View File

@@ -0,0 +1,40 @@
/**
* @file lv_gc.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_gc.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
#if (!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0
LV_ROOTS
#endif /* LV_ENABLE_GC */
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/

77
lv_misc/lv_gc.h Normal file
View File

@@ -0,0 +1,77 @@
/**
* @file lv_gc.h
*
*/
#ifndef LV_GC_H
#define LV_GC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#include <stdint.h>
#include <stdbool.h>
#include "lv_mem.h"
#include "lv_ll.h"
/*********************
* DEFINES
*********************/
#define LV_GC_ROOTS(prefix) \
prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \
prefix lv_ll_t _lv_scr_ll; /*Linked list of screens*/ \
prefix lv_ll_t _lv_drv_ll;\
prefix lv_ll_t _lv_file_ll;\
prefix lv_ll_t _lv_anim_ll;\
prefix void * _lv_def_scr;\
prefix void * _lv_act_scr;\
prefix void * _lv_top_layer;\
prefix void * _lv_sys_layer;\
prefix void * _lv_task_act;\
prefix void * _lv_indev_list;\
prefix void * _lv_disp_list;\
#define LV_NO_PREFIX
#define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX)
#if LV_ENABLE_GC == 1
# if LV_MEM_CUSTOM != 1
# error "GC requires CUSTOM_MEM"
# endif /* LV_MEM_CUSTOM */
#else /* LV_ENABLE_GC */
# define LV_GC_ROOT(x) x
LV_GC_ROOTS(extern)
#endif /* LV_ENABLE_GC */
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_GC_H*/

View File

@@ -45,27 +45,27 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex
/**
* Initialize linked list
* @param ll_dsc pointer to ll_dsc variable
* @param n_size the size of 1 node in bytes
* @param node_size the size of 1 node in bytes
*/
void lv_ll_init(lv_ll_t * ll_p, uint32_t n_size)
void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size)
{
ll_p->head = NULL;
ll_p->tail = NULL;
#ifdef LV_MEM_ENV64
/*Round the size up to 8*/
if(n_size & 0x7) {
n_size = n_size & (~0x7);
n_size += 8;
if(node_size & 0x7) {
node_size = node_size & (~0x7);
node_size += 8;
}
#else
/*Round the size up to 4*/
if(n_size & 0x3) {
n_size = n_size & (~0x3);
n_size += 4;
if(node_size & 0x3) {
node_size = node_size & (~0x3);
node_size += 4;
}
#endif
ll_p->n_size = n_size;
ll_p->n_size = node_size;
}
/**
@@ -157,7 +157,7 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p)
/**
* Remove the node 'node_p' from 'll_p' linked list.
* It Dose not free the the memory of node.
* It does not free the the memory of node.
* @param ll_p pointer to the linked list of 'node_p'
* @param node_p pointer to node in 'll_p' linked list
*/
@@ -321,7 +321,10 @@ void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
if(n_act == n_after) return; /*Can't move before itself*/
void * n_before = lv_ll_get_prev(ll_p, n_after);
void * n_before;
if(n_after != NULL) n_before = lv_ll_get_prev(ll_p, n_after);
else n_before = lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/
if(n_act == n_before) return; /*Already before `n_after`*/
/*It's much easier to remove from the list and add again*/

View File

@@ -72,7 +72,7 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p);
/**
* Remove the node 'node_p' from 'll_p' linked list.
* It Dose not free the the memory of node.
* It does not free the the memory of node.
* @param ll_p pointer to the linked list of 'node_p'
* @param node_p pointer to node in 'll_p' linked list
*/

View File

@@ -54,7 +54,7 @@ void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const
* @param line line number in the source code where the log added
* @param dsc description of the log
*/
void lv_log_add(lv_log_level_t level, const char * file, uint32_t line, const char * dsc)
void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc)
{
if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/

View File

@@ -32,7 +32,7 @@ extern "C" {
#define LV_LOG_LEVEL_ERROR 3 /*Only critical issue, when the system may fail*/
#define _LV_LOG_LEVEL_NUM 4
typedef uint8_t lv_log_level_t;
typedef int8_t lv_log_level_t;
#if USE_LV_LOG
/**********************
@@ -58,7 +58,7 @@ void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const
* @param line line number in the source code where the log added
* @param dsc description of the log
*/
void lv_log_add(lv_log_level_t level, const char * file, uint32_t line, const char * dsc);
void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc);
/**********************
* MACROS

View File

@@ -8,6 +8,7 @@
*********************/
#include "lv_math.h"
#include <stdbool.h>
#include <stdlib.h>
/*********************
* DEFINES
@@ -33,7 +34,8 @@ static int16_t sin0_90_table[] = {
25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087,
28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591,
30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165,
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762,
32767
};
@@ -117,13 +119,13 @@ int16_t lv_trigo_sin(int16_t angle)
if(angle < 90) {
ret = sin0_90_table[angle];
} else if(angle >= 90 && angle < 180) {
angle = 179 - angle;
angle = 180 - angle;
ret = sin0_90_table[angle];
} else if(angle >= 180 && angle < 270) {
angle = angle - 180;
ret = - sin0_90_table[angle];
} else { /*angle >=270*/
angle = 359 - angle;
angle = 360 - angle;
ret = - sin0_90_table[angle];
}

View File

@@ -19,9 +19,9 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define LV_MATH_MIN(a,b) (a<b?a:b)
#define LV_MATH_MAX(a,b) (a>b?a:b)
#define LV_MATH_ABS(x) ((x)>0?(x):(-(x)))
#define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b))
#define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b))
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
#define LV_TRIGO_SIN_MAX 32767
#define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/

View File

@@ -32,6 +32,8 @@
* TYPEDEFS
**********************/
#if LV_ENABLE_GC == 0 /*gc custom allocations must not include header*/
/*The size of this union must be 4 bytes (uint32_t)*/
typedef union {
struct {
@@ -46,6 +48,8 @@ typedef struct {
uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/
} lv_mem_ent_t;
#endif /* LV_ENABLE_GC */
/**********************
* STATIC PROTOTYPES
**********************/
@@ -59,7 +63,6 @@ static void ent_trunc(lv_mem_ent_t * e, uint32_t size);
* STATIC VARIABLES
**********************/
#if LV_MEM_CUSTOM == 0
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)]; /*Work memory for allocations*/
static uint8_t * work_mem;
#endif
@@ -79,7 +82,15 @@ static uint32_t zero_mem; /*Give the address of this variable if 0 byte sh
void lv_mem_init(void)
{
#if LV_MEM_CUSTOM == 0
#if LV_MEM_ADR == 0
/*Allocate a large array to store the dynamically allocated data*/
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)];
work_mem = (uint8_t *) work_mem_int;
#else
work_mem = (uint8_t *) LV_MEM_ADR;
#endif
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.used = 0;
/*The total mem size id reduced by the first header and the close patterns */
@@ -128,11 +139,11 @@ void * lv_mem_alloc(uint32_t size)
//End if there is not next entry OR the alloc. is successful
} while(e != NULL && alloc == NULL);
#if LV_MEM_ADD_JUNK
if(alloc != NULL) memset(alloc, 0xaa, size);
#endif
#else /*Use custom, user defined malloc function*/
#if LV_ENABLE_GC == 1 /*gc must not include header*/
alloc = LV_MEM_CUSTOM_ALLOC(size);
#else /* LV_ENABLE_GC */
/*Allocate a header too to store the size*/
alloc = LV_MEM_CUSTOM_ALLOC(size + sizeof(lv_mem_header_t));
if(alloc != NULL) {
@@ -140,6 +151,11 @@ void * lv_mem_alloc(uint32_t size)
((lv_mem_ent_t *) alloc)->header.used = 1;
alloc = &((lv_mem_ent_t *) alloc)->first_data;
}
#endif /* LV_ENABLE_GC */
#endif /* LV_MEM_CUSTOM */
#if LV_MEM_ADD_JUNK
if(alloc != NULL) memset(alloc, 0xaa, size);
#endif
if(alloc == NULL) LV_LOG_WARN("Couldn't allocate memory");
@@ -161,9 +177,11 @@ void lv_mem_free(const void * data)
memset((void *)data, 0xbb, lv_mem_get_size(data));
#endif
#if LV_ENABLE_GC==0
/*e points to the header*/
lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *) data - sizeof(lv_mem_header_t));
e->header.used = 0;
#endif
#if LV_MEM_CUSTOM == 0
#if LV_MEM_AUTO_DEFRAG
@@ -181,7 +199,11 @@ void lv_mem_free(const void * data)
}
#endif
#else /*Use custom, user defined free function*/
#if LV_ENABLE_GC==0
LV_MEM_CUSTOM_FREE(e);
#else
LV_MEM_CUSTOM_FREE((void*)data);
#endif /*LV_ENABLE_GC*/
#endif
}
@@ -192,6 +214,9 @@ void lv_mem_free(const void * data)
* @param new_size the desired new size in byte
* @return pointer to the new memory
*/
#if LV_ENABLE_GC==0
void * lv_mem_realloc(void * data_p, uint32_t new_size)
{
/*data_p could be previously freed pointer (in this case it is invalid)*/
@@ -232,6 +257,17 @@ void * lv_mem_realloc(void * data_p, uint32_t new_size)
return new_p;
}
#else /* LV_ENABLE_GC */
void * lv_mem_realloc(void * data_p, uint32_t new_size)
{
void * new_p = LV_MEM_CUSTOM_REALLOC(data_p, new_size);
if(new_p == NULL) LV_LOG_WARN("Couldn't allocate memory");
return new_p;
}
#endif /* lv_enable_gc */
/**
* Join the adjacent free memory blocks
*/
@@ -314,6 +350,9 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
* @param data pointer to an allocated memory
* @return the size of data memory in bytes
*/
#if LV_ENABLE_GC==0
uint32_t lv_mem_get_size(const void * data)
{
if(data == NULL) return 0;
@@ -324,6 +363,15 @@ uint32_t lv_mem_get_size(const void * data)
return e->header.d_size;
}
#else /* LV_ENABLE_GC */
uint32_t lv_mem_get_size(const void * data)
{
return LV_MEM_CUSTOM_GET_SIZE(data);
}
#endif /*LV_ENABLE_GC*/
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -34,7 +34,7 @@ extern "C" {
// Check GCC
#ifdef __GNUC__
# if __x86_64__ || __ppc64__
# if defined(__x86_64__) || defined(__ppc64__)
# define LV_MEM_ENV64
# endif
#endif

View File

@@ -11,8 +11,9 @@ CSRCS += lv_txt.c
CSRCS += lv_ufs.c
CSRCS += lv_math.c
CSRCS += lv_log.c
CSRCS += lv_gc.c
DEPPATH += --dep-path lvgl/lv_misc
VPATH += :lvgl/lv_misc
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_misc
VPATH += :$(LVGL_DIR)/lvgl/lv_misc
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_misc"

View File

@@ -22,115 +22,182 @@ extern "C" {
#if LV_TXT_UTF8 == 0
#define LV_SYMBOL_GLYPH_FIRST 0xC0
#define SYMBOL_AUDIO "\xC0"
#define SYMBOL_VIDEO "\xC1"
#define SYMBOL_LIST "\xC2"
#define SYMBOL_OK "\xC3"
#define SYMBOL_CLOSE "\xC4"
#define SYMBOL_POWER "\xC5"
#define SYMBOL_SETTINGS "\xC6"
#define SYMBOL_TRASH "\xC7"
#define SYMBOL_HOME "\xC8"
#define SYMBOL_DOWNLOAD "\xC9"
#define SYMBOL_DRIVE "\xCA"
#define SYMBOL_REFRESH "\xCB"
#define SYMBOL_MUTE "\xCC"
#define SYMBOL_VOLUME_MID "\xCD"
#define SYMBOL_VOLUME_MAX "\xCE"
#define SYMBOL_IMAGE "\xCF"
#define SYMBOL_EDIT "\xD0"
#define SYMBOL_PREV "\xD1"
#define SYMBOL_PLAY "\xD2"
#define SYMBOL_PAUSE "\xD3"
#define SYMBOL_STOP "\xD4"
#define SYMBOL_NEXT "\xD5"
#define SYMBOL_EJECT "\xD6"
#define SYMBOL_LEFT "\xD7"
#define SYMBOL_RIGHT "\xD8"
#define SYMBOL_PLUS "\xD9"
#define SYMBOL_MINUS "\xDA"
#define SYMBOL_WARNING "\xDB"
#define SYMBOL_SHUFFLE "\xDC"
#define SYMBOL_UP "\xDD"
#define SYMBOL_DOWN "\xDE"
#define SYMBOL_LOOP "\xDF"
#define SYMBOL_DIRECTORY "\xE0"
#define SYMBOL_UPLOAD "\xE1"
#define SYMBOL_CALL "\xE2"
#define SYMBOL_CUT "\xE3"
#define SYMBOL_COPY "\xE4"
#define SYMBOL_SAVE "\xE5"
#define SYMBOL_CHARGE "\xE6"
#define SYMBOL_BELL "\xE7"
#define SYMBOL_KEYBOARD "\xE8"
#define SYMBOL_GPS "\xE9"
#define SYMBOL_FILE "\xEA"
#define SYMBOL_WIFI "\xEB"
#define SYMBOL_BATTERY_FULL "\xEC"
#define SYMBOL_BATTERY_3 "\xED"
#define SYMBOL_BATTERY_2 "\xEE"
#define SYMBOL_BATTERY_1 "\xEF"
#define SYMBOL_BATTERY_EMPTY "\xF0"
#define SYMBOL_BLUETOOTH "\xF1"
#define SYMBOL_AUDIO _SYMBOL_VALUE1(C0)
#define SYMBOL_VIDEO _SYMBOL_VALUE1(C1)
#define SYMBOL_LIST _SYMBOL_VALUE1(C2)
#define SYMBOL_OK _SYMBOL_VALUE1(C3)
#define SYMBOL_CLOSE _SYMBOL_VALUE1(C4)
#define SYMBOL_POWER _SYMBOL_VALUE1(C5)
#define SYMBOL_SETTINGS _SYMBOL_VALUE1(C6)
#define SYMBOL_TRASH _SYMBOL_VALUE1(C7)
#define SYMBOL_HOME _SYMBOL_VALUE1(C8)
#define SYMBOL_DOWNLOAD _SYMBOL_VALUE1(C9)
#define SYMBOL_DRIVE _SYMBOL_VALUE1(CA)
#define SYMBOL_REFRESH _SYMBOL_VALUE1(CB)
#define SYMBOL_MUTE _SYMBOL_VALUE1(CC)
#define SYMBOL_VOLUME_MID _SYMBOL_VALUE1(CD)
#define SYMBOL_VOLUME_MAX _SYMBOL_VALUE1(CE)
#define SYMBOL_IMAGE _SYMBOL_VALUE1(CF)
#define SYMBOL_EDIT _SYMBOL_VALUE1(D0)
#define SYMBOL_PREV _SYMBOL_VALUE1(D1)
#define SYMBOL_PLAY _SYMBOL_VALUE1(D2)
#define SYMBOL_PAUSE _SYMBOL_VALUE1(D3)
#define SYMBOL_STOP _SYMBOL_VALUE1(D4)
#define SYMBOL_NEXT _SYMBOL_VALUE1(D5)
#define SYMBOL_EJECT _SYMBOL_VALUE1(D6)
#define SYMBOL_LEFT _SYMBOL_VALUE1(D7)
#define SYMBOL_RIGHT _SYMBOL_VALUE1(D8)
#define SYMBOL_PLUS _SYMBOL_VALUE1(D9)
#define SYMBOL_MINUS _SYMBOL_VALUE1(DA)
#define SYMBOL_WARNING _SYMBOL_VALUE1(DB)
#define SYMBOL_SHUFFLE _SYMBOL_VALUE1(DC)
#define SYMBOL_UP _SYMBOL_VALUE1(DD)
#define SYMBOL_DOWN _SYMBOL_VALUE1(DE)
#define SYMBOL_LOOP _SYMBOL_VALUE1(DF)
#define SYMBOL_DIRECTORY _SYMBOL_VALUE1(E0)
#define SYMBOL_UPLOAD _SYMBOL_VALUE1(E1)
#define SYMBOL_CALL _SYMBOL_VALUE1(E2)
#define SYMBOL_CUT _SYMBOL_VALUE1(E3)
#define SYMBOL_COPY _SYMBOL_VALUE1(E4)
#define SYMBOL_SAVE _SYMBOL_VALUE1(E5)
#define SYMBOL_CHARGE _SYMBOL_VALUE1(E6)
#define SYMBOL_BELL _SYMBOL_VALUE1(E7)
#define SYMBOL_KEYBOARD _SYMBOL_VALUE1(E8)
#define SYMBOL_GPS _SYMBOL_VALUE1(E9)
#define SYMBOL_FILE _SYMBOL_VALUE1(EA)
#define SYMBOL_WIFI _SYMBOL_VALUE1(EB)
#define SYMBOL_BATTERY_FULL _SYMBOL_VALUE1(EC)
#define SYMBOL_BATTERY_3 _SYMBOL_VALUE1(ED)
#define SYMBOL_BATTERY_2 _SYMBOL_VALUE1(EE)
#define SYMBOL_BATTERY_1 _SYMBOL_VALUE1(EF)
#define SYMBOL_BATTERY_EMPTY _SYMBOL_VALUE1(F0)
#define SYMBOL_BLUETOOTH _SYMBOL_VALUE1(F1)
#define LV_SYMBOL_GLYPH_LAST 0xF1
#define SYMBOL_DUMMY "\xFF" /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
#define SYMBOL_DUMMY _SYMBOL_VALUE1(FF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
#else
#define LV_SYMBOL_GLYPH_FIRST 0xF800
#define SYMBOL_AUDIO "\xEF\xA0\x80"
#define SYMBOL_VIDEO "\xEF\xA0\x81"
#define SYMBOL_LIST "\xEF\xA0\x82"
#define SYMBOL_OK "\xEF\xA0\x83"
#define SYMBOL_CLOSE "\xEF\xA0\x84"
#define SYMBOL_POWER "\xEF\xA0\x85"
#define SYMBOL_SETTINGS "\xEF\xA0\x86"
#define SYMBOL_TRASH "\xEF\xA0\x87"
#define SYMBOL_HOME "\xEF\xA0\x88"
#define SYMBOL_DOWNLOAD "\xEF\xA0\x89"
#define SYMBOL_DRIVE "\xEF\xA0\x8A"
#define SYMBOL_REFRESH "\xEF\xA0\x8B"
#define SYMBOL_MUTE "\xEF\xA0\x8C"
#define SYMBOL_VOLUME_MID "\xEF\xA0\x8D"
#define SYMBOL_VOLUME_MAX "\xEF\xA0\x8E"
#define SYMBOL_IMAGE "\xEF\xA0\x8F"
#define SYMBOL_EDIT "\xEF\xA0\x90"
#define SYMBOL_PREV "\xEF\xA0\x91"
#define SYMBOL_PLAY "\xEF\xA0\x92"
#define SYMBOL_PAUSE "\xEF\xA0\x93"
#define SYMBOL_STOP "\xEF\xA0\x94"
#define SYMBOL_NEXT "\xEF\xA0\x95"
#define SYMBOL_EJECT "\xEF\xA0\x96"
#define SYMBOL_LEFT "\xEF\xA0\x97"
#define SYMBOL_RIGHT "\xEF\xA0\x98"
#define SYMBOL_PLUS "\xEF\xA0\x99"
#define SYMBOL_MINUS "\xEF\xA0\x9A"
#define SYMBOL_WARNING "\xEF\xA0\x9B"
#define SYMBOL_SHUFFLE "\xEF\xA0\x9C"
#define SYMBOL_UP "\xEF\xA0\x9D"
#define SYMBOL_DOWN "\xEF\xA0\x9E"
#define SYMBOL_LOOP "\xEF\xA0\x9F"
#define SYMBOL_DIRECTORY "\xEF\xA0\xA0"
#define SYMBOL_UPLOAD "\xEF\xA0\xA1"
#define SYMBOL_CALL "\xEF\xA0\xA2"
#define SYMBOL_CUT "\xEF\xA0\xA3"
#define SYMBOL_COPY "\xEF\xA0\xA4"
#define SYMBOL_SAVE "\xEF\xA0\xA5"
#define SYMBOL_CHARGE "\xEF\xA0\xA6"
#define SYMBOL_BELL "\xEF\xA0\xA7"
#define SYMBOL_KEYBOARD "\xEF\xA0\xA8"
#define SYMBOL_GPS "\xEF\xA0\xA9"
#define SYMBOL_FILE "\xEF\xA0\xAA"
#define SYMBOL_WIFI "\xEF\xA0\xAB"
#define SYMBOL_BATTERY_FULL "\xEF\xA0\xAC"
#define SYMBOL_BATTERY_3 "\xEF\xA0\xAD"
#define SYMBOL_BATTERY_2 "\xEF\xA0\xAE"
#define SYMBOL_BATTERY_1 "\xEF\xA0\xAF"
#define SYMBOL_BATTERY_EMPTY "\xEF\xA0\xB0"
#define SYMBOL_BLUETOOTH "\xEF\xA0\xB1"
#define SYMBOL_AUDIO _SYMBOL_VALUE3(EF,A0,80)
#define SYMBOL_VIDEO _SYMBOL_VALUE3(EF,A0,81)
#define SYMBOL_LIST _SYMBOL_VALUE3(EF,A0,82)
#define SYMBOL_OK _SYMBOL_VALUE3(EF,A0,83)
#define SYMBOL_CLOSE _SYMBOL_VALUE3(EF,A0,84)
#define SYMBOL_POWER _SYMBOL_VALUE3(EF,A0,85)
#define SYMBOL_SETTINGS _SYMBOL_VALUE3(EF,A0,86)
#define SYMBOL_TRASH _SYMBOL_VALUE3(EF,A0,87)
#define SYMBOL_HOME _SYMBOL_VALUE3(EF,A0,88)
#define SYMBOL_DOWNLOAD _SYMBOL_VALUE3(EF,A0,89)
#define SYMBOL_DRIVE _SYMBOL_VALUE3(EF,A0,8A)
#define SYMBOL_REFRESH _SYMBOL_VALUE3(EF,A0,8B)
#define SYMBOL_MUTE _SYMBOL_VALUE3(EF,A0,8C)
#define SYMBOL_VOLUME_MID _SYMBOL_VALUE3(EF,A0,8D)
#define SYMBOL_VOLUME_MAX _SYMBOL_VALUE3(EF,A0,8E)
#define SYMBOL_IMAGE _SYMBOL_VALUE3(EF,A0,8F)
#define SYMBOL_EDIT _SYMBOL_VALUE3(EF,A0,90)
#define SYMBOL_PREV _SYMBOL_VALUE3(EF,A0,91)
#define SYMBOL_PLAY _SYMBOL_VALUE3(EF,A0,92)
#define SYMBOL_PAUSE _SYMBOL_VALUE3(EF,A0,93)
#define SYMBOL_STOP _SYMBOL_VALUE3(EF,A0,94)
#define SYMBOL_NEXT _SYMBOL_VALUE3(EF,A0,95)
#define SYMBOL_EJECT _SYMBOL_VALUE3(EF,A0,96)
#define SYMBOL_LEFT _SYMBOL_VALUE3(EF,A0,97)
#define SYMBOL_RIGHT _SYMBOL_VALUE3(EF,A0,98)
#define SYMBOL_PLUS _SYMBOL_VALUE3(EF,A0,99)
#define SYMBOL_MINUS _SYMBOL_VALUE3(EF,A0,9A)
#define SYMBOL_WARNING _SYMBOL_VALUE3(EF,A0,9B)
#define SYMBOL_SHUFFLE _SYMBOL_VALUE3(EF,A0,9C)
#define SYMBOL_UP _SYMBOL_VALUE3(EF,A0,9D)
#define SYMBOL_DOWN _SYMBOL_VALUE3(EF,A0,9E)
#define SYMBOL_LOOP _SYMBOL_VALUE3(EF,A0,9F)
#define SYMBOL_DIRECTORY _SYMBOL_VALUE3(EF,A0,A0)
#define SYMBOL_UPLOAD _SYMBOL_VALUE3(EF,A0,A1)
#define SYMBOL_CALL _SYMBOL_VALUE3(EF,A0,A2)
#define SYMBOL_CUT _SYMBOL_VALUE3(EF,A0,A3)
#define SYMBOL_COPY _SYMBOL_VALUE3(EF,A0,A4)
#define SYMBOL_SAVE _SYMBOL_VALUE3(EF,A0,A5)
#define SYMBOL_CHARGE _SYMBOL_VALUE3(EF,A0,A6)
#define SYMBOL_BELL _SYMBOL_VALUE3(EF,A0,A7)
#define SYMBOL_KEYBOARD _SYMBOL_VALUE3(EF,A0,A8)
#define SYMBOL_GPS _SYMBOL_VALUE3(EF,A0,A9)
#define SYMBOL_FILE _SYMBOL_VALUE3(EF,A0,AA)
#define SYMBOL_WIFI _SYMBOL_VALUE3(EF,A0,AB)
#define SYMBOL_BATTERY_FULL _SYMBOL_VALUE3(EF,A0,AC)
#define SYMBOL_BATTERY_3 _SYMBOL_VALUE3(EF,A0,AD)
#define SYMBOL_BATTERY_2 _SYMBOL_VALUE3(EF,A0,AE)
#define SYMBOL_BATTERY_1 _SYMBOL_VALUE3(EF,A0,AF)
#define SYMBOL_BATTERY_EMPTY _SYMBOL_VALUE3(EF,A0,B0)
#define SYMBOL_BLUETOOTH _SYMBOL_VALUE3(EF,A0,B1)
#define LV_SYMBOL_GLYPH_LAST 0xF831
#define SYMBOL_DUMMY "\xEF\xA3\xBF" /*Invalid symbol at (U+F831). If written before a string then `lv_img` will show it as a label*/
#define SYMBOL_DUMMY _SYMBOL_VALUE3(EF,A3,BF) /*Invalid symbol at (U+F831). If written before a string then `lv_img` will show it as a label*/
#endif
#define _SYMBOL_VALUE1(x) (0x ## x)
#define _SYMBOL_VALUE3(x, y, z) (0x ## z ## y ## x)
#define _SYMBOL_NUMSTR(sym) LV_ ## sym ## _NUMSTR = sym
enum
{
_SYMBOL_NUMSTR(SYMBOL_AUDIO),
_SYMBOL_NUMSTR(SYMBOL_VIDEO),
_SYMBOL_NUMSTR(SYMBOL_LIST),
_SYMBOL_NUMSTR(SYMBOL_OK),
_SYMBOL_NUMSTR(SYMBOL_CLOSE),
_SYMBOL_NUMSTR(SYMBOL_POWER),
_SYMBOL_NUMSTR(SYMBOL_SETTINGS),
_SYMBOL_NUMSTR(SYMBOL_TRASH),
_SYMBOL_NUMSTR(SYMBOL_HOME),
_SYMBOL_NUMSTR(SYMBOL_DOWNLOAD),
_SYMBOL_NUMSTR(SYMBOL_DRIVE),
_SYMBOL_NUMSTR(SYMBOL_REFRESH),
_SYMBOL_NUMSTR(SYMBOL_MUTE),
_SYMBOL_NUMSTR(SYMBOL_VOLUME_MID),
_SYMBOL_NUMSTR(SYMBOL_VOLUME_MAX),
_SYMBOL_NUMSTR(SYMBOL_IMAGE),
_SYMBOL_NUMSTR(SYMBOL_EDIT),
_SYMBOL_NUMSTR(SYMBOL_PREV),
_SYMBOL_NUMSTR(SYMBOL_PLAY),
_SYMBOL_NUMSTR(SYMBOL_PAUSE),
_SYMBOL_NUMSTR(SYMBOL_STOP),
_SYMBOL_NUMSTR(SYMBOL_NEXT),
_SYMBOL_NUMSTR(SYMBOL_EJECT),
_SYMBOL_NUMSTR(SYMBOL_LEFT),
_SYMBOL_NUMSTR(SYMBOL_RIGHT),
_SYMBOL_NUMSTR(SYMBOL_PLUS),
_SYMBOL_NUMSTR(SYMBOL_MINUS),
_SYMBOL_NUMSTR(SYMBOL_WARNING),
_SYMBOL_NUMSTR(SYMBOL_SHUFFLE),
_SYMBOL_NUMSTR(SYMBOL_UP),
_SYMBOL_NUMSTR(SYMBOL_DOWN),
_SYMBOL_NUMSTR(SYMBOL_LOOP),
_SYMBOL_NUMSTR(SYMBOL_DIRECTORY),
_SYMBOL_NUMSTR(SYMBOL_UPLOAD),
_SYMBOL_NUMSTR(SYMBOL_CALL),
_SYMBOL_NUMSTR(SYMBOL_CUT),
_SYMBOL_NUMSTR(SYMBOL_COPY),
_SYMBOL_NUMSTR(SYMBOL_SAVE),
_SYMBOL_NUMSTR(SYMBOL_CHARGE),
_SYMBOL_NUMSTR(SYMBOL_BELL),
_SYMBOL_NUMSTR(SYMBOL_KEYBOARD),
_SYMBOL_NUMSTR(SYMBOL_GPS),
_SYMBOL_NUMSTR(SYMBOL_FILE),
_SYMBOL_NUMSTR(SYMBOL_WIFI),
_SYMBOL_NUMSTR(SYMBOL_BATTERY_FULL),
_SYMBOL_NUMSTR(SYMBOL_BATTERY_3),
_SYMBOL_NUMSTR(SYMBOL_BATTERY_2),
_SYMBOL_NUMSTR(SYMBOL_BATTERY_1),
_SYMBOL_NUMSTR(SYMBOL_BATTERY_EMPTY),
_SYMBOL_NUMSTR(SYMBOL_BLUETOOTH),
_SYMBOL_NUMSTR(SYMBOL_DUMMY),
};
#undef _SYMBOL_VALUE1
#undef _SYMBOL_VALUE3
#define _SYMBOL_STR_(x) #x
#define _SYMBOL_STR(x) _SYMBOL_STR_(x)
#define _SYMBOL_CHAR(c) \x ## c
#define _SYMBOL_VALUE1(x) _SYMBOL_STR(_SYMBOL_CHAR(x))
#define _SYMBOL_VALUE3(x, y, z) _SYMBOL_STR(_SYMBOL_CHAR(x)_SYMBOL_CHAR(y)_SYMBOL_CHAR(z))
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -10,6 +10,11 @@
#include <stddef.h>
#include "lv_task.h"
#include "../lv_hal/lv_hal_tick.h"
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -28,9 +33,10 @@ static bool lv_task_exec(lv_task_t * lv_task_p);
/**********************
* STATIC VARIABLES
**********************/
static lv_ll_t lv_task_ll; /*Linked list to store the lv_tasks*/
static bool lv_task_run = false;
static uint8_t idle_last = 0;
static bool task_deleted;
static bool task_created;
/**********************
* MACROS
@@ -45,7 +51,7 @@ static uint8_t idle_last = 0;
*/
void lv_task_init(void)
{
lv_ll_init(&lv_task_ll, sizeof(lv_task_t));
lv_ll_init(&LV_GC_ROOT(_lv_task_ll), sizeof(lv_task_t));
/*Initially enable the lv_task handling*/
lv_task_enable(true);
@@ -79,33 +85,35 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
bool end_flag;
do {
end_flag = true;
lv_task_t * act = lv_ll_get_head(&lv_task_ll);
while(act) {
task_deleted = false;
task_created = false;
LV_GC_ROOT(_lv_task_act) = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll));
while(LV_GC_ROOT(_lv_task_act)) {
/* The task might be deleted if it runs only once ('once = 1')
* So get next element until the current is surely valid*/
next = lv_ll_get_next(&lv_task_ll, act);
next = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), LV_GC_ROOT(_lv_task_act));
/*We reach priority of the turned off task. There is nothing more to do.*/
if(act->prio == LV_TASK_PRIO_OFF) {
if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio == LV_TASK_PRIO_OFF) {
break;
}
/*Here is the interrupter task. Don't execute it again.*/
if(act == task_interrupter) {
if(LV_GC_ROOT(_lv_task_act) == task_interrupter) {
task_interrupter = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/
act = next;
LV_GC_ROOT(_lv_task_act) = next;
continue; /*Load the next task*/
}
/*Just try to run the tasks with highest priority.*/
if(act->prio == LV_TASK_PRIO_HIGHEST) {
lv_task_exec(act);
if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio == LV_TASK_PRIO_HIGHEST) {
lv_task_exec(LV_GC_ROOT(_lv_task_act));
}
/*Tasks with higher priority then the interrupted shall be run in every case*/
else if(task_interrupter) {
if(act->prio > task_interrupter->prio) {
if(lv_task_exec(act)) {
task_interrupter = act; /*Check all tasks again from the highest priority */
if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio > task_interrupter->prio) {
if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) {
task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */
end_flag = false;
break;
}
@@ -114,13 +122,17 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
/* It is no interrupter task or we already reached it earlier.
* Just run the remaining tasks*/
else {
if(lv_task_exec(act)) {
task_interrupter = act; /*Check all tasks again from the highest priority */
if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) {
task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */
end_flag = false;
break;
}
}
act = next; /*Load the next task*/
if(task_deleted) break; /*If a task was deleted then this or the next item might be corrupted*/
if(task_created) break; /*If a task was deleted then this or the next item might be corrupted*/
LV_GC_ROOT(_lv_task_act) = next; /*Load the next task*/
}
} while(!end_flag);
@@ -155,24 +167,24 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t
lv_task_t * tmp;
/*Create task lists in order of priority from high to low*/
tmp = lv_ll_get_head(&lv_task_ll);
tmp = lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll));
if(NULL == tmp) { /*First task*/
new_lv_task = lv_ll_ins_head(&lv_task_ll);
new_lv_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll));
lv_mem_assert(new_lv_task);
if(new_lv_task == NULL) return NULL;
} else {
do {
if(tmp->prio <= prio) {
new_lv_task = lv_ll_ins_prev(&lv_task_ll, tmp);
new_lv_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp);
lv_mem_assert(new_lv_task);
if(new_lv_task == NULL) return NULL;
break;
}
tmp = lv_ll_get_next(&lv_task_ll, tmp);
tmp = lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), tmp);
} while(tmp != NULL);
if(tmp == NULL) { /*Only too high priority tasks were found*/
new_lv_task = lv_ll_ins_tail(&lv_task_ll);
new_lv_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll));
lv_mem_assert(new_lv_task);
if(new_lv_task == NULL) return NULL;
}
@@ -185,6 +197,8 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t
new_lv_task->once = 0;
new_lv_task->last_run = lv_tick_get();
task_created = true;
return new_lv_task;
}
@@ -194,9 +208,11 @@ lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t
*/
void lv_task_del(lv_task_t * lv_task_p)
{
lv_ll_rem(&lv_task_ll, lv_task_p);
lv_ll_rem(&LV_GC_ROOT(_lv_task_ll), lv_task_p);
lv_mem_free(lv_task_p);
if(LV_GC_ROOT(_lv_task_act) == lv_task_p) task_deleted = true; /*The active task was deleted*/
}
/**
@@ -208,16 +224,16 @@ void lv_task_set_prio(lv_task_t * lv_task_p, lv_task_prio_t prio)
{
/*Find the tasks with new priority*/
lv_task_t * i;
LL_READ(lv_task_ll, i) {
LL_READ(LV_GC_ROOT(_lv_task_ll), i) {
if(i->prio <= prio) {
if(i != lv_task_p) lv_ll_move_before(&lv_task_ll, lv_task_p, i);
if(i != lv_task_p) lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, i);
break;
}
}
/*There was no such a low priority so far then add the node to the tail*/
if(i == NULL) {
lv_ll_move_before(&lv_task_ll, lv_task_p, NULL);
lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, NULL);
}
@@ -298,11 +314,16 @@ static bool lv_task_exec(lv_task_t * lv_task_p)
uint32_t elp = lv_tick_elaps(lv_task_p->last_run);
if(elp >= lv_task_p->period) {
lv_task_p->last_run = lv_tick_get();
task_deleted = false;
task_created = false;
lv_task_p->task(lv_task_p->param);
/*Delete if it was a one shot lv_task*/
if(lv_task_p->once != 0) lv_task_del(lv_task_p);
if(task_deleted == false) { /*The task might be deleted by itself as well*/
if(lv_task_p->once != 0) {
lv_task_del(lv_task_p);
}
}
exec = true;
}

View File

@@ -14,6 +14,18 @@
*********************/
#define NO_BREAK_FOUND UINT32_MAX
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
#endif
#ifndef LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
#endif
/**********************
* TYPEDEFS
**********************/
@@ -148,11 +160,14 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
uint32_t i = 0;
lv_coord_t cur_w = 0;
lv_coord_t w_at_last_break = 0;
uint32_t n_char_since_last_break = 0; /* Used count word length of long words */
uint32_t last_break = NO_BREAK_FOUND;
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t letter = 0;
while(txt[i] != '\0') {
lv_coord_t letter_width;
letter = lv_txt_encoded_next(txt, &i);
/*Handle the recolor command*/
@@ -162,6 +177,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
}
}
/*Check for new line chars*/
if(letter == '\n' || letter == '\r') {
uint32_t i_tmp = i;
@@ -171,19 +187,80 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
return i; /*Return with the first letter of the next line*/
} else { /*Check the actual length*/
cur_w += lv_font_get_width(font, letter);
n_char_since_last_break++;
letter_width = lv_font_get_width(font, letter);
cur_w += letter_width;
/*If the txt is too long then finish, this is the line end*/
/* Get the length of the current work and determine best place
* to break the line. */
if(cur_w > max_width) {
/*If this a break char then break here.*/
if(is_break_char(letter)) {
/* Now 'i' points to the next char because of txt_utf8_next()
* But we need the first char of the next line so keep it.
* Hence do nothing here*/
}
/*If already a break character is found, then break there*/
if(last_break != NO_BREAK_FOUND) {
i = last_break;
if( last_break != NO_BREAK_FOUND ) {
/* Continue searching for next breakable character to see if the next word will fit */
uint32_t n_char_fit = n_char_since_last_break - 1;
if( n_char_since_last_break <= LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN ) {
i = last_break;
}
else {
uint32_t i_tmp = i;
cur_w -= w_at_last_break + letter_space; /*ignore the first letter_space after the break char */
bool other = true;
while(txt[i_tmp] != '\0') {
letter = lv_txt_encoded_next(txt, &i_tmp);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, letter) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
/*Check for new line chars*/
if(letter == '\n' || letter == '\r' || is_break_char(letter)) {
if(n_char_since_last_break >= LV_TXT_LINE_BREAK_LONG_LEN) {
/* Figure out the prettiest place to break */
uint32_t char_remain;
lv_txt_encoded_prev(txt, &i);
for(char_remain=n_char_since_last_break - n_char_fit;
char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN;
char_remain++) {
lv_txt_encoded_prev(txt, &i);
}
}
else{
i = last_break;
}
other = false;
break;
}
n_char_since_last_break++;
lv_coord_t letter_width2 = lv_font_get_width(font, letter);
cur_w += letter_width2;
if(cur_w > max_width) {
/* Current letter already exceeds, return previous */
lv_txt_encoded_prev(txt, &i);
other = false;
break;
}
if(letter_width2 > 0){
cur_w += letter_space;
}
}
if( other ) {
if(n_char_since_last_break >= LV_TXT_LINE_BREAK_LONG_LEN) {
/* Figure out the prettiest place to break */
uint32_t char_remain;
lv_txt_encoded_prev(txt, &i);
for(char_remain=n_char_since_last_break - n_char_fit;
char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN;
char_remain++){
lv_txt_encoded_prev(txt, &i);
}
}
else{
i = last_break;
}
}
}
} else {
/* Now this character is out of the area so it will be first character of the next line*/
/* But 'i' already points to the next character (because of lv_txt_utf8_next) step beck one*/
@@ -200,10 +277,17 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
* txt can be broken here later */
else if(is_break_char(letter)) {
last_break = i; /*Save the first char index after break*/
w_at_last_break = cur_w;
if(letter_width > 0) {
w_at_last_break += letter_space;
}
n_char_since_last_break = 0;
}
}
cur_w += letter_space;
if(letter_width > 0) {
cur_w += letter_space;
}
}
return i;
@@ -212,7 +296,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
/**
* Give the length of a text with a given font
* @param txt a '\0' terminate string
* @param length length of 'txt' in character count and not bytes(UTF-8 can be 1,2,3 or 4 bytes long)
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8)
* @param font pointer to a font
* @param letter_space letter space
* @param flags settings for the text from 'txt_flag_t' enum
@@ -230,7 +314,7 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
uint32_t letter;
if(length != 0) {
while(i < length) {
while(i< length){
letter = lv_txt_encoded_next(txt, &i);
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, letter) != false) {
@@ -238,11 +322,16 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
}
}
width += lv_font_get_width(font, letter);
width += letter_space;
lv_coord_t char_width = lv_font_get_width(font, letter);
if(char_width > 0){
width += char_width;
width += letter_space;
}
}
width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */
if(width > 0) {
width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */
}
}
return width;

View File

@@ -70,19 +70,19 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
/**
* Get the next line of text. Check line length and break chars too.
* @param txt a '\0' terminated string
* @param font_p pointer to a font
* @param font pointer to a font
* @param letter_space letter space
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
* @param flags settings for the text from 'txt_flag_t' enum
* @return the index of the first char of the new line
* @param flags settings for the text from 'txt_flag_type' enum
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
*/
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font_p,
lv_coord_t letter_space, lv_coord_t max_l, lv_txt_flag_t flag);
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag);
/**
* Give the length of a text with a given font
* @param txt a '\0' terminate string
* @param length length of 'txt' in character count and not bytes(UTF-8 can be 1,2,3 or 4 bytes long)
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8)
* @param font pointer to a font
* @param letter_space letter space
* @param flags settings for the text from 'txt_flag_t' enum
@@ -122,7 +122,7 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len);
***************************************************************/
/**
* Give the size of an encoded character
* Give the size of an encoded character
* @param str pointer to a character in a string
* @return length of the encoded character (1,2,3 ...). O in invalid
*/

View File

@@ -14,6 +14,12 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "lv_gc.h"
#if defined(LV_GC_INCLUDE)
# include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@@ -32,7 +38,6 @@ static lv_ufs_ent_t * lv_ufs_ent_new(const char * fn);
/**********************
* STATIC VARIABLES
**********************/
static lv_ll_t file_ll;
static bool inited = false;
/**********************
@@ -48,7 +53,7 @@ static bool inited = false;
*/
void lv_ufs_init(void)
{
lv_ll_init(&file_ll, sizeof(lv_ufs_ent_t));
lv_ll_init(&LV_GC_ROOT(_lv_file_ll), sizeof(lv_ufs_ent_t));
lv_fs_drv_t ufs_drv;
memset(&ufs_drv, 0, sizeof(lv_fs_drv_t)); /*Initialization*/
@@ -202,7 +207,7 @@ lv_fs_res_t lv_ufs_remove(const char * fn)
/*Can not be deleted is opened*/
if(ent->oc != 0) return LV_FS_RES_DENIED;
lv_ll_rem(&file_ll, ent);
lv_ll_rem(&LV_GC_ROOT(_lv_file_ll), ent);
lv_mem_free(ent->fn_d);
ent->fn_d = NULL;
if(ent->const_data == 0) {
@@ -412,9 +417,9 @@ lv_fs_res_t lv_ufs_dir_read(void * dir_p, char * fn)
lv_ufs_dir_t * ufs_dir_p = dir_p;
if(ufs_dir_p->last_ent == NULL) {
ufs_dir_p->last_ent = lv_ll_get_head(&file_ll);
ufs_dir_p->last_ent = lv_ll_get_head(&LV_GC_ROOT(_lv_file_ll));
} else {
ufs_dir_p->last_ent = lv_ll_get_next(&file_ll, ufs_dir_p->last_ent);
ufs_dir_p->last_ent = lv_ll_get_next(&LV_GC_ROOT(_lv_file_ll), ufs_dir_p->last_ent);
}
if(ufs_dir_p->last_ent != NULL) {
@@ -472,7 +477,7 @@ static lv_ufs_ent_t * lv_ufs_ent_get(const char * fn)
{
lv_ufs_ent_t * fp;
LL_READ(file_ll, fp) {
LL_READ(LV_GC_ROOT(_lv_file_ll), fp) {
if(strcmp(fp->fn_d, fn) == 0) {
return fp;
}
@@ -490,7 +495,7 @@ static lv_ufs_ent_t * lv_ufs_ent_get(const char * fn)
static lv_ufs_ent_t * lv_ufs_ent_new(const char * fn)
{
lv_ufs_ent_t * new_ent = NULL;
new_ent = lv_ll_ins_head(&file_ll); /*Create a new file*/
new_ent = lv_ll_ins_head(&LV_GC_ROOT(_lv_file_ll)); /*Create a new file*/
lv_mem_assert(new_ent);
if(new_ent == NULL) return NULL;

View File

@@ -80,7 +80,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Set the default styles*/
lv_theme_t * th = lv_theme_get_current();
if(th) {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->preload);
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->arc);
} else {
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
}
@@ -153,7 +153,7 @@ void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, lv_style_t * style)
*====================*/
/**
* Get the start angles of an arc.
* Get the start angle of an arc.
* @param arc pointer to an arc object
* @return the start angle [0..360]
*/
@@ -165,7 +165,7 @@ uint16_t lv_arc_get_angle_start(lv_obj_t * arc)
}
/**
* Get the end angles of an arc.
* Get the end angle of an arc.
* @param arc pointer to an arc object
* @return the end angle [0..360]
*/
@@ -173,7 +173,7 @@ uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
{
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
return ext->angle_start;
return ext->angle_end;
}
/**
@@ -184,16 +184,18 @@ uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
* */
lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type)
{
lv_style_t * style = NULL;
switch(type) {
case LV_ARC_STYLE_MAIN:
return lv_obj_get_style(arc);
style = lv_obj_get_style(arc);
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/*=====================

View File

@@ -89,14 +89,14 @@ void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, lv_style_t *style);
*====================*/
/**
* Get the start angles of an arc.
* Get the start angle of an arc.
* @param arc pointer to an arc object
* @return the start angle [0..360]
*/
uint16_t lv_arc_get_angle_start(lv_obj_t * arc);
/**
* Get the end angles of an arc.
* Get the end angle of an arc.
* @param arc pointer to an arc object
* @return the end angle [0..360]
*/

View File

@@ -70,6 +70,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->min_value = 0;
ext->max_value = 100;
ext->cur_value = 0;
ext->sym = 0;
ext->style_indic = &lv_style_pretty_color;
lv_obj_set_signal_func(new_bar, lv_bar_signal);
@@ -94,6 +95,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->max_value = ext_copy->max_value;
ext->cur_value = ext_copy->cur_value;
ext->style_indic = ext_copy->style_indic;
ext->sym = ext_copy->sym;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_bar);
@@ -183,6 +185,16 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
lv_obj_invalidate(bar);
}
/**
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum position.
* @param bar pointer to a bar object
* @param en true: enable disable symmetric behavior; false: disable
*/
void lv_bar_set_sym(lv_obj_t * bar, bool en)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
ext->sym = en ? 1 : 0;
}
/**
* Set a style of a bar
@@ -242,6 +254,17 @@ int16_t lv_bar_get_max_value(const lv_obj_t * bar)
return ext->max_value;
}
/**
* Get whether the bar is symmetric or not.
* @param bar pointer to a bar object
* @return true: symmetric is enabled; false: disable
*/
bool lv_bar_get_sym(lv_obj_t * bar)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
return ext->sym ? true : false;
}
/**
* Get a style of a bar
* @param bar pointer to a bar object
@@ -250,19 +273,22 @@ int16_t lv_bar_get_max_value(const lv_obj_t * bar)
*/
lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type)
{
lv_style_t * style = NULL;
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
switch(type) {
case LV_BAR_STYLE_BG:
return lv_obj_get_style(bar);
style = lv_obj_get_style(bar);
break;
case LV_BAR_STYLE_INDIC:
return ext->style_indic;
style = ext->style_indic;
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/**********************
@@ -304,7 +330,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
#endif
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->cur_value != ext->min_value) {
if(ext->cur_value != ext->min_value || ext->sym) {
lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
lv_area_t indic_area;
lv_area_copy(&indic_area, &bar->coords);
@@ -317,13 +343,37 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
lv_coord_t h = lv_area_get_height(&indic_area);
if(w >= h) {
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
indic_area.x2 = indic_area.x1 + indic_area.x2;
/*Horizontal*/
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
indic_area.x2 = indic_area.x1 + indic_area.x2 - 1;
if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
/*Calculate the coordinate of the zero point*/
lv_coord_t zero;
zero = indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value);
if(indic_area.x2 > zero) indic_area.x1 = zero;
else {
indic_area.x1 = indic_area.x2;
indic_area.x2 = zero;
}
}
} else {
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
indic_area.y1 = indic_area.y2 - indic_area.y1;
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
indic_area.y1 = indic_area.y2 - indic_area.y1 + 1;
if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
/*Calculate the coordinate of the zero point*/
lv_coord_t zero;
zero = indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value);
if(indic_area.y1 < zero) indic_area.y2 = zero;
else {
indic_area.y2 = indic_area.y1;
indic_area.y1 = zero;
}
}
}
/*Draw the indicator*/
lv_draw_rect(&indic_area, mask, style_indic, opa_scale);
}

View File

@@ -42,6 +42,7 @@ typedef struct
int16_t cur_value; /*Current value of the bar*/
int16_t min_value; /*Minimum value of the bar*/
int16_t max_value; /*Maximum value of the bar*/
uint8_t sym :1; /*Symmetric: means the center is around zero value*/
lv_style_t *style_indic; /*Style of the indicator*/
} lv_bar_ext_t;
@@ -91,6 +92,13 @@ void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time);
*/
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
/**
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum position.
* @param bar pointer to a bar object
* @param en true: enable disable symmetric behavior; false: disable
*/
void lv_bar_set_sym(lv_obj_t * bar, bool en);
/**
* Set a style of a bar
* @param bar pointer to a bar object
@@ -124,6 +132,12 @@ int16_t lv_bar_get_min_value(const lv_obj_t * bar);
*/
int16_t lv_bar_get_max_value(const lv_obj_t * bar);
/**
* Get whether the bar is symmetric or not.
* @param bar pointer to a bar object
* @return true: symmetric is enabled; false: disable
*/
bool lv_bar_get_sym(lv_obj_t * bar);
/**
* Get a style of a bar

View File

@@ -31,7 +31,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_btn_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_design_mode_t mode);
static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
#if USE_LV_ANIMATION && LV_BTN_INK_EFFECT
@@ -233,6 +233,8 @@ void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_in_time = time;
#else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_ink_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif
}
@@ -249,6 +251,8 @@ void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_wait_time = time;
#else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_wait_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif
}
@@ -264,6 +268,8 @@ void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
ext->ink_out_time = time;
#else
(void)btn; /*Unused*/
(void)time; /*Unused*/
LV_LOG_WARN("`lv_btn_set_ink_out_time` has no effect if LV_BTN_INK_EFEFCT or USE_LV_ANIMATION is disabled")
#endif
}
@@ -352,6 +358,7 @@ uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_in_time;
#else
(void)btn; /*Unused*/
return 0;
#endif
}
@@ -368,6 +375,7 @@ uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_wait_time;
#else
(void)btn; /*Unused*/
return 0;
#endif
}
@@ -382,6 +390,7 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
return ext->ink_in_time;
#else
(void)btn; /*Unused*/
return 0;
#endif
}
@@ -394,25 +403,31 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
*/
lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type)
{
lv_style_t * style = NULL;
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
switch(type) {
case LV_BTN_STYLE_REL:
return ext->styles[LV_BTN_STATE_REL];
style = ext->styles[LV_BTN_STATE_REL];
break;
case LV_BTN_STYLE_PR:
return ext->styles[LV_BTN_STATE_PR];
style = ext->styles[LV_BTN_STATE_PR];
break;
case LV_BTN_STYLE_TGL_REL:
return ext->styles[LV_BTN_STATE_TGL_REL];
style = ext->styles[LV_BTN_STATE_TGL_REL];
break;
case LV_BTN_STYLE_TGL_PR:
return ext->styles[LV_BTN_STATE_TGL_PR];
style = ext->styles[LV_BTN_STATE_TGL_PR];
break;
case LV_BTN_STYLE_INA:
return ext->styles[LV_BTN_STATE_INA];
style = ext->styles[LV_BTN_STATE_INA];
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/**********************
@@ -659,16 +674,19 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
} else if(c == LV_GROUP_KEY_ENTER) {
if(!ext->long_pr_action_executed) {
if(lv_btn_get_toggle(btn)) {
if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR);
else if(state == LV_BTN_STATE_TGL_REL) lv_btn_set_state(btn, LV_BTN_STATE_REL);
else if(state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_PR);
if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
} else {
if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
}
if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_CLICK](btn);
}
}
ext->long_pr_action_executed = 0;
if(res != LV_RES_INV) {
ext->long_pr_action_executed = 0;
}
}
} else if(sign == LV_SIGNAL_CLEANUP) {
#if USE_LV_ANIMATION && LV_BTN_INK_EFFECT

View File

@@ -35,7 +35,7 @@ static bool button_is_inactive(const char * btn_str);
const char * cut_ctrl_byte(const char * btn_str);
static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p);
static uint16_t get_button_text(lv_obj_t * btnm, uint16_t btn_id);
static void create_buttons(lv_obj_t * btnm, const char ** map);
static void allocate_btn_areas(lv_obj_t * btnm, const char ** map);
/**********************
* STATIC VARIABLES
@@ -84,6 +84,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
ext->action = NULL;
ext->map_p = NULL;
ext->toggle = 0;
ext->recolor = 0;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
@@ -154,7 +155,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
ext->map_p = map;
/*Analyze the map and create the required number of buttons*/
create_buttons(btnm, map);
allocate_btn_areas(btnm, map);
/*Set size and positions of the buttons*/
lv_style_t * style_bg = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
@@ -193,6 +194,11 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
btn_cnt ++;
}
/*Make sure the last row is at the bottom of 'btnm'*/
if(map_p_tmp[btn_cnt][0] == '\0') { /*Last row?*/
btn_h = max_h - act_y + style_bg->body.padding.ver - 1;
}
/*Only deal with the non empty lines*/
if(btn_cnt != 0) {
/*Calculate the width of all units*/
@@ -231,11 +237,6 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
}
act_y += btn_h + style_bg->body.padding.inner;
/*If no vertical padding then make sure the last row is at the bottom of 'btnm'*/
if(style_bg->body.padding.ver == 0 &&
act_y + btn_h * 2 > max_h) { /*Last row?*/
btn_h = max_h - act_y - 1;
}
if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/
map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/
@@ -314,6 +315,14 @@ void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, lv_style_t * style
}
}
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
ext->recolor = en;
lv_obj_invalidate(btnm);
}
/*=====================
* Getter functions
*====================*/
@@ -340,16 +349,27 @@ lv_btnm_action_t lv_btnm_get_action(const lv_obj_t * btnm)
return ext->action;
}
/**
* Get the pressed button
* @param btnm pointer to button matrix object
* @return index of the currently pressed button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed(const lv_obj_t * btnm)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_pr;
}
/**
* Get the toggled button
* @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset)
* @return index of the currently toggled button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->toggle == 0) return 0;
if(ext->toggle == 0) return LV_BTNM_PR_NONE;
else return ext->btn_id_tgl;
}
@@ -361,27 +381,41 @@ uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm)
*/
lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
{
lv_style_t * style = NULL;
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
switch(type) {
case LV_BTNM_STYLE_BG:
return lv_obj_get_style(btnm);
style = lv_obj_get_style(btnm);
break;
case LV_BTNM_STYLE_BTN_REL:
return ext->styles_btn[LV_BTN_STATE_REL];
style = ext->styles_btn[LV_BTN_STATE_REL];
break;
case LV_BTNM_STYLE_BTN_PR:
return ext->styles_btn[LV_BTN_STATE_PR];
style = ext->styles_btn[LV_BTN_STATE_PR];
break;
case LV_BTNM_STYLE_BTN_TGL_REL:
return ext->styles_btn[LV_BTN_STATE_TGL_REL];
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
break;
case LV_BTNM_STYLE_BTN_TGL_PR:
return ext->styles_btn[LV_BTN_STATE_TGL_PR];
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
break;
case LV_BTNM_STYLE_BTN_INA:
return ext->styles_btn[LV_BTN_STATE_INA];
style = ext->styles_btn[LV_BTN_STATE_INA];
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
bool lv_btnm_get_recolor(const lv_obj_t * btnm)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->recolor;
}
/**********************
@@ -406,6 +440,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design_f(btnm, mask, mode);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
@@ -419,13 +454,19 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
lv_area_t area_tmp;
lv_coord_t btn_w;
lv_coord_t btn_h;
bool border_mod = false;
uint16_t btn_i = 0;
uint16_t txt_i = 0;
lv_style_t style_tmp;
lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE;
if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i ++, txt_i ++) {
/*Search the next valid text in the map*/
while(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
while(strcmp(ext->map_p[txt_i], "\n") == 0) {
txt_i ++;
}
/*Skip hidden buttons*/
if(button_is_hidden(ext->map_p[txt_i])) continue;
@@ -447,20 +488,29 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
else if(btn_i == ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
else btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/
/*On the right buttons clear the border if only right borders are drawn*/
if(ext->map_p[txt_i + 1][0] == '\0' || ext->map_p[txt_i + 1][0] == '\n') {
if(btn_style->body.border.part == LV_BORDER_RIGHT) {
btn_style->body.border.part = LV_BORDER_NONE;
border_mod = true;
lv_style_copy(&style_tmp, btn_style);
/*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
if(style_tmp.body.border.part & LV_BORDER_INTERNAL) {
if(area_tmp.y1 == btnm->coords.y1 + bg_style->body.padding.ver) {
style_tmp.body.border.part &= ~LV_BORDER_TOP;
}
if(area_tmp.y2 == btnm->coords.y2 - bg_style->body.padding.ver) {
style_tmp.body.border.part &= ~LV_BORDER_BOTTOM;
}
if(txt_i == 0) {
style_tmp.body.border.part &= ~LV_BORDER_LEFT;
}
else if(strcmp(ext->map_p[txt_i - 1],"\n") == 0) {
style_tmp.body.border.part &= ~LV_BORDER_LEFT;
}
if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
style_tmp.body.border.part &= ~LV_BORDER_RIGHT;
}
}
lv_draw_rect(&area_tmp, mask, btn_style, opa_scale);
if(border_mod) {
border_mod = false;
btn_style->body.border.part = LV_BORDER_RIGHT;
}
lv_draw_rect(&area_tmp, mask, &style_tmp, opa_scale);
/*Calculate the size of the text*/
if(btn_style->glass) btn_style = bg_style;
@@ -468,15 +518,14 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
lv_point_t txt_size;
lv_txt_get_size(&txt_size, ext->map_p[txt_i], font,
btn_style->text.letter_space, btn_style->text.line_space,
lv_area_get_width(&area_btnm), LV_TXT_FLAG_NONE);
lv_area_get_width(&area_btnm), txt_flag);
area_tmp.x1 += (btn_w - txt_size.x) / 2;
area_tmp.y1 += (btn_h - txt_size.y) / 2;
area_tmp.x2 = area_tmp.x1 + txt_size.x;
area_tmp.y2 = area_tmp.y1 + txt_size.y;
lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL);
}
}
return true;
@@ -541,51 +590,50 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(txt_i != LV_BTNM_PR_NONE) {
if(button_is_repeat_disabled(ext->map_p[txt_i]) == false &&
button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
} else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/
if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
if(res == LV_RES_OK) {
/*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area);
lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->btn_id_tgl = ext->btn_id_pr;
}
#if USE_LV_GROUP
/*Leave the clicked button when releases if this not the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
}
#else
ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif
}
}
/*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area);
lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->btn_id_tgl = ext->btn_id_pr;
}
#if USE_LV_GROUP
/*Leave the clicked button as pressed if this the focused object in a group*/
lv_group_t * g = lv_obj_get_group(btnm);
if(lv_group_get_focused(g) != btnm) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
}
#else
ext->btn_id_pr = LV_BTNM_PR_NONE;
#endif
}
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pr = LV_BTNM_PR_NONE;
@@ -666,7 +714,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
@@ -691,7 +739,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
* @param btnm pointer to button matrix object
* @param map_p pointer to a string array
*/
static void create_buttons(lv_obj_t * btnm, const char ** map)
static void allocate_btn_areas(lv_obj_t * btnm, const char ** map)
{
/*Count the buttons in the map*/
uint16_t btn_cnt = 0;

View File

@@ -62,6 +62,7 @@ typedef struct
uint16_t btn_id_pr; /*Index of the currently pressed button (in `button_areas`) or LV_BTNM_PR_NONE*/
uint16_t btn_id_tgl; /*Index of the currently toggled button (in `button_areas`) or LV_BTNM_PR_NONE */
uint8_t toggle :1; /*Enable toggling*/
uint8_t recolor :1; /*Enable button recoloring*/
} lv_btnm_ext_t;
enum {
@@ -129,6 +130,13 @@ void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id);
*/
void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style);
/**
* Set whether recoloring is enabled
* @param btnm pointer to button matrix object
* @param en whether recoloring is enabled
*/
void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en);
/*=====================
* Getter functions
*====================*/
@@ -147,11 +155,17 @@ const char ** lv_btnm_get_map(const lv_obj_t * btnm);
*/
lv_btnm_action_t lv_btnm_get_action(const lv_obj_t * btnm);
/**
* Get the pressed button
* @param btnm pointer to button matrix object
* @return index of the currently pressed button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_pressed(const lv_obj_t * btnm);
/**
* Get the toggled button
* @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset)
* @return index of the currently toggled button (LV_BTNM_PR_NONE: if unset)
*/
uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm);
@@ -163,6 +177,13 @@ uint16_t lv_btnm_get_toggled(const lv_obj_t * btnm);
*/
lv_style_t * lv_btnm_get_style(const lv_obj_t *btnm, lv_btnm_style_t type);
/**
* Find whether recoloring is enabled
* @param btnm pointer to button matrix object
* @return whether recoloring is enabled
*/
bool lv_btnm_get_recolor(const lv_obj_t * btnm);
/**********************
* MACROS
**********************/

View File

@@ -14,6 +14,7 @@
#include "../lv_misc/lv_math.h"
#include "../lv_core/lv_indev.h"
#include "../lv_themes/lv_theme.h"
#include <string.h>
/*********************
* DEFINES
@@ -34,7 +35,9 @@ typedef uint8_t day_draw_state_t;
**********************/
static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * param);
static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touched_point);
static lv_coord_t get_header_height(lv_obj_t * calendar);
static lv_coord_t get_day_names_height(lv_obj_t * calendar);
static void draw_header(lv_obj_t * calendar, const lv_area_t * mask);
static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask);
static void draw_days(lv_obj_t * calendar, const lv_area_t * mask);
@@ -45,6 +48,7 @@ static const char * get_month_name(lv_obj_t * calendar, int32_t month);
static uint8_t get_month_length(int32_t year, int32_t month);
static uint8_t is_leap_year(uint32_t year);
/**********************
* STATIC VARIABLES
**********************/
@@ -52,9 +56,9 @@ static lv_signal_func_t ancestor_signal;
static lv_design_func_t ancestor_design;
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
static const char * month_name[12] = {"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
};
"May", "June", "July", "August",
"September", "October", "November", "December"
};
/**********************
* MACROS
@@ -95,10 +99,18 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->showed_date.month = 1;
ext->showed_date.day = 1;
ext->pressed_date.year = 0;
ext->pressed_date.month = 0;
ext->pressed_date.day = 0;
ext->highlighted_dates = NULL;
ext->highlighted_dates_num = 0;
ext->day_names = NULL;
ext->month_names = NULL;
ext->actions[LV_CALENDAR_ACTION_PR] = NULL;
ext->actions[LV_CALENDAR_ACTION_CLICK] = NULL;
ext->actions[LV_CALENDAR_ACTION_LONG_PR] = NULL;
ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT] = NULL;
ext->style_header = &lv_style_plain_color;
ext->style_header_pr = &lv_style_pretty_color;
ext->style_highlighted_days = &lv_style_plain_color;
@@ -153,6 +165,9 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->highlighted_dates = copy_ext->highlighted_dates;
ext->highlighted_dates_num = copy_ext->highlighted_dates_num;
ext->day_names = copy_ext->day_names;
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
ext->month_names = copy_ext->month_names;
ext->style_header = copy_ext->style_header;
ext->style_header_pr = copy_ext->style_header_pr;
@@ -183,6 +198,19 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
* Setter functions
*====================*/
/**
* Set a function to call when a calendar event happens
* @param calendar pointer to a calendar object
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
*/
void lv_calendar_set_action(lv_obj_t * calendar, lv_calendar_action_t type, lv_action_t action)
{
if(type >= LV_CALENDAR_ACTION_NUM) return;
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
ext->actions[type] = action;
}
/**
* Set the today's date
* @param calendar pointer to a calendar object
@@ -266,30 +294,30 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
switch(type) {
case LV_CALENDAR_STYLE_BG:
lv_obj_set_style(calendar, style);
break;
case LV_CALENDAR_STYLE_DAY_NAMES:
ext->style_day_names = style;
break;
case LV_CALENDAR_STYLE_HEADER:
ext->style_header = style;
break;
case LV_CALENDAR_STYLE_HEADER_PR:
ext->style_header_pr = style;
break;
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
ext->style_highlighted_days = style;
break;
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
ext->style_inactive_days = style;
break;
case LV_CALENDAR_STYLE_TODAY_BOX:
ext->style_today_box = style;
break;
case LV_CALENDAR_STYLE_WEEK_BOX:
ext->style_week_box = style;
break;
case LV_CALENDAR_STYLE_BG:
lv_obj_set_style(calendar, style);
break;
case LV_CALENDAR_STYLE_DAY_NAMES:
ext->style_day_names = style;
break;
case LV_CALENDAR_STYLE_HEADER:
ext->style_header = style;
break;
case LV_CALENDAR_STYLE_HEADER_PR:
ext->style_header_pr = style;
break;
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
ext->style_highlighted_days = style;
break;
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
ext->style_inactive_days = style;
break;
case LV_CALENDAR_STYLE_TODAY_BOX:
ext->style_today_box = style;
break;
case LV_CALENDAR_STYLE_WEEK_BOX:
ext->style_week_box = style;
break;
}
lv_obj_invalidate(calendar);
@@ -299,6 +327,18 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
* Getter functions
*====================*/
/**
* Get the action of a calendar
* @param calendar pointer to a calendar object
* @return pointer to the action function
*/
lv_action_t lv_calendar_get_action(const lv_obj_t * calendar, lv_calendar_action_t type)
{
if(type >= LV_CALENDAR_ACTION_NUM) return NULL;
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
return ext->actions[type];
}
/**
* Get the today's date
@@ -322,6 +362,17 @@ lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar)
return &ext->showed_date;
}
/**
* Get the the pressed date.
* @param calendar pointer to a calendar object
* @return pointer to an `lv_calendar_date_t` variable containing the pressed date.
*/
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar)
{
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
return &ext->pressed_date;
}
/**
* Get the the highlighted dates
* @param calendar pointer to a calendar object
@@ -374,31 +425,40 @@ const char ** lv_calendar_get_month_names(const lv_obj_t * calendar)
* */
lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type)
{
lv_style_t * style = NULL;
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
switch(type) {
case LV_CALENDAR_STYLE_BG:
return lv_obj_get_style(calendar);
style = lv_obj_get_style(calendar);
break;
case LV_CALENDAR_STYLE_HEADER:
return ext->style_header;
style = ext->style_header;
break;
case LV_CALENDAR_STYLE_HEADER_PR:
return ext->style_header_pr;
style = ext->style_header_pr;
break;
case LV_CALENDAR_STYLE_DAY_NAMES:
return ext->style_day_names;
style = ext->style_day_names;
break;
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
return ext->style_highlighted_days;
style = ext->style_highlighted_days;
break;
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
return ext->style_inactive_days;
style = ext->style_inactive_days;
break;
case LV_CALENDAR_STYLE_WEEK_BOX:
return ext->style_week_box;
style = ext->style_week_box;
break;
case LV_CALENDAR_STYLE_TODAY_BOX:
return ext->style_today_box;
style = ext->style_today_box;
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/*=====================
@@ -465,11 +525,26 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_PRESSED) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
/*Call the press action, 'param' is the caller indev_proc*/
if(ext->actions[LV_CALENDAR_ACTION_PR]) {
lv_indev_t * indev = lv_indev_get_act();
lv_point_t p;
lv_indev_get_point(indev, &p);
if(calculate_touched_day(calendar, &p)){
if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
ext->btn_pressing = 0;
res = ext->actions[LV_CALENDAR_ACTION_PR](calendar);
}
}
} else if(sign == LV_SIGNAL_PRESSING) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
lv_area_t header_area;
lv_area_copy(&header_area, &calendar->coords);
header_area.y2 = header_area.y1 + get_header_height(calendar);
lv_indev_t * indev = lv_indev_get_act();
lv_point_t p;
lv_indev_get_point(indev, &p);
@@ -482,14 +557,22 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
if(ext->btn_pressing != 1) lv_obj_invalidate(calendar);
ext->btn_pressing = 1;
}
ext->pressed_date.year = 0;
} else if(calculate_touched_day(calendar, &p)) {
if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
ext->btn_pressing = 0;
} else {
if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
ext->btn_pressing = 0;
ext->pressed_date.year = 0;
}
} else if(sign == LV_SIGNAL_PRESS_LOST) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
ext->pressed_date.year = 0;
ext->btn_pressing = 0;
lv_obj_invalidate(calendar);
} else if(sign == LV_SIGNAL_RELEASED) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(ext->btn_pressing < 0) {
@@ -507,10 +590,28 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
ext->showed_date.month ++;
}
}
else if(ext->pressed_date.year != 0)
{
if(ext->actions[LV_CALENDAR_ACTION_CLICK]) {
res = ext->actions[LV_CALENDAR_ACTION_CLICK](calendar);
}
}
ext->pressed_date.year = 0;
ext->btn_pressing = 0;
lv_obj_invalidate(calendar);
} else if(sign == LV_SIGNAL_LONG_PRESS) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(ext->actions[LV_CALENDAR_ACTION_LONG_PR] && (ext->pressed_date.year != 0)) {
res = ext->actions[LV_CALENDAR_ACTION_LONG_PR](calendar);
}
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT] && (ext->pressed_date.year != 0)) {
res = ext->actions[LV_CALENDAR_ACTION_LONG_PR_REPEAT](calendar);
}
} else if(sign == LV_SIGNAL_CONTROLL) {
uint8_t c = *((uint8_t *) param);
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
@@ -543,6 +644,60 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
return res;
}
/**
* It will check if the days part of calendar is touched
* and if it is, it will calculate the day and put it in pressed_date of calendar object.
* @param calendar pointer to a calendar object
* @param pointer to a point
* @return true: days part of calendar is touched and its related date is put in pressed date
* false: the point is out of days part area.
*/
static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touched_point)
{
lv_area_t days_area;
lv_area_copy(&days_area, &calendar->coords);
lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG);
days_area.x1 += style_bg->body.padding.hor;
days_area.x2 -= style_bg->body.padding.hor;
days_area.y1 = calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.ver;
if(lv_area_is_point_on(&days_area, touched_point)) {
lv_coord_t w = (days_area.x2 - days_area.x1 + 1) / 7;
lv_coord_t h = (days_area.y2 - days_area.y1 + 1) / 6;
uint8_t x_pos = 0;
x_pos = (touched_point->x - days_area.x1) / w;
if(x_pos > 6) x_pos = 6;
uint8_t y_pos = 0;
y_pos = (touched_point->y - days_area.y1) / h;
if(y_pos > 5) y_pos = 5;
uint8_t i_pos = 0;
i_pos = (y_pos * 7) + x_pos;
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) ) {
ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0);
ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
ext->pressed_date.day = get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
}
else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
get_month_length(ext->showed_date.year, ext->showed_date.month))) {
ext->pressed_date.year = ext->showed_date.year;
ext->pressed_date.month = ext->showed_date.month;
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
}
else if(i_pos < 42) {
ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0);
ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)
- get_month_length(ext->showed_date.year, ext->showed_date.month);
}
return true;
}else {
return false;
}
}
/**
* Get the height of a calendar's header based on it's style
* @param calendar point to a calendar
@@ -555,6 +710,18 @@ static lv_coord_t get_header_height(lv_obj_t * calendar)
return lv_font_get_height(ext->style_header->text.font) + ext->style_header->body.padding.ver * 2;
}
/**
* Get the height of a calendar's day_names based on it's style
* @param calendar point to a calendar
* @return the day_names's height
*/
static lv_coord_t get_day_names_height(lv_obj_t * calendar)
{
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
return lv_font_get_height(ext->style_day_names->text.font) + ext->style_day_names->body.padding.ver * 2;
}
/**
* Draw the calendar header with month name and arrows
* @param calendar point to a calendar
@@ -590,8 +757,8 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
/*Add the right arrow*/
arrow_style = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header;
header_area.x1 = header_area.x2 - ext->style_header->body.padding.hor -
lv_txt_get_width(SYMBOL_RIGHT, 1, arrow_style->text.font,
arrow_style->text.line_space, LV_TXT_FLAG_NONE);
lv_txt_get_width(SYMBOL_RIGHT, strlen(SYMBOL_RIGHT), arrow_style->text.font,
arrow_style->text.line_space, LV_TXT_FLAG_NONE);
lv_draw_label(&header_area, mask, arrow_style, opa_scale, SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL);
}
@@ -634,8 +801,8 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
lv_area_t label_area;
lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) +
ext->style_day_names->body.padding.ver + lv_font_get_height(ext->style_day_names->text.font) +
style_bg->body.padding.inner;
ext->style_day_names->body.padding.ver + lv_font_get_height(ext->style_day_names->text.font) +
ext->style_day_names->body.padding.ver;
label_area.y2 = label_area.y1 + lv_font_get_height(style_bg->text.font);
lv_coord_t w = lv_obj_get_width(calendar) - 2 * hpad;
@@ -677,7 +844,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
/*Draw the "week box"*/
if(month_of_today_shown &&
((draw_state == DAY_DRAW_ACT_MONTH && ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) ||
(draw_state == DAY_DRAW_PREV_MONTH && ext->today.day <= 7 - month_start_day && week == 0))) {
(draw_state == DAY_DRAW_PREV_MONTH && ext->today.day <= 7 - month_start_day && week == 0))) {
lv_area_t week_box_area;
lv_area_copy(&week_box_area, &label_area); /*'label_area' is already set for this row*/
week_box_area.x1 = calendar->coords.x1 + style_bg->body.padding.hor - ext->style_week_box->body.padding.hor;
@@ -728,18 +895,18 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
lv_style_t * final_style;
if(draw_state == DAY_DRAW_PREV_MONTH &&
is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1,
day_cnt)) {
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1,
day_cnt)) {
final_style = ext->style_highlighted_days;
} else if(draw_state == DAY_DRAW_ACT_MONTH &&
is_highlighted(calendar, ext->showed_date.year,
ext->showed_date.month,
day_cnt)) {
is_highlighted(calendar, ext->showed_date.year,
ext->showed_date.month,
day_cnt)) {
final_style = ext->style_highlighted_days;
} else if(draw_state == DAY_DRAW_NEXT_MONTH &&
is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1,
day_cnt)) {
is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1,
day_cnt)) {
final_style = ext->style_highlighted_days;
} else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_today_box;
else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_week_box;
@@ -863,7 +1030,7 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
uint32_t b = year - a;
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) +
b + (b / 4) - (b / 100) + (b / 400)) % 7;
b + (b / 4) - (b / 100) + (b / 400)) % 7;
return day_of_week;
}

View File

@@ -37,6 +37,16 @@ typedef struct {
int8_t day;
} lv_calendar_date_t;
enum
{
LV_CALENDAR_ACTION_CLICK,
LV_CALENDAR_ACTION_PR,
LV_CALENDAR_ACTION_LONG_PR,
LV_CALENDAR_ACTION_LONG_PR_REPEAT,
LV_CALENDAR_ACTION_NUM,
};
typedef uint8_t lv_calendar_action_t;
/*Data of calendar*/
typedef struct {
/*None*/ /*Ext. of ancestor*/
@@ -46,8 +56,10 @@ typedef struct {
lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/
uint8_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/
int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/
lv_calendar_date_t pressed_date;
const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/
const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/
lv_action_t actions[LV_CALENDAR_ACTION_NUM];
/*Styles*/
lv_style_t * style_header;
@@ -74,6 +86,7 @@ typedef uint8_t lv_calendar_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
@@ -94,6 +107,12 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set a function to call when a calendar event happens
* @param calendar pointer to a calendar object
* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)
*/
void lv_calendar_set_action(lv_obj_t * calendar, lv_calendar_action_t type, lv_action_t action);
/**
* Set the today's date
@@ -145,6 +164,12 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
/*=====================
* Getter functions
*====================*/
/**
* Get the action of a calendar
* @param calendar pointer to a calendar object
* @return pointer to the action function
*/
lv_action_t lv_calendar_get_action(const lv_obj_t * calendar, lv_calendar_action_t type);
/**
* Get the today's date
@@ -160,6 +185,13 @@ lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);
*/
lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);
/**
* Get the the pressed date.
* @param calendar pointer to a calendar object
* @return pointer to an `lv_calendar_date_t` variable containing the pressed date.
*/
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar);
/**
* Get the the highlighted dates
* @param calendar pointer to a calendar object

594
lv_objx/lv_canvas.c Normal file
View File

@@ -0,0 +1,594 @@
/**
* @file lv_canvas.c
*
*/
/*********************
* INCLUDES
*********************/
#include <stdlib.h>
#include "lv_canvas.h"
#if USE_LV_CANVAS != 0
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
**********************/
static lv_signal_func_t ancestor_signal;
static lv_design_func_t ancestor_design;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create a canvas object
* @param par pointer to an object, it will be the parent of the new canvas
* @param copy pointer to a canvas object, if not NULL then the new object will be copied from it
* @return pointer to the created canvas
*/
lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("canvas create started");
/*Create the ancestor of canvas*/
lv_obj_t * new_canvas = lv_img_create(par, copy);
lv_mem_assert(new_canvas);
if(new_canvas == NULL) return NULL;
/*Allocate the canvas type specific extended data*/
lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t));
lv_mem_assert(ext);
if(ext == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_canvas);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_canvas);
/*Initialize the allocated 'ext' */
ext->dsc.header.always_zero = 0;
ext->dsc.header.cf = LV_IMG_CF_TRUE_COLOR;
ext->dsc.header.h = 0;
ext->dsc.header.w = 0;
ext->dsc.data_size = 0;
ext->dsc.data = NULL;
lv_img_set_src(new_canvas, &ext->dsc);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_canvas, lv_canvas_signal);
/*Init the new canvas canvas*/
if(copy == NULL) {
}
/*Copy an existing canvas*/
else {
//lv_canvas_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_canvas);
}
LV_LOG_INFO("canvas created");
return new_canvas;
}
/*=====================
* Setter functions
*====================*/
/**
* Set a buffer for the canvas.
* @param buf a buffer where the content of the canvas will be.
* The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8)
* It can be allocated with `lv_mem_alloc()` or
* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or
* it can be an address in RAM or external SRAM
* @param canvas pointer to a canvas object
* @param w width of the canvas
* @param h height of the canvas
* @param cf color format. The following formats are supported:
* LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT
*
*/
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
{
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
ext->dsc.header.cf = cf;
ext->dsc.header.w = w;
ext->dsc.header.h = h;
ext->dsc.data = buf;
ext->dsc.data_size = (lv_img_color_format_get_px_size(cf) * w * h) / 8;
lv_img_set_src(canvas, &ext->dsc);
}
/**
* Set the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @param c color of the point
*/
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
{
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x >= ext->dsc.header.w || y >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_set_px: x or y out of the canvas");
return;
}
uint8_t * buf_u8 = (uint8_t *) ext->dsc.data;
if(ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR ||
ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
uint32_t px = ext->dsc.header.w * y * sizeof(lv_color_t) + x * sizeof(lv_color_t);
memcpy(&buf_u8[px], &c, sizeof(lv_color_t));
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += 4 * 2;
uint8_t bit = x & 0x7;
x = x >> 3;
uint32_t px = (ext->dsc.header.w >> 3) * y + x;
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0x1) << (7 - bit));
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_2BIT) {
buf_u8 += 4 * 4;
uint8_t bit = (x & 0x3) * 2;
x = x >> 2;
uint32_t px = (ext->dsc.header.w >> 2) * y + x;
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0x3) << (6 - bit));
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_4BIT) {
buf_u8 += 4 * 16;
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
uint32_t px = (ext->dsc.header.w >> 1) * y + x;
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
buf_u8[px] = buf_u8[px] | ((c.full & 0xF) << (4 - bit));
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_8BIT) {
buf_u8 += 4 * 256;
uint32_t px = ext->dsc.header.w * y + x;
buf_u8[px] = c.full;
}
}
/**
* Set a style of a canvas.
* @param canvas pointer to canvas object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style)
{
switch(type) {
case LV_CANVAS_STYLE_MAIN:
lv_img_set_style(canvas, style);
break;
}
}
/*=====================
* Getter functions
*====================*/
/**
* Get the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @return color of the point
*/
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
{
lv_color_t p_color = LV_COLOR_BLACK;
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x >= ext->dsc.header.w || y >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_get_px: x or y out of the canvas");
return p_color;
}
uint8_t * buf_u8 = (uint8_t *) ext->dsc.data;
if(ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR ||
ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
{
uint32_t px = ext->dsc.header.w * y * sizeof(lv_color_t) + x * sizeof(lv_color_t);
memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t));
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += 4 * 2;
uint8_t bit = x & 0x7;
x = x >> 3;
uint32_t px = (ext->dsc.header.w >> 3) * y + x;
p_color.full = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_2BIT) {
buf_u8 += 4 * 4;
uint8_t bit = (x & 0x3) * 2;
x = x >> 2;
uint32_t px = (ext->dsc.header.w >> 2) * y + x;
p_color.full = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_4BIT) {
buf_u8 += 4 * 16;
uint8_t bit = (x & 0x1) * 4;
x = x >> 1;
uint32_t px = (ext->dsc.header.w >> 1) * y + x;
p_color.full = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
}
else if(ext->dsc.header.cf == LV_IMG_CF_INDEXED_8BIT) {
buf_u8 += 4 * 256;
uint32_t px = ext->dsc.header.w * y + x;
p_color.full = buf_u8[px];
}
return p_color;
}
/**
* Get style of a canvas.
* @param canvas pointer to canvas object
* @param type which style should be get
* @return style pointer to the style
*/
lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type)
{
// lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
lv_style_t * style = NULL;
switch(type) {
case LV_CANVAS_STYLE_MAIN:
style = lv_img_get_style(canvas);
break;
default:
style = NULL;
}
return style;
}
/*=====================
* Other functions
*====================*/
/**
* Copy a buffer to the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color format
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
{
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_copy_buf: x or y out of the canvas");
return;
}
uint32_t px_size = lv_img_color_format_get_px_size(ext->dsc.header.cf) >> 3;
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
uint8_t * to_copy8 = (uint8_t *) to_copy;
lv_coord_t i;
for(i = 0; i < h; i++) {
memcpy((void*)&ext->dsc.data[px], to_copy8, w * px_size);
px += ext->dsc.header.w * px_size;
to_copy8 += w * px_size;
}
}
/**
* Multiply a buffer with the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy (multiply). LV_IMG_CF_TRUE_COLOR_ALPHA is not supported
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
{
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
LV_LOG_WARN("lv_canvas_mult_buf: x or y out of the canvas");
return;
}
if(ext->dsc.header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
LV_LOG_WARN("lv_canvas_mult_buf: LV_IMG_CF_TRUE_COLOR_ALPHA is not supported");
return;
}
uint32_t px_size = lv_img_color_format_get_px_size(ext->dsc.header.cf) >> 3;
uint32_t px = ext->dsc.header.w * y * px_size + x * px_size;
lv_color_t * copy_buf_color = (lv_color_t *) to_copy;
lv_color_t * canvas_buf_color = (lv_color_t *) &ext->dsc.data[px];
lv_coord_t i;
lv_coord_t j;
for(i = 0; i < h; i++) {
for(j = 0; j < w; j++) {
#if LV_COLOR_DEPTH == 32
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 8;
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 8;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 8;
#elif LV_COLOR_DEPTH == 16
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 5;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 5;
# if LV_COLOR_16_SWAP == 0
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 6;
# else
uint8_t green_canvas = (canvas_buf_color[j].green_h << 3) + (canvas_buf_color[j].green_l);
uint8_t green_buf = (copy_buf_color[j].green_h << 3) + (copy_buf_color[j].green_l);
uint8_t green_res = (uint16_t)((uint16_t)green_canvas * green_buf) >> 6;
canvas_buf_color[j].green_h = (green_res >> 3) & 0x07;
canvas_buf_color[j].green_l = green_res & 0x07;
# endif /*LV_COLOR_16_SWAP*/
#elif LV_COLOR_DEPTH == 8
canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 3;
canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 3;
canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 2;
#endif
}
copy_buf_color += w;
canvas_buf_color += ext->dsc.header.w;
}
}
/**
* Draw circle function of the canvas
* @param canvas pointer to a canvas object
* @param x0 x coordinate of the circle
* @param y0 y coordinate of the circle
* @param radius radius of the circle
* @param color border color of the circle
*/
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius, lv_color_t color)
{
int x = radius;
int y = 0;
int err = 0;
while (x >= y)
{
lv_canvas_set_px(canvas, x0 + x, y0 + y, color);
lv_canvas_set_px(canvas, x0 + y, y0 + x, color);
lv_canvas_set_px(canvas, x0 - y, y0 + x, color);
lv_canvas_set_px(canvas, x0 - x, y0 + y, color);
lv_canvas_set_px(canvas, x0 - x, y0 - y, color);
lv_canvas_set_px(canvas, x0 - y, y0 - x, color);
lv_canvas_set_px(canvas, x0 + y, y0 - x, color);
lv_canvas_set_px(canvas, x0 + x, y0 - y, color);
if (err <= 0)
{
y += 1;
err += 2*y + 1;
}
if (err > 0)
{
x -= 1;
err -= 2*x + 1;
}
}
}
/**
* Draw line function of the canvas
* @param canvas pointer to a canvas object
* @param point1 start point of the line
* @param point2 end point of the line
* @param color color of the line
*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
*/
/*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
*/
void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2, lv_color_t color)
{
lv_coord_t x0, y0, x1, y1;
x0 = point1.x;
y0 = point1.y;
x1 = point2.x;
y1 = point2.y;
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
int err = (dx>dy ? dx : -dy)/2, e2;
for(;;){
lv_canvas_set_px(canvas, x0, y0, color);
if (x0==x1 && y0==y1) break;
e2 = err;
if (e2 >-dx) { err -= dy; x0 += sx; }
if (e2 < dy) { err += dx; y0 += sy; }
}
}
/**
* Draw triangle function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the triangle
* @param color line color of the triangle
*/
void lv_canvas_draw_triangle(lv_obj_t * canvas, lv_point_t * points, lv_color_t color)
{
lv_canvas_draw_polygon(canvas, points, 3, color);
}
/**
* Draw rectangle function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the rectangle
* @param color line color of the rectangle
*/
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_point_t * points, lv_color_t color)
{
lv_canvas_draw_polygon(canvas, points, 4, color);
}
/**
* Draw polygon function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param color line color of the polygon
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t color)
{
uint8_t i;
for(i=0; i < (size - 1); i++) {
lv_canvas_draw_line(canvas, points[i], points[i + 1], color);
}
lv_canvas_draw_line(canvas, points[size - 1], points[0], color);
}
/**
* Fill polygon function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param boundary_color line color of the polygon
* @param fill_color fill color of the polygon
*/
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color)
{
uint32_t x = 0, y = 0;
uint8_t i;
for(i=0; i<size; i++) {
x += points[i].x;
y += points[i].y;
}
x = x / size;
y = y / size;
lv_canvas_boundary_fill4(canvas, (lv_coord_t) x, (lv_coord_t) y, boundary_color, fill_color);
}
/**
* Boundary fill function of the canvas
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param boundary_color edge/boundary color of the area
* @param fill_color fill color of the area
*/
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color)
{
lv_color_t c;
c = lv_canvas_get_px(canvas, x, y);
if(c.full != boundary_color.full &&
c.full != fill_color.full)
{
lv_canvas_set_px(canvas, x, y, fill_color);
lv_canvas_boundary_fill4(canvas, x + 1, y, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x, y + 1, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x - 1, y, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x, y - 1, boundary_color, fill_color);
}
}
/**
* Flood fill function of the canvas
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param fill_color fill color of the area
* @param bg_color background color of the area
*/
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t bg_color)
{
lv_color_t c;
c = lv_canvas_get_px(canvas, x, y);
if(c.full == bg_color.full)
{
lv_canvas_set_px(canvas, x, y, fill_color);
lv_canvas_flood_fill(canvas, x+1, y, fill_color, bg_color);
lv_canvas_flood_fill(canvas, x, y+1, fill_color, bg_color);
lv_canvas_flood_fill(canvas, x-1, y, fill_color, bg_color);
lv_canvas_flood_fill(canvas, x, y-1, fill_color, bg_color);
}
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Signal function of the canvas
* @param canvas pointer to a canvas object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_canvas_signal(lv_obj_t * canvas, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(canvas, sign, param);
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_canvas";
}
return res;
}
#endif

229
lv_objx/lv_canvas.h Normal file
View File

@@ -0,0 +1,229 @@
/**
* @file lv_canvas.h
*
*/
#ifndef LV_CANVAS_H
#define LV_CANVAS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../lv_conf.h"
#endif
#if USE_LV_CANVAS != 0
#include "../lv_core/lv_obj.h"
#include "../lv_objx/lv_img.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of canvas*/
typedef struct {
lv_img_ext_t img; /*Ext. of ancestor*/
/*New data for this type */
lv_img_dsc_t dsc;
} lv_canvas_ext_t;
/*Styles*/
enum {
LV_CANVAS_STYLE_MAIN,
};
typedef uint8_t lv_canvas_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a canvas object
* @param par pointer to an object, it will be the parent of the new canvas
* @param copy pointer to a canvas object, if not NULL then the new object will be copied from it
* @return pointer to the created canvas
*/
lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set a buffer for the canvas.
* @param buf a buffer where the content of the canvas will be.
* The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8)
* It can be allocated with `lv_mem_alloc()` or
* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or
* it can be an address in RAM or external SRAM
* @param canvas pointer to a canvas object
* @param w width of the canvas
* @param h height of the canvas
* @param cf color format. The following formats are supported:
* LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT
*/
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
/**
* Set the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @param c color of the point
*/
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);
/**
* Set a style of a canvas.
* @param canvas pointer to canvas object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style);
/*=====================
* Getter functions
*====================*/
/**
* Get the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @return color of the point
*/
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y);
/**
* Get style of a canvas.
* @param canvas pointer to canvas object
* @param type which style should be get
* @return style pointer to the style
*/
lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type);
/*=====================
* Other functions
*====================*/
/**
* Copy a buffer to the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color format
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
/**
* Multiply a buffer with the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy (multiply). LV_IMG_CF_TRUE_COLOR_ALPHA is not supported
* @param w width of the buffer to copy
* @param h height of the buffer to copy
* @param x left side of the destination position
* @param y top side of the destination position
*/
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
/**
* Draw circle function of the canvas
* @param canvas pointer to a canvas object
* @param x0 x coordinate of the circle
* @param y0 y coordinate of the circle
* @param radius radius of the circle
* @param color border color of the circle
*/
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius, lv_color_t color);
/**
* Draw line function of the canvas
* @param canvas pointer to a canvas object
* @param point1 start point of the line
* @param point2 end point of the line
* @param color color of the line
*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
*/
void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2, lv_color_t color);
/**
* Draw triangle function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the triangle
* @param color line color of the triangle
*/
void lv_canvas_draw_triangle(lv_obj_t * canvas, lv_point_t * points, lv_color_t color);
/**
* Draw rectangle function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the rectangle
* @param color line color of the rectangle
*/
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_point_t * points, lv_color_t color);
/**
* Draw polygon function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param color line color of the polygon
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t color);
/**
* Fill polygon function of the canvas
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param boundary_color line color of the polygon
* @param fill_color fill color of the polygon
*/
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color);
/**
* Boundary fill function of the canvas
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param boundary_color edge/boundary color of the area
* @param fill_color fill color of the area
*/
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color);
/**
* Flood fill function of the canvas
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param fill_color fill color of the area
* @param bg_color background color of the area
*/
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t bg_color);
/**********************
* MACROS
**********************/
#endif /*USE_LV_CANVAS*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_CANVAS_H*/

View File

@@ -192,25 +192,31 @@ const char * lv_cb_get_text(const lv_obj_t * cb)
* */
lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type)
{
lv_style_t * style = NULL;
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
switch(type) {
case LV_CB_STYLE_BOX_REL:
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
break;
case LV_CB_STYLE_BOX_PR:
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
break;
case LV_CB_STYLE_BOX_TGL_REL:
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
break;
case LV_CB_STYLE_BOX_TGL_PR:
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
break;
case LV_CB_STYLE_BOX_INA:
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid awrning*/
return NULL;
return style;
}
/**********************
@@ -229,9 +235,11 @@ lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type)
*/
static bool lv_cb_design(lv_obj_t * cb, const lv_area_t * mask, lv_design_mode_t mode)
{
bool result = true;
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return ancestor_bg_design(cb, mask, mode);
result = ancestor_bg_design(cb, mask, mode);
} else if(mode == LV_DESIGN_DRAW_MAIN || mode == LV_DESIGN_DRAW_POST) {
lv_cb_ext_t * cb_ext = lv_obj_get_ext_attr(cb);
lv_btn_ext_t * bullet_ext = lv_obj_get_ext_attr(cb_ext->bullet);
@@ -239,13 +247,13 @@ static bool lv_cb_design(lv_obj_t * cb, const lv_area_t * mask, lv_design_mode_t
/*Be sure the state of the bullet is the same as the parent button*/
bullet_ext->state = cb_ext->bg_btn.state;
return ancestor_bg_design(cb, mask, mode);
result = ancestor_bg_design(cb, mask, mode);
} else {
return ancestor_bg_design(cb, mask, mode);
result = ancestor_bg_design(cb, mask, mode);
}
return true;
return result;
}
/**

View File

@@ -34,6 +34,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask);
static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask);
static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask);
static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask);
static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mask);
/**********************
* STATIC VARIABLES
@@ -57,8 +58,6 @@ static lv_signal_func_t ancestor_signal;
*/
lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
{
LV_LOG_TRACE("chart create started");
/*Create the ancestor basic object*/
@@ -138,7 +137,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
lv_mem_assert(ser);
if(ser == NULL) return NULL;
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
lv_coord_t def = LV_CHART_POINT_DEF;
if(ser == NULL) return NULL;
@@ -152,6 +151,8 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
return NULL;
}
ser->start_point = 0;
uint16_t i;
lv_coord_t * p_tmp = ser->points;
for(i = 0; i < ext->point_cnt; i++) {
@@ -164,6 +165,28 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
return ser;
}
/**
* Clear the point of a serie
* @param chart pointer to a chart object
* @param serie pointer to the chart's serie to clear
*/
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
{
if(chart == NULL || serie == NULL)
return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext == NULL) return;
uint32_t i;
for(i = 0; i < ext->point_cnt; i++)
{
serie->points[i] = LV_CHART_POINT_DEF;
}
serie->start_point = 0;
}
/*=====================
* Setter functions
*====================*/
@@ -230,23 +253,49 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
lv_chart_series_t * ser;
uint16_t point_cnt_old = ext->point_cnt;
uint16_t i;
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
lv_coord_t def = LV_CHART_POINT_DEF;
if(point_cnt < 1) point_cnt = 1;
LL_READ_BACK(ext->series_ll, ser) {
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
lv_mem_assert(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {
for(i = point_cnt_old - 1; i < point_cnt; i++) {
ser->points[i] = def;
if(ser->start_point != 0) {
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
lv_mem_assert(new_points);
if(new_points == NULL) return;
if(point_cnt >= point_cnt_old) {
for(i = 0; i < point_cnt_old; i++) {
new_points[i] = ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
}
for(i = point_cnt_old; i < point_cnt; i++) {
new_points[i] = def; /*Fill up the rest with default value*/
}
} else {
for(i = 0; i < point_cnt; i++) {
new_points[i] = ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
}
}
/*Switch over pointer from old to new*/
lv_mem_free(ser->points);
ser->points = new_points;
} else {
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
lv_mem_assert(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {
for(i = point_cnt_old - 1; i < point_cnt; i++) {
ser->points[i] = def;
}
}
}
ser->start_point = 0;
}
ext->point_cnt = point_cnt;
lv_chart_refresh(chart);
}
@@ -304,6 +353,7 @@ void lv_chart_init_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t
for(i = 0; i < ext->point_cnt; i++) {
ser->points[i] = y;
}
ser->start_point = 0;
lv_chart_refresh(chart);
}
@@ -317,27 +367,24 @@ void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t *
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
memcpy(ser->points, y_array, ext->point_cnt * (sizeof(lv_coord_t)));
ser->start_point = 0;
lv_chart_refresh(chart);
}
/**
* Shift all data right and set the most right data on a data line
* Shift all data left and set the rightmost data on a data line
* @param chart pointer to chart object
* @param ser pointer to a data series on 'chart'
* @param y the new value of the most right data
* @param y the new value of the rightmost data
*/
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
uint16_t i;
for(i = 0; i < ext->point_cnt - 1; i++) {
ser->points[i] = ser->points[i + 1];
}
ser->points[ser->start_point] = y; /*This was the place of the former left most value, after shifting it is the rightmost*/
ser->start_point = (ser->start_point + 1) % ext->point_cnt;
ser->points[ext->point_cnt - 1] = y;
lv_chart_refresh(chart);
}
/*=====================
@@ -442,6 +489,7 @@ static bool lv_chart_design(lv_obj_t * chart, const lv_area_t * mask, lv_design_
if(ext->type & LV_CHART_TYPE_LINE) lv_chart_draw_lines(chart, mask);
if(ext->type & LV_CHART_TYPE_COLUMN) lv_chart_draw_cols(chart, mask);
if(ext->type & LV_CHART_TYPE_POINT) lv_chart_draw_points(chart, mask);
if(ext->type & LV_CHART_TYPE_VERTICAL_LINE) lv_chart_draw_vertical_lines(chart, mask);
}
return true;
}
@@ -562,6 +610,8 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
lv_coord_t x_ofs = chart->coords.x1;
lv_coord_t y_ofs = chart->coords.y1;
int32_t y_tmp;
lv_coord_t p_prev;
lv_coord_t p_act;
lv_chart_series_t * ser;
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
lv_style_t style;
@@ -575,7 +625,9 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
p1.x = 0 + x_ofs;
p2.x = 0 + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
p_prev = ser->start_point;
y_tmp = (int32_t)((int32_t) ser->points[p_prev] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
@@ -585,11 +637,16 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
p_act = (ser->start_point + i) % ext->point_cnt;
y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF)
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
p_prev = p_act;
}
}
}
@@ -610,6 +667,7 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
lv_coord_t x_ofs = chart->coords.x1;
lv_coord_t y_ofs = chart->coords.y1;
int32_t y_tmp;
lv_coord_t p_act;
lv_chart_series_t * ser;
uint8_t series_cnt = 0;
lv_style_t style_point;
@@ -630,14 +688,15 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
cir_a.x2 = cir_a.x1 + style_point.body.radius;
cir_a.x1 -= style_point.body.radius;
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
p_act = (ser->start_point + i) % ext->point_cnt;
y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
cir_a.y1 = h - y_tmp + y_ofs;
cir_a.y2 = cir_a.y1 + style_point.body.radius;
cir_a.y1 -= style_point.body.radius;
lv_draw_rect(&cir_a, mask, &style_point, lv_obj_get_opa_scale(chart));
if(ser->points[p_act] != LV_CHART_POINT_DEF)
lv_draw_rect(&cir_a, mask, &style_point, lv_obj_get_opa_scale(chart));
}
series_cnt++;
}
@@ -687,15 +746,79 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
col_a.x2 = col_a.x1 + col_w;
x_act += col_w;
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
lv_coord_t p_act = (ser->start_point + i) % ext->point_cnt;
y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
col_a.y1 = h - y_tmp + chart->coords.y1;
mask_ret = lv_area_intersect(&col_mask, mask, &col_a);
if(mask_ret != false) {
if(mask_ret != false && ser->points[p_act] != LV_CHART_POINT_DEF) {
lv_draw_rect(&chart->coords, &col_mask, &rects, lv_obj_get_opa_scale(chart));
}
}
}
}
/**
* Draw the data lines as vertical lines on a chart if there is only 1px between point
* @param obj pointer to chart object
*/
static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mask)
{
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
lv_coord_t w = lv_obj_get_width(chart);
/*Vertical lines works only if the width == point count. Else use the normal line type*/
if(ext->point_cnt != w) {
lv_chart_draw_lines(chart, mask);
return;
}
uint16_t i;
lv_point_t p1;
lv_point_t p2;
lv_coord_t h = lv_obj_get_height(chart);
lv_coord_t x_ofs = chart->coords.x1;
lv_coord_t y_ofs = chart->coords.y1;
int32_t y_tmp;
lv_chart_series_t * ser;
lv_opa_t opa_scale = lv_obj_get_opa_scale(chart);
lv_style_t style;
lv_style_copy(&style, &lv_style_plain);
style.line.opa = ext->series.opa;
style.line.width = ext->series.width;
/*Go through all data lines*/
LL_READ_BACK(ext->series_ll, ser) {
style.line.color = ser->color;
p1.x = 0 + x_ofs;
p2.x = 0 + x_ofs;
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
p1.y = p2.y;
for(i = 0; i < ext->point_cnt; i++)
{
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
p2.y = h - y_tmp + y_ofs;
if(p1.y == p2.y)
{
p2.x++;
}
if(ser->points[i] != LV_CHART_POINT_DEF) {
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
}
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
p1.x = p2.x;
p1.y = p2.y;
}
}
}
#endif

View File

@@ -27,6 +27,7 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define LV_CHART_POINT_DEF (LV_COORD_MIN)
/**********************
* TYPEDEFS
@@ -35,6 +36,7 @@ typedef struct
{
lv_coord_t * points;
lv_color_t color;
uint16_t start_point;
} lv_chart_series_t;
/*Data of chart */
@@ -48,21 +50,22 @@ typedef struct
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
uint8_t vdiv_cnt; /*Number of vertical division lines*/
uint16_t point_cnt; /*Point number in a data line*/
uint8_t type :3; /*Line, column or point chart (from 'lv_chart_type_t')*/
uint8_t type :4; /*Line, column or point chart (from 'lv_chart_type_t')*/
struct {
lv_coord_t width; /*Line width or point radius*/
uint8_t num; /*Number of data lines in dl_ll*/
lv_opa_t opa; /*Opacity of data lines*/
lv_opa_t dark; /*Dark level of the point/column bottoms*/
uint8_t num; /*Number of data lines in dl_ll*/
lv_opa_t opa; /*Opacity of data lines*/
lv_opa_t dark; /*Dark level of the point/column bottoms*/
} series;
} lv_chart_ext_t;
/*Chart types*/
enum
{
LV_CHART_TYPE_LINE = 0x01,
LV_CHART_TYPE_COLUMN = 0x02,
LV_CHART_TYPE_POINT = 0x04,
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
};
typedef uint8_t lv_chart_type_t;
@@ -91,6 +94,13 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);
*/
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
/**
* Clear the point of a serie
* @param chart pointer to a chart object
* @param serie pointer to the chart's serie to clear
*/
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
/*=====================
* Setter functions
*====================*/

View File

@@ -189,6 +189,30 @@ bool lv_cont_get_ver_fit(const lv_obj_t * cont)
return ext->ver_fit == 0 ? false : true;
}
/**
* Get that width reduced by the horizontal padding. Useful if a layout is used.
* @param cont pointer to a container object
* @return the width which still fits into the container
*/
lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont)
{
lv_style_t * style = lv_cont_get_style(cont);
return lv_obj_get_width(cont) - 2 * style->body.padding.hor;
}
/**
* Get that height reduced by the vertical padding. Useful if a layout is used.
* @param cont pointer to a container object
* @return the height which still fits into the container
*/
lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont)
{
lv_style_t * style = lv_cont_get_style(cont);
return lv_obj_get_height(cont) - 2 * style->body.padding.ver;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -125,6 +125,21 @@ bool lv_cont_get_hor_fit(const lv_obj_t * cont);
*/
bool lv_cont_get_ver_fit(const lv_obj_t * cont);
/**
* Get that width reduced by the horizontal padding. Useful if a layout is used.
* @param cont pointer to a container object
* @return the width which still fits into the container
*/
lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont);
/**
* Get that height reduced by the vertical padding. Useful if a layout is used.
* @param cont pointer to a container object
* @return the height which still fits into the container
*/
lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont);
/**
* Get the style of a container
* @param cont pointer to a container object

View File

@@ -16,6 +16,7 @@
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_symbol_def.h"
#include "../lv_misc/lv_anim.h"
#include <string.h>
/*********************
* DEFINES
@@ -92,6 +93,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->option_cnt = 0;
ext->anim_time = LV_DDLIST_ANIM_TIME;
ext->sel_style = &lv_style_plain_color;
ext->draw_arrow = 0; /*Do not draw arrow by default*/
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_ddlist, lv_ddlist_signal);
@@ -136,6 +138,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->option_cnt = copy_ext->option_cnt;
ext->sel_style = copy_ext->sel_style;
ext->anim_time = copy_ext->anim_time;
ext->draw_arrow = copy_ext->draw_arrow;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_ddlist);
@@ -151,6 +154,19 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
* Setter functions
*====================*/
/**
* Set arrow draw in a drop down list
* @param ddlist pointer to drop down list object
* @param en enable/disable a arrow draw. E.g. "true" for draw.
*/
void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*Set the flag*/
ext->draw_arrow = en;
}
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
@@ -183,7 +199,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
if(ext->sel_opt_id == sel_opt) return;
ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1;
ext->sel_opt_id_ori = ext->sel_opt_id;
/*Move the list to show the current option*/
if(ext->opened == 0) {
lv_ddlist_pos_current_option(ddlist);
@@ -222,12 +238,12 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
/**
* Enable or disable the horizontal fit to the content
* @param ddlist pointer to a drop down list
* @param fit en true: enable auto fit; false: disable auto fit
* @param en true: enable auto fit; false: disable auto fit
*/
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool fit_en)
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en)
{
lv_cont_set_fit(ddlist, fit_en, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, fit_en, lv_page_get_scrl_fit_ver(ddlist));
lv_cont_set_fit(ddlist, en, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, en, lv_page_get_scrl_fit_ver(ddlist));
lv_ddlist_refr_size(ddlist, false);
}
@@ -272,10 +288,27 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, lv_style_t *
}
}
void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_label_set_align(ext->label, align);
}
/*=====================
* Getter functions
*====================*/
/**
* Get arrow draw in a drop down list
* @param ddlist pointer to drop down list object
*/
bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->draw_arrow;
}
/**
* Get the options of a drop down list
* @param ddlist pointer to drop down list object
@@ -357,7 +390,6 @@ uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist)
return ext->anim_time;
}
/**
* Get a style of a drop down list
* @param ddlist pointer to a drop down list object
@@ -382,6 +414,14 @@ lv_style_t * lv_ddlist_get_style(const lv_obj_t * ddlist, lv_ddlist_style_t type
/*To avoid warning*/
return NULL;
}
lv_label_align_t lv_ddlist_get_align(const lv_obj_t *ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return lv_label_get_align(ext->label);
}
/*=====================
* Other functions
*====================*/
@@ -422,6 +462,32 @@ void lv_ddlist_close(lv_obj_t * ddlist, bool anim_en)
* STATIC FUNCTIONS
**********************/
/**
* Get the text alignment flag for a drop down list.
* @param ddlist drop down list
* @return text alignment flag
*/
static lv_txt_flag_t lv_ddlist_get_txt_flag(const lv_obj_t *ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
/*The label might be already deleted so just return with some value*/
if(!ext->label) return LV_TXT_FLAG_CENTER;
lv_label_align_t align = lv_label_get_align(ext->label);
switch(align)
{
default:
case LV_LABEL_ALIGN_LEFT:
return LV_TXT_FLAG_NONE;
case LV_LABEL_ALIGN_CENTER:
return LV_TXT_FLAG_CENTER;
case LV_LABEL_ALIGN_RIGHT:
return LV_TXT_FLAG_RIGHT;
}
}
/**
* Handle the drawing related tasks of the drop down lists
* @param ddlist pointer to an object
@@ -444,7 +510,6 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
/*If the list is opened draw a rectangle under the selected item*/
if(ext->opened != 0) {
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
@@ -493,11 +558,44 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
new_style.text.opa = sel_style->text.opa;
lv_txt_flag_t flag = lv_ddlist_get_txt_flag(ddlist);
lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale,
lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL);
lv_label_get_text(ext->label), flag, NULL);
}
}
/*Add a down symbol in ddlist when closed*/
else
{
/*Draw a arrow in ddlist if enabled*/
if(ext->draw_arrow)
{
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
lv_coord_t font_h = lv_font_get_height(font);
lv_style_t new_style;
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
new_style.text.opa = sel_style->text.opa;
lv_area_t area_arrow;
area_arrow.x2 = ddlist->coords.x2 - style->body.padding.hor;
area_arrow.x1 = area_arrow.x2 - lv_txt_get_width(SYMBOL_DOWN, strlen(SYMBOL_DOWN), sel_style->text.font, 0, 0);
area_arrow.y1 = ddlist->coords.y1 + style->text.line_space;
area_arrow.y2 = area_arrow.y1 + font_h;
lv_area_t mask_arrow;
bool area_ok;
area_ok = lv_area_intersect(&mask_arrow, mask, &area_arrow);
if (area_ok)
{
lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale,
SYMBOL_DOWN, LV_TXT_FLAG_NONE, NULL); /*Use a down arrow in ddlist, you can replace it with your custom symbol*/
}
}
}
/*Draw the scrollbar in the ancestor page design function*/
ancestor_design(ddlist, mask, mode);
}
@@ -526,6 +624,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
} else if(sign == LV_SIGNAL_CLEANUP) {
ext->label = NULL;
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g);
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
@@ -553,6 +652,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
lv_ddlist_refr_size(ddlist, true);
}
}
#endif
} else if(sign == LV_SIGNAL_DEFOCUS) {
if(ext->opened) {
ext->opened = false;
@@ -588,9 +688,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
ext->opened = 0;
if(ext->action) ext->action(ddlist);
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(ddlist);
bool editing = lv_group_get_editing(g);
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
#endif
} else {
ext->opened = 1;
}
@@ -599,6 +701,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
} else if(c == LV_GROUP_KEY_ESC) {
if(ext->opened) {
ext->opened = 0;
ext->sel_opt_id = ext->sel_opt_id_ori;
lv_ddlist_refr_size(ddlist, true);
}
}

View File

@@ -54,6 +54,8 @@ typedef struct
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
uint16_t anim_time; /*Open/Close animation time [ms]*/
uint8_t opened :1; /*1: The list is opened (handled by the library)*/
uint8_t draw_arrow :1; /*1: Draw arrow*/
lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/
} lv_ddlist_ext_t;
@@ -79,6 +81,13 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy);
* Setter functions
*====================*/
/**
* Set arrow draw in a drop down list
* @param ddlist pointer to drop down list object
* @param en enable/disable a arrow draw. E.g. "true" for draw.
*/
void lv_ddlist_set_draw_arrow(lv_obj_t * ddlist, bool en);
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
@@ -111,9 +120,9 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h);
/**
* Enable or disable the horizontal fit to the content
* @param ddlist pointer to a drop down list
* @param fit en true: enable auto fit; false: disable auto fit
* @param en true: enable auto fit; false: disable auto fit
*/
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool fit_en);
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en);
/**
* Set the scroll bar mode of a drop down list
@@ -141,10 +150,23 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time);
* */
void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *style);
/**
* Set the alignment of the labels in a drop down list
* @param ddlist pointer to a drop down list object
* @param align alignment of labels
*/
void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align);
/*=====================
* Getter functions
*====================*/
/**
* Get arrow draw in a drop down list
* @param ddlist pointer to drop down list object
*/
bool lv_ddlist_get_draw_arrow(lv_obj_t * ddlist);
/**
* Get the options of a drop down list
* @param ddlist pointer to drop down list object
@@ -205,6 +227,13 @@ uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist);
*/
lv_style_t * lv_ddlist_get_style(const lv_obj_t *ddlist, lv_ddlist_style_t type);
/**
* Get the alignment of the labels in a drop down list
* @param ddlist pointer to a drop down list object
* @return alignment of labels
*/
lv_label_align_t lv_ddlist_get_align(const lv_obj_t *ddlist);
/*=====================
* Other functions
*====================*/
@@ -214,14 +243,14 @@ lv_style_t * lv_ddlist_get_style(const lv_obj_t *ddlist, lv_ddlist_style_t type)
* @param ddlist pointer to drop down list object
* @param anim_en true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim);
void lv_ddlist_open(lv_obj_t * ddlist, bool anim_en);
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
* @param anim_en true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
void lv_ddlist_close(lv_obj_t * ddlist, bool anim_en);
/**********************
* MACROS

View File

@@ -24,7 +24,8 @@
#define LV_GAUGE_DEF_LABEL_COUNT 6
#define LV_GAUGE_DEF_LINE_COUNT 21 /*Should be: ((label_cnt - 1) * internal_lines) + 1*/
#define LV_GAUGE_DEF_ANGLE 220
#define LV_GAUGE_INTERPOLATE_SHIFT 5 /*Interpolate the needle drawing between to degrees*/
#define LV_GAUGE_INTERPOLATE_MASK 0x1F
/**********************
* TYPEDEFS
@@ -406,6 +407,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
int16_t max = lv_gauge_get_max_value(gauge);
lv_point_t p_mid;
lv_point_t p_end;
lv_point_t p_end_low;
lv_point_t p_end_high;
uint8_t i;
lv_style_copy(&style_needle, style);
@@ -414,9 +417,28 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
p_mid.y = y_ofs;
for(i = 0; i < ext->needle_count; i++) {
/*Calculate the end point of a needle*/
int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs;
p_end.y = (lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end.x = (lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
int16_t needle_angle = (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) / (max - min); //+ angle_ofs;
int16_t needle_angle_low = (needle_angle >> LV_GAUGE_INTERPOLATE_SHIFT) + angle_ofs;
int16_t needle_angle_high = needle_angle_low + 1;
p_end_low.y = (lv_trigo_sin(needle_angle_low) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end_low.x = (lv_trigo_sin(needle_angle_low + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
p_end_high.y = (lv_trigo_sin(needle_angle_high) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end_high.x = (lv_trigo_sin(needle_angle_high + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
uint16_t rem = needle_angle & ((1 << LV_GAUGE_INTERPOLATE_SHIFT) - 1);
int16_t x_mod = ((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
int16_t y_mod = ((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
if(p_end_high.x < p_end_low.x) x_mod = -x_mod;
if(p_end_high.y < p_end_low.y) y_mod = -y_mod;
p_end.x = p_end_low.x + x_mod;
p_end.y = p_end_low.y + y_mod;
/*Draw the needle with the corresponding color*/
if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;

View File

@@ -14,6 +14,7 @@
#error "lv_img: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
#endif
#include "../lv_core/lv_lang.h"
#include "../lv_themes/lv_theme.h"
#include "../lv_misc/lv_fs.h"
#include "../lv_misc/lv_ufs.h"
@@ -77,6 +78,9 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
ext->w = lv_obj_get_width(new_img);
ext->h = lv_obj_get_height(new_img);
ext->auto_size = 1;
#if USE_LV_MULTI_LANG
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
#endif
/*Init the new object*/
lv_obj_set_signal_func(new_img, lv_img_signal);
@@ -155,17 +159,25 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
lv_img_header_t header;
lv_img_dsc_get_info(src_img, &header);
/*Save the source*/
if(src_type == LV_IMG_SRC_VARIABLE) {
LV_LOG_INFO("lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found");
/*If memory was allocated because of the previous `src_type` then free it*/
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) {
lv_mem_free(ext->src);
}
ext->src = src_img;
} else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) {
/* If the new and the old src are the same then it was only a refresh.*/
if(ext->src != src_img) {
lv_mem_free(ext->src);
char * new_str = lv_mem_alloc(strlen(src_img) + 1);
/*If memory was allocated because of the previous `src_type` then free it*/
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) {
lv_mem_free(ext->src);
}
char * new_str = lv_mem_alloc(strlen(src_img) + 1);
lv_mem_assert(new_str);
if(new_str == NULL) return;
strcpy(new_str, src_img);
@@ -194,17 +206,33 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
lv_obj_invalidate(img);
}
#if USE_LV_MULTI_LANG
/**
* Set an ID which means a the same source but in different languages
* @param img pointer to an image object
* @param src_id ID of the source
*/
void lv_img_set_src_id(lv_obj_t * img, uint32_t src_id)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
ext->lang_txt_id = src_id;
/*Apply the new language*/
img->signal_func(img, LV_SIGNAL_LANG_CHG, NULL);
}
#endif
/**
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
* @param img pointer to an image
* @param autosize_en true: auto size enable, false: auto size disable
* @param en true: auto size enable, false: auto size disable
*/
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en)
void lv_img_set_auto_size(lv_obj_t * img, bool en)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
ext->auto_size = (autosize_en == false ? 0 : 1);
ext->auto_size = (en == false ? 0 : 1);
}
@@ -238,6 +266,18 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
else return "";
}
#if USE_LV_MULTI_LANG
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_src_id(lv_obj_t * img)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
return ext->lang_txt_id;
}
#endif
/**
* Get the auto size enable attribute
@@ -299,7 +339,10 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
}
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
LV_LOG_TRACE("lv_img_design: start to draw symbol");
lv_draw_label(&coords, mask, style, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
lv_style_t style_mod;
lv_style_copy(&style_mod, style);
style_mod.text.color = style->image.color;
lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL);
} else {
/*Trigger the error handler of image drawer*/
LV_LOG_WARN("lv_img_design: image source type is unknown");
@@ -339,6 +382,17 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
lv_img_set_src(img, ext->src);
}
} else if(sign == LV_SIGNAL_LANG_CHG) {
#if USE_LV_MULTI_LANG
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
const char * lang_src = lv_lang_get_text(ext->lang_txt_id);
if(lang_src) {
lv_img_set_src(img, lang_src);
} else {
LV_LOG_WARN("lv_lang_get_text return NULL for an image's source");
}
}
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;

View File

@@ -43,6 +43,9 @@ typedef struct
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
#if USE_LV_MULTI_LANG
uint16_t lang_txt_id; /*The ID of the image to display. */
#endif
uint8_t src_type :2; /*See: lv_img_src_t*/
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
uint8_t cf :5; /*Color format from `lv_img_color_format_t`*/
@@ -71,6 +74,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_img_set_src(lv_obj_t * img, const void * src_img);
#if USE_LV_MULTI_LANG
/**
* Set an ID which means a the same source but on different languages
* @param img pointer to an image object
* @param src_id ID of the source
*/
void lv_img_set_src_id(lv_obj_t * img, uint32_t txt_id);
#endif
/**
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
* Use 'lv_img_set_src()' instead.
@@ -87,7 +99,7 @@ static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
* @param img pointer to an image
* @param autosize_en true: auto size enable, false: auto size disable
* @param en true: auto size enable, false: auto size disable
*/
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
@@ -130,6 +142,15 @@ const void * lv_img_get_src(lv_obj_t * img);
*/
const char * lv_img_get_file_name(const lv_obj_t * img);
#if USE_LV_MULTI_LANG
/**
* Get the source ID of the image. (Used by the multi-language feature)
* @param img pointer to an image
* @return ID of the source
*/
uint16_t lv_img_get_src_id(lv_obj_t * img);
#endif
/**
* Get the auto size enable attribute
* @param img pointer to an image

View File

@@ -61,11 +61,14 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_imgbtn);
/*Initialize the allocated 'ext' */
ext->img_src[LV_BTN_STATE_REL] = NULL;
ext->img_src[LV_BTN_STATE_PR] = NULL;
ext->img_src[LV_BTN_STATE_TGL_REL] = NULL;
ext->img_src[LV_BTN_STATE_TGL_PR] = NULL;;
ext->img_src[LV_BTN_STATE_INA] = NULL;
#if LV_IMGBTN_TILED == 0
memset(ext->img_src, 0, sizeof(ext->img_src));
#else
memset(ext->img_src_left, 0, sizeof(ext->img_src_left));
memset(ext->img_src_mid, 0, sizeof(ext->img_src_mid));
memset(ext->img_src_right, 0, sizeof(ext->img_src_right));
#endif
ext->act_cf = LV_IMG_CF_UNKOWN;
/*The signal and design functions are not copied so set them here*/
@@ -79,12 +82,13 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Copy an existing image button*/
else {
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_REL, copy_ext->img_src[LV_BTN_STATE_REL]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_PR, copy_ext->img_src[LV_BTN_STATE_PR]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_TGL_REL, copy_ext->img_src[LV_BTN_STATE_TGL_REL]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_TGL_PR, copy_ext->img_src[LV_BTN_STATE_TGL_PR]);
lv_imgbtn_set_src(new_imgbtn, LV_BTN_STATE_INA, copy_ext->img_src[LV_BTN_STATE_INA]);
#if LV_IMGBTN_TILED == 0
memcpy(ext->img_src, copy_ext->img_src, sizeof(ext->img_src));
#else
memcpy(ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
memcpy(ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
memcpy(ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
#endif
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_imgbtn);
}
@@ -98,6 +102,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
* Setter functions
*====================*/
#if LV_IMGBTN_TILED == 0
/**
* Set images for a state of the image button
* @param imgbtn pointer to an image button object
@@ -113,6 +118,28 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src
refr_img(imgbtn);
}
#else
/**
* Set images for a state of the image button
* @param imgbtn pointer to an image button object
* @param state for which state set the new image (from `lv_btn_state_t`) `
* @param src_left pointer to an image source for the left side of the button (a C array or path to a file)
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C array or path to a file)
* @param src_right pointer to an image source for the right side of the button (a C array or path to a file)
*/
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, const void * src_right)
{
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
ext->img_src_left[state] = src_left;
ext->img_src_mid[state] = src_mid;
ext->img_src_right[state] = src_right;
refr_img(imgbtn);
}
#endif
/**
* Set a style of a image button.
* @param imgbtn pointer to image button object
@@ -128,6 +155,7 @@ void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, lv_style_t *
* Getter functions
*====================*/
#if LV_IMGBTN_TILED == 0
/**
* Get the images in a given state
* @param imgbtn pointer to an image button object
@@ -140,6 +168,48 @@ const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_btn_state_t state)
return ext->img_src[state];
}
#else
/**
* Get the left image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the left image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_btn_state_t state)
{
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
return ext->img_src_left[state];
}
/**
* Get the middle image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the middle image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_btn_state_t state)
{
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
return ext->img_src_mid[state];
}
/**
* Get the right image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the left image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_btn_state_t state)
{
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
return ext->img_src_right[state];
}
#endif
/**
* Get style of a image button.
@@ -191,10 +261,62 @@ static bool lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * mask, lv_desig
/*Just draw an image*/
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
lv_btn_state_t state = lv_imgbtn_get_state(imgbtn);
const void * src = ext->img_src[state];
lv_style_t * style = lv_imgbtn_get_style(imgbtn, state);
lv_opa_t opa_scale = lv_obj_get_opa_scale(imgbtn);
#if LV_IMGBTN_TILED == 0
const void * src = ext->img_src[state];
lv_draw_img(&imgbtn->coords, mask, src, style, opa_scale);
#else
const void * src;
lv_img_header_t header;
lv_area_t coords;
lv_coord_t left_w = 0;
lv_coord_t right_w = 0;
src = ext->img_src_left[state];
if(src) {
lv_img_dsc_get_info(src, &header);
left_w = header.w;
coords.x1 = imgbtn->coords.x1;
coords.y1 = imgbtn->coords.y1;
coords.x2 = coords.x1 + header.w - 1;
coords.y2 = coords.y1 + header.h - 1;
lv_draw_img(&coords, mask, src, style, opa_scale);
}
src = ext->img_src_right[state];
if(src) {
lv_img_dsc_get_info(src, &header);
right_w = header.w;
coords.x1 = imgbtn->coords.x2 - header.w + 1;
coords.y1 = imgbtn->coords.y1;
coords.x2 = imgbtn->coords.x2;
coords.y2 = imgbtn->coords.y1 + header.h - 1;
lv_draw_img(&coords, mask, src, style, opa_scale);
}
src = ext->img_src_mid[state];
if(src) {
lv_coord_t obj_w = lv_obj_get_width(imgbtn);
lv_coord_t i;
lv_img_dsc_get_info(src, &header);
coords.x1 = imgbtn->coords.x1 + left_w ;
coords.y1 = imgbtn->coords.y1;
coords.x2 = coords.x1 + header.w - 1;
coords.y2 = imgbtn->coords.y1 + header.h - 1;
for(i = 0; i < obj_w - right_w - left_w; i += header.w) {
lv_draw_img(&coords, mask, src, style, opa_scale);
coords.x1 = coords.x2 + 1;
coords.x2 += header.w;
}
}
#endif
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@@ -243,17 +365,27 @@ static void refr_img(lv_obj_t * imgbtn)
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
lv_btn_state_t state = lv_imgbtn_get_state(imgbtn);
lv_img_header_t header;
#if LV_IMGBTN_TILED == 0
const void * src = ext->img_src[state];
#else
const void * src = ext->img_src_mid[state];
#endif
lv_res_t info_res;
info_res = lv_img_dsc_get_info(src, &header);
if(info_res == LV_RES_OK) {
ext->act_cf = header.cf;
#if LV_IMGBTN_TILED == 0
lv_obj_set_size(imgbtn, header.w, header.h);
#else
lv_obj_set_height(imgbtn, header.h);
#endif
} else {
ext->act_cf = LV_IMG_CF_UNKOWN;
}
lv_obj_invalidate(imgbtn);
}
#endif

View File

@@ -41,7 +41,13 @@ extern "C" {
typedef struct {
lv_btn_ext_t btn; /*Ext. of ancestor*/
/*New data for this type */
#if LV_IMGBTN_TILED == 0
const void * img_src[LV_BTN_STATE_NUM]; /*Store images to each state*/
#else
const void * img_src_left[LV_BTN_STATE_NUM]; /*Store left side images to each state*/
const void * img_src_mid[LV_BTN_STATE_NUM]; /*Store center images to each state*/
const void * img_src_right[LV_BTN_STATE_NUM]; /*Store right side images to each state*/
#endif
lv_img_cf_t act_cf; /*Color format of the currently active image*/
} lv_imgbtn_ext_t;
@@ -78,6 +84,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy);
* Setter functions
*====================*/
#if LV_IMGBTN_TILED == 0
/**
* Set images for a state of the image button
* @param imgbtn pointer to an image button object
@@ -85,6 +92,18 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy);
* @param src pointer to an image source (a C array or path to a file)
*/
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src);
#else
/**
* Set images for a state of the image button
* @param imgbtn pointer to an image button object
* @param state for which state set the new image (from `lv_btn_state_t`) `
* @param src_left pointer to an image source for the left side of the button (a C array or path to a file)
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C array or path to a file)
* @param src_right pointer to an image source for the right side of the button (a C array or path to a file)
*/
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, const void * src_right);
#endif
/**
* Enable the toggled states. On release the button will change from/to toggled state.
@@ -137,6 +156,8 @@ void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, lv_style_t *
* Getter functions
*====================*/
#if LV_IMGBTN_TILED == 0
/**
* Get the images in a given state
* @param imgbtn pointer to an image button object
@@ -145,6 +166,33 @@ void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, lv_style_t *
*/
const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_btn_state_t state);
#else
/**
* Get the left image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the left image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_btn_state_t state);
/**
* Get the middle image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the middle image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_btn_state_t state);
/**
* Get the right image in a given state
* @param imgbtn pointer to an image button object
* @param state the state where to get the image (from `lv_btn_state_t`) `
* @return pointer to the left image source (a C array or path to a file)
*/
const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_btn_state_t state);
#endif
/**
* Get the current state of the image button
* @param imgbtn pointer to a image button object

View File

@@ -25,7 +25,7 @@
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt);
static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt);
/**********************
* STATIC VARIABLES
@@ -33,21 +33,21 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt);
static lv_signal_func_t ancestor_signal;
static const char * kb_map_lc[] = {
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Del", "\n",
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Bksp", "\n",
"\226ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_uc[] = {
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Del", "\n",
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Bksp", "\n",
"\226abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_spec[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Del", "\n",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Bksp", "\n",
"\222abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
@@ -56,7 +56,7 @@ static const char * kb_map_spec[] = {
static const char * kb_map_num[] = {
"1", "2", "3", "\202"SYMBOL_CLOSE, "\n",
"4", "5", "6", "\202"SYMBOL_OK, "\n",
"7", "8", "9", "\202Del", "\n",
"7", "8", "9", "\202Bksp", "\n",
"+/-", "0", ".", SYMBOL_LEFT, SYMBOL_RIGHT, ""
};
/**********************
@@ -104,7 +104,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btnm_set_action(new_kb, lv_app_kb_action);
lv_btnm_set_action(new_kb, lv_kb_def_action);
lv_btnm_set_map(new_kb, kb_map_lc);
/*Set the default styles*/
@@ -330,25 +330,33 @@ lv_action_t lv_kb_get_hide_action(const lv_obj_t * kb)
*/
lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
{
lv_style_t * style = NULL;
switch(type) {
case LV_KB_STYLE_BG:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
break;
case LV_KB_STYLE_BTN_REL:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
break;
case LV_KB_STYLE_BTN_PR:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
break;
case LV_KB_STYLE_BTN_TGL_REL:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
break;
case LV_KB_STYLE_BTN_TGL_PR:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
break;
case LV_KB_STYLE_BTN_INA:
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/**********************
@@ -390,9 +398,10 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
* @param i the index of the released button from the current btnm map
* @return LV_ACTION_RES_INV if the btnm is deleted else LV_ACTION_RES_OK
*/
static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt)
{
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
lv_res_t res = LV_RES_OK;
/*Do the corresponding action according to the text of the button*/
if(strcmp(txt, "abc") == 0) {
@@ -405,27 +414,30 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
lv_btnm_set_map(kb, kb_map_spec);
return LV_RES_OK;
} else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
if(ext->hide_action) ext->hide_action(kb);
if(ext->hide_action) res = ext->hide_action(kb);
else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_obj_del(kb);
}
return LV_RES_INV;
return res;
} else if(strcmp(txt, SYMBOL_OK) == 0) {
if(ext->ok_action) ext->ok_action(kb);
if(ext->ok_action) res = ext->ok_action(kb);
else {
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
lv_obj_del(kb);
res = lv_obj_del(kb);
}
return LV_RES_INV;
return res;
}
if(ext->ta == NULL) return LV_RES_OK;
if(res != LV_RES_OK) return res; /*The keyboard might be deleted in the actions*/
/*Add the characters to the text area if set*/
if(ext->ta == NULL) return res;
if(strcmp(txt, "Enter") == 0)lv_ta_add_char(ext->ta, '\n');
else if(strcmp(txt, SYMBOL_LEFT) == 0) lv_ta_cursor_left(ext->ta);
else if(strcmp(txt, SYMBOL_RIGHT) == 0) lv_ta_cursor_right(ext->ta);
else if(strcmp(txt, "Del") == 0) lv_ta_del_char(ext->ta);
else if(strcmp(txt, "Bksp") == 0) lv_ta_del_char(ext->ta);
else if(strcmp(txt, "+/-") == 0) {
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
const char * ta_txt = lv_ta_get_text(ext->ta);

View File

@@ -11,6 +11,7 @@
#include "../lv_core/lv_obj.h"
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_lang.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_math.h"
@@ -90,6 +91,9 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
ext->offset.x = 0;
ext->offset.y = 0;
#if USE_LV_MULTI_LANG
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
#endif
lv_obj_set_design_func(new_label, lv_label_design);
lv_obj_set_signal_func(new_label, lv_label_signal);
@@ -175,6 +179,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
lv_label_refr_text(label);
}
/**
* Set a new text for a label from a character array. The array don't has to be '\0' terminated.
* Memory will be allocated to store the array by the label.
@@ -232,6 +237,22 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
lv_label_refr_text(label);
}
#if USE_LV_MULTI_LANG
/**
*Set a text ID which refers a the same text but in a different languages
* @param label pointer to a label object
* @param txt_id ID of the text
*/
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
ext->lang_txt_id = txt_id;
/*Apply the new language*/
label->signal_func(label, LV_SIGNAL_LANG_CHG, NULL);
}
#endif
/**
* Set the behavior of the label with longer text then the object size
* @param label pointer to a label object
@@ -277,20 +298,19 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
ext->align = align;
lv_obj_invalidate(label); /*Enough to invalidate because alignment is only drawing related (lv_refr_label_text() not required)*/
}
/**
* Enable the recoloring by in-line commands
* @param label pointer to a label object
* @param recolor_en true: enable recoloring, false: disable
* @param en true: enable recoloring, false: disable
*/
void lv_label_set_recolor(lv_obj_t * label, bool recolor_en)
void lv_label_set_recolor(lv_obj_t * label, bool en)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->recolor == recolor_en) return;
if(ext->recolor == en) return;
ext->recolor = recolor_en == false ? 0 : 1;
ext->recolor = en == false ? 0 : 1;
lv_label_refr_text(label); /*Refresh the text because the potential colo codes in text needs to be hided or revealed*/
}
@@ -298,14 +318,14 @@ void lv_label_set_recolor(lv_obj_t * label, bool recolor_en)
/**
* Set the label to draw (or not draw) background specified in its style's body
* @param label pointer to a label object
* @param body_en true: draw body; false: don't draw body
* @param en true: draw body; false: don't draw body
*/
void lv_label_set_body_draw(lv_obj_t * label, bool body_en)
void lv_label_set_body_draw(lv_obj_t * label, bool en)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->body_draw == body_en) return;
if(ext->body_draw == en) return;
ext->body_draw = body_en == false ? 0 : 1;
ext->body_draw = en == false ? 0 : 1;
lv_obj_refresh_ext_size(label);
@@ -345,6 +365,19 @@ char * lv_label_get_text(const lv_obj_t * label)
return ext->text;
}
#if USE_LV_MULTI_LANG
/**
* Get the text ID of the label. (Used by the multi-language feature)
* @param label pointer to a label object
* @return ID of the text
*/
uint16_t lv_label_get_text_id(lv_obj_t * label)
{
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->lang_txt_id;
}
#endif
/**
* Get the long mode of a label
* @param label pointer to a label object
@@ -440,28 +473,18 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
}
/*If the last character is line break then go to the next line*/
if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') {
y += letter_height + style->text.line_space;
line_start = index;
if(index > 0) {
if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') {
y += letter_height + style->text.line_space;
line_start = index;
}
}
/*Calculate the x coordinate*/
lv_coord_t x = 0;
uint32_t i = line_start;
uint32_t cnt = line_start; /*Count the letter (in UTF-8 1 letter not 1 byte)*/
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t letter;
while(cnt < index) {
cnt += lv_txt_encoded_size(&txt[i]);
letter = lv_txt_encoded_next(txt, &i);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
x += lv_font_get_width(font, letter) + style->text.letter_space;
}
lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start,
font, style->text.letter_space, flag);
if(index != line_start) x += style->text.letter_space;
if(ext->align == LV_LABEL_ALIGN_CENTER) {
lv_coord_t line_w;
@@ -476,7 +499,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
x += lv_obj_get_width(label) - line_w;
}
pos->x = x;
pos->y = y;
}
@@ -731,6 +753,17 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.hor);
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.ver);
}
} else if(sign == LV_SIGNAL_LANG_CHG) {
#if USE_LV_MULTI_LANG
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
const char * lang_txt = lv_lang_get_text(ext->lang_txt_id);
if(lang_txt) {
lv_label_set_text(label, lang_txt);
} else {
LV_LOG_WARN("lv_lang_get_text return NULL for a label's text");
}
}
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
@@ -787,7 +820,7 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = lv_font_get_width(font, ' ');
anim.start = 0;
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = lv_anim_path_linear;
@@ -797,7 +830,7 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.repeat_pause = anim.playback_pause;
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) - lv_font_get_width(font, ' ');
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label);
anim.fp = (lv_anim_fp_t) lv_obj_set_x;
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
lv_anim_create(&anim);
@@ -817,7 +850,7 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = lv_font_get_width(font, ' ');
anim.start = 0;
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = lv_anim_path_linear;
@@ -826,7 +859,7 @@ static void lv_label_refr_text(lv_obj_t * label)
bool hor_anim = false;
if(size.x > lv_obj_get_width(label)) {
anim.end = lv_obj_get_width(label) - size.x - lv_font_get_width(font, ' ');
anim.end = lv_obj_get_width(label) - size.x;
anim.fp = (lv_anim_fp_t) lv_label_set_offset_x;
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
lv_anim_create(&anim);

View File

@@ -61,16 +61,20 @@ typedef struct
{
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
/*New data for this type */
char * text; /*Text of the label*/
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
char * text; /*Text of the label*/
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
#if LV_TXT_UTF8 == 0
char dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
char dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
#else
char dot_tmp[LV_LABEL_DOT_NUM * 4 + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
#endif
#if USE_LV_MULTI_LANG
uint16_t lang_txt_id; /*The ID of the text to display*/
#endif
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
lv_point_t offset; /*Text draw position offset*/
lv_point_t offset; /*Text draw position offset*/
uint8_t static_txt :1; /*Flag to indicate the text is static*/
uint8_t align :2; /*Align type from 'lv_label_align_t'*/
uint8_t recolor :1; /*Enable in-line letter re-coloring*/
@@ -119,6 +123,15 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
*/
void lv_label_set_static_text(lv_obj_t * label, const char * text);
/**
*Set a text ID which means a the same text but on different languages
* @param label pointer to a label object
* @param txt_id ID of the text
*/
#if USE_LV_MULTI_LANG
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id);
#endif
/**
* Set the behavior of the label with longer text then the object size
* @param label pointer to a label object
@@ -137,16 +150,16 @@ void lv_label_set_align(lv_obj_t *label, lv_label_align_t align);
/**
* Enable the recoloring by in-line commands
* @param label pointer to a label object
* @param recolor_en true: enable recoloring, false: disable
* @param en true: enable recoloring, false: disable
*/
void lv_label_set_recolor(lv_obj_t * label, bool recolor_en);
void lv_label_set_recolor(lv_obj_t * label, bool en);
/**
* Set the label to draw (or not draw) background specified in its style's body
* @param label pointer to a label object
* @param body_en true: draw body; false: don't draw body
* @param en true: draw body; false: don't draw body
*/
void lv_label_set_body_draw(lv_obj_t *label, bool body_en);
void lv_label_set_body_draw(lv_obj_t *label, bool en);
/**
* Set the label's animation speed in LV_LABEL_LONG_ROLL and SCROLL modes
@@ -175,6 +188,15 @@ static inline void lv_label_set_style(lv_obj_t *label, lv_style_t *style)
*/
char * lv_label_get_text(const lv_obj_t * label);
#if USE_LV_MULTI_LANG
/**
* Get the text ID of the label. (Used by the multi-language feature)
* @param label pointer to a label object
* @return ID of the text
*/
uint16_t lv_label_get_text_id(lv_obj_t * label);
#endif
/**
* Get the long mode of a label
* @param label pointer to a label object

View File

@@ -82,7 +82,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
else {
lv_line_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_line_set_auto_size(new_line, lv_line_get_auto_size(copy));
lv_line_set_y_invert(new_line, lv_line_get_y_inv(copy));
lv_line_set_y_invert(new_line, lv_line_get_y_invert(copy));
lv_line_set_auto_size(new_line, lv_line_get_auto_size(copy));
lv_line_set_points(new_line, copy_ext->point_array, copy_ext->point_num);
/*Refresh the style with new signal function*/
@@ -132,17 +132,17 @@ void lv_line_set_points(lv_obj_t * line, const lv_point_t * point_a, uint16_t po
* Enable (or disable) the auto-size option. The size of the object will fit to its points.
* (set width to x max and height to y max)
* @param line pointer to a line object
* @param autosize_en true: auto size is enabled, false: auto size is disabled
* @param en true: auto size is enabled, false: auto size is disabled
*/
void lv_line_set_auto_size(lv_obj_t * line, bool autosize_en)
void lv_line_set_auto_size(lv_obj_t * line, bool en)
{
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
if(ext->auto_size == autosize_en) return;
if(ext->auto_size == en) return;
ext->auto_size = autosize_en == false ? 0 : 1;
ext->auto_size = en == false ? 0 : 1;
/*Refresh the object*/
if(autosize_en) lv_line_set_points(line, ext->point_array, ext->point_num);
if(en) lv_line_set_points(line, ext->point_array, ext->point_num);
}
/**
@@ -150,14 +150,14 @@ void lv_line_set_auto_size(lv_obj_t * line, bool autosize_en)
* If enabled then y will be subtracted from the height of the object,
* therefore the y=0 coordinate will be on the bottom.
* @param line pointer to a line object
* @param yinv_en true: enable the y inversion, false:disable the y inversion
* @param en true: enable the y inversion, false:disable the y inversion
*/
void lv_line_set_y_invert(lv_obj_t * line, bool yinv_en)
void lv_line_set_y_invert(lv_obj_t * line, bool en)
{
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
if(ext->y_inv == yinv_en) return;
if(ext->y_inv == en) return;
ext->y_inv = yinv_en == false ? 0 : 1;
ext->y_inv = en == false ? 0 : 1;
lv_obj_invalidate(line);
}
@@ -183,7 +183,7 @@ bool lv_line_get_auto_size(const lv_obj_t * line)
* @param line pointer to a line object
* @return true: y inversion is enabled, false: disabled
*/
bool lv_line_get_y_inv(const lv_obj_t * line)
bool lv_line_get_y_invert(const lv_obj_t * line)
{
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);

View File

@@ -70,18 +70,20 @@ void lv_line_set_points(lv_obj_t * line, const lv_point_t * point_a, uint16_t po
* Enable (or disable) the auto-size option. The size of the object will fit to its points.
* (set width to x max and height to y max)
* @param line pointer to a line object
* @param autosize_en true: auto size is enabled, false: auto size is disabled
* @param en true: auto size is enabled, false: auto size is disabled
*/
void lv_line_set_auto_size(lv_obj_t * line, bool autosize_en);
void lv_line_set_auto_size(lv_obj_t * line, bool en);
/**
* Enable (or disable) the y coordinate inversion.
* If enabled then y will be subtracted from the height of the object,
* therefore the y=0 coordinate will be on the bottom.
* @param line pointer to a line object
* @param yinv_en true: enable the y inversion, false:disable the y inversion
* @param en true: enable the y inversion, false:disable the y inversion
*/
void lv_line_set_y_invert(lv_obj_t * line, bool yinv_en);
void lv_line_set_y_invert(lv_obj_t * line, bool en);
#define lv_line_set_y_inv lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will work */
/**
* Set the style of a line
@@ -119,7 +121,7 @@ bool lv_line_get_auto_size(const lv_obj_t * line);
* @param line pointer to a line object
* @return true: y inversion is enabled, false: disabled
*/
bool lv_line_get_y_inv(const lv_obj_t * line);
bool lv_line_get_y_invert(const lv_obj_t * line);
/**
* Get the style of an line object

View File

@@ -38,6 +38,10 @@
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
static void refr_btn_width(lv_obj_t * list);
static void lv_list_btn_single_selected(lv_obj_t *btn);
static bool lv_list_is_list_btn(lv_obj_t * list_btn);
static bool lv_list_is_list_img(lv_obj_t * list_btn);
static bool lv_list_is_list_label(lv_obj_t * list_btn);
/**********************
* STATIC VARIABLES
@@ -89,7 +93,13 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->anim_time = LV_LIST_FOCUS_TIME;
ext->single_mode = false;
ext->size = 0;
#if USE_LV_GROUP
ext->last_sel = NULL;
ext->selected_btn = NULL;
#endif
lv_obj_set_signal_func(new_list, lv_list_signal);
@@ -125,7 +135,6 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy_img) img_src = lv_img_get_src(copy_img);
#endif
lv_list_add(new_list, img_src, lv_list_get_btn_text(copy_btn), lv_btn_get_action(copy_btn, LV_BTN_ACTION_CLICK));
// new_btn = lv_btn_create(new_list, copy_btn);
copy_btn = lv_list_get_next_btn(copy, copy_btn);
}
@@ -154,6 +163,8 @@ void lv_list_clean(lv_obj_t * obj)
{
lv_obj_t * scrl = lv_page_get_scrl(obj);
lv_obj_clean(scrl);
lv_list_ext_t * ext = lv_obj_get_ext_attr(obj);
ext->size = 0;
}
/*======================
@@ -172,7 +183,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
{
lv_style_t * style = lv_obj_get_style(list);
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->size ++;
/*Create a list element with the image an the text*/
lv_obj_t * liste;
liste = lv_btn_create(list, NULL);
@@ -212,21 +223,68 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
}
#endif
if(txt != NULL) {
lv_coord_t btn_hor_pad = ext->styles_btn[LV_BTN_STYLE_REL]->body.padding.hor;
lv_obj_t * label = lv_label_create(liste, NULL);
lv_label_set_text(label, txt);
lv_obj_set_click(label, false);
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1);
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - btn_hor_pad);
if(label_signal == NULL) label_signal = lv_obj_get_signal_func(label);
}
#if USE_LV_GROUP
/* If this is the first item to be added to the list and the list is
* focussed, select it */
{
lv_group_t *g = lv_obj_get_group(list);
if(ext->size == 1 && lv_group_get_focused(g) == list) {
lv_list_set_btn_selected(list, liste);
}
}
#endif
return liste;
}
/**
* Remove the index of the button in the list
* @param list pointer to a list object
* @param index pointer to a the button's index in the list, index must be 0 <= index < lv_list_ext_t.size
* @return true: successfully deleted
*/
bool lv_list_remove(const lv_obj_t * list, uint32_t index)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(index >= ext->size) return false;
uint32_t count = 0;
lv_obj_t * e = lv_list_get_next_btn(list, NULL);
while(e != NULL) {
if(count == index) {
lv_obj_del(e);
ext->size --;
return true;
}
e = lv_list_get_next_btn(list, e);
count ++;
}
return false;
}
/*=====================
* Setter functions
*====================*/
/**
* Set single button selected mode, only one button will be selected if enabled.
* @param list pointer to the currently pressed list object
* @param mode, enable(true)/disable(false) single selected mode.
*/
void lv_list_set_single_mode(lv_obj_t *list, bool mode)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->single_mode = mode;
}
#if USE_LV_GROUP
/**
@@ -245,6 +303,9 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
}
ext->selected_btn = btn;
if( btn != NULL ) {
ext->last_sel = btn;
}
if(ext->selected_btn) {
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
@@ -297,6 +358,9 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, lv_style_t * style
case LV_LIST_STYLE_SB:
lv_page_set_style(list, LV_PAGE_STYLE_SB, style);
break;
case LV_LIST_STYLE_EDGE_FLASH:
lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style);
break;
case LV_LIST_STYLE_BTN_REL:
ext->styles_btn[LV_BTN_STATE_REL] = style;
btn_style_refr = LV_BTN_STYLE_REL;
@@ -336,6 +400,17 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, lv_style_t * style
* Getter functions
*====================*/
/**
* Get single button selected mode.
* @param list pointer to the currently pressed list object.
*/
bool lv_list_get_single_mode(lv_obj_t *list)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return (ext->single_mode);
}
/**
* Get the text of a list element
* @param btn pointer to list element
@@ -358,7 +433,7 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
lv_obj_t * label = lv_obj_get_child(btn, NULL);
if(label == NULL) return NULL;
while(label->signal_func != label_signal) {
while(lv_list_is_list_label(label) == false) {
label = lv_obj_get_child(btn, label);
if(label == NULL) break;
}
@@ -377,7 +452,7 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
lv_obj_t * img = lv_obj_get_child(btn, NULL);
if(img == NULL) return NULL;
while(img->signal_func != img_signal) {
while(lv_list_is_list_img(img) == false) {
img = lv_obj_get_child(btn, img);
if(img == NULL) break;
}
@@ -389,10 +464,10 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
}
/**
* Get the next button from list. (Starts from the bottom button)
* Get the previous button from list. (Starts from the top button)
* @param list pointer to a list object
* @param prev_btn pointer to button. Search the next after it.
* @return pointer to the next button or NULL when no more buttons
* @param prev_btn pointer to button. Search the previous before it.
* @return pointer to the previous button or NULL when no more buttons
*/
lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
{
@@ -405,8 +480,8 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
btn = lv_obj_get_child(scrl, prev_btn);
if(btn == NULL) return NULL;
while(btn->signal_func != lv_list_btn_signal) {
btn = lv_obj_get_child(scrl, prev_btn);
while(lv_list_is_list_btn(btn) == false) {
btn = lv_obj_get_child(scrl, btn);
if(btn == NULL) break;
}
@@ -414,11 +489,12 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
}
/**
* Get the previous button from list. (Starts from the top button)
/**
* Get the next button from list. (Starts from the bottom button)
* @param list pointer to a list object
* @param prev_btn pointer to button. Search the previous before it.
* @return pointer to the previous button or NULL when no more buttons
* @param prev_btn pointer to button. Search the next after it.
* @return pointer to the next button or NULL when no more buttons
*/
lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
{
@@ -431,14 +507,49 @@ lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
btn = lv_obj_get_child_back(scrl, prev_btn);
if(btn == NULL) return NULL;
while(btn->signal_func != lv_list_btn_signal) {
btn = lv_obj_get_child_back(scrl, prev_btn);
while(lv_list_is_list_btn(btn) == false) {
btn = lv_obj_get_child_back(scrl, btn);
if(btn == NULL) break;
}
return btn;
}
/**
* Get the index of the button in the list
* @param list pointer to a list object. If NULL, assumes btn is part of a list.
* @param btn pointer to a list element (button)
* @return the index of the button in the list, or -1 of the button not in this list
*/
int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn)
{
int index = 0;
if( list == NULL ){
/* no list provided, assuming btn is part of a list */
list = lv_obj_get_parent(lv_obj_get_parent(btn));
}
lv_obj_t * e = lv_list_get_next_btn(list, NULL);
while(e != NULL) {
if(e == btn) {
return index;
}
index ++;
e = lv_list_get_next_btn(list, e);
}
return -1;
}
/**
* Get the number of buttons in the list
* @param list pointer to a list object
* @return the number of buttons in the list
*/
uint32_t lv_list_get_size(const lv_obj_t * list)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->size;
}
#if USE_LV_GROUP
/**
* Get the currently selected button
@@ -472,31 +583,43 @@ uint16_t lv_list_get_anim_time(const lv_obj_t * list)
* */
lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
{
lv_style_t * style = NULL;
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
switch(type) {
case LV_LIST_STYLE_BG:
return lv_page_get_style(list, LV_PAGE_STYLE_BG);
style = lv_page_get_style(list, LV_PAGE_STYLE_BG);
break;
case LV_LIST_STYLE_SCRL:
return lv_page_get_style(list, LV_PAGE_STYLE_SB);
style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
break;
case LV_LIST_STYLE_SB:
return lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
style = lv_page_get_style(list, LV_PAGE_STYLE_SB);
break;
case LV_LIST_STYLE_EDGE_FLASH:
style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH);
break;
case LV_LIST_STYLE_BTN_REL:
return ext->styles_btn[LV_BTN_STATE_REL];
style = ext->styles_btn[LV_BTN_STATE_REL];
break;
case LV_LIST_STYLE_BTN_PR:
return ext->styles_btn[LV_BTN_STATE_PR];
style = ext->styles_btn[LV_BTN_STATE_PR];
break;
case LV_LIST_STYLE_BTN_TGL_REL:
return ext->styles_btn[LV_BTN_STATE_TGL_REL];
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
break;
case LV_LIST_STYLE_BTN_TGL_PR:
return ext->styles_btn[LV_BTN_STATE_TGL_PR];
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
break;
case LV_LIST_STYLE_BTN_INA:
return ext->styles_btn[LV_BTN_STATE_INA];
style = ext->styles_btn[LV_BTN_STATE_INA];
break;
default:
return NULL;
style = NULL;
break;
}
/*To avoid warning*/
return NULL;
return style;
}
/*=====================
* Other functions
@@ -625,8 +748,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
res = ancestor_page_signal(list, sign, param);
if(res != LV_RES_OK) return res;
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(sign == LV_SIGNAL_CORD_CHG) {
/*Be sure the width of the buttons are correct*/
lv_coord_t w = lv_obj_get_width(list);
@@ -637,13 +758,22 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
refr_btn_width(list);
} else if(sign == LV_SIGNAL_FOCUS) {
#if USE_LV_GROUP
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
/*With ENCODER select the first button only in edit mode*/
if(indev_type == LV_INDEV_TYPE_ENCODER) {
lv_group_t * g = lv_obj_get_group(list);
if(lv_group_get_editing(g)) {
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(ext->last_sel) {
/* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel);
}
else {
/*Get the first button and mark it as selected*/
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
}
} else {
lv_list_set_btn_selected(list, NULL);
}
@@ -654,21 +784,36 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(last_clicked_btn) {
lv_list_set_btn_selected(list, last_clicked_btn);
} else {
/*Get the first button and mark it as selected*/
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(ext->last_sel) {
/* Select the last used button */
lv_list_set_btn_selected(list, ext->last_sel);
}
else {
/*Get the first button and mark it as selected*/
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
}
}
}
#endif
} else if(sign == LV_SIGNAL_DEFOCUS) {
#if USE_LV_GROUP
/*De-select the selected btn*/
lv_list_set_btn_selected(list, NULL);
last_clicked_btn = NULL; /*button click will be set if click happens before focus*/
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->selected_btn = NULL;
#endif
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
*editable = true;
} else if(sign == LV_SIGNAL_CONTROLL) {
#if USE_LV_GROUP
char c = *((char *)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
/*If there is a valid selected button the make the previous selected*/
if(ext->selected_btn) {
lv_obj_t * btn_prev = lv_list_get_next_btn(list, ext->selected_btn);
@@ -680,6 +825,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(btn) lv_list_set_btn_selected(list, btn); /*If there are no buttons on the list then there is no first button*/
}
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
/*If there is a valid selected button the make the next selected*/
if(ext->selected_btn != NULL) {
lv_obj_t * btn_next = lv_list_get_prev_btn(list, ext->selected_btn);
@@ -700,18 +846,21 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
}
if(btn != NULL) {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->last_sel = btn;
lv_action_t rel_action;
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK);
if(rel_action != NULL) rel_action(btn);
}
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_list";
}
#endif
} else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_list";
}
return res;
}
@@ -732,9 +881,12 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
res = ancestor_btn_signal(btn, sign, param);
if(res != LV_RES_OK) return res;
#if USE_LV_GROUP
if(sign == LV_SIGNAL_RELEASED) {
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->page.scroll_prop_ip = 0;
#if USE_LV_GROUP
lv_group_t * g = lv_obj_get_group(list);
if(lv_group_get_focused(g) == list && lv_indev_is_dragging(lv_indev_get_act()) == false) {
/* Is the list is focused then be sure only the button being released
@@ -754,9 +906,25 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
/* If `click_focus == 1` then LV_SIGNAL_FOCUS need to know which button triggered the focus
* to mark it as selected (pressed state)*/
last_clicked_btn = btn;
}
#endif
if(lv_indev_is_dragging(lv_indev_get_act()) == false && ext->single_mode)
{
lv_list_btn_single_selected(btn);
}
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->page.scroll_prop_ip = 0;
}
else if(sign == LV_SIGNAL_CLEANUP) {
#if USE_LV_GROUP
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_obj_t * sel = lv_list_get_btn_selected(list);
if(sel == btn) lv_list_set_btn_selected(list, lv_list_get_next_btn(list, btn));
#endif
}
return res;
@@ -783,5 +951,81 @@ static void refr_btn_width(lv_obj_t * list)
}
}
/**
* Make a single button selected in the list, deselect others, should be called in list btns call back.
* @param btn pointer to the currently pressed list btn object
*/
static void lv_list_btn_single_selected(lv_obj_t *btn)
{
lv_obj_t *list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_obj_t * e = lv_list_get_next_btn(list, NULL);
do
{
if(e == btn)
{
lv_btn_set_state(e, LV_BTN_STATE_TGL_REL);
}
else
{
lv_btn_set_state(e, LV_BTN_STATE_REL);
}
e = lv_list_get_next_btn(list, e);
} while (e != NULL);
}
/**
* Check if this is really a list button or another object.
* @param list_btn List button
*/
static bool lv_list_is_list_btn(lv_obj_t * list_btn)
{
lv_obj_type_t type;
lv_obj_get_type(list_btn, &type);
uint8_t cnt;
for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) {
if(type.type[cnt] == NULL) break;
if(!strcmp(type.type[cnt], "lv_btn"))
return true;
}
return false;
}
/**
* Check if this is really a list label or another object.
* @param list_label List label
*/
static bool lv_list_is_list_label(lv_obj_t * list_label)
{
lv_obj_type_t type;
lv_obj_get_type(list_label, &type);
uint8_t cnt;
for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) {
if(type.type[cnt] == NULL) break;
if(!strcmp(type.type[cnt], "lv_label"))
return true;
}
return false;
}
/**
* Check if this is really a list image or another object.
* @param list_image List image
*/
static bool lv_list_is_list_img(lv_obj_t * list_img)
{
lv_obj_type_t type;
lv_obj_get_type(list_img, &type);
uint8_t cnt;
for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) {
if(type.type[cnt] == NULL) break;
if(!strcmp(type.type[cnt], "lv_img"))
return true;
}
return false;
}
#endif

Some files were not shown because too many files have changed in this diff Show More