Compare commits
2526 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
135c119b20 | ||
|
|
3e77e0de8b | ||
|
|
a77b2ab408 | ||
|
|
9af89dd1b3 | ||
|
|
3c539d5751 | ||
|
|
683545f5f0 | ||
|
|
f91479470b | ||
|
|
c1072a6289 | ||
|
|
e2147d4be5 | ||
|
|
d3d83f4991 | ||
|
|
72cf43a176 | ||
|
|
b4dfa5678f | ||
|
|
0e71a34128 | ||
|
|
2ecd0c4166 | ||
|
|
bbc9c886c6 | ||
|
|
fc42d02e97 | ||
|
|
03ac0284ae | ||
|
|
925e1f9adf | ||
|
|
d433114cc2 | ||
|
|
a2e6589529 | ||
|
|
c15f7135cd | ||
|
|
7d278b1c09 | ||
|
|
0bd3a9f4d0 | ||
|
|
f8924511d6 | ||
|
|
d8745e3050 | ||
|
|
a6b81d3da8 | ||
|
|
4c85125a87 | ||
|
|
9dcc47ec33 | ||
|
|
8f962a0464 | ||
|
|
e1989c5706 | ||
|
|
e1a4590fe3 | ||
|
|
ac8e4af167 | ||
|
|
d99bd91fe6 | ||
|
|
b04367c702 | ||
|
|
47bc4c91b7 | ||
|
|
ce29102dcf | ||
|
|
f806f8c526 | ||
|
|
5b150e57ab | ||
|
|
977b74332c | ||
|
|
071bf4cc4c | ||
|
|
25c5c54b3b | ||
|
|
d823194378 | ||
|
|
cba7dfc51b | ||
|
|
fda41d62a1 | ||
|
|
5168b5c44f | ||
|
|
1ae0a68e55 | ||
|
|
f62f839a25 | ||
|
|
b71b1f1e3a | ||
|
|
9d6cf5d2d8 | ||
|
|
08101e6d6b | ||
|
|
cd3d7248c5 | ||
|
|
721d056803 | ||
|
|
5e4bd1fd0c | ||
|
|
4891f803fc | ||
|
|
ff657882bc | ||
|
|
c54003f014 | ||
|
|
f56cd37f65 | ||
|
|
ab4c2bcd93 | ||
|
|
bba22bfa55 | ||
|
|
00008879b7 | ||
|
|
d66ff20df5 | ||
|
|
b856391c96 | ||
|
|
d67f84bc1a | ||
|
|
189ca15d7c | ||
|
|
d85efb9926 | ||
|
|
a88cacb71e | ||
|
|
2f95d4a0ca | ||
|
|
2f5ec6befe | ||
|
|
44b2197721 | ||
|
|
3227a2c780 | ||
|
|
7f7034f50f | ||
|
|
58ce1460d8 | ||
|
|
3c2accacb6 | ||
|
|
cd6f99c718 | ||
|
|
d79df213a1 | ||
|
|
bc030e7a2e | ||
|
|
65d9dc503d | ||
|
|
1bba2a803f | ||
|
|
ce7b183f50 | ||
|
|
8e8271ffe6 | ||
|
|
ecd21d512d | ||
|
|
76e392edd5 | ||
|
|
4c1dbc63d2 | ||
|
|
ca1f21ad04 | ||
|
|
a9c818a6ef | ||
|
|
a63c5eb968 | ||
|
|
68f28d1fda | ||
|
|
d25650f561 | ||
|
|
f5de02ad5a | ||
|
|
7a0ccd74a8 | ||
|
|
e72ba9f11b | ||
|
|
d84e977218 | ||
|
|
e48e0d8026 | ||
|
|
1c0f24cfbd | ||
|
|
1b33667642 | ||
|
|
8173c427aa | ||
|
|
c630493fc0 | ||
|
|
b0b27515bd | ||
|
|
625aaa25ff | ||
|
|
1844d060ab | ||
|
|
d80cc562d4 | ||
|
|
6cfcc3fa55 | ||
|
|
b9081cacef | ||
|
|
22e8ec2b01 | ||
|
|
c46f64c6d5 | ||
|
|
648e2c4f17 | ||
|
|
b9692ee798 | ||
|
|
eacf2e5b93 | ||
|
|
3088849b63 | ||
|
|
7fe458229d | ||
|
|
abae15ab7c | ||
|
|
51878e65dc | ||
|
|
760359fd5a | ||
|
|
b8c35308f2 | ||
|
|
622c5deada | ||
|
|
728c221986 | ||
|
|
a92ffe7cde | ||
|
|
5bb1653991 | ||
|
|
021420775f | ||
|
|
4f07e9b4ab | ||
|
|
9e34000dfc | ||
|
|
10c46e73a8 | ||
|
|
dd8fdafe3e | ||
|
|
89fae4458e | ||
|
|
71f00017af | ||
|
|
7cbc2d0e7f | ||
|
|
f69dfce051 | ||
|
|
c52d8e8120 | ||
|
|
0e41e9aacb | ||
|
|
3abcf52ad7 | ||
|
|
bceb46b813 | ||
|
|
ed69452c45 | ||
|
|
4139cd619b | ||
|
|
a2c9c72186 | ||
|
|
56b9893854 | ||
|
|
288b972ce0 | ||
|
|
857d1734fd | ||
|
|
a1d2d631f0 | ||
|
|
8254ee6661 | ||
|
|
5cc1548b83 | ||
|
|
f2ca0b15f3 | ||
|
|
dbb5f23cd6 | ||
|
|
23f842e462 | ||
|
|
dba4cebfea | ||
|
|
81729dfd51 | ||
|
|
48e1efb6ef | ||
|
|
9396b097ab | ||
|
|
b4d54c71d3 | ||
|
|
9139b58abc | ||
|
|
0ef39ed144 | ||
|
|
b29c84cc88 | ||
|
|
3a2def1e76 | ||
|
|
62c531eec3 | ||
|
|
c54d2d2fd7 | ||
|
|
e01577845a | ||
|
|
e8c14961df | ||
|
|
b0de5b9c0d | ||
|
|
33bb0d8004 | ||
|
|
366698bba3 | ||
|
|
ff65ecd102 | ||
|
|
4075a7adfc | ||
|
|
ca01b558f7 | ||
|
|
f692e00ffe | ||
|
|
30419b3881 | ||
|
|
a94866a115 | ||
|
|
df4aecc4c2 | ||
|
|
2dfaef4668 | ||
|
|
23dc884f35 | ||
|
|
cd8bfa49e2 | ||
|
|
cf124e60ad | ||
|
|
7884636b7c | ||
|
|
8c6ef82947 | ||
|
|
23e7e4e8e2 | ||
|
|
56d7b986d4 | ||
|
|
f173875310 | ||
|
|
4cffb73357 | ||
|
|
b174398cb5 | ||
|
|
7189a60866 | ||
|
|
d94075ac92 | ||
|
|
0acabe460c | ||
|
|
a5bbb5e651 | ||
|
|
005a7954ca | ||
|
|
bf667f747b | ||
|
|
0aeff32442 | ||
|
|
5ebed4f24e | ||
|
|
eba910be40 | ||
|
|
b6a86f31d7 | ||
|
|
d1e59483b4 | ||
|
|
f2afc18d6b | ||
|
|
72347d4bc1 | ||
|
|
1ed8207b5c | ||
|
|
ceff78476b | ||
|
|
62ffe5ab94 | ||
|
|
d2e28abb79 | ||
|
|
6093053240 | ||
|
|
7cfbf5ed64 | ||
|
|
01f990061f | ||
|
|
b0fffaa55b | ||
|
|
2c7cdea1ee | ||
|
|
5ef94e395d | ||
|
|
6bde219324 | ||
|
|
d3d9fde245 | ||
|
|
225c2f727c | ||
|
|
a3e88e1ecd | ||
|
|
0f1e260155 | ||
|
|
8efb91d51d | ||
|
|
5803fa6214 | ||
|
|
9cb633981f | ||
|
|
d066004783 | ||
|
|
037e828c8a | ||
|
|
5652a163c5 | ||
|
|
f42e6b82c4 | ||
|
|
6212d0a507 | ||
|
|
cd1ad6eb3a | ||
|
|
cbb9c3f73b | ||
|
|
40576b5445 | ||
|
|
9b38d455ab | ||
|
|
3cc2043fd7 | ||
|
|
a6f0afde4c | ||
|
|
ba3e7d1da6 | ||
|
|
9d70ccc226 | ||
|
|
d658eef2a0 | ||
|
|
22c2bc4453 | ||
|
|
0d2b61f0f3 | ||
|
|
45a29c1b88 | ||
|
|
1c2d71a0f8 | ||
|
|
ba9f0cf9bb | ||
|
|
fd834ae60f | ||
|
|
e8605a52ed | ||
|
|
7bbe91512a | ||
|
|
aed05f26e4 | ||
|
|
87979b5645 | ||
|
|
22195f3455 | ||
|
|
b0a4fd7dad | ||
|
|
b6d24040bf | ||
|
|
0be212c26c | ||
|
|
90b8bc9597 | ||
|
|
8c5c8ed82a | ||
|
|
f28efdd9f3 | ||
|
|
62ea055785 | ||
|
|
89a2856d6e | ||
|
|
80760c4669 | ||
|
|
b1622166b4 | ||
|
|
f7bc8c2328 | ||
|
|
83d64fed42 | ||
|
|
234fa34254 | ||
|
|
d8edbb8a41 | ||
|
|
077a645a92 | ||
|
|
432e87bfdf | ||
|
|
f16561295b | ||
|
|
d197ae53e5 | ||
|
|
42b546a6d7 | ||
|
|
eb1e28e1f5 | ||
|
|
cb6a4527a9 | ||
|
|
2f4654b009 | ||
|
|
ca19c7d92f | ||
|
|
1ef0c197cd | ||
|
|
b842db91aa | ||
|
|
1f334ba88b | ||
|
|
c136382be3 | ||
|
|
e525c08a0c | ||
|
|
b926fd4966 | ||
|
|
4c623cae44 | ||
|
|
c5ba739627 | ||
|
|
e421e08c2f | ||
|
|
bd15b805db | ||
|
|
292ca72c03 | ||
|
|
322211b1ed | ||
|
|
04df148f0c | ||
|
|
8273499a8c | ||
|
|
c1b8c2f522 | ||
|
|
6cba2fbab0 | ||
|
|
5a712931ef | ||
|
|
de824833a0 | ||
|
|
78c527ee4f | ||
|
|
c46ff018ed | ||
|
|
862a4c3496 | ||
|
|
569bbdf058 | ||
|
|
648d42ec94 | ||
|
|
c8d1413ece | ||
|
|
6a265896a2 | ||
|
|
eebe04bd95 | ||
|
|
fe8157cc88 | ||
|
|
5af101a1eb | ||
|
|
e31b6a156e | ||
|
|
f706de5517 | ||
|
|
72fb15c3fb | ||
|
|
5afe9c119a | ||
|
|
3a78360b62 | ||
|
|
d58c8663d4 | ||
|
|
85ead39b6a | ||
|
|
a3bfdb240e | ||
|
|
dab545e770 | ||
|
|
7f30fb0058 | ||
|
|
1489629b61 | ||
|
|
77d43069e0 | ||
|
|
5b1f0caa8d | ||
|
|
1cd4ac4aef | ||
|
|
8b29a88b58 | ||
|
|
3079d2c6e6 | ||
|
|
7631d41c88 | ||
|
|
523170297e | ||
|
|
0442ffe6cb | ||
|
|
aa4897cdc5 | ||
|
|
512eb05a22 | ||
|
|
424bff48f5 | ||
|
|
c31ab099f7 | ||
|
|
0f6f2accb6 | ||
|
|
1ddf659631 | ||
|
|
861e090023 | ||
|
|
e7e24697ea | ||
|
|
0b31110d3e | ||
|
|
be84581bbc | ||
|
|
45c4970fc6 | ||
|
|
1a70d98ba4 | ||
|
|
f4c0055c5a | ||
|
|
18d59bef01 | ||
|
|
f6c60b8204 | ||
|
|
73ef86f9a9 | ||
|
|
0c7d9b96f7 | ||
|
|
469157ebd9 | ||
|
|
cc97e114c2 | ||
|
|
864c970ba3 | ||
|
|
ed1632f464 | ||
|
|
b7850e2584 | ||
|
|
9f216a55be | ||
|
|
1e4fd8fdfb | ||
|
|
12ee3b3504 | ||
|
|
d8a17c483a | ||
|
|
c7e6af03e6 | ||
|
|
cc48391333 | ||
|
|
0892cbadc4 | ||
|
|
5243d235a6 | ||
|
|
15c27c8a9b | ||
|
|
630199d9a3 | ||
|
|
b623eabb0a | ||
|
|
5321b9b62e | ||
|
|
926490502b | ||
|
|
8745d16ba9 | ||
|
|
8dc2b36bf7 | ||
|
|
4b657eb07b | ||
|
|
2edf8f4aab | ||
|
|
dc9f8baf0e | ||
|
|
4e6aac2157 | ||
|
|
1e5f690a45 | ||
|
|
ef0f8b29cf | ||
|
|
514e2baaca | ||
|
|
d7661e8bbc | ||
|
|
abd081da30 | ||
|
|
9cd7de8ccd | ||
|
|
5e60002a9b | ||
|
|
3860c115d4 | ||
|
|
4a663c42d4 | ||
|
|
2fbc082633 | ||
|
|
ca19f8f4ff | ||
|
|
9e3162080f | ||
|
|
56fcd2d151 | ||
|
|
e2cfba7c9f | ||
|
|
2d5183b05d | ||
|
|
4b43adaad1 | ||
|
|
b4a632116e | ||
|
|
ac89e880a7 | ||
|
|
c9c635ca3a | ||
|
|
e49de22941 | ||
|
|
9c708d6f4d | ||
|
|
e9d2191463 | ||
|
|
95fc629aa5 | ||
|
|
8675a345b4 | ||
|
|
b5898a750e | ||
|
|
1b1df9f931 | ||
|
|
755f68c87b | ||
|
|
cdb6f1fdd7 | ||
|
|
d6ef684867 | ||
|
|
7419900508 | ||
|
|
4454683ff0 | ||
|
|
5353dae027 | ||
|
|
850693a840 | ||
|
|
9fc1423ef7 | ||
|
|
a983dfa80a | ||
|
|
5d65def464 | ||
|
|
0ad121865c | ||
|
|
8f7e01fc1a | ||
|
|
82c57e0ceb | ||
|
|
a2cb299c0c | ||
|
|
702ca86879 | ||
|
|
beeedfc1b2 | ||
|
|
dfb12a31f9 | ||
|
|
a3c08e9985 | ||
|
|
b477a14fdf | ||
|
|
2abf55f4c4 | ||
|
|
d0550b7feb | ||
|
|
1181c07b76 | ||
|
|
6446f78aeb | ||
|
|
a9036eb6b1 | ||
|
|
b75688b317 | ||
|
|
857a4e1406 | ||
|
|
ad1162922f | ||
|
|
5a88709a5c | ||
|
|
41fc80e96b | ||
|
|
9a711d9e88 | ||
|
|
cf21115029 | ||
|
|
84d79bcf56 | ||
|
|
2e0c8ca8f5 | ||
|
|
1ba23100f6 | ||
|
|
b9af3b0383 | ||
|
|
6148d498a9 | ||
|
|
0811096f21 | ||
|
|
de0037e7fe | ||
|
|
ff6b6725a5 | ||
|
|
d7b193d3fc | ||
|
|
c401481509 | ||
|
|
eb70f39e42 | ||
|
|
2c5b3fe223 | ||
|
|
619403ce48 | ||
|
|
b3f60153cf | ||
|
|
30dcf68351 | ||
|
|
3d77137178 | ||
|
|
50edf4e1f8 | ||
|
|
f40ee380c8 | ||
|
|
522d59861e | ||
|
|
991f892a98 | ||
|
|
9603ddfbe5 | ||
|
|
2b26b9dc51 | ||
|
|
29daec0caf | ||
|
|
bbb93d315e | ||
|
|
610499c278 | ||
|
|
1cbbd1c59b | ||
|
|
ff6fb2611a | ||
|
|
6284e3a21b | ||
|
|
3764d7a6ba | ||
|
|
cf943b16e1 | ||
|
|
a4d4d59346 | ||
|
|
580d1e111d | ||
|
|
b6df62a62a | ||
|
|
e6b7afccd2 | ||
|
|
5ccf31793e | ||
|
|
6a3c7d2b95 | ||
|
|
84ea78c1c1 | ||
|
|
2b0cdc853f | ||
|
|
0dd723183f | ||
|
|
00f2df74dc | ||
|
|
3606ea2588 | ||
|
|
12125248c6 | ||
|
|
2f0921161f | ||
|
|
6c9ed1969f | ||
|
|
2345e0073d | ||
|
|
de12c95a80 | ||
|
|
e3244b7a37 | ||
|
|
0bffba11d6 | ||
|
|
9af730c6cb | ||
|
|
b59e058f8d | ||
|
|
3d4c784c3b | ||
|
|
fb1ca3fb87 | ||
|
|
427d11e7f5 | ||
|
|
d3b494b030 | ||
|
|
b0f3949b3c | ||
|
|
c4f8e5f8be | ||
|
|
c2653174f5 | ||
|
|
28d24a3d4d | ||
|
|
ea7c82f478 | ||
|
|
5edb1dd38a | ||
|
|
ef0e0f812f | ||
|
|
b5c7960255 | ||
|
|
e8b081b015 | ||
|
|
67ff40afd0 | ||
|
|
3d7641733e | ||
|
|
d691e72b40 | ||
|
|
fc7c7ec619 | ||
|
|
36d4807a69 | ||
|
|
e5c699ba23 | ||
|
|
75f42fde2f | ||
|
|
0c3a18e1fe | ||
|
|
e47750864e | ||
|
|
8976b118f8 | ||
|
|
dff8eb9a3c | ||
|
|
c7d582e403 | ||
|
|
65b83dd1c1 | ||
|
|
2b0e378c73 | ||
|
|
231ad935f4 | ||
|
|
9c8296edf9 | ||
|
|
cbd32d9f28 | ||
|
|
5db6b73725 | ||
|
|
b3f4bd1c46 | ||
|
|
912b014b03 | ||
|
|
c58fd97cf7 | ||
|
|
31ff0fd3ff | ||
|
|
6df6614016 | ||
|
|
264eacd0bc | ||
|
|
248521da53 | ||
|
|
0cff8c7963 | ||
|
|
789e7a3a12 | ||
|
|
d85c138137 | ||
|
|
5f76d98311 | ||
|
|
d6088f2b06 | ||
|
|
1eca54616a | ||
|
|
3f2b6bb685 | ||
|
|
2794b786d7 | ||
|
|
bc8cd2068e | ||
|
|
d4bfeb2bed | ||
|
|
66585f508f | ||
|
|
ba2160042a | ||
|
|
80e2a1d5d5 | ||
|
|
a8c8b6b7a2 | ||
|
|
18809da818 | ||
|
|
f19f8a9b5c | ||
|
|
41ee89e6d2 | ||
|
|
889c21b639 | ||
|
|
aec671dc67 | ||
|
|
6e047e6d27 | ||
|
|
787dd591c1 | ||
|
|
1d986e13df | ||
|
|
c55c36c366 | ||
|
|
75f5849a73 | ||
|
|
08722f5f8d | ||
|
|
84ace67720 | ||
|
|
38c55377c6 | ||
|
|
af61c96802 | ||
|
|
bb20b8ca1a | ||
|
|
103f6c3041 | ||
|
|
09f362a1ed | ||
|
|
9515e800d4 | ||
|
|
eb6daa51d7 | ||
|
|
438ae64502 | ||
|
|
e902f0955f | ||
|
|
a4a5bef8ca | ||
|
|
1cd983941e | ||
|
|
272ee1b466 | ||
|
|
5919cf5613 | ||
|
|
97089da7f5 | ||
|
|
f5609b6bce | ||
|
|
e63e1f230a | ||
|
|
3b747718ea | ||
|
|
0a4e8979ec | ||
|
|
b14ed6288a | ||
|
|
82a095b94a | ||
|
|
87d27a5665 | ||
|
|
b8fece6e0a | ||
|
|
6468d925ed | ||
|
|
c1e98d3f37 | ||
|
|
cd47fd72f6 | ||
|
|
ed9a1f3df5 | ||
|
|
881d6c060f | ||
|
|
20961a4dda | ||
|
|
5be450a3aa | ||
|
|
41754236f8 | ||
|
|
0464444502 | ||
|
|
e8a3f3dd6a | ||
|
|
0f43ee23de | ||
|
|
cf05e2c336 | ||
|
|
9347165a5a | ||
|
|
21eab152a6 | ||
|
|
e575d4728b | ||
|
|
5456418d54 | ||
|
|
dccdf1e5a4 | ||
|
|
a979a445ac | ||
|
|
516a69e218 | ||
|
|
b262381c58 | ||
|
|
aaad794085 | ||
|
|
8890589dc1 | ||
|
|
37e873fa09 | ||
|
|
347f7db20d | ||
|
|
770d1e08e1 | ||
|
|
06da93f43b | ||
|
|
d4559a0f39 | ||
|
|
a402f8258d | ||
|
|
f7f1b5c5ea | ||
|
|
221e269ccb | ||
|
|
ec787b92ba | ||
|
|
fa3947576d | ||
|
|
298cf31340 | ||
|
|
13e7f162a0 | ||
|
|
7cf2b8f1c2 | ||
|
|
7c2abad471 | ||
|
|
2cbffaeaea | ||
|
|
36b47ba98d | ||
|
|
81696b85d0 | ||
|
|
db4f4f0360 | ||
|
|
5565516e96 | ||
|
|
d479927e96 | ||
|
|
9c71696373 | ||
|
|
e22beaea22 | ||
|
|
a8dc1afe2c | ||
|
|
f0e423a71e | ||
|
|
25539b6606 | ||
|
|
f2af4b725a | ||
|
|
e1e6813eb1 | ||
|
|
13033c28d8 | ||
|
|
e1f9462818 | ||
|
|
6e48776abc | ||
|
|
de04b39165 | ||
|
|
e32b40ecf1 | ||
|
|
5149d36c1f | ||
|
|
0150586db7 | ||
|
|
36b212d4dc | ||
|
|
22f84314a4 | ||
|
|
03b3070871 | ||
|
|
73ab6b3e2f | ||
|
|
2f86a67e71 | ||
|
|
1b12ee50bb | ||
|
|
ee4e61ed68 | ||
|
|
46d5debc7a | ||
|
|
087ab979d6 | ||
|
|
f972eb54aa | ||
|
|
0005f4c88e | ||
|
|
f5aa26f7e1 | ||
|
|
e7b4bef8ac | ||
|
|
47093d057e | ||
|
|
c9cf1edc07 | ||
|
|
e8a05aaa65 | ||
|
|
12a5e16a75 | ||
|
|
a7735b85e9 | ||
|
|
fe4e95af2b | ||
|
|
11faf1df5f | ||
|
|
a83fdb39a8 | ||
|
|
efe4845923 | ||
|
|
5218a5f8b8 | ||
|
|
58d375bc93 | ||
|
|
ee04c41da8 | ||
|
|
4d8ec83866 | ||
|
|
1927376fe5 | ||
|
|
627383fd0d | ||
|
|
02689fceab | ||
|
|
615186c5d6 | ||
|
|
795f5772b6 | ||
|
|
4dabad3d6e | ||
|
|
7560f01745 | ||
|
|
9f37a9803d | ||
|
|
7af6818897 | ||
|
|
d965db9fe6 | ||
|
|
cc8119d0a7 | ||
|
|
fd26209b16 | ||
|
|
a9f807ac99 | ||
|
|
53b720cff7 | ||
|
|
9f29289afd | ||
|
|
abfdfd1b20 | ||
|
|
3198340451 | ||
|
|
85442c25c0 | ||
|
|
b222fa3744 | ||
|
|
fc5f86d696 | ||
|
|
b84358dc7f | ||
|
|
6c1152ed0c | ||
|
|
5cbdde7729 | ||
|
|
f51bf17e39 | ||
|
|
2db846d5e0 | ||
|
|
efd647f853 | ||
|
|
03b7bb72ea | ||
|
|
0ab28f623c | ||
|
|
3964f3b843 | ||
|
|
5a297777c0 | ||
|
|
80738425f6 | ||
|
|
5916f1f5c4 | ||
|
|
d7b3aeba66 | ||
|
|
de9119a27d | ||
|
|
96f227e7e1 | ||
|
|
87117be081 | ||
|
|
6d1be4cc11 | ||
|
|
9c499bdeae | ||
|
|
dc7ba94b06 | ||
|
|
855832b574 | ||
|
|
240744f9c9 | ||
|
|
a624019943 | ||
|
|
edb58cc61b | ||
|
|
1e763e6c5e | ||
|
|
51824b4316 | ||
|
|
92149e11a6 | ||
|
|
5e41a28dcf | ||
|
|
2819b30716 | ||
|
|
43371a4980 | ||
|
|
8264492f87 | ||
|
|
abf8cbfb92 | ||
|
|
c9703af47e | ||
|
|
0b53f0f9ed | ||
|
|
15baa59a8f | ||
|
|
ee5976ce12 | ||
|
|
c3156db6b9 | ||
|
|
a0b6136dcf | ||
|
|
e0aeed2e97 | ||
|
|
22ad2e0ec1 | ||
|
|
02e5ed8b16 | ||
|
|
3a49ece938 | ||
|
|
250ef8b136 | ||
|
|
e8fdac41a9 | ||
|
|
b8f598112f | ||
|
|
98d43daa5d | ||
|
|
095a159005 | ||
|
|
2be9e67697 | ||
|
|
89d56e5723 | ||
|
|
ec6598ccfb | ||
|
|
6967a8e52f | ||
|
|
3458b1bfb1 | ||
|
|
4e66afc65b | ||
|
|
4b3859f949 | ||
|
|
a1ca0bd796 | ||
|
|
c74e48249d | ||
|
|
92b79cf3a8 | ||
|
|
2bf4e080e4 | ||
|
|
2640727b29 | ||
|
|
52ee38d7c9 | ||
|
|
74a9f5b18e | ||
|
|
2eaa579121 | ||
|
|
fcd06e4c1c | ||
|
|
245a6ccae6 | ||
|
|
e263dddde9 | ||
|
|
4ab2e505fd | ||
|
|
bef17224e4 | ||
|
|
a59a6880f0 | ||
|
|
363304f53e | ||
|
|
bff65c217d | ||
|
|
14b03df174 | ||
|
|
93e2b9e0b9 | ||
|
|
15007e9071 | ||
|
|
b882174bf9 | ||
|
|
370f8223b6 | ||
|
|
d5dd1c4b10 | ||
|
|
bc1d71a1d1 | ||
|
|
702fb9565d | ||
|
|
210de388d9 | ||
|
|
c4ca9870b0 | ||
|
|
3d4f823884 | ||
|
|
d9874ae0f4 | ||
|
|
66e70afbb4 | ||
|
|
0bce1876c1 | ||
|
|
fc375fd115 | ||
|
|
cc190bbb29 | ||
|
|
4c8015541e | ||
|
|
9d0f68880a | ||
|
|
78574541e3 | ||
|
|
b30ca0da76 | ||
|
|
13a3364656 | ||
|
|
cabbe414a5 | ||
|
|
c2e3e9d494 | ||
|
|
e298f493ce | ||
|
|
69b07acc4e | ||
|
|
9d72ced2b6 | ||
|
|
b8c6783207 | ||
|
|
c713c4135b | ||
|
|
2c4ea022b9 | ||
|
|
961d8e0350 | ||
|
|
6f53e4616a | ||
|
|
e788907d9c | ||
|
|
2b4185ec23 | ||
|
|
f509d8fa4f | ||
|
|
13f0b61953 | ||
|
|
e50410ffb1 | ||
|
|
cae61d4e3e | ||
|
|
86d7f4c888 | ||
|
|
4743e11967 | ||
|
|
2ffeef667f | ||
|
|
2ffb0a83b0 | ||
|
|
4608f72098 | ||
|
|
c318a7fc37 | ||
|
|
25df5347aa | ||
|
|
148cb16cd4 | ||
|
|
13fff73bdb | ||
|
|
fbeb1d785c | ||
|
|
d992a71513 | ||
|
|
672626f225 | ||
|
|
513a7e0a4e | ||
|
|
4e9df1679e | ||
|
|
4a54b6e4fa | ||
|
|
a7338085ec | ||
|
|
7ac2009f16 | ||
|
|
00ef778c7c | ||
|
|
fbe838730f | ||
|
|
55197a2934 | ||
|
|
205c791e00 | ||
|
|
b0d3164ecf | ||
|
|
551eadc1d5 | ||
|
|
409a998df2 | ||
|
|
c9a58a8a8c | ||
|
|
aa4b17900b | ||
|
|
3f4c1fe91b | ||
|
|
b2e07d858b | ||
|
|
dfbcec2f0d | ||
|
|
53b8056502 | ||
|
|
e323924176 | ||
|
|
1efb3d87c8 | ||
|
|
591e02c71b | ||
|
|
e85e4a8eb9 | ||
|
|
dc0ce46b0c | ||
|
|
50e69bab6b | ||
|
|
cc3ef640da | ||
|
|
f7d6604b9b | ||
|
|
a6821a6cb8 | ||
|
|
f386101e82 | ||
|
|
2aa5f67381 | ||
|
|
eb33596d02 | ||
|
|
663b8d6c89 | ||
|
|
ca2a2e9c49 | ||
|
|
54778eb303 | ||
|
|
72288f4450 | ||
|
|
c59c71b5c9 | ||
|
|
e7a14993c7 | ||
|
|
408ba8d574 | ||
|
|
054e43e6e9 | ||
|
|
65685a0da6 | ||
|
|
0bab902753 | ||
|
|
9141d95865 | ||
|
|
ddbd8386d2 | ||
|
|
285ff7d3b4 | ||
|
|
5f94480bfb | ||
|
|
7cfa099ec3 | ||
|
|
a374baa376 | ||
|
|
7e60fcb298 | ||
|
|
02c95e8fed | ||
|
|
9264cd9d56 | ||
|
|
c34d5a4f6b | ||
|
|
56f54d864a | ||
|
|
465f8fa96a | ||
|
|
a7260bbfa9 | ||
|
|
4a6e34dcbd | ||
|
|
7f6131d440 | ||
|
|
374dfcd60a | ||
|
|
457f667cab | ||
|
|
4b6e78cf78 | ||
|
|
1f25bfb60b | ||
|
|
a1e062bc49 | ||
|
|
438e665c6d | ||
|
|
fd6e5ae3ef | ||
|
|
b9ed89a976 | ||
|
|
07e9fc4ccf | ||
|
|
000cc9d92f | ||
|
|
a39d617ac9 | ||
|
|
69456cd3f5 | ||
|
|
d27dfbd6d7 | ||
|
|
0ccaac4e00 | ||
|
|
030fe60b34 | ||
|
|
be8db0719f | ||
|
|
f4498fd0a4 | ||
|
|
28b97582b6 | ||
|
|
236f9291be | ||
|
|
fcf1d52e4a | ||
|
|
f2bd701927 | ||
|
|
8581a249bd | ||
|
|
688cd79a55 | ||
|
|
d5f7f3d51c | ||
|
|
1b519cd104 | ||
|
|
a6d8d1cbc5 | ||
|
|
a494521d7b | ||
|
|
245d81ee92 | ||
|
|
99825aa29f | ||
|
|
d05ec536fd | ||
|
|
153f16fc05 | ||
|
|
2e0b8e10ae | ||
|
|
df88e319a8 | ||
|
|
5dfac5a92b | ||
|
|
62195b7cc7 | ||
|
|
9572c7d4ed | ||
|
|
20282ce89f | ||
|
|
62e58a25c9 | ||
|
|
19ea8ac55f | ||
|
|
2af6ca8833 | ||
|
|
f9d8269274 | ||
|
|
3c7b6ae94c | ||
|
|
8ec60fbe3e | ||
|
|
79dc8b2ace | ||
|
|
e3bbe0a4fd | ||
|
|
96adbe3827 | ||
|
|
ef8563c9bd | ||
|
|
533d39b4c2 | ||
|
|
48bd4fecc6 | ||
|
|
92babea8c8 | ||
|
|
3425f29130 | ||
|
|
673892cd80 | ||
|
|
f5b8dd17b8 | ||
|
|
cfa7d22d33 | ||
|
|
fabd551e2a | ||
|
|
327d7c84ca | ||
|
|
2b67dcd2cf | ||
|
|
7571bedc46 | ||
|
|
b15ffa3d89 | ||
|
|
5addccc270 | ||
|
|
c94fb96bb2 | ||
|
|
9ac933fb9e | ||
|
|
44c2397804 | ||
|
|
8c4e4c3861 | ||
|
|
fa736411e3 | ||
|
|
728cd17275 | ||
|
|
caa2064c90 | ||
|
|
6f47dd6522 | ||
|
|
c71047f359 | ||
|
|
6871e0252a | ||
|
|
56cfcc693a | ||
|
|
a87f4388e5 | ||
|
|
44e5cc446c | ||
|
|
f686243f64 | ||
|
|
d64902b2a5 | ||
|
|
5b92b4d01b | ||
|
|
0733885a73 | ||
|
|
c42f378184 | ||
|
|
ad74d32f51 | ||
|
|
321a08b42e | ||
|
|
b7d5537961 | ||
|
|
32017ff659 | ||
|
|
e2c0e58af9 | ||
|
|
1c67d07dc3 | ||
|
|
e72589c6d4 | ||
|
|
e2e6479fb0 | ||
|
|
89e8995dc4 | ||
|
|
b0b1174564 | ||
|
|
57a542fcac | ||
|
|
fb1a7fc0fc | ||
|
|
4f50a5a147 | ||
|
|
2692100bb1 | ||
|
|
e7fcb58bec | ||
|
|
2752b51d50 | ||
|
|
a71964f0b2 | ||
|
|
43b20179ed | ||
|
|
0d76cc4ef3 | ||
|
|
cfe0c14e56 | ||
|
|
1e6dc74c5a | ||
|
|
e1afa61128 | ||
|
|
b5bcede82f | ||
|
|
23dfc37171 | ||
|
|
148539d242 | ||
|
|
8acc122ab0 | ||
|
|
4e61a2da33 | ||
|
|
dc9cffec5d | ||
|
|
86b34460dd | ||
|
|
b66e8410f6 | ||
|
|
9a272039d3 | ||
|
|
dc69cf82eb | ||
|
|
17c19fc35a | ||
|
|
4cd13016d3 | ||
|
|
84781c62c2 | ||
|
|
378453c954 | ||
|
|
40709625cc | ||
|
|
77f6844340 | ||
|
|
68083fa15a | ||
|
|
cbab184002 | ||
|
|
0819688f50 | ||
|
|
6770e1ab32 | ||
|
|
078bc96b77 | ||
|
|
ed8ec4a4c2 | ||
|
|
4fbf1401fa | ||
|
|
5f2f6b6617 | ||
|
|
e3c2a7db67 | ||
|
|
ace5acea0b | ||
|
|
8511c6b9cf | ||
|
|
3ef4a73db5 | ||
|
|
2274ca348b | ||
|
|
e9fca9cad6 | ||
|
|
96eba5f877 | ||
|
|
3db41c327f | ||
|
|
6de1ad36dc | ||
|
|
635ca1ab90 | ||
|
|
215cdda238 | ||
|
|
ffbabfc8fe | ||
|
|
5a62ac79e9 | ||
|
|
846a470717 | ||
|
|
f6f8f09bce | ||
|
|
6ffd1475c5 | ||
|
|
5bbc3e69e9 | ||
|
|
f1d5e9c4a2 | ||
|
|
68f25fa999 | ||
|
|
ef7aa132a6 | ||
|
|
f41ce51bf9 | ||
|
|
ed38f7dcb5 | ||
|
|
cc77d78d5a | ||
|
|
159e07a8ea | ||
|
|
cf434828dc | ||
|
|
649a21ad86 | ||
|
|
dd5f66e125 | ||
|
|
c8920b0c06 | ||
|
|
09bcf9dd12 | ||
|
|
d1b593be66 | ||
|
|
3acd6c3cd0 | ||
|
|
aca2a2d428 | ||
|
|
d3dc1f8bf1 | ||
|
|
a91c142b3c | ||
|
|
fa28cee957 | ||
|
|
93ec0a512a | ||
|
|
1bf36221f4 | ||
|
|
0e3f95c1a9 | ||
|
|
01e2bf2374 | ||
|
|
34bcab34d8 | ||
|
|
fceaf167a4 | ||
|
|
950fb33206 | ||
|
|
7b23f7a8fd | ||
|
|
43e852d43a | ||
|
|
0bef3ab1bf | ||
|
|
967d3b54a3 | ||
|
|
ec31125af3 | ||
|
|
84d44b2487 | ||
|
|
9f2f89163f | ||
|
|
d29536673a | ||
|
|
8283fcc2d7 | ||
|
|
5e33e5574e | ||
|
|
dd41f411e6 | ||
|
|
92be58d1d8 | ||
|
|
fd1e8483a5 | ||
|
|
855dc44e32 | ||
|
|
9185e1c4a6 | ||
|
|
08007aa4d5 | ||
|
|
3b7a468c6a | ||
|
|
fba3337925 | ||
|
|
811f3c0834 | ||
|
|
31d0a7f3ae | ||
|
|
4adbdad9b3 | ||
|
|
120a431766 | ||
|
|
9cecebfe0a | ||
|
|
514511c15a | ||
|
|
610548ba3d | ||
|
|
dd3c65df7a | ||
|
|
195a3d3768 | ||
|
|
65236ede89 | ||
|
|
0e8984d121 | ||
|
|
9f84fb1749 | ||
|
|
b6046a8e23 | ||
|
|
af3cb73fbc | ||
|
|
c816847a3c | ||
|
|
652809d005 | ||
|
|
8bfa8ff721 | ||
|
|
a6c89ee54f | ||
|
|
0935110284 | ||
|
|
f5bd68fa77 | ||
|
|
d44a618169 | ||
|
|
ae3eca803d | ||
|
|
b087c1153c | ||
|
|
e12a8b06f0 | ||
|
|
fce445e464 | ||
|
|
5bb66ef268 | ||
|
|
eca9245382 | ||
|
|
aaa969dc8a | ||
|
|
28414505bc | ||
|
|
ac8ce1f643 | ||
|
|
5ed73c1918 | ||
|
|
79e973bfeb | ||
|
|
64c87e0e4a | ||
|
|
6af285adb8 | ||
|
|
d962e36dbb | ||
|
|
7713b5f941 | ||
|
|
8764388033 | ||
|
|
2ae3733cd9 | ||
|
|
2762222fcc | ||
|
|
a337e25fb1 | ||
|
|
fe5eab8f9a | ||
|
|
bdb3bb778e | ||
|
|
98b6e446f0 | ||
|
|
c8f5638780 | ||
|
|
c6bafdf203 | ||
|
|
1bbc482f1a | ||
|
|
a89fc9460b | ||
|
|
fd2e78965c | ||
|
|
10f3928169 | ||
|
|
bf01817ab8 | ||
|
|
b58e526a0b | ||
|
|
fe479fe261 | ||
|
|
473c2276dd | ||
|
|
1e8ea6b15b | ||
|
|
a883f0b39a | ||
|
|
848939683e | ||
|
|
6cd62851bb | ||
|
|
97b9fce748 | ||
|
|
c18be9809d | ||
|
|
68a860b958 | ||
|
|
a6ead395a0 | ||
|
|
e0fe252b90 | ||
|
|
0a673294c8 | ||
|
|
15d08b6692 | ||
|
|
b500f0c8f3 | ||
|
|
5c33fb67e5 | ||
|
|
50dc23f42c | ||
|
|
10b86cea37 | ||
|
|
7c6d92ec10 | ||
|
|
4a39e2b731 | ||
|
|
ce94a1ad5b | ||
|
|
264f630467 | ||
|
|
9711cf9d9a | ||
|
|
a005c62d17 | ||
|
|
7b193a40ef | ||
|
|
6718decbb7 | ||
|
|
87e262f27a | ||
|
|
a7207af953 | ||
|
|
d0f42c26cc | ||
|
|
6d449962ff | ||
|
|
8ddc9f21fe | ||
|
|
3ab541949f | ||
|
|
b9e61de4d2 | ||
|
|
38d0e5b6e7 | ||
|
|
bb4b37c6b3 | ||
|
|
6f12166af2 | ||
|
|
eec348132f | ||
|
|
623fc13407 | ||
|
|
a3f50c61f9 | ||
|
|
da01b4dd31 | ||
|
|
ae0ceee8f6 | ||
|
|
088936e7f8 | ||
|
|
d76b9c5b17 | ||
|
|
645eeae16c | ||
|
|
84bcf11d57 | ||
|
|
6d8b8a878d | ||
|
|
bd30245492 | ||
|
|
48cd728693 | ||
|
|
1a4a35f5a1 | ||
|
|
5b8e2cb6e1 | ||
|
|
8a3b60e0c5 | ||
|
|
6c55ba5d31 | ||
|
|
440c6415bc | ||
|
|
fcb95272b9 | ||
|
|
ff21f5a590 | ||
|
|
ec19c8c87e | ||
|
|
d25f0db948 | ||
|
|
62d7b3b034 | ||
|
|
d8aa9bfa1d | ||
|
|
56fd6d944c | ||
|
|
a4d6c628e3 | ||
|
|
9bbdd5840c | ||
|
|
52bb50550d | ||
|
|
1468da5c33 | ||
|
|
d3fab62f8f | ||
|
|
c64a7f1f9c | ||
|
|
db219daeda | ||
|
|
ee2ddf26f3 | ||
|
|
ced3903100 | ||
|
|
b5e40a44b1 | ||
|
|
5f11d67812 | ||
|
|
4b2cd9030c | ||
|
|
239ed85889 | ||
|
|
61bb01e06d | ||
|
|
666136851c | ||
|
|
a6714bbe47 | ||
|
|
167e26a243 | ||
|
|
7c322c36ed | ||
|
|
752e752dbd | ||
|
|
ab1a9b41e6 | ||
|
|
b7c08e8aed | ||
|
|
9c675a8e82 | ||
|
|
22e1ccdfa9 | ||
|
|
a4bfd51401 | ||
|
|
10b648c96e | ||
|
|
d109f409fb | ||
|
|
83cadc8abe | ||
|
|
31d18a21b2 | ||
|
|
20150c1418 | ||
|
|
9610d914e9 | ||
|
|
0a0df60f77 | ||
|
|
b4960b19fb | ||
|
|
3922c18054 | ||
|
|
53c19167f3 | ||
|
|
20464832da | ||
|
|
73ecaefde8 | ||
|
|
2ab274542a | ||
|
|
280cba0c54 | ||
|
|
bbe78633a2 | ||
|
|
c20af89a11 | ||
|
|
72fa6f092d | ||
|
|
db26a60320 | ||
|
|
e6126bc218 | ||
|
|
29200c8814 | ||
|
|
5bbb83c68b | ||
|
|
8ec482fdbd | ||
|
|
f2c4aadfe1 | ||
|
|
75f3198c3d | ||
|
|
d3101f8e96 | ||
|
|
1927a4cf47 | ||
|
|
0bd55a1fa1 | ||
|
|
cda531fc56 | ||
|
|
8b3786db40 | ||
|
|
639edca434 | ||
|
|
bf43316942 | ||
|
|
9c7c200048 | ||
|
|
ceab2ac138 | ||
|
|
6322798b61 | ||
|
|
a9921c78e8 | ||
|
|
7ac12cd071 | ||
|
|
d7ae21ce85 | ||
|
|
31468efc8e | ||
|
|
f25dec516b | ||
|
|
8bca90a40b | ||
|
|
62b3b2c578 | ||
|
|
ae68e0a449 | ||
|
|
6536a30b03 | ||
|
|
0dcaa505fa | ||
|
|
963d91f07d | ||
|
|
65cfdd1bf6 | ||
|
|
67972f787b | ||
|
|
d78c2f0ef5 | ||
|
|
a114a42b74 | ||
|
|
3e8e94d49c | ||
|
|
fa89846ee3 | ||
|
|
bffa23c4b2 | ||
|
|
d19792289d | ||
|
|
2bfcce40e2 | ||
|
|
9cf4cc1533 | ||
|
|
60ee852587 | ||
|
|
9531f04abf | ||
|
|
6f5c1ba629 | ||
|
|
4c2df29808 | ||
|
|
bfba1c477f | ||
|
|
8c74a23ec1 | ||
|
|
fd5ca1e52b | ||
|
|
f46958bb3f | ||
|
|
1787b63599 | ||
|
|
f80c6ab178 | ||
|
|
7947a991a4 | ||
|
|
391fda7ba6 | ||
|
|
19a5f5cd54 | ||
|
|
8cd0fcefef | ||
|
|
a4a98617c7 | ||
|
|
222ef3a76a | ||
|
|
4fbfbc3dd7 | ||
|
|
693ab86a6c | ||
|
|
837cb2b695 | ||
|
|
cc20e4cb7d | ||
|
|
789775d8d7 | ||
|
|
1314eff237 | ||
|
|
47f507ff62 | ||
|
|
e32c35905a | ||
|
|
61caef8e94 | ||
|
|
e6c4845983 | ||
|
|
e5f449e74f | ||
|
|
93781909bb | ||
|
|
60c07120c7 | ||
|
|
4c0cd82d9c | ||
|
|
f0aa7abf21 | ||
|
|
35901db2cd | ||
|
|
0fa3fecfe4 | ||
|
|
8a0868e2e0 | ||
|
|
59151b375c | ||
|
|
5e080ad61d | ||
|
|
ea224d409e | ||
|
|
37761540d0 | ||
|
|
b4d4759383 | ||
|
|
52ffa29ebe | ||
|
|
c74f4656fc | ||
|
|
92747ec37a | ||
|
|
3b81dc2a55 | ||
|
|
47bdf497b6 | ||
|
|
b1712325a7 | ||
|
|
9817e050e0 | ||
|
|
001f788631 | ||
|
|
6f1d0ef97b | ||
|
|
964965be9d | ||
|
|
4919f24985 | ||
|
|
1e23df926c | ||
|
|
dea81daa79 | ||
|
|
1ccec72f8c | ||
|
|
bd38e5a7f2 | ||
|
|
6c552e8447 | ||
|
|
86de6f5fbc | ||
|
|
a7bc41b528 | ||
|
|
49b136191f | ||
|
|
e68c3ab725 | ||
|
|
a2a03d8d53 | ||
|
|
d712a12db1 | ||
|
|
e60482ca0e | ||
|
|
42a8c59886 | ||
|
|
b1499cd954 | ||
|
|
f504d01644 | ||
|
|
e084fb022b | ||
|
|
3fc3c9d0cf | ||
|
|
e5dabf716a | ||
|
|
739b0d4399 | ||
|
|
92d1e5cefd | ||
|
|
429dca127d | ||
|
|
303f55f3a3 | ||
|
|
648c3430ef | ||
|
|
50fe1ba14d | ||
|
|
c7846c827b | ||
|
|
be8d241e06 | ||
|
|
545b97de65 | ||
|
|
64a2a85077 | ||
|
|
efa9f0a5d1 | ||
|
|
546262df38 | ||
|
|
6eb9a636d1 | ||
|
|
33f0900ab7 | ||
|
|
cde5f31135 | ||
|
|
7da01d8683 | ||
|
|
ccea31d3ab | ||
|
|
aebe5c1dfc | ||
|
|
1efd06ef56 | ||
|
|
7d7a85c78f | ||
|
|
28c4599436 | ||
|
|
7933435ffc | ||
|
|
1baaf560c5 | ||
|
|
0002d6f833 | ||
|
|
0c8782c0ff | ||
|
|
23a0b28326 | ||
|
|
8e10f79075 | ||
|
|
1e19574645 | ||
|
|
e7058e9135 | ||
|
|
c1140ec6a7 | ||
|
|
47127e9e4e | ||
|
|
04e42a8d70 | ||
|
|
1d7dd0a227 | ||
|
|
63b86cab2e | ||
|
|
9bd7847afb | ||
|
|
097a0c4a90 | ||
|
|
916c6b3b2f | ||
|
|
e82638fa03 | ||
|
|
dd26bcb22b | ||
|
|
47ec7141ac | ||
|
|
b42cc9f4ad | ||
|
|
4bde73d7a9 | ||
|
|
a9eb9f9ea5 | ||
|
|
2cda0fc1fe | ||
|
|
c62cd4dfcb | ||
|
|
c37cd19a23 | ||
|
|
dd8f1c7b38 | ||
|
|
3785fc4887 | ||
|
|
f6fb219ab2 | ||
|
|
6a2b4a81b5 | ||
|
|
15dae7dcbc | ||
|
|
e8013a4252 | ||
|
|
f6bc6a0bf6 | ||
|
|
57dc4ed476 | ||
|
|
9d3f6dacb8 | ||
|
|
cc651d0b4c | ||
|
|
f30f3ea8ed | ||
|
|
f317ff6d43 | ||
|
|
d277e80d81 | ||
|
|
cc801277ce | ||
|
|
45cf22ebf5 | ||
|
|
ce1a1f749a | ||
|
|
d797d10376 | ||
|
|
e04a3e7fce | ||
|
|
b8009d7c9a | ||
|
|
be783a65e0 | ||
|
|
6dc8b2f9f7 | ||
|
|
e37846bdcb | ||
|
|
9b4e5e57d6 | ||
|
|
e68969daa6 | ||
|
|
c584586985 | ||
|
|
c255e4bf8d | ||
|
|
c1c7cfd234 | ||
|
|
dc436a66cc | ||
|
|
699f40c9b2 | ||
|
|
84d20442a4 | ||
|
|
5416c2b778 | ||
|
|
5d09a25abc | ||
|
|
74f8c0e06a | ||
|
|
892f2be487 | ||
|
|
bf557a1bb0 | ||
|
|
073e99e538 | ||
|
|
ee544893f6 | ||
|
|
2c8cf7d7ea | ||
|
|
2c74944566 | ||
|
|
042147b010 | ||
|
|
0d3cc14c5e | ||
|
|
07f2e18dfc | ||
|
|
938819a8b8 | ||
|
|
4de708b5ad | ||
|
|
65d6c82f81 | ||
|
|
1da612e8a0 | ||
|
|
e6214480c4 | ||
|
|
6de61f3f5b | ||
|
|
81634d410b | ||
|
|
7528e2a9b2 | ||
|
|
a9a55321c7 | ||
|
|
4cbd8ea8c9 | ||
|
|
91f250d4d2 | ||
|
|
5102e71e84 | ||
|
|
7b9710aa4e | ||
|
|
624939f6ba | ||
|
|
16aaa93e76 | ||
|
|
7897500c1e | ||
|
|
64558e138b | ||
|
|
cc995b625b | ||
|
|
c81d1b5dd0 | ||
|
|
9ae58caadb | ||
|
|
f2f7681be2 | ||
|
|
970d8e813a | ||
|
|
4007834f15 | ||
|
|
96cd245463 | ||
|
|
6742d626e7 | ||
|
|
e1bde8c730 | ||
|
|
b44da3c27f | ||
|
|
8e70d18a32 | ||
|
|
f6ce901132 | ||
|
|
4637f4085d | ||
|
|
134b887adc | ||
|
|
4a4d7209ba | ||
|
|
e159e1a8bd | ||
|
|
ac9ee5d1f8 | ||
|
|
54435fce60 | ||
|
|
4092adbe28 | ||
|
|
06f81e8a61 | ||
|
|
e94774ccec | ||
|
|
a4d950a2f2 | ||
|
|
63bc66c40d | ||
|
|
2a053b86bf | ||
|
|
d643219ee8 | ||
|
|
74015d6d18 | ||
|
|
224bd55d50 | ||
|
|
4f51940274 | ||
|
|
d2263c121a | ||
|
|
075f8740d4 | ||
|
|
8fd442531f | ||
|
|
4f49061084 | ||
|
|
d02cdc2fec | ||
|
|
29a695b4a6 | ||
|
|
9504cb8531 | ||
|
|
8a341d78b1 | ||
|
|
63075b73bd | ||
|
|
2a27c469fe | ||
|
|
b3c159d968 | ||
|
|
fa25d7c428 | ||
|
|
ba769623be | ||
|
|
82ff19092b | ||
|
|
e5f59799ee | ||
|
|
88392f9bd3 | ||
|
|
0a3621cdee | ||
|
|
7c32c9c6e7 | ||
|
|
3f059575ee | ||
|
|
d4fb9b1343 | ||
|
|
9c2b0ac5ea | ||
|
|
5088e903cb | ||
|
|
5e8a6924b6 | ||
|
|
7c76a46cbc | ||
|
|
fbf44f1991 | ||
|
|
e37e0079be | ||
|
|
96c0050cb8 | ||
|
|
2c7b51ca56 | ||
|
|
d5747a0379 | ||
|
|
b0962095f3 | ||
|
|
77162e7784 | ||
|
|
6e116d9e59 | ||
|
|
a81b735016 | ||
|
|
e5464f5be7 | ||
|
|
d86f8a8981 | ||
|
|
deb8048da5 | ||
|
|
a88ad62af3 | ||
|
|
8cafd07e0a | ||
|
|
46309f7333 | ||
|
|
612c618240 | ||
|
|
e2bbbefb04 | ||
|
|
f1b59388bb | ||
|
|
c083150072 | ||
|
|
3353a74e1d | ||
|
|
79b5b0f1fc | ||
|
|
ed53728010 | ||
|
|
0fceadc529 | ||
|
|
404c52e3c2 | ||
|
|
9b5ec3572e | ||
|
|
46b4186216 | ||
|
|
bcf0a42674 | ||
|
|
029d0af946 | ||
|
|
f5e397341d | ||
|
|
32843f9f91 | ||
|
|
6ecd3f1f8a | ||
|
|
17bc493612 | ||
|
|
34f8013465 | ||
|
|
5b05afe948 | ||
|
|
686c6c9033 | ||
|
|
04239f9287 | ||
|
|
e163a796b2 | ||
|
|
63f1bf2d45 | ||
|
|
0e7d25ba85 | ||
|
|
b7792f0aa2 | ||
|
|
429a188318 | ||
|
|
0ff6026df8 | ||
|
|
984b35e2b0 | ||
|
|
fc319a4502 | ||
|
|
4f11ad7adb | ||
|
|
436c09aa51 | ||
|
|
cd3f6340da | ||
|
|
78428b523f | ||
|
|
f259b56e67 | ||
|
|
e0afb3b8b4 | ||
|
|
e2ddaf7577 | ||
|
|
63b9c5265f | ||
|
|
88b8e982b4 | ||
|
|
bf00102f83 | ||
|
|
4751cb16c9 | ||
|
|
c9111563b1 | ||
|
|
f7d25a8ee9 | ||
|
|
be24c90532 | ||
|
|
3c5093f3cb | ||
|
|
dd7072c875 | ||
|
|
6610929eaf | ||
|
|
39395465a2 | ||
|
|
071b10f3f4 | ||
|
|
5a8fb4651c | ||
|
|
eab7a961df | ||
|
|
23166f43d7 | ||
|
|
7427e01b60 | ||
|
|
7e4187e89a | ||
|
|
603e9336d4 | ||
|
|
03e6b1bff7 | ||
|
|
d833a65d1e | ||
|
|
e315170c8d | ||
|
|
c444d43fe8 | ||
|
|
c6d8f8ee28 | ||
|
|
108278c4b5 | ||
|
|
556306a269 | ||
|
|
49b1fe421e | ||
|
|
def0169dda | ||
|
|
a482132652 | ||
|
|
4cf6a4c22e | ||
|
|
10dddd85c5 | ||
|
|
fe24ce53b7 | ||
|
|
0ee104d155 | ||
|
|
b6b77f4b45 | ||
|
|
0fdfa32d4a | ||
|
|
7d1e1e6147 | ||
|
|
a4b4ebaf7d | ||
|
|
4677c5955d | ||
|
|
ca7f8e66bb | ||
|
|
0a6151ade9 | ||
|
|
039deed864 | ||
|
|
83cef11a78 | ||
|
|
0825819586 | ||
|
|
2d0c21f8a8 | ||
|
|
41695bf9ac | ||
|
|
23b65ca454 | ||
|
|
96f8392555 | ||
|
|
6df5de17c6 | ||
|
|
a539909972 | ||
|
|
85c022e1e7 | ||
|
|
dd60df83a1 | ||
|
|
e42605590f | ||
|
|
1a28d8d5d2 | ||
|
|
b945fc01dd | ||
|
|
85bd5a9933 | ||
|
|
63be4a3dd1 | ||
|
|
fbff08080a | ||
|
|
1e37afc49d | ||
|
|
23f72ac774 | ||
|
|
5c1a1d6e94 | ||
|
|
cef6b09b68 | ||
|
|
789532a95f | ||
|
|
be2174b1d2 | ||
|
|
f4449d1c9d | ||
|
|
7c52aa6932 | ||
|
|
76f663d31c | ||
|
|
e18e14f779 | ||
|
|
0a7d5b8e32 | ||
|
|
675715a917 | ||
|
|
590ca9c7a6 | ||
|
|
0d07a7be65 | ||
|
|
d3af29fada | ||
|
|
522d20d9e4 | ||
|
|
f38ac2cc7d | ||
|
|
d7654190f7 | ||
|
|
36369325e7 | ||
|
|
0835e0584a | ||
|
|
0ef64fde73 | ||
|
|
0bebaf410a | ||
|
|
8712598ca1 | ||
|
|
258e1f2348 | ||
|
|
ad553f3782 | ||
|
|
2b15c6f204 | ||
|
|
0bf87e554c | ||
|
|
64d1fcbe9c | ||
|
|
224550a50c | ||
|
|
60231ca8d9 | ||
|
|
92acc6d991 | ||
|
|
d2dfabee3f | ||
|
|
a9df82a0af | ||
|
|
fa683200b5 | ||
|
|
044194c64e | ||
|
|
651fd7b133 | ||
|
|
f4ac890a3c | ||
|
|
f7d8cfd5c8 | ||
|
|
5f14079695 | ||
|
|
fa2a36311f | ||
|
|
18988f0059 | ||
|
|
6fce22c555 | ||
|
|
71fb5185a4 | ||
|
|
fc3b3d5c96 | ||
|
|
839757e6c8 | ||
|
|
589e7f28e0 | ||
|
|
bf8eb078ca | ||
|
|
25bd7b13b6 | ||
|
|
f726622241 | ||
|
|
b5806968cb | ||
|
|
602332a97c | ||
|
|
3d95d9a8ee | ||
|
|
745c6e57c2 | ||
|
|
21f21dbe75 | ||
|
|
faeb4b9cd3 | ||
|
|
071343da5e | ||
|
|
91f4b8f504 | ||
|
|
1391df3948 | ||
|
|
5a301bff76 | ||
|
|
c8ac841fbb | ||
|
|
9c601ef49b | ||
|
|
4c2ccf1d6b | ||
|
|
16e7e4403e | ||
|
|
47dacc09ef | ||
|
|
4479080864 | ||
|
|
73695aa413 | ||
|
|
d6793e792d | ||
|
|
89e946cc51 | ||
|
|
17785070a4 | ||
|
|
0cd6c6eb08 | ||
|
|
9780277e48 | ||
|
|
a6b3addb4f | ||
|
|
17d2782182 | ||
|
|
086dac4444 | ||
|
|
9777cf3416 | ||
|
|
a89548ed48 | ||
|
|
7abfa7609e | ||
|
|
e332e8586f | ||
|
|
d06c2f93da | ||
|
|
4b25f24175 | ||
|
|
b894c423d3 | ||
|
|
c84f114dd6 | ||
|
|
61a2540ed4 | ||
|
|
4db5e54737 | ||
|
|
59464fa41b | ||
|
|
6d2a69113b | ||
|
|
467fd77a28 | ||
|
|
54f6e42a44 | ||
|
|
b9a295afaf | ||
|
|
f49dcdd62a | ||
|
|
42722d0fd6 | ||
|
|
aa83d9109b | ||
|
|
8db4e97d65 | ||
|
|
657a3b76c5 | ||
|
|
cafdce69fe | ||
|
|
298cba3c01 | ||
|
|
f6173cdb0d | ||
|
|
025b829638 | ||
|
|
a50b6f56d5 | ||
|
|
4e70bbc49f | ||
|
|
32805d8e36 | ||
|
|
20ab09a1d5 | ||
|
|
225afe0d6d | ||
|
|
c335e46384 | ||
|
|
fe7971759c | ||
|
|
d4b8fab303 | ||
|
|
55ae32362e | ||
|
|
db6d15624d | ||
|
|
4e6c0b6976 | ||
|
|
87fd28f0c2 | ||
|
|
8e0dc2055f | ||
|
|
d8d583ee57 | ||
|
|
f0753a82b5 | ||
|
|
372605440c | ||
|
|
b39a802336 | ||
|
|
bc430db812 | ||
|
|
6f308aba11 | ||
|
|
1714caae58 | ||
|
|
1ec7d264cf | ||
|
|
27a082c325 | ||
|
|
25a6b0cde6 | ||
|
|
415a176f6b | ||
|
|
9d844ef113 | ||
|
|
40c70cf06b | ||
|
|
9337cb591d | ||
|
|
91385e13eb | ||
|
|
1bf8ad6366 | ||
|
|
507235a681 | ||
|
|
e96bbdd31a | ||
|
|
ad79620983 | ||
|
|
1b800e2499 | ||
|
|
eaef1c70d6 | ||
|
|
f12c24ce0a | ||
|
|
e9eeb767e4 | ||
|
|
37f38b3211 | ||
|
|
0297bb1870 | ||
|
|
e33f3e31bc | ||
|
|
1e20118645 | ||
|
|
1ece6c1612 | ||
|
|
d8c88fa510 | ||
|
|
e9abfe3cc8 | ||
|
|
1fa580f6f0 | ||
|
|
a4812c4706 | ||
|
|
b521c8b97e | ||
|
|
b0f7aeabbb | ||
|
|
604ee63096 | ||
|
|
8fbf1267a5 | ||
|
|
31ad141f7e | ||
|
|
e7f55612b0 | ||
|
|
9b2097e5e4 | ||
|
|
73bc138b70 | ||
|
|
58134f78dc | ||
|
|
8105bced11 | ||
|
|
bcba74d0e7 | ||
|
|
b352e67088 | ||
|
|
1561b7a08a | ||
|
|
586fbbe925 | ||
|
|
c4e26724a4 | ||
|
|
5931c23695 | ||
|
|
7a2693e4f1 | ||
|
|
f968792286 | ||
|
|
fbf0303b2d | ||
|
|
390ef3b2ba | ||
|
|
c2712963d6 | ||
|
|
769c7b28ff | ||
|
|
a005d832cb | ||
|
|
c9508d9b7e | ||
|
|
39ba305f73 | ||
|
|
857becbd66 | ||
|
|
412710884c | ||
|
|
15fa3beb6d | ||
|
|
81a20ef328 | ||
|
|
bcd583914f | ||
|
|
a1abe14414 | ||
|
|
7cc8e74d1a | ||
|
|
678cbdc23d | ||
|
|
2d5fa3b9dc | ||
|
|
c4aec5ae33 | ||
|
|
69434c8b7d | ||
|
|
2d8b3b2b6e | ||
|
|
2e17562e51 | ||
|
|
405acfcbba | ||
|
|
e6516c3a90 | ||
|
|
1b9845e38f | ||
|
|
818cd278b2 | ||
|
|
1fa77fa5d7 | ||
|
|
6d9888462c | ||
|
|
d7c9193662 | ||
|
|
de3ef5fc1f | ||
|
|
97f3ed08c0 | ||
|
|
d0b5c705bf | ||
|
|
d094d0262b | ||
|
|
8b70eccca6 | ||
|
|
8005f1bb28 | ||
|
|
dc4541f267 | ||
|
|
edf94bf1b2 | ||
|
|
f4a66c4b22 | ||
|
|
4e2f371fc9 | ||
|
|
3fec97db45 | ||
|
|
6e7cc4414a | ||
|
|
8746d3de45 | ||
|
|
f803f8b92a | ||
|
|
0a4c00c5f2 | ||
|
|
4773dfd53f | ||
|
|
fecc974ade | ||
|
|
43ec140124 | ||
|
|
d483d14c8e | ||
|
|
9a28e559a4 | ||
|
|
29e810dd2a | ||
|
|
cfc811900d | ||
|
|
43cfd5fea5 | ||
|
|
bac918d4c8 | ||
|
|
e0c600eb14 | ||
|
|
d67096f58c | ||
|
|
fde3ee73af | ||
|
|
9c0bb3d392 | ||
|
|
8a7a966a7b | ||
|
|
4b44e07188 | ||
|
|
9676c2e486 | ||
|
|
5e8c1d0221 | ||
|
|
08a17fd5b2 | ||
|
|
a78df87f8e | ||
|
|
ddd2b740c8 | ||
|
|
87de768af4 | ||
|
|
a23a6f7c90 | ||
|
|
2c1255ffb6 | ||
|
|
bcab0ffcc6 | ||
|
|
dbc7957a50 | ||
|
|
41dbff4d76 | ||
|
|
a6ee4a680c | ||
|
|
90679c2cf5 | ||
|
|
dd9324ac05 | ||
|
|
94702f63ff | ||
|
|
b65b03765d | ||
|
|
c4eaa1359d | ||
|
|
48375bb780 | ||
|
|
70d5e5a012 | ||
|
|
8083432925 | ||
|
|
a4a210c9e5 | ||
|
|
7bd4775b01 | ||
|
|
75878b96e6 | ||
|
|
3379467484 | ||
|
|
930673c2f2 | ||
|
|
dd7c562c96 | ||
|
|
46ae9146d8 | ||
|
|
7503242a6a | ||
|
|
7db7482ac5 | ||
|
|
a659d40202 | ||
|
|
11dcf5b970 | ||
|
|
3484cb7964 | ||
|
|
880171aa08 | ||
|
|
ab0b60c584 | ||
|
|
76bc18cb12 | ||
|
|
12237142da | ||
|
|
3c2dca13ab | ||
|
|
383ce0599e | ||
|
|
175f06a7f9 | ||
|
|
c33a26b2f9 | ||
|
|
dc918930ab | ||
|
|
a7d616c224 | ||
|
|
df598675fb | ||
|
|
5ff4125c56 | ||
|
|
8e9335d49f | ||
|
|
6038064e71 | ||
|
|
4ac1c29ca9 | ||
|
|
31b3a2a350 | ||
|
|
2e2f5bc165 | ||
|
|
49a54e0978 | ||
|
|
bf366ea075 | ||
|
|
1cf5d5db9e | ||
|
|
73c83cbd25 | ||
|
|
001fcb43e7 | ||
|
|
75ea3b9edb | ||
|
|
2a15cffbb9 | ||
|
|
1eb3e1711a | ||
|
|
1cac01280a | ||
|
|
3d315a891b | ||
|
|
bed22463dc | ||
|
|
90f97f14ee | ||
|
|
c092fb3303 | ||
|
|
a30b117c60 | ||
|
|
f6e054ba73 | ||
|
|
cb79f816a0 | ||
|
|
bd0d0eead7 | ||
|
|
e4a12b22b4 | ||
|
|
df226053cf | ||
|
|
ebac219ba3 | ||
|
|
c858a13aa3 | ||
|
|
bfe1760904 | ||
|
|
ea323d260e | ||
|
|
f2d380ce96 | ||
|
|
f9f542e7e3 | ||
|
|
e241e4334f | ||
|
|
8826892b00 | ||
|
|
cc1c20d6fe | ||
|
|
3890e85527 | ||
|
|
e4dea6da91 | ||
|
|
d08c0953fb | ||
|
|
ceae0c539e | ||
|
|
25b978126e | ||
|
|
5189991b53 | ||
|
|
ae10bd8332 | ||
|
|
8d87846907 | ||
|
|
098267f942 | ||
|
|
b92705f414 | ||
|
|
8937ae9073 | ||
|
|
fb6b2c7d23 | ||
|
|
bc9473a439 | ||
|
|
47412da33a | ||
|
|
7d563b8789 | ||
|
|
4d617a1aab | ||
|
|
d0d73ca2c0 | ||
|
|
32b0170c3b | ||
|
|
d7904efccf | ||
|
|
8441f8bff7 | ||
|
|
47cafb52b5 | ||
|
|
20c8e12e09 | ||
|
|
61645fe5a9 | ||
|
|
bc917a33b6 | ||
|
|
9751a9c8cb | ||
|
|
ad22d4b9b5 | ||
|
|
e5bba0529a | ||
|
|
c17df70f8e | ||
|
|
5d37d87cf1 | ||
|
|
6a610949e9 | ||
|
|
eba3105cae | ||
|
|
47fb0afe79 | ||
|
|
bf6d114893 | ||
|
|
f5d4bf8fc4 | ||
|
|
1254020b8b | ||
|
|
7f03c17a08 | ||
|
|
4440506858 | ||
|
|
01b4820b93 | ||
|
|
6bf1a8ffda | ||
|
|
fc8ee11955 | ||
|
|
fe30f9739b | ||
|
|
6be0089cac | ||
|
|
80cb93f8e1 | ||
|
|
a3ad4b3616 | ||
|
|
5fedbdf414 | ||
|
|
125555afcf | ||
|
|
89b5907eb6 | ||
|
|
68d262ba93 | ||
|
|
ee3a44388c | ||
|
|
5ae4ebccba | ||
|
|
51e15ced3f | ||
|
|
aac716d497 | ||
|
|
420fe9710b | ||
|
|
e57954ef2e | ||
|
|
2353ca0621 | ||
|
|
8bc5770c28 | ||
|
|
913517f19d | ||
|
|
0d385c237a | ||
|
|
94bf21b9be | ||
|
|
a4b697f41e | ||
|
|
b047c1318f | ||
|
|
a5d6881e9e | ||
|
|
eddbbc58b1 | ||
|
|
908db3cd59 | ||
|
|
8a42ab14ad | ||
|
|
c2f70d1cc7 | ||
|
|
89452a9d8e | ||
|
|
563411a33a | ||
|
|
d1889b77e5 | ||
|
|
e8a9d1bdc7 | ||
|
|
9b2de5f215 | ||
|
|
779cac9b77 | ||
|
|
a4d77bec6b | ||
|
|
dd6bad1b6e | ||
|
|
0d93816827 | ||
|
|
ca95d76659 | ||
|
|
d58a83cda7 | ||
|
|
5256656efa | ||
|
|
bb1e00a263 | ||
|
|
b2f0ed0cb9 | ||
|
|
75a43a536c | ||
|
|
0263c2cf68 | ||
|
|
69c5373db0 | ||
|
|
a55d02dd31 | ||
|
|
02d318e66d | ||
|
|
9f72ca2329 | ||
|
|
2d12ad9251 | ||
|
|
09c072bda6 | ||
|
|
9909a4123f | ||
|
|
63c59b6570 | ||
|
|
ee4cd4756b | ||
|
|
bd0c6c9ce3 | ||
|
|
213e621412 | ||
|
|
2d9056aa78 | ||
|
|
5d53a9edaf | ||
|
|
c2fb0fffbd | ||
|
|
fc05fad277 | ||
|
|
1466d2b97e | ||
|
|
13351c0091 | ||
|
|
19f98ce8ea | ||
|
|
4b5fefa521 | ||
|
|
f8b4dc3a2d | ||
|
|
4d571290c7 | ||
|
|
3a35da8f27 | ||
|
|
1b1efbd0f0 | ||
|
|
d068c85e80 | ||
|
|
145ea416be | ||
|
|
0b6be3a0f6 | ||
|
|
7cf2cf0756 | ||
|
|
69eb3a9756 | ||
|
|
7b20da2276 | ||
|
|
eb376899ce | ||
|
|
2123ee0218 | ||
|
|
6e94c70fbb | ||
|
|
80b181293a | ||
|
|
fb59508ad1 | ||
|
|
9e20b3a18e | ||
|
|
505c44a4d3 | ||
|
|
c0d55112b4 | ||
|
|
e246db4604 | ||
|
|
2d5e41d566 | ||
|
|
c3e248ec79 | ||
|
|
7da60e219d | ||
|
|
8978f27145 | ||
|
|
a6749c0a26 | ||
|
|
d20fe1f4ee | ||
|
|
05fe9b6b81 | ||
|
|
e4b677be3d | ||
|
|
05a98a0107 | ||
|
|
769f864360 | ||
|
|
af3012abff | ||
|
|
cdebffe462 | ||
|
|
5b9c9c4833 | ||
|
|
9605a6b712 | ||
|
|
6f304736c5 | ||
|
|
dbe7ef7a0c | ||
|
|
f0a705595b | ||
|
|
076540752b | ||
|
|
5bc8f819f0 | ||
|
|
f3e1df3997 | ||
|
|
465ce80e41 | ||
|
|
b2f72d3f70 | ||
|
|
a676590e30 | ||
|
|
7688535204 | ||
|
|
7310a2c6cc | ||
|
|
3bbc052794 | ||
|
|
d57749ec98 | ||
|
|
5b637c68ee | ||
|
|
3e8ca224a8 | ||
|
|
6e6a7de1a8 | ||
|
|
ff2e425b48 | ||
|
|
f7ee864709 | ||
|
|
93330eaf1d | ||
|
|
c4503cb8f8 | ||
|
|
a11957d0b4 | ||
|
|
2177e51857 | ||
|
|
ff3bbc56bc | ||
|
|
3e5d43fd8b | ||
|
|
fada3aabfa | ||
|
|
7a09086c6b | ||
|
|
890829aa93 | ||
|
|
88096cbbfe | ||
|
|
c56f5421f0 | ||
|
|
fa6eb2fc22 | ||
|
|
c547d2cf67 | ||
|
|
2f5f63ed13 | ||
|
|
2237ebd46e | ||
|
|
f4679bffc3 | ||
|
|
133bfe161c | ||
|
|
39961a686f | ||
|
|
dfedda8e28 | ||
|
|
7e17d38754 | ||
|
|
9f7e091aba | ||
|
|
55a276ff9a | ||
|
|
5f5c5f3d42 | ||
|
|
83aab8f825 | ||
|
|
d5bc4c0522 | ||
|
|
e5133e27e6 | ||
|
|
bbbf822561 | ||
|
|
b0e26d865c | ||
|
|
0bf1d14756 | ||
|
|
e5676aaf9b | ||
|
|
acc4d77fe9 | ||
|
|
241c2e5d38 | ||
|
|
cab6ce93d6 | ||
|
|
aad9f76a39 | ||
|
|
ec19ceb22f | ||
|
|
1689a121e5 | ||
|
|
120a694324 | ||
|
|
90c67d8f64 | ||
|
|
a2db424eb1 | ||
|
|
bff582d5ed | ||
|
|
8bc9868705 | ||
|
|
7b46bfa0d1 | ||
|
|
2770752813 | ||
|
|
2d83b6edb2 | ||
|
|
39e76b0e4f | ||
|
|
e9805c98d5 | ||
|
|
177af6cae7 | ||
|
|
cb1bbeaf3a | ||
|
|
46a1a8dfde | ||
|
|
4b4ac7c706 | ||
|
|
ad0ad2c4e1 | ||
|
|
df2204d50f | ||
|
|
fa883a0220 | ||
|
|
436833f138 | ||
|
|
4ecee47caa | ||
|
|
5db75661cf | ||
|
|
64b5010b15 | ||
|
|
0733018ba5 | ||
|
|
6f43efde23 | ||
|
|
fb75153d29 | ||
|
|
339227877a | ||
|
|
7710b1df43 | ||
|
|
c0a8460575 | ||
|
|
7027c7486b | ||
|
|
a42b56c7c7 | ||
|
|
c331659026 | ||
|
|
01088f77ab | ||
|
|
7d302574cc | ||
|
|
ee4a419019 | ||
|
|
1173b33715 | ||
|
|
0fe5a3ba5e | ||
|
|
6c06bfbf41 | ||
|
|
6bab1d2840 | ||
|
|
89044a8649 | ||
|
|
94e686ba44 | ||
|
|
86110cf1de | ||
|
|
9b664e2944 | ||
|
|
78ff568dfb | ||
|
|
e1d2709431 | ||
|
|
47556f2290 | ||
|
|
531eb4b417 | ||
|
|
7f8b1e920a | ||
|
|
2f084d204e | ||
|
|
a93fedf945 | ||
|
|
8fd88300ce | ||
|
|
d3f0331e8e | ||
|
|
9fb0da69cc | ||
|
|
4675bf9ae8 | ||
|
|
da631cd441 | ||
|
|
fd40f53d2e | ||
|
|
9f420af5e2 | ||
|
|
9ff4b0e5b2 | ||
|
|
901cb1fab0 | ||
|
|
809c93a19e | ||
|
|
62c307d6f2 | ||
|
|
31488478c1 | ||
|
|
59fa14f989 | ||
|
|
1c34777024 | ||
|
|
dc3bc9f30d | ||
|
|
96692bfc3b | ||
|
|
4aa3927b55 | ||
|
|
6eea879a14 | ||
|
|
c7862fd701 | ||
|
|
e1f4426f76 | ||
|
|
cc37769c91 | ||
|
|
337d533dd5 | ||
|
|
bc4a62da96 | ||
|
|
4a58c778e4 | ||
|
|
866e9e73b1 | ||
|
|
3582f6501a | ||
|
|
dfa0970585 | ||
|
|
33f2d2fbd8 | ||
|
|
85bb30a19d | ||
|
|
90ee83fb3e | ||
|
|
bb30cac9df | ||
|
|
d8ecb4afec | ||
|
|
9d097c7cc1 | ||
|
|
e7356bfbb6 | ||
|
|
b0d84a4a3d | ||
|
|
ee795362ba | ||
|
|
e5e76f163c | ||
|
|
d47db72584 | ||
|
|
cde8738f0e | ||
|
|
925a174ae2 | ||
|
|
5654c97c6b | ||
|
|
d9590baf4c | ||
|
|
dda1a38143 | ||
|
|
d239b319ef | ||
|
|
8164e8eac3 | ||
|
|
60cbe5ec4c | ||
|
|
b9b735ce9f | ||
|
|
65032619e2 | ||
|
|
da581072b4 | ||
|
|
f242eba9c1 | ||
|
|
7dad802981 | ||
|
|
3f54e37143 | ||
|
|
ad3c0ebbfe | ||
|
|
4fce2f394d | ||
|
|
ce61609900 | ||
|
|
ae23300c07 | ||
|
|
e7055bedf8 | ||
|
|
dffc613d46 | ||
|
|
7fb2974259 | ||
|
|
4138785a4e | ||
|
|
91b788dc57 | ||
|
|
0bfb73b632 | ||
|
|
893475ad89 | ||
|
|
8bd9ab7b84 | ||
|
|
266487fdab | ||
|
|
76902e00eb | ||
|
|
2cf7ed0d26 | ||
|
|
1060e3c25a | ||
|
|
562486c14e | ||
|
|
acd0a98641 | ||
|
|
92e75fe05d | ||
|
|
43646b78ef | ||
|
|
03d076197f | ||
|
|
596b15799d | ||
|
|
d6e1705a1a | ||
|
|
525c8d3dd9 | ||
|
|
defa3a0922 | ||
|
|
15c2187c57 | ||
|
|
cabf623e11 | ||
|
|
47f2e0a8f7 | ||
|
|
b5af497aad | ||
|
|
514d2b38b4 | ||
|
|
2f5a09bc99 | ||
|
|
11c2d5dce4 | ||
|
|
bfc735a004 | ||
|
|
b26bb2e5b7 | ||
|
|
366ac0c03c | ||
|
|
617438d770 | ||
|
|
dfb0789191 | ||
|
|
8db441d6a8 | ||
|
|
1a1840ae11 | ||
|
|
cc7128ce4c | ||
|
|
9d87a82210 | ||
|
|
d6692e3ead | ||
|
|
80b408f9a6 | ||
|
|
7f486ac48f | ||
|
|
1ea356688f | ||
|
|
193ca45248 | ||
|
|
6678e48ccc | ||
|
|
1eab2ccba3 | ||
|
|
2d09b3dbdf | ||
|
|
83b01aa627 | ||
|
|
0a3ff11223 | ||
|
|
c9b28c7692 | ||
|
|
c890dc8d43 | ||
|
|
84477fccee | ||
|
|
1d103f11c3 | ||
|
|
c157f0cdad | ||
|
|
8e1f54a213 | ||
|
|
17a691ad39 | ||
|
|
2ff3c37a54 | ||
|
|
c48a521882 | ||
|
|
a8ceb6bcaf | ||
|
|
1fcda8092e | ||
|
|
c3471fd04e | ||
|
|
c5b9a4eb17 | ||
|
|
b90f3c7d32 | ||
|
|
38663e1365 | ||
|
|
d8d49d1835 | ||
|
|
25f9500d5a | ||
|
|
7de9b97c6c | ||
|
|
bd60d7cd3b | ||
|
|
eaacc34c6e | ||
|
|
b2ef660b3a | ||
|
|
22f9c69fc1 | ||
|
|
2f896ab068 | ||
|
|
9d2d7ee869 | ||
|
|
b749236724 | ||
|
|
fc6f7ceba4 | ||
|
|
d4aba14fea | ||
|
|
cff1c299ab | ||
|
|
8fd12c53d2 | ||
|
|
68133801d8 | ||
|
|
79e3951ac8 | ||
|
|
4ca6a04ce3 | ||
|
|
cc687c8ead | ||
|
|
1e139dc86c | ||
|
|
552e7a8cf1 | ||
|
|
dc9b619307 | ||
|
|
1f6855f085 | ||
|
|
fef902f1da | ||
|
|
ec8deaad69 | ||
|
|
f66a45ba8b | ||
|
|
40f8a12c40 | ||
|
|
3ca4aa6858 | ||
|
|
4004153a5a | ||
|
|
a006082a47 | ||
|
|
7753257842 | ||
|
|
63d54b0212 | ||
|
|
feb445d558 | ||
|
|
b973dd342a | ||
|
|
e3378d23d4 | ||
|
|
38c799e27e | ||
|
|
350ceddf3f | ||
|
|
86daac1424 | ||
|
|
39075fe06d | ||
|
|
b8b0869a54 | ||
|
|
eb0383ea89 | ||
|
|
cab8e4e7f5 | ||
|
|
f03efd9460 | ||
|
|
8f715434ac | ||
|
|
4ecd589d84 | ||
|
|
0a5bd40430 | ||
|
|
6862cbdec2 | ||
|
|
72605cac51 | ||
|
|
a2ab0cde79 | ||
|
|
d6739192fd | ||
|
|
410ea1f8f1 | ||
|
|
e42d63c7be | ||
|
|
f7baf2716a | ||
|
|
0671556002 | ||
|
|
36f236bc44 | ||
|
|
b160b1d1d5 | ||
|
|
1246878f00 | ||
|
|
27237acc88 | ||
|
|
8eb4317e37 | ||
|
|
4412b13928 | ||
|
|
9497090093 | ||
|
|
8175e4e723 | ||
|
|
a256f58de1 | ||
|
|
44818d3527 | ||
|
|
c517d73a71 | ||
|
|
4076c8ddaf | ||
|
|
5325a93990 | ||
|
|
a1afdc5f3c | ||
|
|
6e5db9e44e | ||
|
|
2b6a69068c | ||
|
|
21475e86f2 | ||
|
|
c13507ae0c | ||
|
|
0646509b9a | ||
|
|
0dbc0f0442 | ||
|
|
919a8e81ea | ||
|
|
5608bf868e | ||
|
|
df238e2f44 | ||
|
|
f0080b944d | ||
|
|
a1b4da6a30 | ||
|
|
816327f4f7 | ||
|
|
964499a06f | ||
|
|
866f53658e | ||
|
|
8707f3f122 | ||
|
|
09c51d1a6a | ||
|
|
bf1903d17b | ||
|
|
2ea1af59b9 | ||
|
|
8c9d4b58ed | ||
|
|
0856790760 | ||
|
|
d9205adc60 | ||
|
|
2b44c68794 | ||
|
|
c9b1d0c75f | ||
|
|
7a65dca973 | ||
|
|
bfb3a105ac | ||
|
|
c96b1d4db3 | ||
|
|
dbe741da12 | ||
|
|
49547a33f8 | ||
|
|
49a50152cc | ||
|
|
f1ba07eab7 | ||
|
|
7b24b47adf | ||
|
|
bf8cf9fb81 | ||
|
|
a7a6812a19 | ||
|
|
af2b6f8034 | ||
|
|
9aac004c2c | ||
|
|
7f6bdbe6eb | ||
|
|
f06534eb2e | ||
|
|
e42fe2fead | ||
|
|
a78ea8f2e8 | ||
|
|
dcf50104f0 | ||
|
|
57619fca06 | ||
|
|
748009735c | ||
|
|
577fc7b528 | ||
|
|
d6fe59bf73 | ||
|
|
dedad11102 | ||
|
|
d32692922b | ||
|
|
7b3c0009f6 | ||
|
|
a5c85244a7 | ||
|
|
aea3154b3b | ||
|
|
f7c8fe9857 | ||
|
|
eb067af098 | ||
|
|
71c5c5814c | ||
|
|
73b042cc82 | ||
|
|
4d2714facc | ||
|
|
d27d8fd087 | ||
|
|
e468f0d5fc | ||
|
|
c0715b4c63 | ||
|
|
445b5ad231 | ||
|
|
315bf64ccb | ||
|
|
d6ccc48963 | ||
|
|
1544f6b6ed | ||
|
|
d1dcc41f69 | ||
|
|
0777561390 | ||
|
|
0c473c6ccb | ||
|
|
974540cc63 | ||
|
|
fc3b967f33 | ||
|
|
b1abcb9310 | ||
|
|
3d38150563 | ||
|
|
380c0b1408 | ||
|
|
5dabd945bd | ||
|
|
9cd49f1554 | ||
|
|
c72bb4502a | ||
|
|
ebfe8fbfd4 | ||
|
|
5a6350df2a | ||
|
|
0afd6cee46 | ||
|
|
a6f5141f42 | ||
|
|
fbb88452fb | ||
|
|
af11110e0f | ||
|
|
d07d4f5300 | ||
|
|
b557331d63 | ||
|
|
280e039e19 | ||
|
|
4935b88588 | ||
|
|
d950ae0ee4 | ||
|
|
1bbe6e1068 | ||
|
|
6e3445c2d6 | ||
|
|
569edb7685 | ||
|
|
d610872ee7 | ||
|
|
8414b1de2b | ||
|
|
0b8daf5283 | ||
|
|
cb6824755d | ||
|
|
1782af2abb | ||
|
|
45f4b64cd4 | ||
|
|
cf69a7ae33 | ||
|
|
637a41d392 | ||
|
|
45b8364b0e | ||
|
|
f55d6fa640 | ||
|
|
ecc8c8af8f | ||
|
|
0c45e9eac4 | ||
|
|
b6820e7e79 | ||
|
|
024d776d2c | ||
|
|
7148f377c4 | ||
|
|
9cefda4f7b | ||
|
|
f78046acce | ||
|
|
9405abb3fd | ||
|
|
eaf7a123d4 | ||
|
|
fce6d2982e | ||
|
|
99dbf35953 | ||
|
|
892745a592 | ||
|
|
922d0ab150 | ||
|
|
ed8df15de4 | ||
|
|
ad2a9a4cea | ||
|
|
ce50c08e91 | ||
|
|
64852194ea | ||
|
|
0ef1fa0627 | ||
|
|
fea552511e | ||
|
|
7c90b4630b | ||
|
|
90d8a11917 | ||
|
|
1bdc650635 | ||
|
|
d0d46d482e | ||
|
|
af0c8d57b5 | ||
|
|
dc7ac427b5 | ||
|
|
ebf7fd20ae | ||
|
|
6d68aabc41 | ||
|
|
8ad9b481a8 | ||
|
|
e6028a913c | ||
|
|
53b7ef0429 | ||
|
|
14cd444f8d | ||
|
|
525a9e381f | ||
|
|
3a4463d2e4 | ||
|
|
2aab61b91d | ||
|
|
4b59ae0976 | ||
|
|
fa5edfb53e | ||
|
|
3980f08440 | ||
|
|
237edae7df | ||
|
|
61c5777a6b | ||
|
|
6852f6ee80 | ||
|
|
2965b351a5 | ||
|
|
798e021803 | ||
|
|
def6cb2c92 | ||
|
|
a053641ea5 | ||
|
|
c6bf07973e | ||
|
|
7dfb4eb374 | ||
|
|
b424927b80 | ||
|
|
42f040f885 | ||
|
|
f776a8f1cf | ||
|
|
9fddc294ab | ||
|
|
7fdd633561 | ||
|
|
b8080ef1db | ||
|
|
e044e02541 | ||
|
|
22dabf9c2a | ||
|
|
96a43ba3c5 | ||
|
|
a8721ff3c3 | ||
|
|
d15980cdd3 | ||
|
|
2e60555506 | ||
|
|
692a4b33c8 | ||
|
|
da0a235a33 | ||
|
|
77e1dc21bb | ||
|
|
94b6be4c3d | ||
|
|
1ff5f1f91d | ||
|
|
3e053db00b | ||
|
|
317c8f40da | ||
|
|
267d0d96af | ||
|
|
660a986e04 | ||
|
|
b83023703b | ||
|
|
740eaa56b7 | ||
|
|
5b06a41ebc | ||
|
|
894d5f5861 | ||
|
|
969640717f | ||
|
|
d69c18dba4 | ||
|
|
125b199f85 | ||
|
|
4924e871b2 | ||
|
|
4ab5d9459e | ||
|
|
ff3f2ed80c | ||
|
|
dee00b08cc | ||
|
|
3052681761 | ||
|
|
a90aa4211b | ||
|
|
09f8e25fdd | ||
|
|
702ba26dd8 | ||
|
|
7284aa0d05 | ||
|
|
fb5cee3b56 | ||
|
|
d9147ae21b | ||
|
|
1749a0e7e1 | ||
|
|
3a7d160bfa | ||
|
|
958ad5f999 | ||
|
|
178f42b89a | ||
|
|
cd15f653f6 | ||
|
|
6e1a32e891 | ||
|
|
0c1e3239b7 | ||
|
|
e6b6c3a19c | ||
|
|
f547a7dbc2 | ||
|
|
fa8846a2ce | ||
|
|
e4cf96cb81 | ||
|
|
9b51181575 | ||
|
|
22d79cd585 | ||
|
|
25651261c2 | ||
|
|
687dea0543 | ||
|
|
55b7a9f513 | ||
|
|
61881ca7cd | ||
|
|
2ab2a5a973 | ||
|
|
d3a07c866f | ||
|
|
7c3263bc7b | ||
|
|
053e70342c | ||
|
|
46f51b1d67 | ||
|
|
81e84ed829 | ||
|
|
04197a83d0 | ||
|
|
931e74e2a6 | ||
|
|
7b26cdc75e | ||
|
|
c72c8c62de | ||
|
|
e65f781bbd | ||
|
|
2846cff2d3 | ||
|
|
31fcc7d395 | ||
|
|
ec776b48d5 | ||
|
|
b8226ace04 | ||
|
|
3bf1dde5b2 | ||
|
|
3b3ba1b5df | ||
|
|
d1837d2684 | ||
|
|
fbe39b7357 | ||
|
|
f4b9b2a477 | ||
|
|
af47b4bd40 | ||
|
|
e78c3d132c | ||
|
|
2dbda3d004 | ||
|
|
6d4791c6e9 | ||
|
|
3c2c4c5f86 | ||
|
|
358f7cf00b | ||
|
|
7248eef1f0 | ||
|
|
422481533e | ||
|
|
6cd9fda009 | ||
|
|
c46e31c536 | ||
|
|
a7a24bcf84 | ||
|
|
73d4fd00bd | ||
|
|
e52a2fb87c | ||
|
|
2bdfdc0ed2 | ||
|
|
6b3444271c | ||
|
|
78c5ad0cdb | ||
|
|
df00db0dc2 | ||
|
|
89731ae74a | ||
|
|
592a54f8ee | ||
|
|
9fcb264e05 | ||
|
|
1456853135 | ||
|
|
92ebe1f940 | ||
|
|
cd83e6febc | ||
|
|
9fcb8e0d1b | ||
|
|
adbd978155 | ||
|
|
455676e982 | ||
|
|
faf33212e7 | ||
|
|
8dba219f42 | ||
|
|
ab21e705d5 | ||
|
|
4fd0dfc7c4 | ||
|
|
fb49ed806e | ||
|
|
5353906dea | ||
|
|
25fb3e368a | ||
|
|
811386090d | ||
|
|
186a5c07c2 | ||
|
|
c6179239e1 | ||
|
|
d1e6063551 | ||
|
|
9de436a61b | ||
|
|
e00cd04963 | ||
|
|
a24c6d30b2 | ||
|
|
cc98cfb27e | ||
|
|
37c9154b13 | ||
|
|
3632b1b916 | ||
|
|
f16c78fc9f | ||
|
|
7fab8564d0 | ||
|
|
8bf03bd7e3 | ||
|
|
056d449f89 | ||
|
|
889807b449 | ||
|
|
2f5d824348 | ||
|
|
6b711b759c | ||
|
|
dcb77a59c7 | ||
|
|
168bda2b8f | ||
|
|
119c4b577b | ||
|
|
cf3b94d29b | ||
|
|
678e119d2f | ||
|
|
b82c4c828b | ||
|
|
5fcbdc3e9a | ||
|
|
941925a56e | ||
|
|
9ee60404cf | ||
|
|
662c22b51a | ||
|
|
166fa39d89 | ||
|
|
23c559bbb0 | ||
|
|
79e372c2f2 | ||
|
|
7cd532ae58 | ||
|
|
3b42e205ad | ||
|
|
15b9d8d808 | ||
|
|
5e9cf2571d | ||
|
|
95b6a2193f | ||
|
|
a13259d3f9 | ||
|
|
c3e9ce73b0 | ||
|
|
8fc7c26aa1 | ||
|
|
fbc4551894 | ||
|
|
06cea6ed3a | ||
|
|
26325e5ee6 | ||
|
|
8578c2f1a2 |
97
.clang-format
Normal file
97
.clang-format
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '$'
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Middle
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
7
.editorconfig
Normal file
7
.editorconfig
Normal 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
|
||||
|
||||
14
.github/ISSUE_TEMPLATE/all-other-issues.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/all-other-issues.md
vendored
Normal 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
27
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal 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
17
.github/stale.yml
vendored
Normal 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
|
||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
**/*.o
|
||||
**/*.swp
|
||||
**/*.swo
|
||||
tags
|
||||
docs/api_doc
|
||||
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
278
README.md
278
README.md
@@ -1,89 +1,221 @@
|
||||
# LittleV Graphics Libraray
|
||||
<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://littlevgl.com/github/cover_ori_reduced_2.gif">
|
||||
</p>
|
||||
|
||||

|
||||
<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>
|
||||
|
||||
The LittlevGL is a graphics library which allows you to create graphical user interfaces (GUI) from the most simple monochrome designs to amazing GUIs for high resolution TFTs. No double buffering is required to use transparency and smooth animations.
|
||||
<h4 align="center">
|
||||
<a href="https://littlevgl.com">Website </a> ·
|
||||
<a href="https://littlevgl.com/live-demo">Live demo</a> ·
|
||||
<a href="https://docs.littlevgl.com/#PC-simulator">Simulator</a> ·
|
||||
<a href="https://docs.littlevgl.com/">Docs</a> ·
|
||||
<a href="https://blog.littlevgl.com/">Blog</a>
|
||||
</h4>
|
||||
|
||||
The graphics library is written in C and it is completely hardware independent. You can even run it in a PC simulator without any embedded hardware.
|
||||
<!--
|
||||
<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>
|
||||
-->
|
||||
|
||||
Visit the http://gl.littlev.hu
|
||||
### 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 (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
|
||||
|
||||
## Key features
|
||||
* Hardware independent
|
||||
* Support any modern microcontroller
|
||||
* No external RAM, FPU or GPU required
|
||||
* High resolution TFTs and monochrome displays are also supported
|
||||
* Scalable and modular
|
||||
* Clear and well-structured source code
|
||||
* Color depth options: 24 bit, 16 bit, 8 bot or 1 bit
|
||||
* Build GUI from simple graphical objects
|
||||
* Buttons, Labels, Images
|
||||
* Charts, Lists, Bars, Sliders, Text areas etc.
|
||||
* High level graphical features:
|
||||
* Antialiassing (font or full screen)
|
||||
* Animations
|
||||
* Transparency
|
||||
* Gradient colors
|
||||
* Smooth dragging and scrolling
|
||||
* Layers
|
||||
* Customizable appearance with styles
|
||||
* Applications for complex tasks
|
||||
* Can run in a PC simulator
|
||||
* Actively developed
|
||||
### 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
|
||||
- **> 16 MHz** clock speed
|
||||
- **> 8 kB RAM for static data** and **> 2 KB RAM for dynamic data** (graphical objects)
|
||||
- **> 64 kB flash** program memory
|
||||
- **Optionally ~1/10 screen sized memory** for buffered drawing (on 240 × 320, 16-bit colors it's 15 kB)
|
||||
|
||||
## Porting
|
||||
The following functions has to be provided
|
||||
* hal/disp `disp_fill(x1, y1, x2, y2, color)` to fill area with a color
|
||||
* hal/disp `disp_map(x1, y1, x2, y2, &color_array)` copy a color map to an area
|
||||
* hal/indev `indev_get(id, &x, &y)` get the *x* and *y* coordinates from an input device (e.g. touch pad)
|
||||
* hal/systick `systick_get()` get a system tick with 1 ms resolution
|
||||
* hal/systick `systick_elapse(prev_time)` get the elapsed milliseconds sience *prev_time*
|
||||
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
|
||||
|
||||
See the [example HAL](https://github.com/littlevgl/hal) repository!
|
||||
### 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.
|
||||
|
||||
## Requirements
|
||||
* [Misc. library](https://github.com/littlevgl/misc) is used by the graphics library
|
||||
Choose a project with your favourite IDE:
|
||||
|
||||
## Project set-up
|
||||
1. Clone or download the following repositories:
|
||||
* lvgl:`git clone https://github.com/littlevgl/lvgl.git`
|
||||
* misc: `git clone https://github.com/littlevgl/misc.git`
|
||||
* hal: `git clone https://github.com/littlevgl/hal.git`
|
||||
2. Create project with your prefered IDE and add the **lvgl**, **misc** and **hal** folders
|
||||
3. Add your projects **root directory as include path**
|
||||
4. Write your display, touch pad and system tick **drivers in hal**
|
||||
5. Copy *lvgl/lv_conf_templ.h* as **lv_conf.h** and *misc/misc_conf_templ.h* as **misc_conf.h** to the projects root folder
|
||||
6. In the *_conf.h files delete the first `#if 0` and its `#endif`. Let the default configurations at first.
|
||||
7. In your *main.c* include:
|
||||
* #include "misc/misc.h"
|
||||
* #include "misc/os/ptask.h"
|
||||
* #include "lvgl/lvgl.h"
|
||||
8. In your *main.c* intialize:
|
||||
* **misc_init()**;
|
||||
* your_systick_init();
|
||||
* your_disp_init();
|
||||
* your_indev_init();
|
||||
* **lvgl_init()**;
|
||||
10. To **test** create a label: `lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);`
|
||||
11. In the main *while(1)* call `ptask_handler();` and make a few milliseconds delay (e.g. `your_delay_ms(5);`)
|
||||
12. Compile the code and load it to your embedded hardware
|
||||
| Eclipse | CodeBlocks | Visual Studio | PlatformIO | Qt Creator |
|
||||
|-------------|-------------|---------------|-----------|------------|
|
||||
| [](https://github.com/littlevgl/pc_simulator_sdl_eclipse) | [](https://github.com/littlevgl/pc_simulator_win_codeblocks) | [](https://github.com/littlevgl/visual_studio_2017_sdl_x64) | [](https://github.com/littlevgl/pc_simulator_sdl_platformio) | [](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 |
|
||||
|
||||
## PC Simulator
|
||||
If you don't have got an embedded hardware you can test the graphics library in a PC simulator. The simulator uses [SDL2](https://www.libsdl.org/) to emulate a display on your monitor and a touch pad with your mouse.
|
||||
### 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. Create a buffer for LittlevGL
|
||||
```c
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
|
||||
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
```
|
||||
4. Implement and register a function which can **copy a pixel array** to an area of your diplay:
|
||||
```c
|
||||
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.hor_res = 480; /*Set the horizontal resolution*/
|
||||
disp_drv.ver_res = 320; /*Set the vertical resolution*/
|
||||
disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/
|
||||
disp_drv.buffer = &disp_buf; /*Assign the buffer to teh display*/
|
||||
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
|
||||
|
||||
void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
int32_t x, y;
|
||||
for(y = area->y1; y <= area->y2; y++) {
|
||||
for(x = area->x1; x <= area->x2; x++) {
|
||||
set_pixel(x, y, *color_p); /* Put a pixel to the display.*/
|
||||
color_p++;
|
||||
}
|
||||
}
|
||||
|
||||
There is a pre-configured PC project for **Eclipse CDT** in this repository: https://github.com/littlevgl/proj_pc
|
||||
lv_disp_flush_ready(disp); /* 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_cb = my_touchpad_read; /*Set your driver function*/
|
||||
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/
|
||||
|
||||
## Contributing
|
||||
1. Fork it!
|
||||
2. Create your feature branch: `git checkout -b my-new-feature`
|
||||
3. Commit your changes: `git commit -am 'Add some feature'`
|
||||
4. Push to the branch: `git push origin my-new-feature`
|
||||
5. Submit a pull request!
|
||||
bool my_touchpad_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
If you find an issue, please report it via GitHub!
|
||||
/*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;
|
||||
|
||||
## Donate
|
||||
If you are pleased with the graphics library and found it useful pleas support its further development:
|
||||
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.**
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GJV3SC5EHDANS)
|
||||
For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting examples](https://github.com/littlevgl/lvgl/tree/multi-disp/lv_porting).
|
||||
|
||||
|
||||
### 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*/
|
||||
|
||||
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*/
|
||||
|
||||
lv_res_t btn_action(lv_obj_t * btn)
|
||||
{
|
||||
printf("Clicked\n");
|
||||
return LV_RES_OK;
|
||||
}
|
||||
```
|
||||

|
||||
|
||||
#### 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);
|
||||
|
||||
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);
|
||||
|
||||
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*/
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### 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);
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### 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:
|
||||
|
||||
[](https://littlevgl.com/donate)
|
||||
|
||||
46
docs/CODE_OF_CONDUCT.md
Normal file
46
docs/CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [atom@github.com](mailto:atom@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
103
docs/CONTRIBUTING.md
Normal file
103
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# Contributing to Littlev Graphics Library
|
||||
|
||||
**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! :)
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* @file img_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0 /*Remove this to enable the content (Delete the last #endif too!)*/
|
||||
|
||||
#ifndef IMG_CONF_H
|
||||
#define IMG_CONF_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/* Enable here the used images
|
||||
* For example:
|
||||
* #define USE_IMG_EXAMPLE 1
|
||||
*
|
||||
* This is compatible with the images
|
||||
* generated by the image converter utility
|
||||
* For more information see: www.littlev.hu */
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*Remove this to enable the content*/
|
||||
1113
lv_app/lv_app.c
1113
lv_app/lv_app.c
File diff suppressed because it is too large
Load Diff
257
lv_app/lv_app.h
257
lv_app/lv_app.h
@@ -1,257 +0,0 @@
|
||||
/**
|
||||
* @file lv_app.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_H
|
||||
#define LV_APP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Check dependencies*/
|
||||
#if LV_OBJ_FREE_P == 0
|
||||
#error "lv_app: Free pointer is required for application. Enable it lv_conf.h: LV_OBJ_FREE_P 1"
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_NUM == 0
|
||||
#error "lv_app: Free number is required for application. Enable it lv_conf.h: LV_OBJ_FREE_NUM 1"
|
||||
#endif
|
||||
|
||||
#if DM_CUSTOM == 0 && DM_MEM_SIZE < (2 * 1024)
|
||||
#error "lv_app: not enough dynamic memory. Increase it in misc_conf.h: DM_MEM_SIZE"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_MODE_NONE = 0x0000,
|
||||
LV_APP_MODE_NOT_LIST = 0x0001, /*Do not list the application*/
|
||||
LV_APP_MODE_NO_SC_TITLE = 0x0002, /*No short cut title*/
|
||||
}lv_app_mode_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_COM_TYPE_CHAR, /*Stream of characters. Not '\0' terminated*/
|
||||
LV_APP_COM_TYPE_INT, /*Stream of 'int32_t' numbers*/
|
||||
LV_APP_COM_TYPE_LOG, /*String about an event to log*/
|
||||
LV_APP_COM_TYPE_TRIG, /*A trigger to do some specific action (data is ignored)*/
|
||||
LV_APP_COM_TYPE_INV, /*Invalid type*/
|
||||
LV_APP_COM_TYPE_NUM, /*Indicates the number of com. types*/
|
||||
}lv_app_com_type_t;
|
||||
|
||||
struct __LV_APP_DSC_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const struct __LV_APP_DSC_T * dsc;
|
||||
char * name;
|
||||
lv_obj_t * sc;
|
||||
lv_obj_t * sc_title;
|
||||
lv_obj_t * win;
|
||||
lv_obj_t * conf_win;
|
||||
void * app_data;
|
||||
void * sc_data;
|
||||
void * win_data;
|
||||
}lv_app_inst_t;
|
||||
|
||||
typedef struct __LV_APP_DSC_T
|
||||
{
|
||||
const char * name;
|
||||
lv_app_mode_t mode;
|
||||
void (*app_run)(lv_app_inst_t *, void *);
|
||||
void (*app_close) (lv_app_inst_t *);
|
||||
void (*com_rec) (lv_app_inst_t *, lv_app_inst_t *, lv_app_com_type_t, const void *, uint32_t);
|
||||
void (*sc_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
void (*sc_close) (lv_app_inst_t *);
|
||||
void (*win_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
void (*win_close) (lv_app_inst_t *);
|
||||
void (*conf_open) (lv_app_inst_t *, lv_obj_t * );
|
||||
uint16_t app_data_size;
|
||||
uint16_t sc_data_size;
|
||||
uint16_t win_data_size;
|
||||
}lv_app_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_style_t menu;
|
||||
lv_style_t menu_btn_rel;
|
||||
lv_style_t menu_btn_pr;
|
||||
lv_style_t sc_rel;
|
||||
lv_style_t sc_pr;
|
||||
lv_style_t sc_send_rel;
|
||||
lv_style_t sc_send_pr;
|
||||
lv_style_t sc_rec_rel;
|
||||
lv_style_t sc_rec_pr;
|
||||
lv_style_t sc_title;
|
||||
lv_style_t win_header;
|
||||
lv_style_t win_scrl;
|
||||
lv_style_t win_cbtn_rel;
|
||||
lv_style_t win_cbtn_pr;
|
||||
}lv_app_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application system
|
||||
*/
|
||||
void lv_app_init(void);
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to an application specific configuration structure or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, void * conf);
|
||||
|
||||
/**
|
||||
* Close a running application. Close the Window and the Shortcut too if opened.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_sc_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_sc_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_win_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Send data to other applications
|
||||
* @param app_send pointer to the application which is sending the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
* @return number application which were received the message
|
||||
*/
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**
|
||||
* Test an application communication connection
|
||||
* @param sender pointer to an application which sends data
|
||||
* @param receiver pointer to an application which receives data
|
||||
* @return false: no connection, true: there is connection
|
||||
*/
|
||||
bool lv_app_con_check(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Create a new connection between two applications
|
||||
* @param sender pointer to a data sender application
|
||||
* @param receiver pointer to a data receiver application
|
||||
*/
|
||||
void lv_app_con_set(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Delete a communication connection
|
||||
* @param sender pointer to a data sender application or NULL to be true for all sender
|
||||
* @param receiver pointer to a data receiver application or NULL to be true for all receiver
|
||||
*/
|
||||
void lv_app_con_del(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Get the application descriptor from its name
|
||||
* @param name name of the app. dsc.
|
||||
* @return pointer to the app. dsc.
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_dsc_get(const char * name);
|
||||
|
||||
/**
|
||||
* Rename an application
|
||||
* @param app pointer to an application
|
||||
* @param name a string with the new name
|
||||
*/
|
||||
void lv_app_rename(lv_app_inst_t * app, const char * name);
|
||||
|
||||
/**
|
||||
* Get the window object from an object located on the window
|
||||
* @param obj pointer to an object on the window
|
||||
* @return pointer to the window of 'obj'
|
||||
*/
|
||||
lv_obj_t * lv_app_win_get_from_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Read the list of the running applications. (Get he next element)
|
||||
* @param prev the previous application (at the first call give NULL to get the first application)
|
||||
* @param dsc pointer to an application descriptor to filer the applications (NULL to do not filter)
|
||||
* @return pointer to the next running application or NULL if no more
|
||||
*/
|
||||
lv_app_inst_t * lv_app_get_next(lv_app_inst_t * prev, lv_app_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Read the list of applications descriptors. (Get he next element)
|
||||
* @param prev the previous application descriptors(at the first call give NULL to get the first)
|
||||
* @return pointer to the next application descriptors or NULL if no more
|
||||
*/
|
||||
lv_app_dsc_t ** lv_app_dsc_get_next(lv_app_dsc_t ** prev);
|
||||
|
||||
|
||||
/**
|
||||
* Get a pointer to the application style structure. If modified then 'lv_app_refr_style' should be called
|
||||
* @return pointer to the application style structure
|
||||
*/
|
||||
lv_app_style_t * lv_app_style_get(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* POST-INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_fsel.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_notice.h"
|
||||
|
||||
#include "lvgl/lv_appx/lv_app_example.h"
|
||||
#include "lvgl/lv_appx/lv_app_phantom.h"
|
||||
#include "lvgl/lv_appx/lv_app_sysmon.h"
|
||||
#include "lvgl/lv_appx/lv_app_terminal.h"
|
||||
#include "lvgl/lv_appx/lv_app_files.h"
|
||||
#include "lvgl/lv_appx/lv_app_wifi.h"
|
||||
#include "lvgl/lv_appx/lv_app_gsm.h"
|
||||
#include "lvgl/lv_appx/lv_app_benchmark.h"
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_H*/
|
||||
@@ -1,381 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_fsel.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_fsel.h"
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lv_app_notice.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void fsel_refr(void);
|
||||
static lv_action_res_t fsel_close_action(lv_obj_t * close, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_up_action(lv_obj_t * up, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_next_action(lv_obj_t * next, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_prev_action(lv_obj_t * prev, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_file_action(lv_obj_t * file, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const char * fsel_filter;
|
||||
static char fsel_path[LV_APP_FSEL_PATH_MAX_LEN];
|
||||
static uint16_t fsel_file_cnt;
|
||||
static lv_obj_t * fsel_win;
|
||||
static lv_obj_t * fsel_list;
|
||||
static void * fsel_param;
|
||||
static void (*fsel_ok_action)(void *, const char *);
|
||||
static lv_style_t style_btn_symbol;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File selector utility
|
||||
*/
|
||||
void lv_app_fsel_init(void)
|
||||
{
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol);
|
||||
style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the File selector
|
||||
* @param path start path
|
||||
* @param filter show only files with a specific extension, e.g. "wav".
|
||||
* "/" means filter to folders.
|
||||
* @param param a free parameter which will be added to 'ok_action'
|
||||
* @param ok_action an action to call when a file or folder is chosen
|
||||
*/
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param, void (*ok_action)(void *, const char *))
|
||||
{
|
||||
/*Save the parameters*/
|
||||
strcpy(fsel_path, path);
|
||||
fsel_filter = filter;
|
||||
fsel_file_cnt = 0;
|
||||
fsel_param = param;
|
||||
fsel_ok_action = ok_action;
|
||||
|
||||
/*Trim the extra '\' or '/' from the end of path*/
|
||||
uint16_t i;
|
||||
for(i = strlen(fsel_path) -1 ; fsel_path[i] == '/' || fsel_path[i] == '\\'; i--) {
|
||||
fsel_path[i] = '\0';
|
||||
}
|
||||
|
||||
/*Check filter: NULL and "" mean no filtering*/
|
||||
if(fsel_filter == NULL) fsel_filter = "";
|
||||
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
/*Create a window for the File selector*/
|
||||
fsel_win = lv_win_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(fsel_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_win_set_styles_cbtn(fsel_win, &app_style->win_cbtn_rel, &app_style->win_cbtn_pr);
|
||||
lv_obj_set_style(lv_win_get_header(fsel_win), &app_style->menu);
|
||||
|
||||
lv_win_add_cbtn(fsel_win, SYMBOL_CLOSE, fsel_close_action);
|
||||
|
||||
fsel_refr(); /*Refresh the list*/
|
||||
|
||||
/*Show instruction when first open with folder filter*/
|
||||
static bool first_folder_call = false;
|
||||
if(first_folder_call == false && fsel_filter[0] == '/') {
|
||||
lv_app_notice_add("Press a folder long\nto choose it!");
|
||||
first_folder_call = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the File selector
|
||||
*/
|
||||
void lv_app_fsel_close(void)
|
||||
{
|
||||
if(fsel_win != NULL) {
|
||||
lv_obj_del(fsel_win);
|
||||
}
|
||||
|
||||
fsel_win = NULL;
|
||||
fsel_list = NULL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Refresh the file list according to the current path and filter
|
||||
*/
|
||||
static void fsel_refr(void)
|
||||
{
|
||||
/*Delete the previous list*/
|
||||
if(fsel_list != NULL) {
|
||||
lv_obj_del(fsel_list);
|
||||
}
|
||||
|
||||
lv_win_set_title(fsel_win, fsel_path);
|
||||
|
||||
/*Create a new list*/
|
||||
fsel_list = lv_list_create(fsel_win, NULL);
|
||||
lv_obj_set_width(fsel_list, lv_win_get_width(fsel_win));
|
||||
lv_list_set_style_img(fsel_list, &style_btn_symbol);
|
||||
lv_obj_set_style(lv_page_get_scrl(fsel_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_drag_parent(fsel_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(fsel_list), true);
|
||||
lv_cont_set_fit(fsel_list, false, true);
|
||||
|
||||
fs_res_t res = FS_RES_OK;
|
||||
lv_obj_t * liste;
|
||||
|
||||
/*At empty path show the drivers */
|
||||
if(fsel_path[0] == '\0') {
|
||||
char drv[16];
|
||||
char buf[2];
|
||||
fs_get_letters(drv);
|
||||
uint8_t i;
|
||||
for(i = 0; drv[i] != '\0'; i++) {
|
||||
buf[0] = drv[i];
|
||||
buf[1] = '\0';
|
||||
liste = lv_list_add(fsel_list, SYMBOL_DRIVE, buf, fsel_drv_action);
|
||||
/*Add long press action to choose the driver as a folder*/
|
||||
if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_drv_lpr_action);
|
||||
}
|
||||
}
|
||||
/*List the files/folders with fs interface*/
|
||||
else {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_UP, "Up", fsel_up_action);
|
||||
|
||||
fs_readdir_t rd;
|
||||
res = fs_readdir_init(&rd, fsel_path);
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
return;
|
||||
}
|
||||
|
||||
/*At not first page add prev. page button */
|
||||
if(fsel_file_cnt != 0) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_LEFT, "Previous page", fsel_prev_action);
|
||||
}
|
||||
|
||||
char fn[LV_APP_FSEL_FN_MAX_LEN];
|
||||
|
||||
/*Read the files from the previous pages*/
|
||||
uint16_t file_cnt = 0;
|
||||
while(file_cnt <= fsel_file_cnt) {
|
||||
res = fs_readdir(&rd, fn);
|
||||
if(res != FS_RES_OK){
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
return;
|
||||
}
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Add list elements from the files and folders*/
|
||||
while(res == FS_RES_OK && fn[0] != '\0') {
|
||||
if(fn[0] == '/') { /*Add a folder*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(fsel_list, SYMBOL_FOLDER, &fn[1], fsel_folder_action);
|
||||
/*Add long press action to choose a folder*/
|
||||
if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_folder_lpr_action);
|
||||
|
||||
fsel_file_cnt ++;
|
||||
file_cnt ++;
|
||||
}
|
||||
/*Add a file if it is not filtered*/
|
||||
else if(fsel_filter[0] == '\0' || /*No filtering or ...*/
|
||||
(strcmp(fs_get_ext(fn), fsel_filter) == 0 && /*.. the filter matches*/
|
||||
fsel_filter[0] != '/')) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_FILE, fn, fsel_file_action);
|
||||
fsel_file_cnt ++;
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Get the next element*/
|
||||
res = fs_readdir(&rd, fn);
|
||||
|
||||
/*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/
|
||||
if(fsel_file_cnt != 0 && fsel_file_cnt % LV_APP_FSEL_PAGE_SIZE == 0) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_RIGHT, "Next page", fsel_next_action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Close the read directory*/
|
||||
fs_readdir_close(&rd);
|
||||
}
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
}
|
||||
|
||||
/*Focus to the top of the list*/
|
||||
lv_obj_set_y(lv_page_get_scrl(fsel_list), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the File selector window close button is released
|
||||
* @param close pointer to the close button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the window is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_close_action(lv_obj_t * close, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_fsel_close();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Up list element is released to step one level
|
||||
* @param up pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_up_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
fs_up(fsel_path);
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Next list element is released to go to the next page
|
||||
* @param next pointer to the Next button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_next_action(lv_obj_t * next, lv_dispi_t * dispi)
|
||||
{
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Prev list element is released to previous page
|
||||
* @param prev pointer to the Prev button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_prev_action(lv_obj_t * prev, lv_dispi_t * dispi)
|
||||
{
|
||||
if(fsel_file_cnt <= 2 * LV_APP_FSEL_PAGE_SIZE) fsel_file_cnt = 0;
|
||||
else if(fsel_file_cnt % LV_APP_FSEL_PAGE_SIZE == 0) {
|
||||
fsel_file_cnt -= 2 * LV_APP_FSEL_PAGE_SIZE;
|
||||
} else {
|
||||
fsel_file_cnt = ((fsel_file_cnt / LV_APP_FSEL_PAGE_SIZE) - 1) * LV_APP_FSEL_PAGE_SIZE;
|
||||
}
|
||||
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is released to step into a driver
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s:", lv_list_get_element_text(drv));
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is long pressed to choose it
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s:", lv_list_get_element_text(drv));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a folder list element is released to enter into it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder));
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a folder list element is long pressed to choose it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a file list element is released to choose it
|
||||
* @param file pointer to a file button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_file_action(lv_obj_t * file, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(file));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_fsel.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_FSEL_H
|
||||
#define LV_APP_FSEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Add the required configurations*/
|
||||
#ifndef LV_APP_FSEL_FN_MAX_LEN
|
||||
#define LV_APP_FSEL_FN_MAX_LEN 128
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_FSEL_PATH_MAX_LEN
|
||||
#define LV_APP_FSEL_PATH_MAX_LEN 256
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_FSEL_PAGE_SIZE
|
||||
#define LV_APP_FSEL_PAGE_SIZE 8
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File selector utility
|
||||
*/
|
||||
void lv_app_fsel_init(void);
|
||||
|
||||
/**
|
||||
* Open the File selector
|
||||
* @param path start path
|
||||
* @param filter show only files with a specific extension, e.g. "wav".
|
||||
* "/" means filter to folders.
|
||||
* @param param a free parameter which will be added to 'ok_action'
|
||||
* @param ok_action an action to call when a file or folder is chosen (give 'param' and the path as parameters)
|
||||
*/
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param,
|
||||
void (*ok_action)(void *, const char *));
|
||||
|
||||
/**
|
||||
* Close the File selector
|
||||
*/
|
||||
void lv_app_fsel_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_FSEL_H*/
|
||||
@@ -1,278 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_kb.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_kb.h"
|
||||
#if USE_LV_APP_KB != 0
|
||||
|
||||
#include "lvgl/lv_objx/lv_btnm.h"
|
||||
#include "lvgl/lv_objx/lv_ta.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_APP_KB_ANIM_TIME
|
||||
#define LV_APP_KB_ANIM_TIME 300 /*ms*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * kb_btnm;
|
||||
static lv_obj_t * kb_win;
|
||||
static lv_obj_t * kb_ta;
|
||||
static const char * kb_map_lc[] = {
|
||||
"\0051#", "\004q", "\004w", "\004e", "\004r", "\004t", "\004y", "\004u", "\004i", "\004o", "\004p", "\007Del", "\n",
|
||||
"\006ABC", "\003a", "\003s", "\003d", "\003f", "\003g", "\003h", "\003j", "\003k", "\003l", "\010Enter", "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_uc[] = {
|
||||
"\0051#", "\004Q", "\004W", "\004E", "\004R", "\004T", "\004Y", "\004U", "\004I", "\004O", "\004P", "\007Del", "\n",
|
||||
"\006abc", "\003A", "\003S", "\003D", "\003F", "\003G", "\003H", "\003J", "\003K", "\003L", "\010Enter", "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_spec[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\002Del", "\n",
|
||||
"\002abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_num[] = {
|
||||
"1", "2", "3", "\002Hide","\n",
|
||||
"4", "5", "6", "\002Ok", "\n",
|
||||
"7", "8", "9", "\002Del", "\n",
|
||||
"+/-", "0", ".", "Left", "Right", ""
|
||||
};
|
||||
|
||||
static cord_t kb_ta_ori_size;
|
||||
static uint8_t kb_mode;
|
||||
static void (*kb_close_action)(lv_obj_t *);
|
||||
static void (*kb_ok_action)(lv_obj_t *);
|
||||
static lv_style_t style_bg;
|
||||
static lv_style_t style_btn_rel;
|
||||
static lv_style_t style_btn_pr;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void)
|
||||
{
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
memcpy(&style_bg, &app_style->menu, sizeof(lv_style_t));
|
||||
style_bg.opa = OPA_COVER;
|
||||
style_bg.hpad = 0;
|
||||
style_bg.vpad = 0;
|
||||
style_bg.opad = 0;
|
||||
|
||||
memcpy(&style_btn_rel, &app_style->menu_btn_rel, sizeof(lv_style_t));
|
||||
style_btn_rel.radius = 0;
|
||||
style_btn_rel.bwidth = 1;
|
||||
|
||||
memcpy(&style_btn_pr, &app_style->menu_btn_pr, sizeof(lv_style_t));
|
||||
style_btn_pr.radius = 0;
|
||||
style_btn_pr.bwidth = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a keyboard for a text area object
|
||||
* @param ta pointer to a text area object
|
||||
* @param mode 'OR'd values of 'lv_app_kb_mode_t' enum
|
||||
* @param close a function to call when the keyboard is closed
|
||||
* @param ok a function to called when the "Ok" button is pressed
|
||||
* @return the created button matrix objects
|
||||
*/
|
||||
lv_obj_t * lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *))
|
||||
{
|
||||
/*Close the previous keyboard*/
|
||||
if(kb_btnm != NULL) {
|
||||
lv_app_kb_close(false);
|
||||
}
|
||||
|
||||
/*Save some parameters*/
|
||||
kb_ta = ta;
|
||||
kb_mode = mode;
|
||||
kb_close_action = close;
|
||||
kb_ok_action = ok;
|
||||
|
||||
/*Create a button matrix for the keyboard */
|
||||
kb_btnm = lv_btnm_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(kb_btnm, &style_bg);
|
||||
lv_obj_set_size(kb_btnm, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_align(kb_btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_btnm_set_action(kb_btnm, lv_app_kb_action);
|
||||
if(mode & LV_APP_KB_MODE_TXT) {
|
||||
style_btn_rel.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
style_btn_pr.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
lv_btnm_set_map(kb_btnm, kb_map_lc);
|
||||
}
|
||||
else if(mode & LV_APP_KB_MODE_NUM) {
|
||||
style_btn_rel.font = font_get(LV_APP_FONT_LARGE);
|
||||
style_btn_pr.font = font_get(LV_APP_FONT_LARGE);
|
||||
lv_btnm_set_map(kb_btnm, kb_map_num);
|
||||
}
|
||||
lv_btnm_set_styles_btn(kb_btnm, &style_btn_rel, &style_btn_pr);
|
||||
|
||||
kb_win = NULL;
|
||||
kb_ta_ori_size = 0;
|
||||
if(mode & LV_APP_KB_MODE_WIN_RESIZE) {
|
||||
/*Reduce the size of the window and align it to the top*/
|
||||
kb_win = lv_app_win_get_from_obj(kb_ta);
|
||||
lv_obj_set_height(kb_win, LV_VER_RES / 2);
|
||||
lv_obj_set_y(kb_win, 0);
|
||||
|
||||
/*If the text area is higher then the new size of the window reduce its size too*/
|
||||
cord_t cont_h = lv_obj_get_height(kb_win) - lv_obj_get_height(lv_win_get_header(kb_win));
|
||||
kb_ta_ori_size = lv_obj_get_height(kb_ta);
|
||||
if(lv_obj_get_height(kb_ta) > cont_h - LV_DPI / 10) {
|
||||
lv_obj_set_height(kb_ta, cont_h - LV_DPI / 10);
|
||||
}
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
}
|
||||
|
||||
lv_ta_set_cursor_pos(kb_ta, LV_TA_CUR_LAST);
|
||||
if(kb_mode & LV_APP_KB_MODE_CUR_MANAGE) {
|
||||
lv_ta_set_cursor_show(kb_ta, true);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_ANIM_IN) {
|
||||
lv_obj_anim(kb_btnm, LV_ANIM_FLOAT_BOTTOM | ANIM_IN, LV_APP_KB_ANIM_TIME, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
return kb_btnm;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the keyboard
|
||||
* @param ok true: call the ok function, false: call the close function
|
||||
*/
|
||||
void lv_app_kb_close(bool ok)
|
||||
{
|
||||
if(kb_btnm == NULL) return;
|
||||
|
||||
if(ok == false) {
|
||||
if(kb_close_action != NULL) kb_close_action(kb_ta);
|
||||
} else {
|
||||
if(kb_ok_action != NULL) kb_ok_action(kb_ta);
|
||||
}
|
||||
|
||||
/*Reset the modified sizes*/
|
||||
if((kb_mode & LV_APP_KB_MODE_WIN_RESIZE) && kb_win != NULL) {
|
||||
lv_obj_set_height(kb_ta, kb_ta_ori_size);
|
||||
lv_obj_set_size(kb_win, LV_HOR_RES, LV_VER_RES);
|
||||
kb_win = NULL;
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_CUR_MANAGE) {
|
||||
lv_ta_set_cursor_show(kb_ta, false);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_ANIM_OUT) {
|
||||
lv_obj_anim(kb_btnm, LV_ANIM_FLOAT_BOTTOM | ANIM_OUT, LV_APP_KB_ANIM_TIME, 0, lv_obj_del);
|
||||
} else {
|
||||
lv_obj_del(kb_btnm);
|
||||
}
|
||||
|
||||
kb_btnm = NULL;
|
||||
kb_ta = NULL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called when a button of 'kb_btnm' is released
|
||||
* @param btnm pointer to 'kb_btnm'
|
||||
* @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_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
|
||||
{
|
||||
const char ** map = lv_btnm_get_map(btnm);
|
||||
const char * txt = map[i];
|
||||
|
||||
/*Ignore the unit size number of the text*/
|
||||
if(txt[0] <= '\011') txt++;
|
||||
|
||||
/*Do the corresponding action according to the text of the button*/
|
||||
if(strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_lc);
|
||||
} else if(strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_uc);
|
||||
} else if(strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_spec);
|
||||
} else if(strcmp(txt, "Enter") == 0) {
|
||||
lv_ta_add_char(kb_ta, '\n');
|
||||
} else if(strcmp(txt, "Left") == 0) {
|
||||
lv_ta_cursor_left(kb_ta);
|
||||
} else if(strcmp(txt, "Right") == 0) {
|
||||
lv_ta_cursor_right(kb_ta);
|
||||
} else if(strcmp(txt, "Del") == 0) {
|
||||
lv_ta_del(kb_ta);
|
||||
} else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(kb_ta);
|
||||
const char * ta_txt = lv_ta_get_txt(kb_ta);
|
||||
if(ta_txt[0] == '-') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '+');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else if(ta_txt[0] == '+') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else {
|
||||
lv_ta_set_cursor_pos(kb_ta, 0);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur + 1);
|
||||
}
|
||||
} else if(strcmp(txt, "Hide") == 0) {
|
||||
lv_app_kb_close(false);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else if(strcmp(txt, "Ok") == 0) {
|
||||
lv_app_kb_close(true);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else {
|
||||
lv_ta_add_text(kb_ta, txt);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_WIN_RESIZE) {
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
#endif
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_kb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_KB_H
|
||||
#define LV_APP_KB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#if USE_LV_APP_KB != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_KB_MODE_TXT = 0x0001,
|
||||
LV_APP_KB_MODE_NUM = 0x0002,
|
||||
LV_APP_KB_MODE_WIN_RESIZE = 0x0004,
|
||||
LV_APP_KB_MODE_CUR_MANAGE = 0x0008,
|
||||
LV_APP_KB_MODE_ANIM_IN = 0x0010,
|
||||
LV_APP_KB_MODE_ANIM_OUT = 0x0020,
|
||||
}lv_app_kb_mode_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void);
|
||||
|
||||
/**
|
||||
* Open a keyboard for a text area object
|
||||
* @param ta pointer to a text area object
|
||||
* @param mode 'OR'd values of 'lv_app_kb_mode_t' enum
|
||||
* @param close a function to call when the keyboard is closed
|
||||
* @param ok a function to called when the "Ok" button is pressed
|
||||
* @return the created button matrix objects
|
||||
*/
|
||||
lv_obj_t * lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *));
|
||||
|
||||
/**
|
||||
* Close the keyboard
|
||||
* @param ok true: call the ok function, false: call the close function
|
||||
*/
|
||||
void lv_app_kb_close(bool ok);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_KB_H*/
|
||||
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_notice.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_notice.h"
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lvgl/lv_objx/lv_label.h"
|
||||
|
||||
#include "misc/gfx/anim.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * notice_h;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
/**
|
||||
* Initialize the Notifications
|
||||
*/
|
||||
void lv_app_notice_init(void)
|
||||
{
|
||||
notice_h = lv_cont_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - LV_DPI / 8);
|
||||
lv_obj_set_y(notice_h, LV_DPI / 8);
|
||||
lv_obj_set_click(notice_h, false);
|
||||
lv_obj_set_style(notice_h, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_cont_set_layout(notice_h, LV_CONT_LAYOUT_COL_R);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...)
|
||||
{
|
||||
char txt[LV_APP_NOTICE_MAX_LEN];
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsprintf(txt,format, va);
|
||||
va_end(va);
|
||||
|
||||
lv_obj_t * mbox;
|
||||
mbox = lv_mbox_create(notice_h, NULL);
|
||||
lv_mbox_set_text(mbox, txt);
|
||||
lv_mbox_set_anim_close_time(mbox, LV_APP_NOTICE_CLOSE_ANIM_TIME);
|
||||
|
||||
#if LV_APP_NOTICE_SHOW_TIME != 0
|
||||
lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME);
|
||||
#endif
|
||||
|
||||
/*Delete the last children if there are too many*/
|
||||
uint32_t child_num = lv_obj_get_child_num(notice_h);
|
||||
if(child_num > LV_APP_NOTICE_MAX_NUM) {
|
||||
lv_obj_t * last_child = ll_get_tail(¬ice_h->child_ll);
|
||||
lv_obj_del(last_child);
|
||||
}
|
||||
|
||||
/*make sure the notices are on the top*/
|
||||
lv_obj_set_parent(notice_h, lv_scr_act());
|
||||
|
||||
return mbox;
|
||||
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_notice.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_NOTICE_H
|
||||
#define LV_APP_NOTICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#include <stdarg.h>
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Add the required configurations*/
|
||||
#ifndef LV_APP_NOTICE_SHOW_TIME
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_CLOSE_ANIM_TIME
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_MAX_NUM
|
||||
#define LV_APP_NOTICE_MAX_NUM 6
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_MAX_LEN
|
||||
#define LV_APP_NOTICE_MAX_LEN 256
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Notifications
|
||||
*/
|
||||
void lv_app_notice_init(void);
|
||||
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_NOTICE_H*/
|
||||
|
||||
@@ -1,580 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_benchmark.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_benchmark.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "lvgl/lv_obj/lv_refr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SHADOW_WIDTH (LV_DPI / 4)
|
||||
#define IMG_RECOLOR OPA_30
|
||||
#define OPACITY OPA_60
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t wp :1;
|
||||
uint8_t recolor :1;
|
||||
uint8_t upscalse :1;
|
||||
uint8_t shadow :1;
|
||||
uint8_t opa :1;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * wp;
|
||||
lv_obj_t * value_l;
|
||||
lv_style_t style_wp;
|
||||
lv_style_t style_value_l;
|
||||
lv_style_t style_btn_rel;
|
||||
lv_style_t style_btn_pr;
|
||||
lv_style_t style_btn_trel;
|
||||
lv_style_t style_btn_tpr;
|
||||
lv_style_t style_btn_ina;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void refr_monitor(uint32_t time_ms, uint32_t px_num);
|
||||
static lv_action_res_t run_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t wp_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t recolor_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t upscale_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t shadow_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t opa_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Benchmark",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_style_t style_win_scrl;
|
||||
static lv_style_t style_sc_btn_rel;
|
||||
static lv_style_t style_sc_btn_pr;
|
||||
|
||||
static bool caputre_next;
|
||||
|
||||
LV_IMG_DECLARE(img_bg);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_benchmark_init(void)
|
||||
{
|
||||
lv_refr_set_monitor_cb(refr_monitor);
|
||||
|
||||
lv_img_create_file("app_bm_wp", img_bg);
|
||||
|
||||
lv_style_get(LV_STYLE_TRANSP, &style_win_scrl);
|
||||
style_win_scrl.opad = 2 * SHADOW_WIDTH + SHADOW_WIDTH / 8 ;
|
||||
style_win_scrl.hpad = SHADOW_WIDTH;
|
||||
style_win_scrl.vpad = SHADOW_WIDTH;
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_sc_btn_rel);
|
||||
style_sc_btn_rel.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_PR, &style_sc_btn_pr);
|
||||
style_sc_btn_pr.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_benchmark_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
my_sc_data_t * sc_data = app_rec->sc_data;
|
||||
if (sc_data->label != NULL) {
|
||||
lv_label_set_text_array(sc_data->label, data, size);
|
||||
lv_obj_align(sc_data->label , NULL,LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
lv_cont_set_layout(sc, LV_CONT_LAYOUT_CENTER);
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "N/A ms");
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(sc, NULL);
|
||||
lv_btn_set_rel_action(btn, run_rel_action);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
lv_btn_set_styles(btn, &style_sc_btn_rel, &style_sc_btn_pr, NULL, NULL, NULL);
|
||||
|
||||
lv_obj_t * btn_l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(btn_l, SYMBOL_PLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_INA, &wdata->style_value_l);
|
||||
wdata->style_value_l.ccolor = COLOR_BLACK;
|
||||
lv_style_get(LV_STYLE_BTN_REL, &wdata->style_btn_rel);
|
||||
lv_style_get(LV_STYLE_BTN_PR, &wdata->style_btn_pr);
|
||||
lv_style_get(LV_STYLE_BTN_TREL, &wdata->style_btn_trel);
|
||||
lv_style_get(LV_STYLE_BTN_TPR, &wdata->style_btn_tpr);
|
||||
lv_style_get(LV_STYLE_BTN_INA, &wdata->style_btn_ina);
|
||||
lv_style_get(LV_STYLE_PLAIN, &wdata->style_wp);
|
||||
wdata->style_wp.ccolor = COLOR_RED;//MAKE(0x10, 0x20, 0x30);
|
||||
|
||||
if(adata->opa == 0) {
|
||||
wdata->style_btn_rel.opa = OPA_COVER;
|
||||
wdata->style_btn_pr.opa = OPA_COVER;
|
||||
wdata->style_btn_trel.opa =OPA_COVER;
|
||||
wdata->style_btn_tpr.opa = OPA_COVER;
|
||||
wdata->style_btn_ina.opa = OPA_COVER;
|
||||
} else {
|
||||
wdata->style_btn_rel.opa = OPACITY;
|
||||
wdata->style_btn_pr.opa = OPACITY;
|
||||
wdata->style_btn_trel.opa =OPACITY;
|
||||
wdata->style_btn_tpr.opa = OPACITY;
|
||||
wdata->style_btn_ina.opa = OPACITY;
|
||||
}
|
||||
|
||||
if(adata->shadow == 0) {
|
||||
wdata->style_btn_rel.swidth = 0;
|
||||
wdata->style_btn_pr.swidth = 0;
|
||||
wdata->style_btn_trel.swidth = 0;
|
||||
wdata->style_btn_tpr.swidth = 0;
|
||||
wdata->style_btn_ina.swidth = 0;
|
||||
} else {
|
||||
wdata->style_btn_rel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_pr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_trel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_tpr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_ina.swidth = SHADOW_WIDTH;
|
||||
}
|
||||
|
||||
if(adata->recolor == 0) {
|
||||
wdata->style_wp.img_recolor = OPA_TRANSP;
|
||||
} else {
|
||||
wdata->style_wp.img_recolor = IMG_RECOLOR;
|
||||
}
|
||||
|
||||
lv_obj_set_style(lv_page_get_scrl(lv_win_get_page(win)), &style_win_scrl);
|
||||
|
||||
wdata->wp = lv_img_create(win, NULL);
|
||||
lv_obj_set_protect(wdata->wp, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(wdata->wp, lv_win_get_page(win));
|
||||
lv_img_set_file(wdata->wp, "U:/app_bm_wp");
|
||||
lv_obj_set_size(wdata->wp, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(lv_win_get_header(win)));
|
||||
lv_obj_set_pos(wdata->wp, 0, 0);
|
||||
lv_obj_set_style(wdata->wp, &wdata->style_wp);
|
||||
if(adata->wp == 0) lv_obj_set_hidden(wdata->wp, true);
|
||||
if(adata->upscalse != 0) lv_img_set_upscale(wdata->wp, true);
|
||||
|
||||
/* The order is changed because the wallpaper's parent change
|
||||
* Therefore add the scrollable again */
|
||||
lv_obj_set_parent(lv_page_get_scrl(lv_win_get_page(win)), lv_win_get_page(win));
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
lv_obj_t * holder;
|
||||
|
||||
holder = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(holder, true, true);
|
||||
lv_obj_set_style(holder, &wdata->style_btn_ina);
|
||||
lv_page_glue_obj(holder, true);
|
||||
|
||||
wdata->value_l = lv_label_create(holder, NULL);
|
||||
lv_obj_set_style(wdata->value_l, &wdata->style_value_l);
|
||||
lv_label_set_text(wdata->value_l, "Screen load: N/A ms\nN/A px/ms");
|
||||
|
||||
lv_obj_t * btn;
|
||||
btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(btn, app);
|
||||
lv_page_glue_obj(btn, true);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
lv_btn_set_styles(btn, &wdata->style_btn_rel, &wdata->style_btn_pr, &wdata->style_btn_trel, &wdata->style_btn_tpr, NULL);
|
||||
lv_btn_set_rel_action(btn, run_rel_action);
|
||||
|
||||
lv_obj_t * btn_l;
|
||||
btn_l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(btn_l, "Run\ntest!");
|
||||
lv_obj_set_protect(btn, LV_PROTECT_FOLLOW);
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
lv_btn_set_tgl(btn, true);
|
||||
lv_obj_clr_protect(btn, LV_PROTECT_FOLLOW);
|
||||
if(adata->wp != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, wp_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wallpaper");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->recolor != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, recolor_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wp. recolor!");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->upscalse != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, upscale_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wp. upscalse!");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->shadow != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
lv_btn_set_rel_action(btn, shadow_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Shadow");
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->opa != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, opa_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Opacity");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void refr_monitor(uint32_t time_ms, uint32_t px_num)
|
||||
{
|
||||
if(caputre_next != false) {
|
||||
lv_app_inst_t * app = NULL;
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
|
||||
char w_buf[256];
|
||||
if(time_ms != 0) sprintf(w_buf, "Screen load: %d ms\n%d px/ms", time_ms, px_num/time_ms);
|
||||
else sprintf(w_buf, "Screen load: %d ms\nN/A px/ms", time_ms);
|
||||
|
||||
char s_buf[16];
|
||||
sprintf(s_buf, "%d ms", time_ms);
|
||||
|
||||
while(app != NULL) {
|
||||
if(app->win_data != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_label_set_text(wdata->value_l, w_buf);
|
||||
}
|
||||
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sdata = app->sc_data;
|
||||
lv_label_set_text(sdata->label, s_buf);
|
||||
}
|
||||
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
|
||||
|
||||
caputre_next = false;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_action_res_t run_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_inv(lv_scr_act());
|
||||
caputre_next = true;
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t wp_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->wp = 1;
|
||||
lv_obj_set_hidden(wdata->wp, false);
|
||||
} else {
|
||||
adata->wp = 0;
|
||||
lv_obj_set_hidden(wdata->wp, true);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t recolor_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->recolor = 1;
|
||||
wdata->style_wp.img_recolor = IMG_RECOLOR;
|
||||
} else {
|
||||
adata->recolor = 0;
|
||||
wdata->style_wp.img_recolor = OPA_TRANSP;
|
||||
}
|
||||
|
||||
lv_obj_refr_style(wdata->wp);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t upscale_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->upscalse = 1;
|
||||
lv_img_set_upscale(wdata->wp, true);
|
||||
} else {
|
||||
adata->upscalse = 0;
|
||||
lv_img_set_upscale(wdata->wp, false);
|
||||
}
|
||||
|
||||
lv_obj_set_size(wdata->wp, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(lv_win_get_header(app->win)));
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t shadow_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->shadow = 1;
|
||||
wdata->style_btn_rel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_pr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_trel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_tpr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_ina.swidth = SHADOW_WIDTH;
|
||||
} else {
|
||||
adata->opa = 0;
|
||||
wdata->style_btn_rel.swidth = 0;
|
||||
wdata->style_btn_pr.swidth = 0;
|
||||
wdata->style_btn_trel.swidth =0;
|
||||
wdata->style_btn_tpr.swidth = 0;
|
||||
wdata->style_btn_ina.swidth = 0;
|
||||
}
|
||||
|
||||
lv_style_refr_objs(&wdata->style_btn_rel);
|
||||
lv_style_refr_objs(&wdata->style_btn_pr);
|
||||
lv_style_refr_objs(&wdata->style_btn_trel);
|
||||
lv_style_refr_objs(&wdata->style_btn_tpr);
|
||||
lv_style_refr_objs(&wdata->style_btn_ina);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t opa_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->opa = 1;
|
||||
wdata->style_btn_rel.opa = OPACITY;
|
||||
wdata->style_btn_pr.opa = OPACITY;
|
||||
wdata->style_btn_trel.opa =OPACITY;
|
||||
wdata->style_btn_tpr.opa = OPACITY;
|
||||
wdata->style_btn_ina.opa = OPACITY;
|
||||
} else {
|
||||
adata->opa = 0;
|
||||
wdata->style_btn_rel.opa = OPA_COVER;
|
||||
wdata->style_btn_pr.opa = OPA_COVER;
|
||||
wdata->style_btn_trel.opa =OPA_COVER;
|
||||
wdata->style_btn_tpr.opa = OPA_COVER;
|
||||
wdata->style_btn_ina.opa = OPA_COVER;
|
||||
}
|
||||
|
||||
lv_style_refr_objs(&wdata->style_btn_rel);
|
||||
lv_style_refr_objs(&wdata->style_btn_pr);
|
||||
lv_style_refr_objs(&wdata->style_btn_trel);
|
||||
lv_style_refr_objs(&wdata->style_btn_tpr);
|
||||
lv_style_refr_objs(&wdata->style_btn_ina);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/*Exceptionally store the data because the big array would be bothering*/
|
||||
|
||||
|
||||
const color_int_t img_bg[] = {
|
||||
/*HEADER
|
||||
Width = 40
|
||||
Height = 40
|
||||
Transp: 0
|
||||
Color depth: 24*/
|
||||
100827176,
|
||||
|
||||
/*IMAGE DATA*/
|
||||
|
||||
263172, 460551, 460551, 526344, 723723, 1447446, 1644825, 1447446, 1447446, 1052688, 1052688, 921102, 1052688, 723723, 263172, 197379, 131586, 65793, 65793, 0, 65793, 0, 65793, 65793, 65793, 65793, 65793, 328965, 789516, 855309, 1250067, 1052688, 1052688, 1184274, 1184274, 986895, 394758, 394758, 394758, 328965,
|
||||
131586, 460551, 526344, 394758, 1776411, 2631720, 2105376, 1447446, 1250067, 1052688, 855309, 1052688, 1579032, 1250067, 460551, 65793, 65793, 65793, 65793, 65793, 0, 65793, 65793, 0, 0, 0, 328965, 986895, 1184274, 789516, 921102, 1250067, 1052688, 1052688, 1842204, 1644825, 1052688, 328965, 263172, 328965,
|
||||
394758, 460551, 526344, 1052688, 2434341, 2434341, 2236962, 1907997, 1052688, 855309, 1052688, 1315860, 1381653, 1447446, 855309, 263172, 0, 0, 131586, 131586, 131586, 131586, 131586, 65793, 0, 263172, 855309, 1052688, 1052688, 1052688, 1118481, 921102, 986895, 1052688, 1579032, 1513239, 1513239, 1118481, 394758, 328965,
|
||||
263172, 460551, 1447446, 1842204, 2171169, 1973790, 1973790, 1776411, 1052688, 986895, 1184274, 1250067, 921102, 1118481, 1118481, 723723, 263172, 0, 65793, 131586, 197379, 263172, 131586, 131586, 328965, 657930, 921102, 855309, 921102, 1052688, 1052688, 1052688, 855309, 1250067, 1579032, 1250067, 1842204, 1710618, 986895, 263172,
|
||||
657930, 921102, 1842204, 1776411, 1250067, 1118481, 1052688, 1118481, 1315860, 1381653, 1052688, 855309, 1052688, 855309, 921102, 1184274, 1381653, 394758, 65793, 131586, 131586, 131586, 65793, 526344, 1579032, 1052688, 723723, 789516, 855309, 921102, 1052688, 1184274, 1315860, 1052688, 1315860, 1447446, 1513239, 1710618, 1644825, 855309,
|
||||
1052688, 1315860, 1710618, 1250067, 1052688, 986895, 921102, 921102, 1052688, 1052688, 1184274, 855309, 855309, 921102, 1052688, 1776411, 2302755, 1644825, 394758, 0, 131586, 131586, 657930, 1776411, 1907997, 1710618, 855309, 723723, 855309, 986895, 1052688, 1052688, 1184274, 1184274, 1052688, 1184274, 1250067, 1513239, 1447446, 1184274,
|
||||
1184274, 1052688, 986895, 1052688, 921102, 986895, 1184274, 1052688, 921102, 1052688, 1052688, 1052688, 986895, 1118481, 1907997, 1907997, 1973790, 2171169, 1513239, 394758, 65793, 657930, 1973790, 1973790, 1842204, 1776411, 1579032, 855309, 789516, 1052688, 986895, 986895, 986895, 1250067, 1315860, 1118481, 1250067, 1118481, 986895, 1118481,
|
||||
1250067, 986895, 1052688, 855309, 986895, 1250067, 1184274, 1052688, 1052688, 1052688, 986895, 921102, 1315860, 1973790, 2105376, 1842204, 1842204, 1973790, 2171169, 1579032, 789516, 1710618, 2105376, 1973790, 1776411, 1907997, 1973790, 1710618, 1118481, 855309, 855309, 855309, 921102, 986895, 1315860, 1381653, 986895, 855309, 789516, 986895,
|
||||
1250067, 855309, 1052688, 657930, 986895, 1118481, 1315860, 1118481, 986895, 986895, 855309, 1381653, 1907997, 2105376, 1842204, 1776411, 1842204, 1907997, 2105376, 2171169, 1776411, 2105376, 2236962, 2105376, 1842204, 1973790, 2171169, 2236962, 1776411, 1052688, 855309, 986895, 921102, 921102, 1118481, 1513239, 921102, 657930, 921102, 855309,
|
||||
986895, 855309, 657930, 855309, 1052688, 1118481, 1118481, 986895, 855309, 657930, 1052688, 1776411, 1907997, 1907997, 1973790, 1907997, 1907997, 2171169, 1973790, 2236962, 2171169, 1973790, 2105376, 2105376, 1776411, 1973790, 2236962, 2236962, 2302755, 1842204, 1118481, 855309, 1052688, 1052688, 1052688, 1184274, 1118481, 1052688, 921102, 1052688,
|
||||
1250067, 1250067, 855309, 1052688, 1052688, 986895, 1052688, 855309, 657930, 855309, 1710618, 1907997, 1907997, 2105376, 2171169, 2302755, 2368548, 2105376, 1973790, 1907997, 1842204, 1842204, 1907997, 1907997, 1842204, 1907997, 1973790, 1973790, 2171169, 2302755, 1776411, 855309, 855309, 1052688, 1052688, 986895, 1184274, 1184274, 855309, 1052688,
|
||||
986895, 1052688, 1315860, 855309, 855309, 855309, 723723, 789516, 1052688, 1710618, 1973790, 1842204, 1973790, 2302755, 2434341, 2434341, 2302755, 1973790, 1842204, 1842204, 1842204, 1973790, 1907997, 2236962, 1907997, 1776411, 1907997, 1907997, 1973790, 2105376, 2236962, 1776411, 1052688, 855309, 855309, 1184274, 1052688, 986895, 1184274, 986895,
|
||||
328965, 657930, 1052688, 1052688, 855309, 855309, 723723, 921102, 2105376, 2236962, 1907997, 1973790, 1710618, 2368548, 2434341, 2434341, 2368548, 2236962, 1842204, 1710618, 1842204, 1842204, 1907997, 1973790, 1907997, 1842204, 1776411, 1710618, 1776411, 1776411, 2171169, 2368548, 1907997, 855309, 986895, 1052688, 986895, 1118481, 1052688, 723723,
|
||||
131586, 131586, 855309, 1118481, 1052688, 1118481, 1447446, 1907997, 1842204, 2105376, 1907997, 1776411, 1776411, 2171169, 2500134, 2171169, 2171169, 2236962, 1907997, 1907997, 2105376, 2105376, 2171169, 1973790, 1842204, 1776411, 1842204, 1776411, 1842204, 1842204, 2171169, 2105376, 2434341, 2105376, 1118481, 1052688, 1381653, 1315860, 657930, 328965,
|
||||
65793, 131586, 263172, 657930, 855309, 1579032, 2236962, 2171169, 1776411, 1776411, 2105376, 1842204, 1776411, 1973790, 2631720, 2434341, 2302755, 2368548, 2105376, 1842204, 1776411, 2236962, 2171169, 1842204, 1842204, 1776411, 1842204, 1842204, 1842204, 2105376, 2105376, 2105376, 2500134, 2631720, 1907997, 1381653, 1052688, 789516, 263172, 197379,
|
||||
65793, 131586, 131586, 131586, 526344, 1644825, 2105376, 1842204, 1907997, 1776411, 1907997, 2105376, 1842204, 1973790, 2105376, 2368548, 2236962, 2302755, 2368548, 2171169, 1513239, 2105376, 2171169, 1776411, 1644825, 1710618, 1644825, 1842204, 1973790, 1973790, 1842204, 2105376, 2236962, 2236962, 2565927, 2105376, 657930, 131586, 131586, 328965,
|
||||
65793, 131586, 197379, 131586, 197379, 1315860, 1973790, 1973790, 1907997, 1907997, 1907997, 1842204, 1842204, 1973790, 2171169, 2236962, 2302755, 2434341, 2302755, 855309, 263172, 1184274, 1842204, 1973790, 1842204, 1710618, 1907997, 1842204, 1842204, 1973790, 1973790, 1842204, 2105376, 2302755, 2105376, 1184274, 328965, 197379, 131586, 263172,
|
||||
65793, 131586, 131586, 65793, 0, 197379, 1250067, 2105376, 1973790, 1907997, 1973790, 1776411, 1842204, 2236962, 2171169, 2105376, 2500134, 2171169, 789516, 131586, 197379, 197379, 1184274, 2171169, 1907997, 1907997, 1842204, 1710618, 1710618, 1842204, 1907997, 1842204, 2171169, 2368548, 1315860, 65793, 263172, 394758, 263172, 197379,
|
||||
65793, 131586, 131586, 131586, 65793, 0, 263172, 1315860, 1907997, 1907997, 1842204, 1907997, 1973790, 2302755, 2302755, 2236962, 2171169, 855309, 131586, 131586, 263172, 131586, 197379, 1052688, 1973790, 1907997, 1710618, 1710618, 1907997, 1842204, 1907997, 1973790, 1973790, 986895, 131586, 197379, 394758, 394758, 263172, 131586,
|
||||
65793, 197379, 65793, 131586, 131586, 131586, 65793, 394758, 1579032, 1907997, 1907997, 1907997, 1973790, 2171169, 2565927, 2171169, 1118481, 263172, 131586, 197379, 197379, 131586, 131586, 197379, 1118481, 1776411, 1776411, 1776411, 1842204, 1907997, 1973790, 1973790, 1052688, 131586, 263172, 328965, 394758, 328965, 197379, 197379,
|
||||
131586, 131586, 131586, 197379, 131586, 131586, 131586, 592137, 1644825, 1973790, 1842204, 1973790, 1973790, 2236962, 2500134, 2368548, 1447446, 263172, 65793, 197379, 197379, 131586, 131586, 394758, 1447446, 1776411, 1776411, 1842204, 1907997, 1973790, 2105376, 2171169, 1513239, 394758, 328965, 460551, 460551, 328965, 197379, 263172,
|
||||
197379, 197379, 197379, 328965, 197379, 131586, 592137, 1710618, 2368548, 2302755, 1907997, 1907997, 2236962, 2434341, 2368548, 2434341, 2236962, 1052688, 131586, 65793, 197379, 131586, 328965, 1579032, 2302755, 1973790, 1842204, 1842204, 1842204, 1907997, 2105376, 2302755, 2500134, 1907997, 657930, 394758, 394758, 394758, 394758, 328965,
|
||||
131586, 131586, 131586, 197379, 131586, 526344, 1776411, 2302755, 2434341, 2368548, 2171169, 1842204, 2302755, 2894892, 2302755, 2236962, 2171169, 1907997, 1118481, 197379, 131586, 394758, 1513239, 2236962, 2171169, 2105376, 2105376, 1842204, 1710618, 1842204, 1907997, 1907997, 2368548, 2565927, 1644825, 592137, 197379, 394758, 328965, 328965,
|
||||
65793, 131586, 131586, 65793, 526344, 1842204, 2302755, 2236962, 2302755, 2302755, 2105376, 2105376, 2434341, 2894892, 2302755, 2105376, 1973790, 2105376, 2105376, 1381653, 592137, 1644825, 2236962, 2302755, 2105376, 1973790, 2171169, 2171169, 2105376, 2105376, 1973790, 1973790, 2171169, 2565927, 2565927, 1973790, 657930, 460551, 460551, 263172,
|
||||
0, 65793, 65793, 263172, 855309, 1776411, 2434341, 2105376, 2236962, 2105376, 2302755, 2302755, 2368548, 2368548, 2105376, 2105376, 1973790, 2171169, 2302755, 2829099, 2565927, 2302755, 2500134, 2105376, 2105376, 1842204, 2171169, 2368548, 2302755, 2368548, 2171169, 1907997, 2368548, 2500134, 2894892, 1842204, 1579032, 789516, 197379, 263172,
|
||||
0, 0, 197379, 789516, 1052688, 921102, 1710618, 2302755, 2105376, 2171169, 2302755, 2236962, 2105376, 2105376, 2302755, 2171169, 2171169, 2302755, 2105376, 2434341, 2302755, 2171169, 2302755, 2105376, 2105376, 1973790, 2105376, 2302755, 2302755, 2368548, 2434341, 2368548, 2500134, 3158064, 1973790, 1118481, 1907997, 1315860, 328965, 131586,
|
||||
65793, 263172, 986895, 1184274, 1052688, 855309, 921102, 1644825, 2368548, 2631720, 2302755, 2236962, 2171169, 2302755, 2565927, 2368548, 2105376, 2105376, 1907997, 1907997, 1973790, 1776411, 2105376, 2171169, 2171169, 2105376, 1907997, 2302755, 2500134, 2434341, 2236962, 2434341, 2829099, 2434341, 1513239, 1184274, 1644825, 1776411, 921102, 394758,
|
||||
657930, 1052688, 1381653, 1184274, 1052688, 1052688, 855309, 855309, 2105376, 2368548, 2105376, 1973790, 2171169, 2302755, 2565927, 2302755, 2171169, 1907997, 1776411, 1710618, 1776411, 1973790, 1842204, 2105376, 2236962, 2105376, 1907997, 1842204, 1776411, 2236962, 2368548, 2500134, 1973790, 1184274, 1513239, 1710618, 1250067, 1381653, 1776411, 1118481,
|
||||
855309, 921102, 1118481, 1118481, 1184274, 1052688, 986895, 855309, 855309, 2631720, 2105376, 2105376, 2105376, 1973790, 2236962, 2302755, 2105376, 1907997, 2171169, 1907997, 1710618, 1842204, 1842204, 1842204, 2236962, 1842204, 1842204, 1710618, 1776411, 1842204, 1842204, 1579032, 1118481, 1513239, 1250067, 1579032, 1579032, 1513239, 1644825, 1052688,
|
||||
986895, 855309, 723723, 1052688, 1052688, 1052688, 1250067, 1052688, 986895, 1052688, 1644825, 1907997, 1973790, 2302755, 2236962, 2236962, 2236962, 2236962, 1973790, 1907997, 1907997, 1710618, 2105376, 2302755, 2105376, 2105376, 2105376, 2105376, 1973790, 1973790, 1315860, 789516, 1118481, 1513239, 1579032, 1381653, 1513239, 1118481, 1052688, 1315860,
|
||||
855309, 855309, 855309, 855309, 986895, 1184274, 1052688, 1118481, 1052688, 921102, 855309, 1842204, 2368548, 2302755, 2236962, 2105376, 2105376, 2236962, 2171169, 1973790, 1907997, 1842204, 2105376, 2434341, 2236962, 2171169, 2302755, 2434341, 2500134, 1776411, 986895, 855309, 1118481, 1250067, 1513239, 1776411, 1184274, 855309, 1052688, 1118481,
|
||||
855309, 789516, 1052688, 1052688, 1052688, 1381653, 1250067, 1315860, 1447446, 1052688, 855309, 1052688, 1973790, 2302755, 2105376, 1973790, 2105376, 2171169, 2302755, 2171169, 1710618, 2105376, 2171169, 2171169, 2500134, 2631720, 2105376, 2434341, 1907997, 1052688, 1118481, 1513239, 1579032, 1579032, 1776411, 1776411, 1184274, 789516, 986895, 1184274,
|
||||
986895, 855309, 789516, 1052688, 1250067, 1644825, 1776411, 1579032, 1184274, 1052688, 1052688, 986895, 1315860, 1776411, 2171169, 2171169, 2105376, 2302755, 2368548, 1315860, 592137, 1710618, 2236962, 2236962, 2171169, 2500134, 2171169, 1710618, 1315860, 1184274, 1644825, 1776411, 1776411, 1776411, 1644825, 1579032, 1184274, 921102, 855309, 1315860,
|
||||
921102, 1052688, 1052688, 1184274, 1315860, 1250067, 1842204, 1776411, 1250067, 1184274, 1118481, 1052688, 986895, 1052688, 1710618, 2302755, 2302755, 2302755, 1315860, 263172, 65793, 526344, 1644825, 2368548, 2631720, 2434341, 1644825, 1052688, 1315860, 1644825, 1579032, 1710618, 1579032, 1447446, 1052688, 921102, 1315860, 1118481, 1118481, 1315860,
|
||||
855309, 1184274, 1513239, 1315860, 1052688, 1118481, 1184274, 1513239, 1579032, 1381653, 1118481, 986895, 986895, 986895, 1052688, 1907997, 2302755, 1184274, 263172, 131586, 131586, 131586, 460551, 1973790, 2829099, 2171169, 1052688, 1184274, 1315860, 1381653, 1644825, 1644825, 1842204, 1250067, 986895, 1184274, 1052688, 1250067, 1513239, 1250067,
|
||||
394758, 657930, 1644825, 1381653, 1315860, 1184274, 1184274, 1184274, 1315860, 1381653, 1052688, 1052688, 1052688, 1184274, 1118481, 1118481, 1052688, 328965, 131586, 197379, 131586, 131586, 197379, 592137, 2105376, 1710618, 1447446, 1184274, 1052688, 1250067, 1447446, 1579032, 1513239, 1513239, 1250067, 1513239, 1579032, 1513239, 1118481, 592137,
|
||||
197379, 197379, 657930, 1381653, 1513239, 1315860, 1315860, 1250067, 789516, 855309, 1250067, 1250067, 1052688, 1513239, 1315860, 657930, 328965, 328965, 328965, 263172, 263172, 197379, 328965, 526344, 855309, 1513239, 1973790, 1710618, 1315860, 1579032, 1381653, 1184274, 1447446, 2368548, 1907997, 2105376, 2500134, 1644825, 657930, 131586,
|
||||
197379, 131586, 131586, 657930, 1710618, 1776411, 1447446, 1052688, 855309, 855309, 921102, 1118481, 1579032, 1447446, 855309, 328965, 328965, 394758, 328965, 263172, 131586, 197379, 263172, 460551, 657930, 789516, 1710618, 2236962, 2105376, 1447446, 1250067, 1381653, 1776411, 2368548, 2631720, 3026478, 2236962, 789516, 263172, 131586,
|
||||
197379, 197379, 131586, 197379, 1381653, 1973790, 1579032, 1184274, 1052688, 921102, 855309, 1052688, 1447446, 1052688, 328965, 131586, 328965, 460551, 460551, 328965, 131586, 263172, 197379, 328965, 460551, 460551, 921102, 2236962, 2105376, 1447446, 1118481, 1250067, 1513239, 2434341, 2302755, 2565927, 1052688, 131586, 131586, 131586,
|
||||
197379, 131586, 131586, 131586, 328965, 1052688, 1447446, 1644825, 1250067, 1052688, 1184274, 1052688, 855309, 394758, 263172, 197379, 131586, 263172, 328965, 263172, 197379, 131586, 197379, 197379, 263172, 592137, 657930, 921102, 1118481, 1250067, 1118481, 1118481, 1710618, 1973790, 1250067, 855309, 263172, 131586, 197379, 131586,
|
||||
};
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_benchmark.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_BENCHMARK_H
|
||||
#define LV_APP_BENCHMARK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_benchmark_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_benchmark_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_BENCHMARK_H */
|
||||
@@ -1,216 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_example.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static void kb_ok_action(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Example",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_example_init(void)
|
||||
{
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
my_sc_data_t * sc_data = app_rec->sc_data;
|
||||
if (sc_data->label != NULL) {
|
||||
lv_label_set_text_array(sc_data->label, data, size);
|
||||
lv_obj_align(sc_data->label , NULL,LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
lv_obj_t * ta;
|
||||
ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size_us(ta, 200, 100);
|
||||
lv_obj_set_pos_us(ta, 0, 0);
|
||||
lv_obj_set_free_p(ta, app);
|
||||
lv_page_set_rel_action(ta, ta_rel_action);
|
||||
lv_ta_set_text(ta, "Write a text to send to the other applications");
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called when the text area on the window is released to open the app. keyboard
|
||||
* @param ta pointer to the text area on the window
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the text area is not deleted
|
||||
*/
|
||||
static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_ta_set_text(ta, ""); /*Clear the ta*/
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, kb_ok_action);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the "Ok" button is pressed on the app. keyboard
|
||||
* @param ta pointer to the text area assigned to the app. kexboard
|
||||
*/
|
||||
static void kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
const char * txt = lv_ta_get_txt(ta);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, txt, strlen(txt));
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,897 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_files.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "misc/os/ptask.h"
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "../lv_app/lv_app_util/lv_app_notice.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_APP_FILES_CHUNK_MIN_SIZE 32
|
||||
#define LV_APP_FILES_CHUNK_MIN_TIME 10
|
||||
#define LV_APP_FILES_CHUNK_MAX_TIME 10000
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char path[LV_APP_FILES_PATH_MAX_LEN];
|
||||
char fn[LV_APP_FILES_FN_MAX_LEN];
|
||||
fs_file_t file;
|
||||
uint8_t file_cnt;
|
||||
uint16_t chunk_delay;
|
||||
uint16_t chunk_size;
|
||||
uint8_t send_fn :1;
|
||||
uint8_t send_size :1;
|
||||
uint8_t send_crc :1;
|
||||
uint8_t send_in_prog :1;
|
||||
ptask_t * send_task;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * file_list;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SEND_SETTINGS_FN,
|
||||
SEND_SETTINGS_SIZE,
|
||||
SEND_SETTINGS_CRC,
|
||||
SEND_SETTINGS_CHUNK_SIZE,
|
||||
SEND_SETTINGS_CHUNK_DELAY,
|
||||
}send_settings_id_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win);
|
||||
|
||||
static void win_load_file_list(lv_app_inst_t * app);
|
||||
static void win_create_list(lv_app_inst_t * app);
|
||||
static lv_action_res_t win_up_action(lv_obj_t * up, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_next_action(lv_obj_t * next, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_prev_action(lv_obj_t * prev, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_drv_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_folder_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_file_action(lv_obj_t * file, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_send_rel_action(lv_obj_t * send, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_send_settings_element_rel_action(lv_obj_t * element, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_back_action(lv_obj_t * back, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_del_rel_action(lv_obj_t * del, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_del_lpr_action(lv_obj_t * del, lv_dispi_t * dispi);
|
||||
static void send_settings_kb_close_action(lv_obj_t * ta);
|
||||
static void send_settings_kb_ok_action(lv_obj_t * ta);
|
||||
static void start_send(lv_app_inst_t * app, const char * path);
|
||||
static void send_task(void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Files",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.conf_open = my_conf_open,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_style_t style_sc_label;
|
||||
static lv_style_t style_btn_symbol;
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_files_init(void)
|
||||
{
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
memcpy(&style_sc_label, &app_style->sc_rec_rel, sizeof(lv_style_t));
|
||||
style_sc_label.font = font_get(LV_APP_FONT_LARGE);
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol);
|
||||
style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
app_data->file_cnt = 0;
|
||||
app_data->path[0] = '\0';
|
||||
app_data->fn[0] = '\0';
|
||||
app_data->send_fn = 0;
|
||||
app_data->send_size = 0;
|
||||
app_data->send_crc = 0;
|
||||
app_data->chunk_size = LV_APP_FILES_CHUNK_DEF_SIZE;
|
||||
app_data->chunk_delay = LV_APP_FILES_CHUNK_DEF_TIME;
|
||||
app_data->send_in_prog = 0;
|
||||
|
||||
app_data->send_task = ptask_create(send_task, LV_APP_FILES_CHUNK_DEF_TIME, PTASK_PRIO_OFF, app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
ptask_del(app_data->send_task);
|
||||
if(app_data->send_in_prog != 0) fs_close(&app_data->file);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) {
|
||||
/*Check for file query. E.g. "U:/file.txt?"*/
|
||||
const char * path = data;
|
||||
if(path[size - 1] == '?') {
|
||||
if(size > LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN) {
|
||||
lv_app_notice_add("Can not send file:\ntoo long path");
|
||||
}
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
memcpy(path_fn, data, size - 1); /*-1 to ignore the '?' at the end*/
|
||||
path_fn[size - 1] = '\0';
|
||||
start_send(app_rec, path_fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_obj_set_style(sc_data->label, &style_sc_label);
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->file_cnt = 0;
|
||||
win_data->file_list = NULL;
|
||||
|
||||
lv_win_set_title(win, app_data->path);
|
||||
|
||||
win_load_file_list(app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create objects to configure the applications
|
||||
* @param app pointer to an application which settings should be created
|
||||
* @param conf_win pointer to a window where the objects can be created
|
||||
* (the window has the proper layout)
|
||||
*/
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Create check boxes*/
|
||||
lv_obj_t * cb;
|
||||
|
||||
/*Send file name check box*/
|
||||
cb = lv_cb_create(conf_win, NULL);
|
||||
lv_cb_set_text(cb, "Send file name");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_FN);
|
||||
lv_obj_set_free_p(cb, app);
|
||||
lv_btn_set_rel_action(cb, win_send_settings_element_rel_action);
|
||||
if(app_data->send_fn != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Send size check box*/
|
||||
cb = lv_cb_create(conf_win, cb);
|
||||
lv_cb_set_text(cb, "Send size");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_SIZE);
|
||||
if(app_data->send_size != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Send CRC check box*/
|
||||
cb = lv_cb_create(conf_win, cb);
|
||||
lv_cb_set_text(cb, "Send CRC");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_CRC);
|
||||
if(app_data->send_crc != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Create a text area to type chunk size*/
|
||||
lv_obj_t * val_set_h;
|
||||
val_set_h = lv_cont_create(conf_win, NULL);
|
||||
lv_obj_set_style(val_set_h, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
|
||||
lv_obj_set_click(val_set_h, false);
|
||||
lv_cont_set_fit(val_set_h, true, true);
|
||||
lv_cont_set_layout(val_set_h, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
lv_label_set_text(label, "Chunk size");
|
||||
|
||||
lv_obj_t * ta;
|
||||
char buf[32];
|
||||
ta = lv_ta_create(val_set_h, NULL);
|
||||
lv_cont_set_fit(ta, false, true);
|
||||
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_SIZE);
|
||||
lv_obj_set_free_p(ta, app);
|
||||
lv_page_set_rel_action(ta, win_send_settings_element_rel_action);
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
lv_ta_set_text(ta, buf);
|
||||
|
||||
/*Create a text area to type the chunk delay*/
|
||||
val_set_h = lv_cont_create(conf_win, val_set_h);
|
||||
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
lv_label_set_text(label, "Inter-chunk delay");
|
||||
|
||||
ta = lv_ta_create(val_set_h, ta);
|
||||
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_DELAY);
|
||||
sprintf(buf, "%d", app_data->chunk_delay);
|
||||
lv_ta_set_text(ta, buf);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
/**
|
||||
* Create an mpty list on the window. 'win_load_file_list' will fill it.
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void win_create_list(lv_app_inst_t * app)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Delete the previous list*/
|
||||
if(win_data->file_list != NULL) {
|
||||
lv_obj_del(win_data->file_list);
|
||||
}
|
||||
|
||||
/*Create a new list*/
|
||||
win_data->file_list = lv_list_create(app->win, NULL);
|
||||
lv_obj_set_width(win_data->file_list, lv_win_get_width(app->win));
|
||||
lv_list_set_style_img(win_data->file_list, &style_btn_symbol);
|
||||
lv_obj_set_style(lv_page_get_scrl(win_data->file_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_drag_parent(win_data->file_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(win_data->file_list), true);
|
||||
lv_cont_set_fit(win_data->file_list, false, true);
|
||||
lv_cont_set_layout(lv_page_get_scrl(win_data->file_list), LV_CONT_LAYOUT_COL_L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file list from the current path on the window
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void win_load_file_list(lv_app_inst_t * app)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Create a new list*/
|
||||
win_create_list(app);
|
||||
|
||||
fs_res_t res = FS_RES_OK;
|
||||
|
||||
/*At empty path show the drivers */
|
||||
lv_obj_t * liste;
|
||||
if(app_data->path[0] == '\0') {
|
||||
char drv[16];
|
||||
char buf[2];
|
||||
fs_get_letters(drv);
|
||||
uint8_t i;
|
||||
for(i = 0; drv[i] != '\0'; i++) {
|
||||
buf[0] = drv[i];
|
||||
buf[1] = '\0';
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_DRIVE, buf, win_drv_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
}
|
||||
}
|
||||
/*List the files/folders with fs interface*/
|
||||
else {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_UP, "Up", win_up_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
fs_readdir_t rd;
|
||||
res = fs_readdir_init(&rd, app_data->path);
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the\npath in Files");
|
||||
return;
|
||||
}
|
||||
|
||||
/*At not first page add prev. page button */
|
||||
if(app_data->file_cnt != 0) {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_LEFT, "Previous page", win_prev_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
}
|
||||
|
||||
char fn[LV_APP_FILES_FN_MAX_LEN];
|
||||
|
||||
/*Read the files from the previous pages*/
|
||||
uint16_t file_cnt = 0;
|
||||
while(file_cnt <= app_data->file_cnt) {
|
||||
res = fs_readdir(&rd, fn);
|
||||
if(res != FS_RES_OK ){
|
||||
lv_app_notice_add("Can not read\nthe path in Files");
|
||||
return;
|
||||
}
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Add list elements from the files and folders*/
|
||||
while(res == FS_RES_OK && fn[0] != '\0') {
|
||||
if(fn[0] == '/') { /*Add a folder*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_FOLDER, &fn[1], win_folder_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
app_data->file_cnt ++;
|
||||
}
|
||||
/*Add a file*/
|
||||
else {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_FILE, fn, win_file_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
app_data->file_cnt ++;
|
||||
}
|
||||
|
||||
/*Get the next element*/
|
||||
res = fs_readdir(&rd, fn);
|
||||
|
||||
/*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/
|
||||
if(app_data->file_cnt != 0 && app_data->file_cnt % LV_APP_FILES_PAGE_SIZE == 0) {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_RIGHT, "Next page", win_next_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Close the read directory*/
|
||||
fs_readdir_close(&rd);
|
||||
}
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read\nthe path in Files");
|
||||
}
|
||||
|
||||
/*Focus to the top of the list*/
|
||||
lv_obj_set_y(lv_page_get_scrl(win_data->file_list), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Up list element is released to step one level
|
||||
* @param up pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_up_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(up);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
fs_up(app_data->path);
|
||||
app_data->file_cnt = 0;
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Next list element is released to go to the next page
|
||||
* @param next pointer to the Next button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_next_action(lv_obj_t * next, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(next);
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Prev list element is released to previous page
|
||||
* @param prev pointer to the Prev button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_prev_action(lv_obj_t * prev, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(prev);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
if(app_data->file_cnt <= 2 * LV_APP_FILES_PAGE_SIZE) app_data->file_cnt = 0;
|
||||
else if(app_data->file_cnt % LV_APP_FILES_PAGE_SIZE == 0) {
|
||||
app_data->file_cnt -= 2 * LV_APP_FILES_PAGE_SIZE;
|
||||
} else {
|
||||
app_data->file_cnt = ((app_data->file_cnt / LV_APP_FILES_PAGE_SIZE) - 1) * LV_APP_FILES_PAGE_SIZE;
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is released to step into a driver
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_drv_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(drv);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
sprintf(app_data->path, "%s:", lv_list_get_element_text(drv));
|
||||
app_data->file_cnt = 0;
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a folder list element is released to enter into it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_folder_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(folder);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
sprintf(app_data->path, "%s/%s", app_data->path, lv_list_get_element_text(folder));
|
||||
app_data->file_cnt = 0;
|
||||
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a file list element is released to show the list of operation on it
|
||||
* @param file pointer to a file button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_file_action(lv_obj_t * file, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(file);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
sprintf(app_data->fn, "%s", lv_list_get_element_text(file));
|
||||
|
||||
win_create_list(app);
|
||||
|
||||
/*Create the list of operations*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(win_data->file_list, "U:/icon_left", "Back", win_back_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
/*Send button*/
|
||||
liste = lv_list_add(win_data->file_list, NULL, "Send", win_send_rel_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
/*Delete button*/
|
||||
liste = lv_list_add(win_data->file_list, NULL, "Delete", win_del_rel_action);
|
||||
lv_btn_set_lpr_action(liste, win_del_lpr_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Back list element is released to when a file chosen to
|
||||
* go back to the file list from file operation
|
||||
* @param back pointer to the back button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_back_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(up);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->file_cnt = 0;
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Send list element is released to send the file
|
||||
* @param sed pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_send_rel_action(lv_obj_t * send, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(send);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(app_data->send_in_prog != 0) {
|
||||
lv_app_notice_add("File sending\nin progress");
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
sprintf(path_fn, "%s/%s", app_data->path, app_data->fn);
|
||||
start_send(app, path_fn);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send settings element is released
|
||||
* @param element pointer to a chekbox or text area
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_send_settings_element_rel_action(lv_obj_t * element, lv_dispi_t * dispi)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(element);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(element);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(id == SEND_SETTINGS_FN) {
|
||||
app_data->send_fn = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
} else if(id == SEND_SETTINGS_SIZE) {
|
||||
app_data->send_size = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
} else if(id == SEND_SETTINGS_CRC) {
|
||||
app_data->send_crc = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
|
||||
/*TODO CRC sending is not supported yet*/
|
||||
if(app_data->send_crc != 0) {
|
||||
lv_app_notice_add("CRC sending is\nnot supported yet");
|
||||
}
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action);
|
||||
} else if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Delete list element is released.
|
||||
* It will show a notification to long press the Delete button to remove the file
|
||||
* @param del pointer to the back button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_del_rel_action(lv_obj_t * del, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_notice_add("Press long the Delete button\n"
|
||||
"to remove the file");
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
/**
|
||||
* Called when the Delete list element is long pressed to remove a file
|
||||
* @param del pointer to the Delete button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_del_lpr_action(lv_obj_t * del, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(del);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
sprintf(path_fn, "%s/%s", app_data->path, app_data->fn);
|
||||
|
||||
fs_res_t res = fs_remove(path_fn);
|
||||
if(res == FS_RES_OK) lv_app_notice_add("%s deleted", app_data->fn);
|
||||
else lv_app_notice_add("Can not delete\n%s", app_data->fn);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send setting is typed and 'Close' pressed on the App. keyboard.
|
||||
* The function reverts the original value in the text area.
|
||||
* @param ta pointer to a text area
|
||||
*/
|
||||
static void send_settings_kb_close_action(lv_obj_t * ta)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(ta);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
char buf[32];
|
||||
buf[0] = '\0';
|
||||
|
||||
if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
}
|
||||
lv_ta_set_text(ta, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send setting is typed and 'Ok' pressed on the App. keyboard.
|
||||
* The function saves teh new value.
|
||||
* @param ta pointer to a text area
|
||||
*/
|
||||
static void send_settings_kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(ta);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
int num;
|
||||
sscanf(lv_ta_get_txt(ta), "%d", &num);
|
||||
|
||||
if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
if(num > LV_APP_FILES_CHUNK_MAX_TIME) num = LV_APP_FILES_CHUNK_MAX_TIME;
|
||||
if(num < LV_APP_FILES_CHUNK_MIN_TIME) num = LV_APP_FILES_CHUNK_MIN_TIME;
|
||||
app_data->chunk_delay = (uint16_t) num;
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
if(num > LV_APP_FILES_CHUNK_MAX_SIZE) num = LV_APP_FILES_CHUNK_MAX_SIZE;
|
||||
if(num < LV_APP_FILES_CHUNK_MIN_SIZE) num = LV_APP_FILES_CHUNK_MIN_SIZE;
|
||||
app_data->chunk_size= (uint16_t) num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the sending of a file
|
||||
* @param app pointer to a Files application
|
||||
* @param path path of the file to send
|
||||
*/
|
||||
static void start_send(lv_app_inst_t * app, const char * path)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Open the file*/
|
||||
fs_res_t res = fs_open(&app_data->file, path, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
app_data->send_in_prog = 1;
|
||||
|
||||
/*Send the header*/
|
||||
if(app_data->send_fn != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, app_data->path, strlen(app_data->path));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "/", 1);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, app_data->fn, strlen(app_data->fn));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
|
||||
if(app_data->send_size != 0) {
|
||||
char buf[64];
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
sprintf(buf,"%d", (int) size);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, buf, strlen(buf));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
if(app_data->send_crc != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "0x0000", 6);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
|
||||
/*Add an extra \n to separate the header from the file data*/
|
||||
if(app_data->send_fn != 0 || app_data->send_size != 0 || app_data->send_crc != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*If an error occurred close the file*/
|
||||
if(res != FS_RES_OK) {
|
||||
fs_close(&app_data->file);
|
||||
ptask_set_prio(app_data->send_task, PTASK_PRIO_OFF);
|
||||
app_data->send_in_prog = 0;
|
||||
lv_app_notice_add("Can not send\nthe file in Files");
|
||||
}
|
||||
/*If no error show notification, start the sender task and refresh the shortcut*/
|
||||
else {
|
||||
/*Start the sender task*/
|
||||
ptask_set_period(app_data->send_task, app_data->chunk_delay);
|
||||
ptask_reset(app_data->send_task);
|
||||
ptask_set_prio(app_data->send_task, PTASK_PRIO_HIGH);
|
||||
lv_app_notice_add("Sending\n%s", fs_get_last(path));
|
||||
|
||||
/*Refresh the shortcut with the percentage of the sending*/
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
uint32_t pos;
|
||||
fs_tell(&app_data->file, &pos);
|
||||
|
||||
int pct = (uint32_t) (pos * 100) / size;
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "Sending\n%d%%", pct);
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Periodically send the next chunk of the file
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void send_task(void * param)
|
||||
{
|
||||
lv_app_inst_t * app = param;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(app_data->send_in_prog == 0) return;
|
||||
|
||||
/*Read a chunk*/
|
||||
uint32_t rn;
|
||||
char rd_buf[LV_APP_FILES_CHUNK_MAX_SIZE];
|
||||
fs_res_t res = fs_read(&app_data->file, rd_buf, app_data->chunk_size, &rn);
|
||||
if(res == FS_RES_OK) {
|
||||
app_data->send_in_prog = 1;
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, rd_buf, rn);
|
||||
}
|
||||
|
||||
/*If the read failed close the file and show an error*/
|
||||
if(res != FS_RES_OK) {
|
||||
fs_close(&app_data->file);
|
||||
app_data->send_in_prog = 0;
|
||||
lv_app_notice_add("Can not send\nthe file in Files");
|
||||
}
|
||||
/*If the read was successful*/
|
||||
else {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
/*If the file is read close it a show a notification*/
|
||||
if(rn < app_data->chunk_size) {
|
||||
lv_app_notice_add("File sent");
|
||||
fs_close(&app_data->file);
|
||||
app_data->send_in_prog = 0;
|
||||
|
||||
/*Refresh the shortut*/
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
/*If the file is not sent yet refresh the shortcut with percentage of sending*/
|
||||
else {
|
||||
if(sc_data != NULL) {
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
uint32_t pos;
|
||||
fs_tell(&app_data->file, &pos);
|
||||
|
||||
uint8_t pct = (uint32_t) (pos * 100) / size;
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "Sending\n%d%%", pct);
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0*/
|
||||
@@ -1,381 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_gsm.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_gsm.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_GSM != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "hal/gsm/gsm.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "misc/comm/gsmmng.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define GSM_MONITOR_PERIOD 1000 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char set_apn[128];
|
||||
char set_ip[32];
|
||||
char set_port[16];
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * netw_apn_ta;
|
||||
lv_obj_t * tcp_ip_ta;
|
||||
lv_obj_t * tcp_port_ta;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void gsm_state_monitor_task(void * param);
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t netw_apn_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
|
||||
static void netw_apn_kb_ok(lv_obj_t * ta);
|
||||
static void netw_apn_kb_close(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta);
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_port_kb_close(lv_obj_t * ta);
|
||||
|
||||
static void tcp_transf_cb(gsm_state_t state, const char * txt);
|
||||
|
||||
static void win_title_refr(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "GSM",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_app_inst_t * app_act_com;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_gsm_init(void)
|
||||
{
|
||||
|
||||
gsmmng_set_last_apn(LV_APP_GSM_APN_DEF);
|
||||
gsmmng_set_last_tcp(LV_APP_GSM_IP_DEF, LV_APP_GSM_PORT_DEF);
|
||||
|
||||
ptask_create(gsm_state_monitor_task, GSM_MONITOR_PERIOD, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_apn, LV_APP_GSM_APN_DEF);
|
||||
strcpy(adata->set_ip, LV_APP_GSM_IP_DEF);
|
||||
strcpy(adata->set_port, LV_APP_GSM_PORT_DEF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
app_act_com = app_rec;
|
||||
gsm_tcp_transf(data, size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_app_data_t * adata = app->app_data;
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
wdata->title = lv_label_create(win, NULL);
|
||||
|
||||
lv_obj_t * ta_cont = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(ta_cont, true, true);
|
||||
lv_cont_set_layout(ta_cont, LV_CONT_LAYOUT_COL_L);
|
||||
lv_obj_set_style(ta_cont, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
|
||||
wdata->netw_apn_ta = lv_ta_create(ta_cont, NULL);
|
||||
lv_cont_set_fit(wdata->netw_apn_ta, false, true);
|
||||
lv_obj_set_free_p(wdata->netw_apn_ta, app);
|
||||
lv_obj_set_width(wdata->netw_apn_ta, LV_DPI * 3);
|
||||
lv_page_set_rel_action(wdata->netw_apn_ta, netw_apn_rel_action);
|
||||
lv_ta_set_text(wdata->netw_apn_ta, adata->set_apn);
|
||||
lv_ta_set_cursor_show(wdata->netw_apn_ta, false);
|
||||
|
||||
wdata->tcp_ip_ta = lv_ta_create(ta_cont, wdata->netw_apn_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_ip_ta, tcp_ip_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_ip_ta, adata->set_ip);
|
||||
|
||||
wdata->tcp_port_ta = lv_ta_create(ta_cont, wdata->netw_apn_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_port_ta, tcp_port_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_port_ta, adata->set_port);
|
||||
|
||||
lv_obj_t * con_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(con_btn, app);
|
||||
lv_btn_set_rel_action(con_btn, netw_con_rel_action);
|
||||
lv_obj_t * label = lv_label_create(con_btn, NULL);
|
||||
lv_label_set_text(label, "Connect");
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void gsm_state_monitor_task(void * param)
|
||||
{
|
||||
static gsmmng_state_t state_prev = GSMMNG_STATE_WAIT;
|
||||
gsmmng_state_t state_act = gsmmng_get_state();
|
||||
|
||||
if(state_prev != state_act && state_act == GSMMNG_STATE_READY) {
|
||||
lv_app_notice_add("GSM connected to:\n%s\n%s:%s",
|
||||
gsmmng_get_last_apn(), gsmmng_get_last_ip(), gsmmng_get_last_port());
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
state_prev = state_act;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
gsmmng_set_last_apn(adata->set_apn);
|
||||
gsmmng_set_last_tcp(adata->set_ip, adata->set_port);
|
||||
gsmmng_reconnect();
|
||||
lv_app_notice_add("Connecting to GSM network\n%s, %s:%s",
|
||||
adata->set_apn, adata->set_ip, adata->set_port);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_apn_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_apn_kb_close ,netw_apn_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_ip_kb_close ,tcp_ip_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_port_kb_close ,tcp_port_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static void netw_apn_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_apn, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_apn_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_apn);
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ip, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ip);
|
||||
}
|
||||
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_port, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_port_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_port);
|
||||
}
|
||||
|
||||
static void tcp_transf_cb(gsm_state_t state, const char * txt)
|
||||
{
|
||||
if(state == GSM_STATE_OK) {
|
||||
uint16_t size = txt[0] + ((txt[1] << 8) & 0xFF00);
|
||||
char buf[256];
|
||||
memcpy(buf, &txt[2], size);
|
||||
buf[size] = '\0';
|
||||
lv_app_com_send(app_act_com, LV_APP_COM_TYPE_CHAR, &txt[2], size);
|
||||
}else if(state == GSM_STATE_ERROR) {
|
||||
lv_app_notice_add("WiFi TCP transfer error\n%s", txt);
|
||||
lv_app_notice_add("Reconnecting to WiFi...");
|
||||
gsmmng_reconnect();
|
||||
}
|
||||
|
||||
app_act_com = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void win_title_refr(void)
|
||||
{
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
if(gsmmng_get_state() != GSMMNG_STATE_READY) lv_label_set_text(wdata->title, "Not connected");
|
||||
else {
|
||||
char buf[256];
|
||||
sprintf(buf, "%s - %s:%s", gsmmng_get_last_apn(), gsmmng_get_last_ip(), gsmmng_get_last_port());
|
||||
lv_label_set_text(wdata->title, buf);
|
||||
}
|
||||
lv_obj_set_width(wdata->title, lv_win_get_width(app->win));
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_phantom.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
void (*com_listen)(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Phantom",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = NULL,
|
||||
.win_close = NULL,
|
||||
.sc_open = NULL,
|
||||
.sc_close = NULL,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_phantom_init(void)
|
||||
{
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_phantom_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
app_data->com_listen = NULL;
|
||||
|
||||
if(conf != NULL) {
|
||||
lv_app_phantom_conf_t * my_conf = conf;
|
||||
app_data->com_listen = my_conf->com_listen;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
|
||||
my_app_data_t * app_data = app_rec->app_data;
|
||||
|
||||
if(app_data->com_listen != NULL) {
|
||||
app_data->com_listen(app_send, app_rec, type, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_phantom.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_PHANTOM_H
|
||||
#define LV_APP_PHANTOM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
void (*com_listen)(lv_app_inst_t * app_send,
|
||||
lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type ,
|
||||
const void * data, uint32_t size);
|
||||
}lv_app_phantom_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_phantom_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_PHANTOM_H */
|
||||
@@ -1,399 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_sysmon.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_sysmon.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/os/idle.h"
|
||||
#include "lvgl/lv_objx/lv_chart.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_notice.h"
|
||||
#include "hal/systick/systick.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CPU_LABEL_COLOR "FF0000"
|
||||
#define MEM_LABEL_COLOR "0000FF"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * chart;
|
||||
lv_chart_dl_t * cpu_dl;
|
||||
lv_chart_dl_t * mem_dl;
|
||||
lv_obj_t * label;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * bar_cpu;
|
||||
lv_obj_t * bar_mem;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void sysmon_task(void * param);
|
||||
static void lv_app_sysmon_refr(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Sys. monitor",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static uint8_t mem_pct[LV_APP_SYSMON_PNUM];
|
||||
static uint8_t cpu_pct[LV_APP_SYSMON_PNUM];
|
||||
static lv_style_t cpu_bar_bg;
|
||||
static lv_style_t mem_bar_bg;
|
||||
static lv_style_t cpu_bar_indic;
|
||||
static lv_style_t mem_bar_indic;
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
static dm_mon_t mem_mon;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_sysmon_init(void)
|
||||
{
|
||||
ptask_create(sysmon_task, LV_APP_SYSMON_REFR_TIME, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
memset(mem_pct, 0, sizeof(mem_pct));
|
||||
memset(cpu_pct, 0, sizeof(cpu_pct));
|
||||
|
||||
/*Create bar styles for the shortcut*/
|
||||
lv_style_get(LV_STYLE_PRETTY, &cpu_bar_bg);
|
||||
cpu_bar_bg.ccolor = COLOR_MAKE(0x40, 0x00, 0x00);
|
||||
cpu_bar_bg.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
cpu_bar_bg.line_space = 0;
|
||||
cpu_bar_bg.txt_align = 1;
|
||||
cpu_bar_bg.hpad = 0;
|
||||
cpu_bar_bg.vpad = 0;
|
||||
|
||||
memcpy(&mem_bar_bg, &cpu_bar_bg, sizeof(lv_style_t));
|
||||
mem_bar_bg.ccolor = COLOR_MAKE(0x00, 0x40, 0x00);
|
||||
|
||||
lv_style_get(LV_STYLE_PRETTY_COLOR, &cpu_bar_indic);
|
||||
cpu_bar_indic.gcolor = COLOR_MARRON;
|
||||
cpu_bar_indic.mcolor = COLOR_RED;
|
||||
cpu_bar_indic.bcolor = COLOR_BLACK;
|
||||
//cpu_bar_indic.bwidth = 1 * LV_DOWNSCALE;
|
||||
cpu_bar_indic.bopa = OPA_50;
|
||||
cpu_bar_indic.hpad = 0 * LV_DOWNSCALE;
|
||||
cpu_bar_indic.vpad = 0 * LV_DOWNSCALE;
|
||||
|
||||
|
||||
memcpy(&mem_bar_indic, &cpu_bar_indic, sizeof(lv_style_t));
|
||||
mem_bar_indic.gcolor = COLOR_GREEN;
|
||||
mem_bar_indic.mcolor = COLOR_LIME;
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_sysmon_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
cord_t w = lv_obj_get_width(sc) / 5;
|
||||
|
||||
/*Create 2 bars for the CPU and the Memory*/
|
||||
sc_data->bar_cpu = lv_bar_create(sc, NULL);
|
||||
lv_obj_set_size(sc_data->bar_cpu, w, 5 * lv_obj_get_height(sc) / 8);
|
||||
lv_obj_align(sc_data->bar_cpu, NULL, LV_ALIGN_IN_BOTTOM_LEFT, w, - lv_obj_get_height(sc) / 8);
|
||||
lv_obj_set_style(sc_data->bar_cpu, &cpu_bar_bg);
|
||||
lv_bar_set_style_indic(sc_data->bar_cpu, &cpu_bar_indic);
|
||||
lv_obj_set_click(sc_data->bar_cpu, false);
|
||||
lv_bar_set_range(sc_data->bar_cpu, 0, 100);
|
||||
lv_obj_t * label = lv_label_create(sc_data->bar_cpu, NULL);
|
||||
lv_label_set_text(label, "C\nP\nU");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
sc_data->bar_mem = lv_bar_create(sc, sc_data->bar_cpu);
|
||||
lv_obj_align(sc_data->bar_mem, sc_data->bar_cpu, LV_ALIGN_OUT_RIGHT_MID, w, 0);
|
||||
lv_obj_set_style(sc_data->bar_mem, &mem_bar_bg);
|
||||
lv_bar_set_style_indic(sc_data->bar_mem, &mem_bar_indic);
|
||||
label = lv_label_create(sc_data->bar_mem, NULL);
|
||||
lv_label_set_text(label, "M\nE\nM");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_app_sysmon_refr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Make the window content responsive*/
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
/*Create a chart with two data lines*/
|
||||
win_data->chart = lv_chart_create(win, NULL);
|
||||
lv_obj_set_size(win_data->chart, LV_HOR_RES / 2, LV_VER_RES / 2);
|
||||
lv_obj_set_pos(win_data->chart, LV_DPI / 10, LV_DPI / 10);
|
||||
lv_chart_set_pnum(win_data->chart, LV_APP_SYSMON_PNUM);
|
||||
lv_chart_set_range(win_data->chart, 0, 100);
|
||||
lv_chart_set_type(win_data->chart, LV_CHART_LINE);
|
||||
lv_chart_set_dl_width(win_data->chart, 2 * LV_DOWNSCALE);
|
||||
win_data->cpu_dl = lv_chart_add_data_line(win_data->chart, COLOR_RED);
|
||||
win_data->mem_dl = lv_chart_add_data_line(win_data->chart, COLOR_BLUE);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < LV_APP_SYSMON_PNUM; i ++) {
|
||||
win_data->cpu_dl->points[i] = cpu_pct[i];
|
||||
win_data->mem_dl->points[i] = mem_pct[i];
|
||||
}
|
||||
|
||||
/*Create a label for the details of Memory and CPU usage*/
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_recolor(win_data->label, true);
|
||||
lv_obj_align(win_data->label, win_data->chart, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI / 4, 0);
|
||||
|
||||
|
||||
lv_app_sysmon_refr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called periodically to monitor the CPU and memory usage.
|
||||
* It refreshes the shortcuts and windows and also add notifications if there is any problem.
|
||||
* @param param unused
|
||||
*/
|
||||
static void sysmon_task(void * param)
|
||||
{
|
||||
/*Shift out the oldest data*/
|
||||
uint16_t i;
|
||||
for(i = 1; i < LV_APP_SYSMON_PNUM; i++) {
|
||||
mem_pct[i - 1] = mem_pct[i];
|
||||
cpu_pct[i - 1] = cpu_pct[i];
|
||||
}
|
||||
|
||||
/*Get CPU and memory information */
|
||||
uint8_t cpu_busy = 0;
|
||||
#if USE_IDLE != 0 /*Use the more precise idle module if enabled*/
|
||||
cpu_busy = 100 - idle_get();
|
||||
#else
|
||||
cpu_busy = 100 - ptask_get_idle();
|
||||
#endif
|
||||
|
||||
uint8_t mem_used_pct = 0;
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
dm_monitor(&mem_mon);
|
||||
mem_used_pct = mem_mon.pct_used;
|
||||
#endif
|
||||
|
||||
/*Add the CPU and memory data*/
|
||||
cpu_pct[LV_APP_SYSMON_PNUM - 1] = cpu_busy;
|
||||
mem_pct[LV_APP_SYSMON_PNUM - 1] = mem_used_pct;
|
||||
|
||||
/*Refresh the shortcuts and windows*/
|
||||
lv_app_sysmon_refr();
|
||||
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
|
||||
/*Handle periodic defrag. if enabled*/
|
||||
#if LV_APP_SYSMON_DEFRAG_PERIOD != 0
|
||||
static uint32_t last_defrag = 0;
|
||||
|
||||
if(systick_elaps(last_defrag) > LV_APP_SYSMON_DEFRAG_PERIOD) {
|
||||
dm_defrag();
|
||||
last_defrag = systick_get();
|
||||
}
|
||||
#endif
|
||||
/*Add notifications if something is critical*/
|
||||
static bool mem_warn_report = false;
|
||||
if(mem_mon.size_free < LV_APP_SYSMON_MEM_WARN && mem_warn_report == false) {
|
||||
mem_warn_report = true;
|
||||
lv_app_notice_add("Critically low memory");
|
||||
}
|
||||
|
||||
if(mem_mon.size_free > LV_APP_SYSMON_MEM_WARN) mem_warn_report = false;
|
||||
|
||||
static bool frag_warn_report = false;
|
||||
if(mem_mon.pct_frag > LV_APP_SYSMON_FRAG_WARN) {
|
||||
if(frag_warn_report == false) {
|
||||
frag_warn_report = true;
|
||||
lv_app_notice_add("Critical memory\nfragmentation");
|
||||
|
||||
dm_defrag(); /*Defrag. if the fragmentation is critical*/
|
||||
}
|
||||
}
|
||||
|
||||
if(mem_mon.pct_frag < LV_APP_SYSMON_FRAG_WARN) frag_warn_report = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the shortcuts and windows.
|
||||
*/
|
||||
static void lv_app_sysmon_refr(void)
|
||||
{
|
||||
|
||||
char buf_long[256];
|
||||
char buf_short[128];
|
||||
sprintf(buf_long, "%c%s CPU: %d %%%c\n\n",TXT_RECOLOR_CMD, CPU_LABEL_COLOR, cpu_pct[LV_APP_SYSMON_PNUM - 1], TXT_RECOLOR_CMD);
|
||||
sprintf(buf_short, "CPU: %d %%\n", cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
sprintf(buf_long, "%s%c%s MEMORY: %d %%%c\nTotal: %d bytes\nUsed: %d bytes\nFree: %d bytes\nFrag: %d %%",
|
||||
buf_long,
|
||||
TXT_RECOLOR_CMD,
|
||||
MEM_LABEL_COLOR,
|
||||
mem_pct[LV_APP_SYSMON_PNUM - 1],
|
||||
TXT_RECOLOR_CMD,
|
||||
(int)mem_mon.size_total,
|
||||
(int)mem_mon.size_total - mem_mon.size_free, mem_mon.size_free, mem_mon.pct_frag);
|
||||
|
||||
sprintf(buf_short, "%sMem: %d %%\nFrag: %d %%\n",
|
||||
buf_short, mem_pct[LV_APP_SYSMON_PNUM - 1], mem_mon.pct_frag);
|
||||
#else
|
||||
sprintf(buf_long, "%s%c%s MEMORY: N/A%c", buf_long, TXT_RECOLOR_CMD, MEM_LABEL_COLOR, TXT_RECOLOR_CMD);
|
||||
sprintf(buf_short, "%sMem: N/A\nFrag: N/A", buf_short);
|
||||
#endif
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
/*Refresh the windows*/
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text(win_data->label, buf_long);
|
||||
|
||||
lv_chart_set_next(win_data->chart, win_data->mem_dl, mem_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
lv_chart_set_next(win_data->chart, win_data->cpu_dl, cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
|
||||
}
|
||||
/*Refresh the shortcut*/
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_bar_set_value(sc_data->bar_cpu, cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
lv_bar_set_value(sc_data->bar_mem, mem_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
}
|
||||
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, buf_short, strlen(buf_short));
|
||||
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0*/
|
||||
@@ -1,498 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_terminal.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include <misc/gfx/area.h>
|
||||
#include <lvgl/lv_obj/lv_dispi.h>
|
||||
#include <lvgl/lv_obj/lv_obj.h>
|
||||
#include <lvgl/lv_objx/lv_btn.h>
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include <lvgl/lv_objx/lv_ddlist.h>
|
||||
#include <lvgl/lv_objx/lv_label.h>
|
||||
#include <lvgl/lv_objx/lv_page.h>
|
||||
#include <lvgl/lv_objx/lv_ta.h>
|
||||
#include <misc/gfx/color.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "lv_app_terminal.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0
|
||||
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define OBJ_PAD (LV_DPI / 12)
|
||||
#define AUTO_CONNECT_TCP_DELAY 5000 /*Wait before TCS server connect when the WiFi connect is ready*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char txt[LV_APP_TERMINAL_LENGTH + 1];
|
||||
lv_app_com_type_t com_type;
|
||||
lv_app_terminal_format_t format;
|
||||
lv_app_inst_t * last_sender;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
lv_obj_t * ta;
|
||||
lv_obj_t * clear_btn;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win);
|
||||
|
||||
static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len);
|
||||
static lv_action_res_t win_ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_comtype_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_format_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_clear_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static void win_ta_kb_ok_action(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Terminal",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.conf_open = my_conf_open,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static const char * com_type_list_txt[] = {"Character", "Integer", "Log", "None", ""};
|
||||
static lv_app_com_type_t com_type_list[] = {LV_APP_COM_TYPE_CHAR, LV_APP_COM_TYPE_INT, LV_APP_COM_TYPE_LOG, LV_APP_COM_TYPE_INV};
|
||||
static const char * txt_format_list_txt[] = {"ASCII", "Hexadecimal", ""};
|
||||
static lv_style_t style_sc_term;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_terminal_init(void)
|
||||
{
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_sc_term);
|
||||
style_sc_term.line_space = 0;
|
||||
style_sc_term.letter_space = 0;
|
||||
style_sc_term.txt_align = 0;
|
||||
style_sc_term.ccolor = COLOR_WHITE;
|
||||
style_sc_term.mcolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
style_sc_term.gcolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(conf != NULL) {
|
||||
app_data->com_type = ((lv_app_terminal_conf_t * ) conf)->com_type;
|
||||
app_data->format = ((lv_app_terminal_conf_t * ) conf)->format;
|
||||
} else {
|
||||
app_data->com_type = LV_APP_COM_TYPE_CHAR;
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_ASCII;
|
||||
}
|
||||
|
||||
app_data->last_sender = NULL;
|
||||
|
||||
memset(app_data->txt, 0, sizeof(app_data->txt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this applicationstring
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
my_app_data_t * app_data = app_rec->app_data;
|
||||
|
||||
/*Add the received data if the type is matches*/
|
||||
if(type == app_data->com_type) {
|
||||
|
||||
/*Insert the name of the sender application if it is not the last*/
|
||||
if(app_data->last_sender != app_send) {
|
||||
add_data(app_rec, "\n@", 2);
|
||||
add_data(app_rec, app_send->name, strlen(app_send->name));
|
||||
add_data(app_rec, "\n", 1);
|
||||
}
|
||||
|
||||
if(app_data->format == LV_APP_TERMINAL_FORMAT_HEX) {
|
||||
char hex_buf[8];
|
||||
const char * data_buf = data;
|
||||
uint32_t i;
|
||||
for(i = 0; i < size; i++) {
|
||||
sprintf(hex_buf, "%02x", data_buf[i]);
|
||||
add_data(app_rec, hex_buf, 2);
|
||||
}
|
||||
} else {
|
||||
add_data(app_rec, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
app_data->last_sender = app_send;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Create a dark background*/
|
||||
lv_obj_t * txt_bg = lv_obj_create(sc, NULL);
|
||||
lv_obj_set_size(txt_bg, 7 * LV_APP_SC_WIDTH / 8 , app->sc->cords.y2 - app->sc_title->cords.y2 - 10 * LV_DOWNSCALE);
|
||||
lv_obj_set_style(txt_bg, &style_sc_term);
|
||||
lv_obj_align(txt_bg, app->sc_title, LV_ALIGN_OUT_BOTTOM_MID, 0, 3 * LV_DOWNSCALE);
|
||||
lv_obj_set_click(txt_bg, false);
|
||||
|
||||
/*Add a text with the text of the terminal*/
|
||||
sc_data->label = lv_label_create(txt_bg, NULL);
|
||||
lv_label_set_long_mode(sc_data->label, LV_LABEL_LONG_BREAK);
|
||||
lv_obj_set_width(sc_data->label, lv_obj_get_width(txt_bg) - LV_APP_SC_WIDTH / 8);
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, txt_bg, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Make the window content responsive*/
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
/*Create a label for the text of the terminal*/
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_long_mode(win_data->label, LV_LABEL_LONG_BREAK);
|
||||
lv_obj_set_width(win_data->label, lv_win_get_width(win));
|
||||
lv_label_set_text_static(win_data->label, app_data->txt); /*Use the app. data text directly*/
|
||||
|
||||
/*Create a text area. Text can be added to the terminal from here by app. keyboard.*/
|
||||
win_data->ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size(win_data->ta, 3 * LV_HOR_RES / 5, LV_VER_RES / 4);
|
||||
lv_obj_set_free_p(win_data->ta, app);
|
||||
lv_page_set_rel_action(win_data->ta, win_ta_rel_action);
|
||||
lv_page_glue_obj(win_data->ta, true);
|
||||
lv_ta_set_text(win_data->ta, "");
|
||||
|
||||
/*Create a clear button*/
|
||||
win_data->clear_btn = lv_btn_create(win, NULL);
|
||||
lv_cont_set_fit(win_data->clear_btn, true, true);
|
||||
lv_obj_set_free_p(win_data->clear_btn, app);
|
||||
lv_page_glue_obj(win_data->ta, true);
|
||||
lv_btn_set_rel_action(win_data->clear_btn, win_clear_rel_action);
|
||||
lv_obj_t * btn_label = lv_label_create(win_data->clear_btn, NULL);
|
||||
lv_label_set_text(btn_label, "Clear");
|
||||
|
||||
/*Align the window to see the text area on the bottom*/
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create objects to configure the applications
|
||||
* @param app pointer to an application which settings should be created
|
||||
* @param conf_win pointer to a window where the objects can be created
|
||||
* (the window has the proper layout)
|
||||
*/
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(conf_win, NULL);
|
||||
lv_label_set_text(label, "Communication type");
|
||||
|
||||
lv_obj_t * ddl;
|
||||
ddl = lv_ddlist_create(conf_win, NULL);
|
||||
lv_obj_set_free_p(ddl, app);
|
||||
lv_ddlist_set_options(ddl, com_type_list_txt);
|
||||
lv_ddlist_set_action(ddl, win_comtype_action);
|
||||
lv_ddlist_set_selected(ddl, app_data->com_type);
|
||||
|
||||
label = lv_label_create(conf_win, label);
|
||||
lv_label_set_text(label, "\nText format"); /*First '\n' keeps space from the list above*/
|
||||
ddl = lv_ddlist_create(conf_win, ddl);
|
||||
lv_ddlist_set_options(ddl, txt_format_list_txt);
|
||||
lv_ddlist_set_selected(ddl, app_data->format);
|
||||
lv_ddlist_set_action(ddl, win_format_action);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called when the Text area is released to open the app. keybard
|
||||
* @param ta pointer to the text area
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the text area is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, win_ta_kb_ok_action);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an option is chosen in the communication type drop down list on the configuration window
|
||||
* @param ddl pointer to the drop down list
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_comtype_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->com_type = com_type_list[lv_ddlist_get_selected(ddlist)];
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an option is chosen in the format drop down list on the configuration window
|
||||
* @param ddl pointer to the drop down list
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_format_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
uint16_t opt = lv_ddlist_get_selected(ddlist);
|
||||
if(strcmp(txt_format_list_txt[opt], "Hexadecimal") == 0) {
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_HEX;
|
||||
} else if (strcmp(txt_format_list_txt[opt], "ASCII") == 0) {
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_ASCII;
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Clear button is released to clear the text of the terminal
|
||||
* @param btn pointer to the clear button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_clear_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
app_data->txt[0] = '\0';
|
||||
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text_static(win_data->label, app_data->txt);
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the 'Ok' button of the keyboard in the window
|
||||
* is pressed to write to the Terminal
|
||||
* @param ta pointer to the Text area in the window
|
||||
*/
|
||||
static void win_ta_kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
const char * ta_txt = lv_ta_get_txt(ta);
|
||||
uint32_t ta_txt_len = strlen(ta_txt);
|
||||
if(app_data->txt[0] != '\0') add_data(app, "\n", 1);
|
||||
add_data(app, ">", 1);
|
||||
add_data(app, ta_txt, ta_txt_len);
|
||||
|
||||
lv_app_com_send(app, app_data->com_type, ta_txt, ta_txt_len);
|
||||
|
||||
lv_ta_set_text(ta, "");
|
||||
app_data->last_sender = NULL; /*Now the least data in the terminal is from this app*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to the terminal
|
||||
* @param app pointer to a Terminal application
|
||||
* @param data pointer to the data
|
||||
* @param data_len length of 'data' in bytes
|
||||
*/
|
||||
static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
uint16_t old_len = strlen(app_data->txt);
|
||||
const char * txt = data;
|
||||
|
||||
/*IF the data is longer then the terminal ax size show the last part of data*/
|
||||
if(data_len > LV_APP_TERMINAL_LENGTH) {
|
||||
txt += (data_len - LV_APP_TERMINAL_LENGTH);
|
||||
data_len = LV_APP_TERMINAL_LENGTH;
|
||||
old_len = 0;
|
||||
}
|
||||
/*If the text become too long 'forget' the oldest lines*/
|
||||
else if(old_len + data_len > LV_APP_TERMINAL_LENGTH) {
|
||||
uint16_t new_start;
|
||||
for(new_start = 0; new_start < old_len; new_start++) {
|
||||
if(app_data->txt[new_start] == '\n') {
|
||||
/*If there is enough space break*/
|
||||
if(new_start >= data_len) {
|
||||
/*Ignore line breaks*/
|
||||
while(app_data->txt[new_start] == '\n' || app_data->txt[new_start] == '\r') new_start++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If it wasn't able to make enough space on line breaks
|
||||
* simply forget the oldest characters*/
|
||||
if(new_start == old_len) {
|
||||
new_start = old_len - (LV_APP_TERMINAL_LENGTH - data_len);
|
||||
}
|
||||
/*Move the remaining text to the beginning*/
|
||||
uint16_t j;
|
||||
for(j = new_start; j < old_len; j++) {
|
||||
app_data->txt[j - new_start] = app_data->txt[j];
|
||||
}
|
||||
old_len = old_len - new_start;
|
||||
app_data->txt[old_len] = '\0';
|
||||
|
||||
}
|
||||
|
||||
memcpy(&app_data->txt[old_len], txt, data_len);
|
||||
app_data->txt[old_len + data_len] = '\0';
|
||||
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text_static(win_data->label, app_data->txt);
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
/*Set the last line on the shortcut*/
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0*/
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_terminal.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_TERMINAL_H
|
||||
#define LV_APP_TERMINAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_TERMINAL_FORMAT_ASCII,
|
||||
LV_APP_TERMINAL_FORMAT_HEX,
|
||||
}lv_app_terminal_format_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_app_terminal_format_t format; /*Data display format*/
|
||||
lv_app_com_type_t com_type; /*The listened communication type (channel) */
|
||||
}lv_app_terminal_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_terminal_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_TERMINAL_H */
|
||||
@@ -1,485 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_wifi.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_wifi.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_WIFI != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "hal/wifi/wifi.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "misc/comm/wifimng.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SSID_LIST_MAX_LENGTH 512
|
||||
#define WIFI_MONITOR_PERIOD 1000 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char set_ssid[64];
|
||||
char set_pwd[64];
|
||||
char set_ip[32];
|
||||
char set_port[16];
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * list;
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * netw_ssid_ta;
|
||||
lv_obj_t * netw_pwd_ta;
|
||||
lv_obj_t * tcp_ip_ta;
|
||||
lv_obj_t * tcp_port_ta;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void wifi_state_monitor_task(void * param);
|
||||
|
||||
static lv_action_res_t netw_list_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi);
|
||||
static lv_action_res_t netw_ssid_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t netw_pwd_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t wifi_ap_select_action( lv_obj_t * ddlist, lv_dispi_t* dispi);
|
||||
|
||||
static void netw_ssid_kb_ok(lv_obj_t * ta);
|
||||
static void netw_ssid_kb_close(lv_obj_t * ta);
|
||||
static void netw_pwd_kb_ok(lv_obj_t * ta);
|
||||
static void netw_pwd_kb_close(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta);
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_port_kb_close(lv_obj_t * ta);
|
||||
|
||||
static void list_cb(wifi_state_t state, const char * txt);
|
||||
static void tcp_transf_cb(wifi_state_t state, const char * txt);
|
||||
|
||||
static void win_title_refr(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "WiFi",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static char ssid_list[SSID_LIST_MAX_LENGTH];
|
||||
static lv_app_inst_t * app_act_com;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_wifi_init(void)
|
||||
{
|
||||
strcpy(ssid_list, "");
|
||||
|
||||
wifimng_set_last_netw(LV_APP_WIFI_SSID_DEF, LV_APP_WIFI_PWD_DEF);
|
||||
wifimng_set_last_tcp(LV_APP_WIFI_IP_DEF, LV_APP_WIFI_PORT_DEF);
|
||||
|
||||
ptask_create(wifi_state_monitor_task, WIFI_MONITOR_PERIOD, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ssid, LV_APP_WIFI_SSID_DEF);
|
||||
strcpy(adata->set_pwd, LV_APP_WIFI_PWD_DEF);
|
||||
strcpy(adata->set_ip, LV_APP_WIFI_IP_DEF);
|
||||
strcpy(adata->set_port, LV_APP_WIFI_PORT_DEF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
app_act_com = app_rec;
|
||||
wifi_tcp_transf(data, size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_app_data_t * adata = app->app_data;
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
wdata->title = lv_label_create(win, NULL);
|
||||
|
||||
wdata->list = lv_ddlist_create(win, NULL);
|
||||
lv_obj_set_free_p(wdata->list, app);
|
||||
lv_ddlist_set_options_str(wdata->list, ssid_list);
|
||||
lv_ddlist_set_action(wdata->list, wifi_ap_select_action);
|
||||
|
||||
lv_obj_t * list_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(list_btn, app);
|
||||
lv_btn_set_rel_action(list_btn, netw_list_rel_action);
|
||||
lv_obj_t * label = lv_label_create(list_btn, NULL);
|
||||
lv_label_set_text(label, "List\nrefresh");
|
||||
|
||||
lv_obj_t * ta_cont = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(ta_cont, true, true);
|
||||
lv_cont_set_layout(ta_cont, LV_CONT_LAYOUT_COL_L);
|
||||
lv_obj_set_style(ta_cont, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
|
||||
wdata->netw_ssid_ta = lv_ta_create(ta_cont, NULL);
|
||||
lv_cont_set_fit(wdata->netw_ssid_ta, false, true);
|
||||
lv_obj_set_free_p(wdata->netw_ssid_ta, app);
|
||||
lv_page_set_rel_action(wdata->netw_ssid_ta, netw_ssid_rel_action);
|
||||
lv_ta_set_text(wdata->netw_ssid_ta, adata->set_ssid);
|
||||
lv_ta_set_cursor_show(wdata->netw_ssid_ta, false);
|
||||
|
||||
wdata->netw_pwd_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->netw_pwd_ta, netw_pwd_rel_action);
|
||||
lv_ta_set_text(wdata->netw_pwd_ta, adata->set_pwd);
|
||||
|
||||
wdata->tcp_ip_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_ip_ta, tcp_ip_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_ip_ta, adata->set_ip);
|
||||
|
||||
wdata->tcp_port_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_port_ta, tcp_port_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_port_ta, adata->set_port);
|
||||
|
||||
|
||||
lv_obj_t * con_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(con_btn, app);
|
||||
lv_btn_set_rel_action(con_btn, netw_con_rel_action);
|
||||
label = lv_label_create(con_btn, NULL);
|
||||
lv_label_set_text(label, "Connect");
|
||||
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void wifi_state_monitor_task(void * param)
|
||||
{
|
||||
static wifimng_state_t state_prev = WIFIMNG_STATE_WAIT;
|
||||
wifimng_state_t state_act = wifimng_get_state();
|
||||
|
||||
if(state_prev != state_act && state_act == WIFIMNG_STATE_READY) {
|
||||
lv_app_notice_add("WiFi connected to:\n%s\n%s:%s",
|
||||
wifimng_get_last_ssid(), wifimng_get_last_ip(), wifimng_get_last_port());
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
|
||||
state_prev = state_act;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_list_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
wifi_state_t ret;
|
||||
ret = wifi_netw_list(list_cb);
|
||||
|
||||
if(ret == WIFI_STATE_OK) {
|
||||
lv_app_notice_add("Listing WiFi networks");
|
||||
} else {
|
||||
lv_app_notice_add("Cannot list networks\nWiFi was busy. Try again");
|
||||
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
wifimng_set_last_netw(adata->set_ssid, adata->set_pwd);
|
||||
wifimng_set_last_tcp(adata->set_ip, adata->set_port);
|
||||
wifimng_reconnect();
|
||||
lv_app_notice_add("Connecting to WiFi network\n%s, %s:%s",
|
||||
adata->set_ssid, adata->set_ip, adata->set_port);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_ssid_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_ssid_kb_close ,netw_ssid_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_pwd_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_pwd_kb_close ,netw_pwd_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_ip_kb_close ,tcp_ip_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_port_kb_close ,tcp_port_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t wifi_ap_select_action( lv_obj_t * ddlist, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
char ssid[256];
|
||||
lv_ddlist_get_selected_str(ddlist, ssid);
|
||||
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_ta_set_text(wdata->netw_ssid_ta, ssid);
|
||||
strcpy(adata->set_ssid, ssid);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static void netw_ssid_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ssid, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_ssid_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ssid);
|
||||
}
|
||||
|
||||
static void netw_pwd_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_pwd, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_pwd_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_pwd);
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ip, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ip);
|
||||
}
|
||||
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_port, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_port_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_port);
|
||||
}
|
||||
|
||||
static void list_cb(wifi_state_t state, const char * txt)
|
||||
{
|
||||
if(state == WIFI_STATE_OK) {
|
||||
if(txt[0] == '\0') {
|
||||
lv_app_notice_add("WiFi network list ready");
|
||||
return;
|
||||
}
|
||||
if(strlen(ssid_list) + strlen(txt) + 4 < sizeof(ssid_list)) {
|
||||
sprintf(ssid_list, "%s\n%s", ssid_list, txt);
|
||||
}
|
||||
|
||||
lv_app_inst_t * app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win_data != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_ddlist_set_options_str(wdata->list, ssid_list);
|
||||
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
} else if(state == WIFI_STATE_ERROR) {
|
||||
lv_app_notice_add("WiFi network list error\n%s", txt);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_transf_cb(wifi_state_t state, const char * txt)
|
||||
{
|
||||
if(state == WIFI_STATE_OK) {
|
||||
uint16_t size = txt[0] + ((txt[1] << 8) & 0xFF00);
|
||||
char buf[256];
|
||||
memcpy(buf, &txt[2], size);
|
||||
buf[size] = '\0';
|
||||
lv_app_com_send(app_act_com, LV_APP_COM_TYPE_CHAR, &txt[2], size);
|
||||
}else if(state == WIFI_STATE_ERROR) {
|
||||
lv_app_notice_add("WiFi TCP transfer error\n%s", txt);
|
||||
lv_app_notice_add("Reconnecting to WiFi...");
|
||||
wifimng_reconnect();
|
||||
}
|
||||
|
||||
app_act_com = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void win_title_refr(void)
|
||||
{
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
if(wifimng_get_state() != WIFIMNG_STATE_READY) lv_label_set_text(wdata->title, "Not connected");
|
||||
else {
|
||||
char buf[256];
|
||||
sprintf(buf, "%s - %s:%s", wifimng_get_last_ssid(), wifimng_get_last_ip(), wifimng_get_last_port());
|
||||
lv_label_set_text(wdata->title, buf);
|
||||
}
|
||||
lv_obj_set_width(wdata->title, lv_win_get_width(app->win));
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
278
lv_conf_templ.h
278
lv_conf_templ.h
@@ -1,278 +0,0 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0 /*Remove this to enable the content (Delete the last #endif too!)*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*=====================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.
|
||||
* Screen resolution multiplied by LV_DOWN_SCALE*/
|
||||
#define LV_HOR_RES (320 * LV_DOWNSCALE)
|
||||
#define LV_VER_RES (240 * LV_DOWNSCALE)
|
||||
#define LV_DPI (80 * LV_DOWNSCALE)
|
||||
|
||||
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
|
||||
#define LV_VDB_SIZE (LV_HOR_RES * 30)
|
||||
|
||||
/* Enable antialaiassing
|
||||
* If enabled everything will half-sized
|
||||
* Use LV_DOWNSCALE to compensate
|
||||
* the down scaling effect of antialiassing*/
|
||||
#define LV_ANTIALIAS 1
|
||||
|
||||
/*Set the downscaling value*/
|
||||
#define LV_DOWNSCALE (1 << LV_ANTIALIAS)
|
||||
|
||||
#define LV_REFR_PERIOD 40 /*Screen refresh period in milliseconds*/
|
||||
#define LV_INV_FIFO_SIZE 32 /*The average number of objects on a screen */
|
||||
|
||||
/*=================
|
||||
Misc. setting
|
||||
*=================*/
|
||||
/*Display Input settings*/
|
||||
#define LV_DISPI_READ_PERIOD 50 /*Input device read period milliseconds*/
|
||||
#define LV_DISPI_TP_MARKER 0 /*Mark the pressed points (Value means marker point size)*/
|
||||
#define LV_DISPI_DRAG_LIMIT (10 * LV_DOWNSCALE) /*Drag threshold in pixels */
|
||||
#define LV_DISPI_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_DISPI_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_DISPI_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
|
||||
/*lv_obj (base object) settings*/
|
||||
#define LV_OBJ_FREE_NUM 1 /*Enable the free number attribute*/
|
||||
#define LV_OBJ_FREE_P 1 /*Enable the free pointer attribute*/
|
||||
|
||||
/*Others*/
|
||||
#define LV_COLOR_TRANSP COLOR_LIME
|
||||
|
||||
/*==================
|
||||
* LV OBJ X USAGE
|
||||
* ================*/
|
||||
|
||||
/*****************
|
||||
* Simple object
|
||||
*****************/
|
||||
|
||||
/*Label (dependencies: -*/
|
||||
#define USE_LV_LABEL 1
|
||||
#if USE_LV_LABEL != 0
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#define LV_LABEL_SCROLL_PLAYBACK_PAUSE 500 /*Wait before the scroll turns back in ms*/
|
||||
#define LV_LABEL_SCROLL_REPEAT_PAUSE 500 /*Wait before the scroll begins again in ms*/
|
||||
#endif
|
||||
|
||||
/*Image (dependencies: lv_label (if symbols are enabled) from misc: FSINT, UFS)*/
|
||||
#define USE_LV_IMG 1
|
||||
#if USE_LV_IMG != 0
|
||||
//#define LV_IMG_DEF_WALLPAPER img_square_x1 /*Comment this line to NOT use wallpaper*/
|
||||
/* 1: enables to interpret the file names as symbol name
|
||||
* from symbol_def.h if they begin with a lower case letter.
|
||||
* (driver letters are always upper case)*/
|
||||
#define LV_IMG_ENABLE_SYMBOLS 1
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#define LV_IMG_DEF_SYMBOL_FONT FONT_SYMBOL_30
|
||||
#endif /*LV_IMG_ENABLE_SYMBOLS*/
|
||||
#endif /*USE_LV_IMG*/
|
||||
|
||||
/*Line (dependencies: -*/
|
||||
#define USE_LV_LINE 1
|
||||
|
||||
/*******************
|
||||
* Container object
|
||||
*******************/
|
||||
|
||||
/*Container (dependencies: -*/
|
||||
#define USE_LV_CONT 1
|
||||
|
||||
/*Page (dependencies: lv_cont)*/
|
||||
#define USE_LV_PAGE 1
|
||||
|
||||
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define USE_LV_WIN 1
|
||||
|
||||
/*************************
|
||||
* Data visualizer object
|
||||
*************************/
|
||||
|
||||
/*Bar (dependencies: -)*/
|
||||
#define USE_LV_BAR 1
|
||||
|
||||
/*Line meter (dependencies: bar; misc: trigo)*/
|
||||
#define USE_LV_LMETER 1
|
||||
|
||||
/*Gauge (dependencies:bar, lmeter; misc: trigo)*/
|
||||
#define USE_LV_GAUGE 1
|
||||
#if USE_LV_GAUGE != 0
|
||||
#define LV_GAUGE_MAX_NEEDLE 4 /*Max number of needles. Used in the style.*/
|
||||
#endif
|
||||
|
||||
/*Chart (dependencies: -)*/
|
||||
#define USE_LV_CHART 1
|
||||
|
||||
/*LED (dependencies: -)*/
|
||||
#define USE_LV_LED 1
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btn, lv_label)*/
|
||||
#define USE_LV_MBOX 1
|
||||
|
||||
/*Text area (dependencies: lv_label, lv_page)*/
|
||||
#define USE_LV_TA 1
|
||||
#if USE_LV_TA != 0
|
||||
#define LV_TA_MAX_LENGTH 256
|
||||
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
|
||||
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
* User input object
|
||||
*************************/
|
||||
|
||||
/*Button (dependencies: lv_cont*/
|
||||
#define USE_LV_BTN 1
|
||||
|
||||
/*Button matrix (dependencies: -)*/
|
||||
#define USE_LV_BTNM 1
|
||||
|
||||
/*Check box (dependencies: lv_btn, lv_label)*/
|
||||
#define USE_LV_CB 1
|
||||
|
||||
/*List (dependencies: lv_page, lv_btn, lv_label, lv_img)*/
|
||||
#define USE_LV_LIST 1
|
||||
|
||||
/*Drop down list (dependencies: lv_page, lv_label)*/
|
||||
#define USE_LV_DDLIST 1
|
||||
|
||||
/*Slider (dependencies: lv_bar)*/
|
||||
#define USE_LV_SLIDER 1
|
||||
|
||||
/*==================
|
||||
* LV APP SETTINGS
|
||||
* =================*/
|
||||
|
||||
/*Enable the application system*/
|
||||
#define LV_APP_ENABLE 0
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/****************************
|
||||
* Basic application settings
|
||||
*****************************/
|
||||
#define LV_APP_DESKTOP 1 /*Create a desktop-like environment*/
|
||||
|
||||
#define LV_APP_SC_WIDTH (LV_DPI * 2) /*Shortcut width*/
|
||||
#define LV_APP_SC_HEIGHT (3 * LV_DPI / 2) /*Shortcut height*/
|
||||
#define LV_APP_FONT_SMALL FONT_DEJAVU_20 /*A small font*/
|
||||
#define LV_APP_FONT_MEDIUM FONT_DEFAULT /*A medium font*/
|
||||
#define LV_APP_FONT_LARGE FONT_DEJAVU_40 /*A large font*/
|
||||
|
||||
/***********************
|
||||
* Animation settings
|
||||
***********************/
|
||||
#define LV_APP_ANIM_WIN 200 /*Animation time of windows [ms] (0: turn off animations)*/
|
||||
#define LV_APP_ANIM_DESKTOP 200 /*Animation time the desktop [ms] (0: turn off animations)*/
|
||||
|
||||
/************************
|
||||
* App. utility settings
|
||||
************************/
|
||||
|
||||
/*Notice*/
|
||||
#define USE_LV_APP_NOTICE 1
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300 /*Notice close animation time. [ms] 0: no animation */
|
||||
#define LV_APP_NOTICE_MAX_NUM 6 /*Max. number of notices*/
|
||||
#define LV_APP_NOTICE_MAX_LEN 256 /*Max. number of characters on a notice*/
|
||||
#endif
|
||||
|
||||
/*File selector*/
|
||||
#define USE_LV_APP_FSEL 1
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
#define LV_APP_FSEL_PAGE_SIZE 8 /*Max. number of files/folder on a page*/
|
||||
#define LV_APP_FSEL_FN_MAX_LEN 32 /*Max file name length*/
|
||||
#define LV_APP_FSEL_PATH_MAX_LEN 256 /*Max path length*/
|
||||
#endif
|
||||
|
||||
/*Keyboard*/
|
||||
#define USE_LV_APP_KB 1
|
||||
#if USE_LV_APP_KB != 0
|
||||
#define LV_APP_KB_ANIM_TIME 300 /*ms*/
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* LV APP X USAGE
|
||||
* ================*/
|
||||
|
||||
/*Example application*/
|
||||
#define USE_LV_APP_EXAMPLE 1
|
||||
|
||||
/*Phantom application*/
|
||||
#define USE_LV_APP_PHANTOM 1
|
||||
#if USE_LV_APP_PHANTOM != 0
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*System monitor*/
|
||||
#define USE_LV_APP_SYSMON 1
|
||||
#if USE_LV_APP_SYSMON != 0
|
||||
#define LV_APP_SYSMON_REFR_TIME 500 /*Mem. and CPU usage read period [ms]*/
|
||||
#define LV_APP_SYSMON_PNUM 64 /*Number of point on the window's chart*/
|
||||
#define LV_APP_SYSMON_MEM_WARN (2 * 1024) /*Make a notice less then this remaining memory [bytes]*/
|
||||
#define LV_APP_SYSMON_FRAG_WARN (70) /*Make a notice above this fragmentation level [%]*/
|
||||
#define LV_APP_SYSMON_DEFRAG_PERIOD (5000) /*Auto-defrag period [ms]*/
|
||||
#endif /*USE_LV_APP_SYSMON != 0*/
|
||||
|
||||
/*Terminal*/
|
||||
#define USE_LV_APP_TERMINAL 1
|
||||
#if USE_LV_APP_TERMINAL != 0
|
||||
#define LV_APP_TERMINAL_LENGTH 512 /*Memory of the terminal [character number]*/
|
||||
#endif /*USE_LV_APP_TERMINAL != 0*/
|
||||
|
||||
/*Files*/
|
||||
#define USE_LV_APP_FILES 1
|
||||
#if USE_LV_APP_FILES != 0
|
||||
#define LV_APP_FILES_PAGE_SIZE 8 /*Max. number of files/folder on a page*/
|
||||
#define LV_APP_FILES_FN_MAX_LEN 32 /*Max file name length*/
|
||||
#define LV_APP_FILES_PATH_MAX_LEN 256 /*Max path length*/
|
||||
#define LV_APP_FILES_CHUNK_DEF_SIZE 256 /*Chunk size when sending a file*/
|
||||
#define LV_APP_FILES_CHUNK_DEF_TIME 100 /*Delay between sent chunks*/
|
||||
#define LV_APP_FILES_CHUNK_MAX_SIZE 1024 /*Max chunk size when the user sets it*/
|
||||
#endif /*USE_LV_APP_FILES != 0*/
|
||||
|
||||
/*Benchmark*/
|
||||
#define USE_LV_APP_BENCHMARK 1
|
||||
#if USE_LV_APP_BENCHMARK != 0
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*WiFi (requires hal/wifi)*/
|
||||
#define USE_LV_APP_WIFI 0
|
||||
#if USE_LV_APP_WIFI != 0
|
||||
#define LV_APP_WIFI_SSID_DEF "my_ssid"
|
||||
#define LV_APP_WIFI_PWD_DEF "my_pasword"
|
||||
#define LV_APP_WIFI_IP_DEF "10.11.12.13"
|
||||
#define LV_APP_WIFI_PORT_DEF "5555"
|
||||
#define LV_APP_WIFI_AUTO_CONNECT 1 /*Try to connect at start up to the deafult SSID and IP:PORT*/
|
||||
#endif /*USE_LV_APP_WIFI != 0*/
|
||||
|
||||
/*GSM (requires hal/gsm)*/
|
||||
#define USE_LV_APP_GSM 0
|
||||
#if USE_LV_APP_GSM != 0
|
||||
#define LV_APP_GSM_APN_DEF "my_apn"
|
||||
#define LV_APP_GSM_IP_DEF "10.11.12.13"
|
||||
#define LV_APP_GSM_PORT_DEF "5555"
|
||||
#define LV_APP_GSM_AUTO_CONNECT 1 /*Try to connect at start up with the deafult APN and IP:PORT*/
|
||||
#endif /*USE_LV_APP_GSM != 0*/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
|
||||
#endif /*Remove this to enable the content*/
|
||||
|
||||
489
lv_conf_template.h
Normal file
489
lv_conf_template.h
Normal file
@@ -0,0 +1,489 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER
|
||||
*/
|
||||
|
||||
#if 0 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
/* clang-format off */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*====================
|
||||
Graphical settings
|
||||
*====================*/
|
||||
|
||||
/* Maximal horizontal and vertical resolution to support by the library.*/
|
||||
#define LV_HOR_RES_MAX (480)
|
||||
#define LV_VER_RES_MAX (320)
|
||||
|
||||
/* Color depth:
|
||||
* - 1: 1 byte per pixel
|
||||
* - 8: RGB233
|
||||
* - 16: RGB565
|
||||
* - 32: ARGB8888
|
||||
*/
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
/* Swap the 2 bytes of RGB565 color.
|
||||
* Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_16_SWAP 0
|
||||
|
||||
/* 1: Enable screen transparency.
|
||||
* Useful for OSD or other overlapping GUIs.
|
||||
* Requires `LV_COLOR_DEPTH = 32` colors and the screen's style should be modified: `style.body.opa = ...`*/
|
||||
#define LV_COLOR_SCREEN_TRANSP 0
|
||||
|
||||
/*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*LV_COLOR_LIME: pure green*/
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#define LV_ANTIALIAS 1
|
||||
|
||||
/* Default display refresh period.
|
||||
* Can be changed in the display driver (`lv_disp_drv_t`).*/
|
||||
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
|
||||
|
||||
/* 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 /*[px]*/
|
||||
|
||||
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
|
||||
typedef int16_t lv_coord_t;
|
||||
|
||||
/*=========================
|
||||
Memory manager settings
|
||||
*=========================*/
|
||||
|
||||
/* LittelvGL's internal memory manager's settings.
|
||||
* The graphical objects and other related data are stored here. */
|
||||
|
||||
/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_SIZE (32U * 1024U)
|
||||
|
||||
/* Complier prefix for a big array declaration */
|
||||
# define LV_MEM_ATTR
|
||||
|
||||
/* Set an address for the memory pool instead of allocating it as an array.
|
||||
* Can be in external SRAM too. */
|
||||
# define LV_MEM_ADR 0
|
||||
|
||||
/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */
|
||||
# define LV_MEM_AUTO_DEFRAG 1
|
||||
#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*/
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Garbage Collector settings
|
||||
* Used if lvgl is binded to higher level language and the memory is managed by that language */
|
||||
#define LV_ENABLE_GC 0
|
||||
#if LV_ENABLE_GC != 0
|
||||
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
|
||||
# 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*/
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*=======================
|
||||
Input device settings
|
||||
*=======================*/
|
||||
|
||||
/* Input device default settings.
|
||||
* Can be changed in the Input device driver (`lv_indev_drv_t`)*/
|
||||
|
||||
/* Input device read period in milliseconds */
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30
|
||||
|
||||
/* Drag threshold in pixels */
|
||||
#define LV_INDEV_DEF_DRAG_LIMIT 10
|
||||
|
||||
/* Drag throw slow-down in [%]. Greater value -> faster slow-down */
|
||||
#define LV_INDEV_DEF_DRAG_THROW 20
|
||||
|
||||
/* Long press time in milliseconds.
|
||||
* Time to send `LV_EVENT_LONG_PRESSSED`) */
|
||||
#define LV_INDEV_DEF_LONG_PRESS_TIME 400
|
||||
|
||||
/* Repeated trigger period in long press [ms]
|
||||
* Time between `LV_EVENT_LONG_PRESSED_REPEAT */
|
||||
#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100
|
||||
|
||||
/*==================
|
||||
* Feature usage
|
||||
*==================*/
|
||||
|
||||
/*1: Enable the Animations */
|
||||
#define LV_USE_ANIMATION 1
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_anim_user_data_t;
|
||||
|
||||
#endif
|
||||
|
||||
/* 1: Enable shadow drawing*/
|
||||
#define LV_USE_SHADOW 1
|
||||
|
||||
/* 1: Enable object groups (for keyboard/encoder navigation) */
|
||||
#define LV_USE_GROUP 1
|
||||
#if LV_USE_GROUP
|
||||
typedef void * lv_group_user_data_t;
|
||||
#endif /*LV_USE_GROUP*/
|
||||
|
||||
/* 1: Enable GPU interface*/
|
||||
#define LV_USE_GPU 1
|
||||
|
||||
/* 1: Enable file system (might be required for images */
|
||||
#define LV_USE_FILESYSTEM 1
|
||||
#if LV_USE_FILESYSTEM
|
||||
/*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_fs_drv_user_data_t;
|
||||
#endif
|
||||
|
||||
/*1: Add a `user_data` to drivers and objects*/
|
||||
#define LV_USE_USER_DATA 1
|
||||
|
||||
/*========================
|
||||
* Image decoder and cache
|
||||
*========================*/
|
||||
|
||||
/* 1: Enable indexed (palette) images */
|
||||
#define LV_IMG_CF_INDEXED 1
|
||||
|
||||
/* 1: Enable alpha indexed images */
|
||||
#define LV_IMG_CF_ALPHA 1
|
||||
|
||||
/* Default image cache size. Image caching keeps the images opened.
|
||||
* If only the built-in image formats are used there is no real advantage of caching.
|
||||
* (I.e. no new image decoder is added)
|
||||
* With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
|
||||
* However the opened images might consume additional RAM.
|
||||
* LV_IMG_CACHE_DEF_SIZE must be >= 1 */
|
||||
#define LV_IMG_CACHE_DEF_SIZE 1
|
||||
|
||||
/*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_img_decoder_user_data_t;
|
||||
|
||||
/*=====================
|
||||
* Compiler settings
|
||||
*====================*/
|
||||
/* Define a custom attribute to `lv_tick_inc` function */
|
||||
#define LV_ATTRIBUTE_TICK_INC
|
||||
|
||||
/* Define a custom attribute to `lv_task_handler` function */
|
||||
#define LV_ATTRIBUTE_TASK_HANDLER
|
||||
|
||||
/* With size optimization (-Os) the compiler might not align data to
|
||||
* 4 or 8 byte boundary. This alignment will be explicitly applied where needed.
|
||||
* E.g. __attribute__((aligned(4))) */
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
|
||||
/* Attribute to mark large constant arrays for example
|
||||
* font's bitmaps */
|
||||
#define LV_ATTRIBUTE_LARGE_CONST
|
||||
|
||||
/*===================
|
||||
* HAL settings
|
||||
*==================*/
|
||||
|
||||
/* 1: use a custom tick source.
|
||||
* It removes the need to manually update the tick with `lv_tick_inc`) */
|
||||
#define LV_TICK_CUSTOM 0
|
||||
#if LV_TICK_CUSTOM == 1
|
||||
#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*/
|
||||
|
||||
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
|
||||
typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/
|
||||
|
||||
/*================
|
||||
* Log settings
|
||||
*===============*/
|
||||
|
||||
/*1: Enable the log module*/
|
||||
#define LV_USE_LOG 1
|
||||
#if LV_USE_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 cause a problem
|
||||
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*/
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
|
||||
/* 1: Print the log with 'printf';
|
||||
* 0: user need to register a callback with `lv_log_register_print`*/
|
||||
# define LV_LOG_PRINTF 0
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
/*================
|
||||
* THEME USAGE
|
||||
*================*/
|
||||
#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
|
||||
#define LV_USE_THEME_TEMPL 0 /*Just for test*/
|
||||
#define LV_USE_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/
|
||||
#define LV_USE_THEME_ALIEN 0 /*Dark futuristic theme*/
|
||||
#define LV_USE_THEME_NIGHT 0 /*Dark elegant theme*/
|
||||
#define LV_USE_THEME_MONO 0 /*Mono color theme for monochrome displays*/
|
||||
#define LV_USE_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/
|
||||
#define LV_USE_THEME_ZEN 0 /*Peaceful, mainly light theme */
|
||||
#define LV_USE_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
*===================*/
|
||||
|
||||
/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel.
|
||||
* The symbols are available via `LV_SYMBOL_...` defines
|
||||
* More info about fonts: https://docs.littlevgl.com/#Fonts
|
||||
* To create a new font go to: https://littlevgl.com/ttf-font-to-c-array
|
||||
*/
|
||||
|
||||
/* Robot fonts with bpp = 4
|
||||
* https://fonts.google.com/specimen/Roboto */
|
||||
#define LV_FONT_ROBOTO_12 0
|
||||
#define LV_FONT_ROBOTO_16 1
|
||||
#define LV_FONT_ROBOTO_22 0
|
||||
#define LV_FONT_ROBOTO_28 0
|
||||
|
||||
/*Pixel perfect monospace font
|
||||
* http://pelulamu.net/unscii/ */
|
||||
#define LV_FONT_UNSCII_8 0
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font from the built-in fonts*/
|
||||
#define LV_FONT_DEFAULT &lv_font_roboto_16
|
||||
|
||||
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_font_user_data_t;
|
||||
|
||||
/*=================
|
||||
* Text settings
|
||||
*=================*/
|
||||
|
||||
/* Select a character encoding for strings.
|
||||
* Your IDE or editor should have the same character encoding
|
||||
* - LV_TXT_ENC_UTF8
|
||||
* - LV_TXT_ENC_ASCII
|
||||
* */
|
||||
#define LV_TXT_ENC LV_TXT_ENC_UTF8
|
||||
|
||||
/*Can break (wrap) texts on these chars*/
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_"
|
||||
|
||||
/*===================
|
||||
* LV_OBJ SETTINGS
|
||||
*==================*/
|
||||
|
||||
/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_obj_user_data_t;
|
||||
|
||||
/*1: enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
|
||||
#define LV_USE_OBJ_REALIGN 1
|
||||
|
||||
/* Enable to make the object clickable on a larger area.
|
||||
* LV_EXT_CLICK_AREA_OFF or 0: Disable this feature
|
||||
* LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted horizontally and vertically (0..255 px)
|
||||
* LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted in all 4 directions (-32k..+32k px)
|
||||
*/
|
||||
#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_OFF
|
||||
|
||||
/*==================
|
||||
* LV OBJ X USAGE
|
||||
*================*/
|
||||
/*
|
||||
* Documentation of the object types: https://docs.littlevgl.com/#Object-types
|
||||
*/
|
||||
|
||||
/*Arc (dependencies: -)*/
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
/*Bar (dependencies: -)*/
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
/*Button (dependencies: lv_cont*/
|
||||
#define LV_USE_BTN 1
|
||||
#if LV_USE_BTN != 0
|
||||
/*Enable button-state animations - draw a circle on click (dependencies: LV_USE_ANIMATION)*/
|
||||
# define LV_BTN_INK_EFFECT 1
|
||||
#endif
|
||||
|
||||
/*Button matrix (dependencies: -)*/
|
||||
#define LV_USE_BTNM 1
|
||||
|
||||
/*Calendar (dependencies: -)*/
|
||||
#define LV_USE_CALENDAR 1
|
||||
|
||||
/*Canvas (dependencies: lv_img)*/
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
/*Check box (dependencies: lv_btn, lv_label)*/
|
||||
#define LV_USE_CB 1
|
||||
|
||||
/*Chart (dependencies: -)*/
|
||||
#define LV_USE_CHART 1
|
||||
#if LV_USE_CHART
|
||||
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 20
|
||||
#endif
|
||||
|
||||
/*Container (dependencies: -*/
|
||||
#define LV_USE_CONT 1
|
||||
|
||||
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
|
||||
#define LV_USE_DDLIST 1
|
||||
#if LV_USE_DDLIST != 0
|
||||
/*Open and close default animation time [ms] (0: no animation)*/
|
||||
# define LV_DDLIST_DEF_ANIM_TIME 200
|
||||
#endif
|
||||
|
||||
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
|
||||
#define LV_USE_GAUGE 1
|
||||
|
||||
/*Image (dependencies: lv_label*/
|
||||
#define LV_USE_IMG 1
|
||||
|
||||
/*Image Button (dependencies: lv_btn*/
|
||||
#define LV_USE_IMGBTN 1
|
||||
#if LV_USE_IMGBTN
|
||||
/*1: The imgbtn requires left, mid and right parts and the width can be set freely*/
|
||||
# define LV_IMGBTN_TILED 0
|
||||
#endif
|
||||
|
||||
/*Keyboard (dependencies: lv_btnm)*/
|
||||
#define LV_USE_KB 1
|
||||
|
||||
/*Label (dependencies: -*/
|
||||
#define LV_USE_LABEL 1
|
||||
#if LV_USE_LABEL != 0
|
||||
/*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode*/
|
||||
# define LV_LABEL_DEF_SCROLL_SPEED 25
|
||||
|
||||
/* Waiting period at beginning/end of animation cycle */
|
||||
# define LV_LABEL_WAIT_CHAR_COUNT 3
|
||||
|
||||
/*Enable selecting text of the label */
|
||||
# define LV_LABEL_TEXT_SEL 0
|
||||
|
||||
/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/
|
||||
# define LV_LABEL_LONG_TXT_HINT 0
|
||||
#endif
|
||||
|
||||
/*LED (dependencies: -)*/
|
||||
#define LV_USE_LED 1
|
||||
|
||||
/*Line (dependencies: -*/
|
||||
#define LV_USE_LINE 1
|
||||
|
||||
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
|
||||
#define LV_USE_LIST 1
|
||||
#if LV_USE_LIST != 0
|
||||
/*Default animation time of focusing to a list element [ms] (0: no animation) */
|
||||
# define LV_LIST_DEF_ANIM_TIME 100
|
||||
#endif
|
||||
|
||||
/*Line meter (dependencies: *;)*/
|
||||
#define LV_USE_LMETER 1
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
|
||||
#define LV_USE_MBOX 1
|
||||
|
||||
/*Page (dependencies: lv_cont)*/
|
||||
#define LV_USE_PAGE 1
|
||||
#if LV_USE_PAGE != 0
|
||||
/*Focus default animation time [ms] (0: no animation)*/
|
||||
# define LV_PAGE_DEF_ANIM_TIME 400
|
||||
#endif
|
||||
|
||||
/*Preload (dependencies: lv_arc, lv_anim)*/
|
||||
#define LV_USE_PRELOAD 1
|
||||
#if LV_USE_PRELOAD != 0
|
||||
# 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
|
||||
|
||||
/*Roller (dependencies: lv_ddlist)*/
|
||||
#define LV_USE_ROLLER 1
|
||||
#if LV_USE_ROLLER != 0
|
||||
/*Focus animation time [ms] (0: no animation)*/
|
||||
# define LV_ROLLER_DEF_ANIM_TIME 200
|
||||
|
||||
/*Number of extra "pages" when the roller is infinite*/
|
||||
# define LV_ROLLER_INF_PAGES 7
|
||||
#endif
|
||||
|
||||
/*Slider (dependencies: lv_bar)*/
|
||||
#define LV_USE_SLIDER 1
|
||||
|
||||
/*Spinbox (dependencies: lv_ta)*/
|
||||
#define LV_USE_SPINBOX 1
|
||||
|
||||
/*Switch (dependencies: lv_slider)*/
|
||||
#define LV_USE_SW 1
|
||||
|
||||
/*Text area (dependencies: lv_label, lv_page)*/
|
||||
#define LV_USE_TA 1
|
||||
#if LV_USE_TA != 0
|
||||
# define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
|
||||
# define LV_TA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
/*Table (dependencies: lv_label)*/
|
||||
#define LV_USE_TABLE 1
|
||||
#if LV_USE_TABLE
|
||||
# define LV_TABLE_COL_MAX 12
|
||||
#endif
|
||||
|
||||
/*Tab (dependencies: lv_page, lv_btnm)*/
|
||||
#define LV_USE_TABVIEW 1
|
||||
# if LV_USE_TABVIEW != 0
|
||||
/*Time of slide animation [ms] (0: no animation)*/
|
||||
# define LV_TABVIEW_DEF_ANIM_TIME 300
|
||||
#endif
|
||||
|
||||
/*Tileview (dependencies: lv_page) */
|
||||
#define LV_USE_TILEVIEW 1
|
||||
#if LV_USE_TILEVIEW
|
||||
/*Time of slide animation [ms] (0: no animation)*/
|
||||
# define LV_TILEVIEW_DEF_ANIM_TIME 300
|
||||
#endif
|
||||
|
||||
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
/*==================
|
||||
* Non-user section
|
||||
*==================*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
/*Be sure every define has a default value*/
|
||||
#include "lvgl/src/lv_conf_checker.h"
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
1376
lv_draw/lv_draw.c
1376
lv_draw/lv_draw.c
File diff suppressed because it is too large
Load Diff
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_H
|
||||
#define LV_DRAW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "../lv_obj/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Draw a rectangle
|
||||
* @param cords_p the coordinates of the rectangle
|
||||
* @param mask_p the rectangle will be drawn only in this mask
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
|
||||
|
||||
/*Experimental use for 3D modeling*/
|
||||
#define USE_LV_TRIANGLE 0
|
||||
#if USE_LV_TRIANGLE != 0
|
||||
/**
|
||||
*
|
||||
* @param points pointer to an array with 3 points
|
||||
* @param mask_p the triangle will be drawn only in this mask
|
||||
* @param color color of the triangle
|
||||
*/
|
||||
void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t color);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Write a text
|
||||
* @param cords_p coordinates of the label
|
||||
* @param mask_p the label will be drawn only in this area
|
||||
* @param style_p pointer to a style
|
||||
* @param txt 0 terminated text to write
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*/
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_t * style_p,
|
||||
const char * txt, txt_flag_t flag, point_t * offset);
|
||||
|
||||
/**
|
||||
* Draw an image
|
||||
* @param cords_p the coordinates of the image
|
||||
* @param mask_p the image will be drawn only in this area
|
||||
* @param map_p pointer to a color_t array which contains the pixels of the image
|
||||
*/
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_style_t * style_p, const char * fn);
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param p1 first point of the line
|
||||
* @param p2 second point of the line
|
||||
* @param mask_pthe line will be drawn only on this area
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
const lv_style_t * style_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_H*/
|
||||
@@ -1,216 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_rbasic.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_conf.h"
|
||||
#include "hal/disp/disp.h"
|
||||
#include "misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Put a pixel to the display
|
||||
* @param x x coordinate of the pixel
|
||||
* @param y y coordinate of the pixel
|
||||
* @param mask_p the pixel will be drawn on this area
|
||||
* @param color color of the pixel
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vpx)
|
||||
*/
|
||||
void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
{
|
||||
area_t area;
|
||||
area.x1 = x;
|
||||
area.y1 = y;
|
||||
area.x2 = x;
|
||||
area.y2 = y;
|
||||
|
||||
lv_rfill(&area, mask_p, color, OPA_COVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill an area on the display
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
area_t masked_area;
|
||||
bool union_ok = true;
|
||||
|
||||
if(mask_p != NULL) {
|
||||
union_ok = area_union(&masked_area, cords_p, mask_p);
|
||||
} else {
|
||||
area_t scr_area;
|
||||
area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1);
|
||||
union_ok = area_union(&masked_area, cords_p, &scr_area);
|
||||
}
|
||||
|
||||
|
||||
if(union_ok != false){
|
||||
disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
uint8_t w = font_get_width(font_p, letter);
|
||||
const uint8_t * bitmap_p = font_get_bitmap(font_p, letter);
|
||||
|
||||
uint8_t col, col_sub, row;
|
||||
#if FONT_ANTIALIAS == 0
|
||||
for(row = 0; row < font_p->height_row; row ++) {
|
||||
for(col = 0, col_sub = 7; col < w; col ++, col_sub--) {
|
||||
if(*bitmap_p & (1 << col_sub)) {
|
||||
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, color, opa);
|
||||
}
|
||||
|
||||
if(col_sub == 0) {
|
||||
bitmap_p++;
|
||||
col_sub = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/*Correction if the letter is short*/
|
||||
bitmap_p += font_p->width_byte - ((w >> 3) + 1);
|
||||
/*Go to the next row*/
|
||||
bitmap_p ++;
|
||||
}
|
||||
#else
|
||||
const uint8_t * map1_p = bitmap_p;
|
||||
const uint8_t * map2_p = bitmap_p + font_p->width_byte;
|
||||
uint8_t px_cnt;
|
||||
uint8_t col_byte_cnt;
|
||||
for(row = 0; row < (font_p->height_row >> 1); row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_sub = 7;
|
||||
for(col = 0; col < (w >> 1); col ++) {
|
||||
|
||||
px_cnt = 0;
|
||||
if((*map1_p & (1 << col_sub)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_sub)) != 0) px_cnt++;
|
||||
if(col_sub != 0) col_sub --;
|
||||
else {
|
||||
col_sub = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
if((*map1_p & (1 << col_sub)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_sub)) != 0) px_cnt++;
|
||||
if(col_sub != 0) col_sub --;
|
||||
else {
|
||||
col_sub = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
|
||||
|
||||
if(px_cnt != 0) {
|
||||
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, color_mix(color, COLOR_SILVER, 63 * px_cnt), OPA_COVER);
|
||||
}
|
||||
}
|
||||
|
||||
map1_p += font_p->width_byte;
|
||||
map2_p += font_p->width_byte;
|
||||
map1_p += font_p->width_byte - col_byte_cnt;
|
||||
map2_p += font_p->width_byte - col_byte_cnt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
bool union_ok;
|
||||
|
||||
union_ok = area_union(&masked_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the mask and map then draw the map*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
/*Go to the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p);
|
||||
map_p+= (masked_a.y1 - cords_p->y1) * map_width;
|
||||
map_p += masked_a.x1 - cords_p->x1;
|
||||
|
||||
if(transp == false) {
|
||||
cord_t row;
|
||||
cord_t mask_w = area_get_width(&masked_a) - 1;
|
||||
for(row = 0; row < area_get_height(&masked_a); row++) {
|
||||
disp_map(masked_a.x1, masked_a.y1 + row, masked_a.x1 + mask_w, masked_a.y1 + row, map_p);
|
||||
|
||||
map_p += map_width;
|
||||
}
|
||||
}else {
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
cord_t row;
|
||||
for(row = 0; row < area_get_height(&masked_a); row++) {
|
||||
cord_t col;
|
||||
for(col = 0; col < area_get_width(&masked_a); col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
lv_rpx(masked_a.x1 + col, masked_a.y1 + row, mask_p, map_p[col], opa);
|
||||
}
|
||||
}
|
||||
map_p += map_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_rbasic..h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_RBASIC_H
|
||||
#define LV_DRAW_RBASIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Fill an area on the display
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_RBASIC_H*/
|
||||
@@ -1,535 +0,0 @@
|
||||
/**
|
||||
* @file lv_vdraw.c
|
||||
*
|
||||
*/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lv_conf.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "hal/disp/disp.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lvgl/lv_obj/lv_vdb.h"
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void sw_color_cpy(color_t * dest, const color_t * src, uint32_t length, opa_t opa);
|
||||
static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_area, color_t color, opa_t opa);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Put a pixel in the Virtual Display Buffer
|
||||
* @param x pixel x coordinate
|
||||
* @param y pixel y coordinate
|
||||
* @param mask_p fill only on this mask (truncated to VDB area)
|
||||
* @param color pixel color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Pixel out of the mask*/
|
||||
if(x < mask_p->x1 || x > mask_p->x2 ||
|
||||
y < mask_p->y1 || y > mask_p->y2) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t vdb_width = area_get_width(&vdb_p->area);
|
||||
|
||||
/*Make the coordinates relative to VDB*/
|
||||
x-=vdb_p->area.x1;
|
||||
y-=vdb_p->area.y1;
|
||||
color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
|
||||
if(opa == OPA_COVER) {
|
||||
*vdb_px_p = color;
|
||||
}
|
||||
else {
|
||||
*vdb_px_p = color_mix(color,*vdb_px_p, opa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask (truncated to VDB area)
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
area_t res_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Get the union of cord and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
union_ok = area_union(&res_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
|
||||
vdb_rel_a.x1 = res_a.x1 - vdb_p->area.x1;
|
||||
vdb_rel_a.y1 = res_a.y1 - vdb_p->area.y1;
|
||||
vdb_rel_a.x2 = res_a.x2 - vdb_p->area.x1;
|
||||
vdb_rel_a.y2 = res_a.y2 - vdb_p->area.y1;
|
||||
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
uint32_t vdb_width = area_get_width(&vdb_p->area);
|
||||
/*Move the vdb_tmp to the first row*/
|
||||
vdb_buf_tmp += vdb_width * vdb_rel_a.y1;
|
||||
|
||||
#if DISP_HW_ACC == 0
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
#else
|
||||
static color_t color_map[LV_HOR_RES];
|
||||
static cord_t last_width = 0;
|
||||
cord_t map_width = area_get_width(&vdb_rel_a);
|
||||
if(color_map[0].full != color.full || last_width != map_width) {
|
||||
uint16_t i;
|
||||
|
||||
for(i =0; i < map_width; i++) {
|
||||
color_map[i].full = color.full;
|
||||
}
|
||||
|
||||
last_width = map_width;
|
||||
}
|
||||
cord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
disp_color_cpy(&vdb_buf_tmp[vdb_rel_a.x1], color_map, map_width, opa);
|
||||
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a letter in the Virtual Display Buffer
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area (truncated to VDB area)
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t letter_w = font_get_width(font_p, letter);
|
||||
uint8_t letter_h = font_get_height(font_p);
|
||||
|
||||
const uint8_t * map_p = font_get_bitmap(font_p, letter);
|
||||
|
||||
if(map_p == NULL) return;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
cord_t vdb_width = area_get_width(&vdb_p->area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
cord_t col, row;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
|
||||
/* Calculate the col/row start/end on the map
|
||||
* If font anti alaiassing is enabled use the reduced letter sizes*/
|
||||
cord_t col_start = pos_p->x > mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
cord_t col_end = pos_p->x + (letter_w >> FONT_ANTIALIAS) < mask_p->x2 ? (letter_w >> FONT_ANTIALIAS) : mask_p->x2 - pos_p->x + 1;
|
||||
cord_t row_start = pos_p->y > mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
cord_t row_end = pos_p->y + (letter_h >> FONT_ANTIALIAS) < mask_p->y2 ? (letter_h >> FONT_ANTIALIAS) : mask_p->y2 - pos_p->y + 1;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_p->y - vdb_p->area.y1) * vdb_width)
|
||||
+ pos_p->x - vdb_p->area.x1;
|
||||
|
||||
/*If the letter is partially out of mask the move there on VDB*/
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
|
||||
/*Move on the map too*/
|
||||
map_p += ((row_start << FONT_ANTIALIAS) * font_p->width_byte) + ((col_start << FONT_ANTIALIAS) >> 3);
|
||||
|
||||
#if FONT_ANTIALIAS != 0
|
||||
opa_t opa_tmp = opa;
|
||||
if(opa_tmp != OPA_COVER) opa_tmp = opa_tmp >> 2; /*Opacity per pixel (used when sum the pixels)*/
|
||||
const uint8_t * map1_p = map_p;
|
||||
const uint8_t * map2_p = map_p + font_p->width_byte;
|
||||
uint8_t px_cnt;
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - ((col_start << FONT_ANTIALIAS) % 8);
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
px_cnt = 0;
|
||||
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map1_p ++;
|
||||
map2_p ++;
|
||||
}
|
||||
|
||||
|
||||
if(px_cnt != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, 63*px_cnt);
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa_tmp * px_cnt);
|
||||
}
|
||||
|
||||
vdb_buf_tmp++;
|
||||
}
|
||||
|
||||
map1_p += font_p->width_byte;
|
||||
map2_p += font_p->width_byte;
|
||||
map1_p += font_p->width_byte - col_byte_cnt;
|
||||
map2_p += font_p->width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - ((col_end) - (col_start)); /*Next row in VDB*/
|
||||
}
|
||||
#else
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - (col_start % 8);
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
if((*map_p & (1 << col_bit)) != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
|
||||
vdb_buf_tmp++;
|
||||
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
map_p += font_p->width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area (truncated to VDB area)
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Get the union of map size and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
union_ok = area_union(&masked_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
uint8_t ds_shift = 0;
|
||||
if(upscale != false) ds_shift = 1;
|
||||
|
||||
/*If the map starts OUT of the masked area then calc. the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p) >> ds_shift;
|
||||
if(cords_p->y1 < masked_a.y1) {
|
||||
map_p += (uint32_t) map_width * ((masked_a.y1 - cords_p->y1) >> ds_shift);
|
||||
}
|
||||
if(cords_p->x1 < masked_a.x1) {
|
||||
map_p += (masked_a.x1 - cords_p->x1) >> ds_shift;
|
||||
}
|
||||
|
||||
/*Stores coordinates relative to the act vdb*/
|
||||
masked_a.x1 = masked_a.x1 - vdb_p->area.x1;
|
||||
masked_a.y1 = masked_a.y1 - vdb_p->area.y1;
|
||||
masked_a.x2 = masked_a.x2 - vdb_p->area.x1;
|
||||
masked_a.y2 = masked_a.y2 - vdb_p->area.y1;
|
||||
|
||||
cord_t vdb_width = area_get_width(&vdb_p->area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/
|
||||
|
||||
map_p -= (masked_a.x1 >> ds_shift); /*Move back. It will be easier to index 'map_p' later*/
|
||||
|
||||
/*No upscalse*/
|
||||
if(upscale == false) {
|
||||
if(transp == false) { /*Simply copy the pixels to the VDB*/
|
||||
cord_t row;
|
||||
cord_t map_useful_w = area_get_width(&masked_a);
|
||||
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
#if DISP_HW_ACC == 0
|
||||
sw_color_cpy(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
#else
|
||||
disp_color_cpy(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
#endif
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
/*To recolor draw simply a rectangle above the image*/
|
||||
if(recolor_opa != OPA_TRANSP) {
|
||||
lv_vfill(cords_p, mask_p, recolor, recolor_opa);
|
||||
}
|
||||
} else { /*transp == true: Check all pixels */
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
|
||||
if(recolor_opa == OPA_TRANSP) {/*No recolor*/
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = map_p[col];
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
} else { /*Recolor needed*/
|
||||
color_t color_tmp;
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*Upscalse*/
|
||||
else {
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
color_t color_tmp;
|
||||
color_t prev_color = COLOR_BLACK;
|
||||
cord_t map_col;
|
||||
|
||||
/*The most simple case (but upscale): 0 opacity, no recolor, no transp. pixels*/
|
||||
if(transp == false && opa == OPA_COVER && recolor_opa == OPA_TRANSP) {
|
||||
cord_t map_col_start = masked_a.x1 >> 1;
|
||||
cord_t map_col_end = masked_a.x2 >> 1;
|
||||
cord_t vdb_col; /*Col. in this row*/
|
||||
cord_t vdb_col2; /*Col. in next row*/
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row += 2) {
|
||||
map_col_start = masked_a.x1 >> 1;
|
||||
map_col_end = masked_a.x2 >> 1;
|
||||
vdb_col = masked_a.x1;
|
||||
vdb_col2 = masked_a.x1 + vdb_width;
|
||||
for(map_col = map_col_start; map_col <= map_col_end; map_col ++, vdb_col += 2, vdb_col2 += 2) {
|
||||
vdb_buf_tmp[vdb_col].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col + 1].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col2].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col2 + 1].full = map_p[map_col].full;
|
||||
}
|
||||
|
||||
map_p += map_width;
|
||||
vdb_buf_tmp += 2 * vdb_width ; /*+ 2 row on the VDB (2 rows are filled because of the upscale)*/
|
||||
|
||||
}
|
||||
}
|
||||
/*Handle other cases*/
|
||||
else {
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
map_col = col >> 1;
|
||||
|
||||
/*Handle recoloring*/
|
||||
if(recolor_opa == OPA_TRANSP) {
|
||||
color_tmp.full = map_p[map_col].full;
|
||||
} else {
|
||||
if(map_p[map_col].full != prev_color.full) {
|
||||
prev_color.full = map_p[map_col].full;
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
}
|
||||
}
|
||||
/*Put the NOT transparent pixels*/
|
||||
if(transp == false || map_p[map_col].full != transp_color.full) {
|
||||
/*Handle opacity*/
|
||||
if(opa == OPA_COVER) {
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
} else {
|
||||
vdb_buf_tmp[col] = color_mix( color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
if((row & 0x1) != 0) map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width ; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if DISP_HW_ACC == 0
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
static void sw_color_cpy(color_t * dest, const color_t * src, uint32_t length, opa_t opa)
|
||||
{
|
||||
if(opa == OPA_COVER) {
|
||||
memcpy(dest, src, length * sizeof(color_t));
|
||||
} else {
|
||||
cord_t col;
|
||||
for(col = 0; col < length; col++) {
|
||||
dest[col] = color_mix(src[col], dest[col], opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mem_area coordinates of 'mem' memory area
|
||||
* @param mem a memory address. Considered to a rectangual window according to 'mem_area'
|
||||
* @param fill_area coordinates of an area to fill. Relative to 'mem_area'.
|
||||
* @param color fill color
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_area, color_t color, opa_t opa)
|
||||
{
|
||||
/*Set all row in vdb to the given color*/
|
||||
cord_t row;
|
||||
uint32_t col;
|
||||
cord_t mem_width = area_get_width(mem_area);
|
||||
|
||||
/*Run simpler function without opacity*/
|
||||
if(opa == OPA_COVER) {
|
||||
/*Fill the first row with 'color'*/
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
mem[col] = color;
|
||||
}
|
||||
/*Copy the first row to all other rows*/
|
||||
color_t * mem_first = &mem[fill_area->x1];
|
||||
cord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(color_t);
|
||||
mem += mem_width;
|
||||
|
||||
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
|
||||
memcpy(&mem[fill_area->x1], mem_first, copy_size);
|
||||
mem += mem_width;
|
||||
}
|
||||
}
|
||||
/*Calculate with alpha too*/
|
||||
else {
|
||||
color_t bg_tmp = COLOR_BLACK;
|
||||
color_t opa_tmp = color_mix(color, bg_tmp, opa);
|
||||
for(row = fill_area->y1; row <= fill_area->y2; row++) {
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
/*If the bg color changed recalculate the result color*/
|
||||
if(mem[col].full != bg_tmp.full) {
|
||||
bg_tmp = mem[col];
|
||||
opa_tmp = color_mix(color, bg_tmp, opa);
|
||||
}
|
||||
mem[col] = opa_tmp;
|
||||
}
|
||||
mem += mem_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*DISP_HW_ACC == 0*/
|
||||
|
||||
#endif
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_vbasic.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_VBASIC_H
|
||||
#define LV_DRAW_VBASIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa);
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter in the Virtual Display Buffer
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_VDB_SIZE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_RBASIC_H*/
|
||||
@@ -1,494 +0,0 @@
|
||||
/**
|
||||
* @file lv_dispi.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lv_dispi.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "hal/indev/indev.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void dispi_task(void * param);
|
||||
static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y);
|
||||
static void dispi_proc_press(lv_dispi_t * dispi_p);
|
||||
static void disi_proc_release(lv_dispi_t * dispi_p);
|
||||
static lv_obj_t * dispi_search_obj(const lv_dispi_t * dispi_p, lv_obj_t * obj);
|
||||
static void dispi_drag(lv_dispi_t * dispi_p);
|
||||
static void dispi_drag_throw(lv_dispi_t * dispi_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ptask_t* dispi_task_p;
|
||||
static bool lv_dispi_reset_qry;
|
||||
static bool lv_dispi_reset_now;
|
||||
static lv_dispi_t dispi_array[INDEV_NUM];
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the display input subsystem
|
||||
*/
|
||||
void lv_dispi_init(void)
|
||||
{
|
||||
lv_dispi_reset_qry = false;
|
||||
lv_dispi_reset_now = false;
|
||||
|
||||
#if LV_DISPI_READ_PERIOD != 0
|
||||
dispi_task_p = ptask_create(dispi_task, LV_DISPI_READ_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
#else
|
||||
dispi_task_p = ptask_create(dispi_task, 1, PTASK_PRIO_OFF); /*Not use lv_dispi*/
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with all the display inputs. Contains (INDEV_NUM elements)
|
||||
* @return pointer to a an lv_dispi_t array.
|
||||
*/
|
||||
lv_dispi_t * lv_dispi_get_array(void)
|
||||
{
|
||||
return dispi_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all display inputs
|
||||
*/
|
||||
void lv_dispi_reset(void)
|
||||
{
|
||||
lv_dispi_reset_qry = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the long press state of a display input
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_reset_lpr(lv_dispi_t * dispi)
|
||||
{
|
||||
dispi->long_press_sent = 0;
|
||||
dispi->lpr_rep_time_stamp = systick_get();
|
||||
dispi->press_time_stamp = systick_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last point on display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi, point_t * point)
|
||||
{
|
||||
point->x = dispi->act_point.x;
|
||||
point->y = dispi->act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is dragging on display input or not
|
||||
* @param dispi pointer to a display input
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi)
|
||||
{
|
||||
return dispi->drag_in_prog == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vector of dragging on a display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi, point_t * point)
|
||||
{
|
||||
point->x = dispi->vect.x;
|
||||
point->y = dispi->vect.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi)
|
||||
{
|
||||
dispi->wait_release = 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called periodically to handle the display inputs
|
||||
* @param param unused
|
||||
*/
|
||||
static void dispi_task(void * param)
|
||||
{
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < INDEV_NUM; i++) {
|
||||
dispi_array[i].pressed = indev_get(i, &x, &y);
|
||||
dispi_proc_point(&dispi_array[i], x, y);
|
||||
}
|
||||
|
||||
/*If reset query occurred in this round then set a flag to
|
||||
* ask the dispis to reset themself in the next round */
|
||||
if(lv_dispi_reset_qry != false) {
|
||||
lv_dispi_reset_qry = false;
|
||||
lv_dispi_reset_now = true;
|
||||
}
|
||||
/*If now a reset occurred then clear the flag*/
|
||||
else if (lv_dispi_reset_now != false){
|
||||
lv_dispi_reset_now = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process new points by a display input. dispi_p->pressed has to be set
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param x x coordinate of the next point
|
||||
* @param y y coordinate of the next point
|
||||
*/
|
||||
static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
||||
{
|
||||
#if LV_ANTIALIAS != 0 && LV_VDB_SIZE != 0
|
||||
dispi_p->act_point.x = x * LV_DOWNSCALE;
|
||||
dispi_p->act_point.y = y * LV_DOWNSCALE;
|
||||
#else
|
||||
dispi_p->act_point.x = x;
|
||||
dispi_p->act_point.y = y;
|
||||
#endif
|
||||
/*Handle the reset query*/
|
||||
if(lv_dispi_reset_now != false) {
|
||||
dispi_p->act_obj = NULL;
|
||||
dispi_p->last_obj = NULL;
|
||||
dispi_p->drag_range_out = 0;
|
||||
dispi_p->drag_in_prog = 0;
|
||||
dispi_p->long_press_sent = 0;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
dispi_p->lpr_rep_time_stamp = 0;
|
||||
dispi_p->vect_sum.x = 0;
|
||||
dispi_p->vect_sum.y = 0;
|
||||
}
|
||||
|
||||
if(dispi_p->pressed != false){
|
||||
#if LV_DISPI_TP_MARKER != 0
|
||||
area_t area;
|
||||
area.x1 = x - (LV_DISPI_TP_MARKER >> 1);
|
||||
area.y1 = y - (LV_DISPI_TP_MARKER >> 1);
|
||||
area.x2 = x + ((LV_DISPI_TP_MARKER >> 1) | 0x1);
|
||||
area.y2 = y + ((LV_DISPI_TP_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, COLOR_MAKE(0xFF, 0, 0), OPA_COVER);
|
||||
#endif
|
||||
dispi_proc_press(dispi_p);
|
||||
} else {
|
||||
disi_proc_release(dispi_p);
|
||||
}
|
||||
|
||||
|
||||
dispi_p->last_point.x = dispi_p->act_point.x;
|
||||
dispi_p->last_point.y = dispi_p->act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the pressed state
|
||||
* @param dispi_p pointer to a display input
|
||||
*/
|
||||
static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
{
|
||||
lv_obj_t * pr_obj = dispi_p->act_obj;
|
||||
|
||||
if(dispi_p->wait_release != 0) return;
|
||||
|
||||
/*If there is no last object then search*/
|
||||
if(dispi_p->act_obj == NULL) {
|
||||
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
||||
}
|
||||
/*If there is last object but it is not dragged also search*/
|
||||
else if(dispi_p->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
||||
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
||||
}
|
||||
/*If a dragable object was the last then keep it*/
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
/*If a new object was found reset some variables and send a pressed signal*/
|
||||
if(pr_obj != dispi_p->act_obj) {
|
||||
|
||||
dispi_p->last_point.x = dispi_p->act_point.x;
|
||||
dispi_p->last_point.y = dispi_p->act_point.y;
|
||||
|
||||
/*If a new object found the previous was lost, so send a signal*/
|
||||
if(dispi_p->act_obj != NULL) {
|
||||
dispi_p->act_obj->signal_f(dispi_p->act_obj,
|
||||
LV_SIGNAL_PRESS_LOST, dispi_p);
|
||||
}
|
||||
|
||||
if(pr_obj != NULL) {
|
||||
/* Save the time when the obj pressed.
|
||||
* It is necessary to count the long press time.*/
|
||||
dispi_p->press_time_stamp = systick_get();
|
||||
dispi_p->long_press_sent = 0;
|
||||
dispi_p->drag_range_out = 0;
|
||||
dispi_p->drag_in_prog = 0;
|
||||
dispi_p->vect_sum.x = 0;
|
||||
dispi_p->vect_sum.y = 0;
|
||||
|
||||
/*Search for 'top' attribute*/
|
||||
lv_obj_t * i = pr_obj;
|
||||
lv_obj_t * last_top = NULL;
|
||||
while(i != NULL){
|
||||
if(i->top_en != 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*/
|
||||
ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_obj_inv(last_top);
|
||||
}
|
||||
|
||||
/*Send a signal about the press*/
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_PRESSED, dispi_p);
|
||||
}
|
||||
}
|
||||
|
||||
/* The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(lv_dispi_reset_qry == false) {
|
||||
dispi_p->act_obj = pr_obj; /*Save the pressed object*/
|
||||
dispi_p->last_obj = dispi_p->act_obj; /*Refresh the last_obj*/
|
||||
|
||||
/*Calculate the vector*/
|
||||
dispi_p->vect.x = dispi_p->act_point.x - dispi_p->last_point.x;
|
||||
dispi_p->vect.y = dispi_p->act_point.y - dispi_p->last_point.y;
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(dispi_p->act_obj != NULL) {
|
||||
dispi_p->act_obj->signal_f(dispi_p->act_obj, LV_SIGNAL_PRESSING, dispi_p);
|
||||
|
||||
dispi_drag(dispi_p);
|
||||
|
||||
/*If there is no drag then check for long press time*/
|
||||
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 0) {
|
||||
/*Send a signal about the long press if enough time elapsed*/
|
||||
if(systick_elaps(dispi_p->press_time_stamp) > LV_DISPI_LONG_PRESS_TIME) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS, dispi_p);
|
||||
|
||||
/*Mark the signal sending to do not send it again*/
|
||||
dispi_p->long_press_sent = 1;
|
||||
|
||||
/*Save the long press time stamp for the long press repeat handler*/
|
||||
dispi_p->lpr_rep_time_stamp = systick_get();
|
||||
}
|
||||
}
|
||||
/*Send long press repeated signal*/
|
||||
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 1) {
|
||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||
if(systick_elaps(dispi_p->lpr_rep_time_stamp) > LV_DISPI_LONG_PRESS_REP_TIME) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS_REP, dispi_p);
|
||||
dispi_p->lpr_rep_time_stamp = systick_get();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the released state
|
||||
* @param dispi_p pointer to a display input
|
||||
*/
|
||||
static void disi_proc_release(lv_dispi_t * dispi_p)
|
||||
{
|
||||
if(dispi_p->wait_release != 0) {
|
||||
dispi_p->act_obj = NULL;
|
||||
dispi_p->last_obj = NULL;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
dispi_p->lpr_rep_time_stamp = 0;
|
||||
dispi_p->wait_release = 0;
|
||||
}
|
||||
|
||||
/*Forgot the act obj and send a released signal */
|
||||
if(dispi_p->act_obj != NULL) {
|
||||
dispi_p->act_obj->signal_f(dispi_p->act_obj,
|
||||
LV_SIGNAL_RELEASED, dispi_p);
|
||||
dispi_p->act_obj = NULL;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
dispi_p->lpr_rep_time_stamp = 0;
|
||||
}
|
||||
|
||||
/*The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(dispi_p->last_obj != NULL && lv_dispi_reset_qry == false) {
|
||||
dispi_drag_throw(dispi_p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the most top, clickable object on the last point of a display input
|
||||
* @param dispi_p pointer to a display input
|
||||
* @param obj pointer to a start object, typically the screen
|
||||
* @return pointer to the found object or NULL if there was no suitable object
|
||||
*/
|
||||
static lv_obj_t * dispi_search_obj(const lv_dispi_t * dispi_p, lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If the point is on this object*/
|
||||
/*Check its children too*/
|
||||
if(area_is_point_on(&obj->cords, &dispi_p->act_point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = dispi_search_obj(dispi_p, i);
|
||||
|
||||
/*If a child was found then break*/
|
||||
if(found_p != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*If then the children was not ok, but this obj is clickable
|
||||
* and it or its parent is not hidden then save this object*/
|
||||
if(found_p == NULL && lv_obj_get_click(obj) != false) {
|
||||
lv_obj_t * i = obj;
|
||||
while(i != NULL) {
|
||||
if(lv_obj_get_hidden(i) == true) break;
|
||||
i = lv_obj_get_parent(i);
|
||||
}
|
||||
/*No parent found with hidden == true*/
|
||||
if(i == NULL) found_p = obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return found_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dragging of dispi_p->act_obj
|
||||
* @param dispi_p pointer to a display input
|
||||
*/
|
||||
static void dispi_drag(lv_dispi_t * dispi_p)
|
||||
{
|
||||
lv_obj_t * drag_obj = dispi_p->act_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
if(lv_obj_get_drag(drag_obj) == false) return;
|
||||
|
||||
/*If still there is no drag then count the movement*/
|
||||
if(dispi_p->drag_range_out == 0) {
|
||||
dispi_p->vect_sum.x += dispi_p->vect.x;
|
||||
dispi_p->vect_sum.y += dispi_p->vect.y;
|
||||
|
||||
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
||||
if(MATH_ABS(dispi_p->vect_sum.x) >= LV_DISPI_DRAG_LIMIT ||
|
||||
MATH_ABS(dispi_p->vect_sum.y) >= LV_DISPI_DRAG_LIMIT)
|
||||
{
|
||||
dispi_p->drag_range_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the drag limit is stepped over then handle the dragging*/
|
||||
if(dispi_p->drag_range_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(dispi_p->vect.x != 0 ||
|
||||
dispi_p->vect.y != 0) {
|
||||
/*Get the coordinates of the object end modify them*/
|
||||
cord_t act_x = lv_obj_get_x(drag_obj);
|
||||
cord_t act_y = lv_obj_get_y(drag_obj);
|
||||
|
||||
lv_obj_set_pos(drag_obj, act_x + dispi_p->vect.x, act_y + dispi_p->vect.y);
|
||||
|
||||
/*Set the drag in progress flag if the object is really moved*/
|
||||
if(lv_obj_get_x(drag_obj) != act_x || lv_obj_get_y(drag_obj) != act_y) {
|
||||
if(dispi_p->drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_BEGIN, dispi_p);
|
||||
}
|
||||
dispi_p->drag_in_prog = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle throwing by drag if the drag is ended
|
||||
* @param dispi_p pointer to a display input
|
||||
*/
|
||||
static void dispi_drag_throw(lv_dispi_t * dispi_p)
|
||||
{
|
||||
if(dispi_p->drag_in_prog == 0) return;
|
||||
|
||||
/*Set new position if the vector is not zero*/
|
||||
lv_obj_t * drag_obj = dispi_p->last_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
/*Return if the drag throw is not enabled*/
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false ){
|
||||
dispi_p->drag_in_prog = 0;
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, dispi_p);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Reduce the vectors*/
|
||||
dispi_p->vect.x = dispi_p->vect.x * (100 -LV_DISPI_DRAG_THROW) / 100;
|
||||
dispi_p->vect.y = dispi_p->vect.y * (100 -LV_DISPI_DRAG_THROW) / 100;
|
||||
|
||||
if(dispi_p->vect.x != 0 ||
|
||||
dispi_p->vect.y != 0)
|
||||
{
|
||||
/*Get the coordinates and modify them*/
|
||||
cord_t act_x = lv_obj_get_x(drag_obj) + dispi_p->vect.x;
|
||||
cord_t act_y = lv_obj_get_y(drag_obj) + dispi_p->vect.y;
|
||||
lv_obj_set_pos(drag_obj, act_x, act_y);
|
||||
}
|
||||
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
|
||||
else {
|
||||
dispi_p->drag_in_prog = 0;
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, dispi_p);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/**
|
||||
* @file lv_dispi.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DISPI_H
|
||||
#define LV_DISPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
bool pressed;
|
||||
point_t act_point;
|
||||
point_t last_point;
|
||||
point_t vect;
|
||||
point_t vect_sum;
|
||||
lv_obj_t * act_obj;
|
||||
lv_obj_t * last_obj;
|
||||
uint32_t press_time_stamp;
|
||||
uint32_t lpr_rep_time_stamp;
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_range_out :1;
|
||||
uint8_t drag_in_prog :1;
|
||||
uint8_t long_press_sent :1;
|
||||
uint8_t wait_release :1;
|
||||
}lv_dispi_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ACTION_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action function*/
|
||||
LV_ACTION_RES_OK, /*The object is valid (no deleted) after the action*/
|
||||
}lv_action_res_t;
|
||||
|
||||
typedef lv_action_res_t ( * lv_action_t) (struct __LV_OBJ_T * obj, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the display input subsystem
|
||||
*/
|
||||
void lv_dispi_init(void);
|
||||
|
||||
/**
|
||||
* Get an array with all the display inputs. Contains (INDEV_NUM elements)
|
||||
* @return pointer to a an lv_dispi_t array.
|
||||
*/
|
||||
lv_dispi_t * lv_dispi_get_array(void);
|
||||
|
||||
/**
|
||||
* Reset all display inputs
|
||||
*/
|
||||
void lv_dispi_reset(void);
|
||||
|
||||
/**
|
||||
* Reset the long press state of a display input
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_reset_lpr(lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Get the last point on display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_dispi_get_point(lv_dispi_t * dispi, point_t * point);
|
||||
|
||||
/**
|
||||
* Check if there is dragging on display input or not
|
||||
* @param dispi pointer to a display input
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_dispi_is_dragging(lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Get the vector of dragging on a display input
|
||||
* @param dispi pointer to a display input
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_dispi_get_vect(lv_dispi_t * dispi, point_t * point);
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param dispi pointer to a display input
|
||||
*/
|
||||
void lv_dispi_wait_release(lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DISPI_H*/
|
||||
1539
lv_obj/lv_obj.c
1539
lv_obj/lv_obj.c
File diff suppressed because it is too large
Load Diff
677
lv_obj/lv_obj.h
677
lv_obj/lv_obj.h
@@ -1,677 +0,0 @@
|
||||
/**
|
||||
* @file lv_obj.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_H
|
||||
#define LV_OBJ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include <misc/gfx/area.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Error check of lv_conf.h*/
|
||||
#if LV_HOR_RES == 0 || LV_VER_RES == 0
|
||||
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
|
||||
#endif
|
||||
|
||||
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2
|
||||
#error "LV: LV_DOWNSCALE can be only 1 or 2"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0
|
||||
#error "LV: If LV_VDB_SIZE == 0 the antialaissing must be disabled"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE != 0 && LV_VDB_SIZE < LV_HOR_RES && LV_ANTIALIAS == 0
|
||||
#error "LV: Small Virtual Display Buffer (lv_conf.h: LV_VDB_SIZE >= LV_HOR_RES)"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE != 0 && LV_VDB_SIZE < 2 *LV_HOR_RES && LV_ANTIALIAS != 0
|
||||
#error "LV: Small Virtual Display Buffer (lv_conf.h: LV_VDB_SIZE >= (2 * LV_HOR_RES))"
|
||||
#endif
|
||||
|
||||
/*New defines*/
|
||||
#define LV_OBJ_DEF_WIDTH (80 * LV_DOWNSCALE)
|
||||
#define LV_OBJ_DEF_HEIGHT (60 * LV_DOWNSCALE)
|
||||
|
||||
#define ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct __LV_OBJ_T;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_DESIGN_DRAW_MAIN,
|
||||
LV_DESIGN_DRAW_POST,
|
||||
LV_DESIGN_COVER_CHK,
|
||||
}lv_design_mode_t;
|
||||
|
||||
typedef bool (* lv_design_f_t) (struct __LV_OBJ_T * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_SIGNAL_CLEANUP,
|
||||
LV_SIGNAL_PRESSED,
|
||||
LV_SIGNAL_PRESSING,
|
||||
LV_SIGNAL_PRESS_LOST,
|
||||
LV_SIGNAL_RELEASED,
|
||||
LV_SIGNAL_LONG_PRESS,
|
||||
LV_SIGNAL_LONG_PRESS_REP,
|
||||
LV_SIGNAL_DRAG_BEGIN,
|
||||
LV_SIGNAL_DRAG_END,
|
||||
LV_SIGNAL_CHILD_CHG,
|
||||
LV_SIGNAL_CORD_CHG,
|
||||
LV_SIGNAL_STYLE_CHG,
|
||||
LV_SIGNAL_REFR_EXT_SIZE,
|
||||
}lv_signal_t;
|
||||
|
||||
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
|
||||
|
||||
typedef struct __LV_OBJ_T
|
||||
{
|
||||
struct __LV_OBJ_T * par; /*Pointer to the parent object*/
|
||||
ll_dsc_t child_ll; /*Linked list to store the children objects*/
|
||||
|
||||
area_t cords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
|
||||
lv_signal_f_t signal_f; /*Object type specific signal function*/
|
||||
lv_design_f_t design_f; /*Object type specific design function*/
|
||||
|
||||
void * ext; /*Object type specific extended data*/
|
||||
lv_style_t * style_p; /*Pointer to the object's style*/
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
void * free_p; /*Application specific pointer (set it freely)*/
|
||||
#endif
|
||||
|
||||
/*Attributes and states*/
|
||||
uint8_t click_en :1; /*1: Can be pressed by a display input device*/
|
||||
uint8_t drag_en :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw_en:1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /*1: Object is hidden*/
|
||||
uint8_t top_en :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t reserved :1;
|
||||
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from lv_obj_prot_t*/
|
||||
|
||||
cord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
uint8_t free_num; /*Application specific identifier (set it freely)*/
|
||||
#endif
|
||||
}lv_obj_t;
|
||||
|
||||
/*Protect some attributes (max. 8 bit)*/
|
||||
typedef enum
|
||||
{
|
||||
LV_PROTECT_NONE = 0x00,
|
||||
LV_PROTECT_CHILD_CHG = 0x01, /*Disable the child change signal. Used by the library*/
|
||||
LV_PROTECT_PARENT = 0x02, /*Prevent automatic parent change (e.g. in lv_page)*/
|
||||
LV_PROTECT_POS = 0x04, /*Prevent automatic positioning (e.g. in lv_cont layout)*/
|
||||
LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in lv_cont PRETTY layout)*/
|
||||
}lv_protect_t;
|
||||
|
||||
typedef 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,
|
||||
}lv_align_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
color_t color;
|
||||
opa_t opa;
|
||||
}lv_objs_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ANIM_NONE = 0,
|
||||
LV_ANIM_FLOAT_TOP, /*Float from/to the top*/
|
||||
LV_ANIM_FLOAT_LEFT, /*Float from/to the left*/
|
||||
LV_ANIM_FLOAT_BOTTOM, /*Float from/to the bottom*/
|
||||
LV_ANIM_FLOAT_RIGHT, /*Float from/to the right*/
|
||||
LV_ANIM_GROW_H, /*Grow/shrink horizontally*/
|
||||
LV_ANIM_GROW_V, /*Grow/shrink vertically*/
|
||||
}lv_anim_builtin_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the 'lv' library.
|
||||
*/
|
||||
void lv_init(void);
|
||||
|
||||
/**
|
||||
* Create a basic object
|
||||
* @param parent pointer to a parent object.
|
||||
* If NULL then a screen will be created
|
||||
* @param copy pointer to a base object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the new object
|
||||
*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Delete 'obj' and all of its children
|
||||
* @param obj pointer to an object to delete
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Signal function of the basic object
|
||||
* @param obj pointer to an object
|
||||
* @param sign signal type
|
||||
* @param param parameter for the signal (depends on signal type)
|
||||
* @return false: the object become invalid (e.g. deleted)
|
||||
*/
|
||||
bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr);
|
||||
|
||||
/**
|
||||
* Set a new parent for an object. Its relative position will be the same.
|
||||
* @param obj pointer to an object
|
||||
* @param parent pointer to the new parent object
|
||||
*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent)
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent).
|
||||
* The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent
|
||||
*/
|
||||
void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the size of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w new width
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the size of an object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w new width
|
||||
*/
|
||||
void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the width of an object. The width will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the height of an object. The height will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* 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(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Align an object to an other object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @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 (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Set the extended size of an object
|
||||
* @param obj pointer to an object
|
||||
* @param ext_size the extended size
|
||||
*/
|
||||
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
|
||||
/**
|
||||
* Set a new style for an object
|
||||
* @param obj pointer to an object
|
||||
* @param style_p pointer to the new style
|
||||
*/
|
||||
void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_objs(void * style);
|
||||
|
||||
/**
|
||||
* Hide an object. It won't be visible and clickable.
|
||||
* @param obj pointer to an object
|
||||
* @param en true: hide the object
|
||||
*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable or disable the clicking of an object
|
||||
* @param obj pointer to an object
|
||||
* @param en true: make the object clickable
|
||||
*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable to bring this object to the foreground if it
|
||||
* or any of its children is clicked
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the auto top feature
|
||||
*/
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable the dragging of an object
|
||||
* @param obj pointer to an object
|
||||
* @param en true: make the object dragable
|
||||
*/
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable the throwing of an object after is is dragged
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the drag throw
|
||||
*/
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Enable to use parent for drag related operations.
|
||||
* If trying to drag the object the parent will be moved instead
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable the 'drag parent' for the object
|
||||
*/
|
||||
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
|
||||
|
||||
/**
|
||||
* Set a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Clear a bit or bits in the protect filed
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Set the signal function of an object.
|
||||
* Always call the previous signal function in the new.
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
|
||||
/**
|
||||
* Set a new design function for an object
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new design function
|
||||
*/
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
|
||||
/**
|
||||
* Allocate a new ext. data for an object
|
||||
* @param obj pointer to an object
|
||||
* @param ext_size the size of the new ext. data
|
||||
* @return Normal pointer to the allocated ext
|
||||
*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
|
||||
/**
|
||||
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_num the new free number
|
||||
*/
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
#endif
|
||||
/**
|
||||
* Animate an object
|
||||
* @param obj pointer to an object to animate
|
||||
* @param type type of animation from 'lv_anim_builtin_t'. 'OR' it with ANIM_IN or ANIM_OUT
|
||||
* @param time time of animation in milliseconds
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *));
|
||||
|
||||
/**
|
||||
* Return with the actual screen
|
||||
* @return pointer to to the actual screen object
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Returns with the parent of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the parent of 'obj'
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Iterate through the children of an object
|
||||
* @param obj pointer to an object
|
||||
* @param child NULL at first call to get the next children
|
||||
* and the previous return value later
|
||||
* @return the child after 'act_child' or NULL if no more child
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child);
|
||||
|
||||
/**
|
||||
* Count the children of an object (only children directly on 'obj')
|
||||
* @param obj pointer to an object
|
||||
* @return children number of 'obj'
|
||||
*/
|
||||
uint16_t lv_obj_get_child_num(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Copy the coordinates of an object to an area
|
||||
* @param obj pointer to an object
|
||||
* @param cords_p pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the left side of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_x(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the y coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the top of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_y(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the width
|
||||
*/
|
||||
cord_t lv_obj_get_width(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the height
|
||||
*/
|
||||
cord_t lv_obj_get_height(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the extended size attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the extended size attribute
|
||||
*/
|
||||
cord_t lv_obj_get_ext_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the style pointer of an object (if NULL get style of the parent)
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_obj_get_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the hidden attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is hidden
|
||||
*/
|
||||
bool lv_obj_get_hidden(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the click enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is clickable
|
||||
*/
|
||||
bool lv_obj_get_click(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
|
||||
*/
|
||||
bool lv_obj_get_top(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the object is dragable
|
||||
*/
|
||||
bool lv_obj_get_drag(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag thow enable attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: drag throw is enabled
|
||||
*/
|
||||
bool lv_obj_get_drag_throw(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the drag parent attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return true: drag parent is enabled
|
||||
*/
|
||||
bool lv_obj_get_drag_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
* @return protect field ('OR'ed values of lv_obj_prot_t)
|
||||
*/
|
||||
uint8_t lv_obj_get_protect(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check at least one bit of a given protect bitfield is set
|
||||
* @param obj pointer to an object
|
||||
* @param prot protect bits to test ('OR'ed values of lv_obj_prot_t)
|
||||
* @return false: none of the given bits are set, true: at least one bit is set
|
||||
*/
|
||||
bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Get the signal function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the design function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the design function
|
||||
*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the ext pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the ext pointer but not the dynamic version
|
||||
* Use it as ext->data1, and NOT da(ext)->data1
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
* @return the free number
|
||||
*/
|
||||
uint8_t lv_obj_get_free_num(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
/**
|
||||
* Get the free pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the free pointer
|
||||
*/
|
||||
void * lv_obj_get_free_p(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_H*/
|
||||
474
lv_obj/lv_refr.c
474
lv_obj/lv_refr.c
@@ -1,474 +0,0 @@
|
||||
/**
|
||||
* @file lv_refr.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stddef.h>
|
||||
#include "lv_conf.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/mem/fifo.h"
|
||||
#include "lv_refr.h"
|
||||
#include "lv_vdb.h"
|
||||
#include "hal/systick/systick.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
area_t area;
|
||||
uint8_t joined;
|
||||
}lv_join_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_refr_task(void * param);
|
||||
static void lv_refr_join_area(void);
|
||||
static void lv_refr_areas(void);
|
||||
#if LV_VDB_SIZE == 0
|
||||
static void lv_refr_area_no_vdb(const area_t * area_p);
|
||||
#else
|
||||
static void lv_refr_area_with_vdb(const area_t * area_p);
|
||||
static void lv_refr_area_part_vdb(const area_t * area_p);
|
||||
#endif
|
||||
static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj);
|
||||
static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p);
|
||||
static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
static uint16_t inv_buf_p;
|
||||
static void (*monitor_cb)(uint32_t, uint32_t);
|
||||
static uint32_t px_num;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the screen refresh subsystem
|
||||
*/
|
||||
void lv_refr_init(void)
|
||||
{
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
ptask_t* task;
|
||||
task = ptask_create(lv_refr_task, LV_REFR_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
dm_assert(task);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p)
|
||||
{
|
||||
/*Clear the invalidate buffer if the parameter is NULL*/
|
||||
if(area_p == NULL) {
|
||||
inv_buf_p = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
area_t scr_area;
|
||||
scr_area.x1 = 0;
|
||||
scr_area.y1 = 0;
|
||||
scr_area.x2 = LV_HOR_RES - 1;
|
||||
scr_area.y2 = LV_VER_RES - 1;
|
||||
|
||||
area_t com_area;
|
||||
bool suc;
|
||||
|
||||
suc = area_union(&com_area, area_p, &scr_area);
|
||||
|
||||
/*The area is truncated to the screen*/
|
||||
if(suc != false)
|
||||
{
|
||||
#if LV_DOWNSCALE == 2
|
||||
/*Rounding*/
|
||||
com_area.x1 = com_area.x1 & (~0x1);
|
||||
com_area.y1 = com_area.y1 & (~0x1);
|
||||
com_area.x2 = com_area.x2 | 0x1;
|
||||
com_area.y2 = com_area.y2 | 0x1;
|
||||
#endif
|
||||
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
}
|
||||
|
||||
|
||||
/*Save the area*/
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&scr_area);
|
||||
}
|
||||
inv_buf_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels
|
||||
* @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num))
|
||||
* time_ms: refresh time in [ms]
|
||||
* px_num: not the drawn pixels but the number of affected pixels of the screen
|
||||
* (more pixels are drawn with opacity areas)
|
||||
*/
|
||||
void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
|
||||
{
|
||||
monitor_cb = cb;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called periodically to handle the refreshing
|
||||
* @param param unused
|
||||
*/
|
||||
static void lv_refr_task(void * param)
|
||||
{
|
||||
|
||||
uint32_t start = systick_get();
|
||||
|
||||
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;
|
||||
|
||||
/* In the callback lv_obj_inv can occur
|
||||
* therefore be sure the inv_buf is cleared prior to it*/
|
||||
if(refr_done != false) {
|
||||
if(monitor_cb != NULL) {
|
||||
monitor_cb(systick_elaps(start), px_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Join the areas which has got common parts
|
||||
*/
|
||||
static void lv_refr_join_area(void)
|
||||
{
|
||||
uint32_t join_from;
|
||||
uint32_t join_in;
|
||||
area_t joined_area;
|
||||
for(join_in = 0; join_in < inv_buf_p; join_in++) {
|
||||
if(inv_buf[join_in].joined != 0) continue;
|
||||
|
||||
/*Check all areas to join them in 'join_in'*/
|
||||
for(join_from = 0; join_from < inv_buf_p; join_from++) {
|
||||
/*Handle only unjoined areas and ignore itself*/
|
||||
if(inv_buf[join_from].joined != 0 || join_in == join_from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(area_is_on(&inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
area_join(&joined_area, &inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area);
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(area_get_size(&joined_area) <
|
||||
(area_get_size(&inv_buf[join_in].area) + area_get_size(&inv_buf[join_from].area))) {
|
||||
area_cpy(&inv_buf[join_in].area, &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
inv_buf[join_from].joined = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the joined areas
|
||||
*/
|
||||
static void lv_refr_areas(void)
|
||||
{
|
||||
px_num = 0;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
/*Refresh the unjoined areas*/
|
||||
if(inv_buf[i].joined == 0) {
|
||||
/*If there is no VDB do simple drawing*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_refr_area_no_vdb(&inv_buf[i].area);
|
||||
#else
|
||||
/*If VDB is used...*/
|
||||
lv_refr_area_with_vdb(&inv_buf[i].area);
|
||||
#endif
|
||||
if(monitor_cb != NULL) px_num += area_get_size(&inv_buf[i].area);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if LV_VDB_SIZE == 0
|
||||
/**
|
||||
* Refresh an area if there is no Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_no_vdb(const area_t * area_p)
|
||||
{
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(area_p, lv_scr_act());
|
||||
|
||||
/*Do the refreshing*/
|
||||
lv_refr_make(top_p, area_p);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Refresh an area if there is Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Always use the full row*/
|
||||
vdb_p->area.x1 = area_p->x1;
|
||||
vdb_p->area.y1 = area_p->y1;
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
|
||||
/*Calculate the max row num*/
|
||||
uint32_t max_row = (uint32_t) LV_VDB_SIZE / (vdb_p->area.x2 - vdb_p->area.x1 + 1);
|
||||
if(max_row > area_get_height(area_p)) max_row = area_get_height(area_p);
|
||||
|
||||
/*Round the row number with downscale*/
|
||||
#if LV_DOWNSCALE == 2
|
||||
max_row &= (~0x1);
|
||||
#endif
|
||||
|
||||
/*Refresh all rows*/
|
||||
cord_t row = area_p->y1;
|
||||
|
||||
for(row = area_p->y1; row + max_row - 1 <= area_p->y2; row += max_row) {
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = row + max_row - 1;
|
||||
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
}
|
||||
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(area_p->y2 != vdb_p->area.y2) {
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = area_p->y2;
|
||||
|
||||
/*Refresh this part too*/
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh a part of an area which is on the actual Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_part_vdb(const area_t * area_p)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get the new mask from the original area and the act. VDB
|
||||
It will be a part of 'area_p'*/
|
||||
area_t start_mask;
|
||||
area_union(&start_mask, area_p, &vdb_p->area);
|
||||
|
||||
/*Get the most top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act());
|
||||
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_make(top_p, &start_mask);
|
||||
|
||||
/*Flush the content of the VDB*/
|
||||
lv_vdb_flush();
|
||||
}
|
||||
|
||||
#endif /*LV_VDB_SIZE == 0*/
|
||||
|
||||
/**
|
||||
* Search the most top object which fully covers an area
|
||||
* @param area_p pointer to an area
|
||||
* @param obj the first object to start the searching (typically a screen)
|
||||
* @return
|
||||
*/
|
||||
static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(area_is_in(area_p, &obj->cords) && obj->hidden == 0)
|
||||
{
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
|
||||
/*If a children is ok then break*/
|
||||
if(found_p != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*If no better children check this object*/
|
||||
if(found_p == NULL) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa == OPA_COVER &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the refreshing from an object. Draw all its children and the youngers too.
|
||||
* @param top_p pointer to an objects. Start the drawing from it.
|
||||
* @param mask_p pointer to an area, the objects will be drawn only here
|
||||
*/
|
||||
static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
{
|
||||
/* Normally always will be a top_obj (at least the screen)
|
||||
* but in special cases (e.g. if the screen has alpha) it won't.
|
||||
* In this case use the screen directly */
|
||||
if(top_p == NULL) top_p = lv_scr_act();
|
||||
|
||||
/*Refresh the top object and its children*/
|
||||
lv_refr_obj(top_p, mask_p);
|
||||
|
||||
/*Draw the 'younger' sibling objects because they can be on top_obj */
|
||||
lv_obj_t * par;
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * border_p = top_p;
|
||||
|
||||
par = lv_obj_get_parent(top_p);
|
||||
|
||||
/*Do until not reach the screen*/
|
||||
while(par != NULL) {
|
||||
/*object before border_p has to be redrawn*/
|
||||
i = ll_get_prev(&(par->child_ll), border_p);
|
||||
|
||||
while(i != NULL) {
|
||||
/*Refresh the objects*/
|
||||
lv_refr_obj(i, mask_p);
|
||||
i = ll_get_prev(&(par->child_ll), i);
|
||||
}
|
||||
|
||||
/*The new border will be there last parents,
|
||||
*so the 'younger' brothers of parent will be refreshed*/
|
||||
border_p = par;
|
||||
/*Go a level deeper*/
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
/*Call the post draw design function of the parents of the to object*/
|
||||
par = lv_obj_get_parent(top_p);
|
||||
while(par != NULL) {
|
||||
par->design_f(par, mask_p, LV_DESIGN_DRAW_POST);
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh an object an all of its children. (Called recursively)
|
||||
* @param obj pointer to an object to refresh
|
||||
* @param mask_ori_p pointer to an area, the objects will be drawn only here
|
||||
*/
|
||||
static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
{
|
||||
/*Do not refresh hidden objects*/
|
||||
if(obj->hidden != 0) return;
|
||||
|
||||
bool union_ok; /* Store the return value of area_union */
|
||||
/* Truncate the original mask to the coordinates of the parent
|
||||
* because the parent and its children are visible only here */
|
||||
area_t obj_mask;
|
||||
area_t obj_ext_mask;
|
||||
area_t obj_area;
|
||||
cord_t ext_size = obj->ext_size;
|
||||
lv_obj_get_cords(obj, &obj_area);
|
||||
obj_area.x1 -= ext_size;
|
||||
obj_area.y1 -= ext_size;
|
||||
obj_area.x2 += ext_size;
|
||||
obj_area.y2 += ext_size;
|
||||
union_ok = area_union(&obj_ext_mask, mask_ori_p, &obj_area);
|
||||
|
||||
/*Draw the parent and its children only if they ore on 'mask_parent'*/
|
||||
if(union_ok != false) {
|
||||
|
||||
/* Redraw the object */
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
//tick_wait_ms(100); /*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_cords(obj, &obj_area);
|
||||
union_ok = area_union(&obj_mask, mask_ori_p, &obj_area);
|
||||
if(union_ok != false) {
|
||||
area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
area_t child_area;
|
||||
LL_READ_BACK(obj->child_ll, child_p)
|
||||
{
|
||||
lv_obj_get_cords(child_p, &child_area);
|
||||
ext_size = child_p->ext_size;
|
||||
child_area.x1 -= ext_size;
|
||||
child_area.y1 -= ext_size;
|
||||
child_area.x2 += ext_size;
|
||||
child_area.y2 += ext_size;
|
||||
/* Get the union (common parts) of original mask (from obj)
|
||||
* and its child */
|
||||
union_ok = area_union(&mask_child, &obj_mask, &child_area);
|
||||
|
||||
/*If the parent and the child has common area then refresh the child */
|
||||
if(union_ok) {
|
||||
/*Refresh the next children*/
|
||||
lv_refr_obj(child_p, &mask_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If all the children are redrawn make 'post draw' design */
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* @file lv_refr.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_REFR_H
|
||||
#define LV_REFR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the screen refresh subsystem
|
||||
*/
|
||||
void lv_refr_init(void);
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p);
|
||||
|
||||
/**
|
||||
* Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels
|
||||
* @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num))
|
||||
*/
|
||||
void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t));
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_REFR_H*/
|
||||
@@ -1,234 +0,0 @@
|
||||
/**
|
||||
* @file lv_style.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static lv_style_t lv_style_scr;
|
||||
static lv_style_t lv_style_transp;
|
||||
static lv_style_t lv_style_transp_tight;
|
||||
static lv_style_t lv_style_plain;
|
||||
static lv_style_t lv_style_plain_color;
|
||||
static lv_style_t lv_style_pretty;
|
||||
static lv_style_t lv_style_pretty_color;
|
||||
static lv_style_t lv_style_btn_rel;
|
||||
static lv_style_t lv_style_btn_pr;
|
||||
static lv_style_t lv_style_btn_trel;
|
||||
static lv_style_t lv_style_btn_tpr;
|
||||
static lv_style_t lv_style_btn_ina;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void)
|
||||
{
|
||||
/* Not White/Black/Gray colors are created by HSV model with
|
||||
* HUE = 210*/
|
||||
|
||||
/*Screen style*/
|
||||
lv_style_scr.ccolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.opa = OPA_COVER;
|
||||
|
||||
lv_style_scr.mcolor = COLOR_MAKE(0xc9, 0xdb, 0xee);
|
||||
lv_style_scr.gcolor = COLOR_MAKE(0x4d, 0x91, 0xd5);
|
||||
lv_style_scr.bcolor = COLOR_BLACK;
|
||||
lv_style_scr.scolor = COLOR_GRAY;
|
||||
lv_style_scr.radius = 0;
|
||||
lv_style_scr.bwidth = 0;
|
||||
lv_style_scr.swidth = 0;
|
||||
lv_style_scr.stype = LV_STYPE_FULL;
|
||||
lv_style_scr.vpad = LV_DPI / 12;
|
||||
lv_style_scr.hpad = LV_DPI / 12;
|
||||
lv_style_scr.opad = LV_DPI / 12;
|
||||
lv_style_scr.bopa = OPA_COVER;
|
||||
lv_style_scr.empty = 0;
|
||||
lv_style_scr.glass = 0;
|
||||
|
||||
lv_style_scr.font = font_get(FONT_DEFAULT);
|
||||
lv_style_scr.letter_space = 1 * LV_DOWNSCALE;
|
||||
lv_style_scr.line_space = 2 * LV_DOWNSCALE;
|
||||
lv_style_scr.txt_align = LV_TXT_ALIGN_LEFT;
|
||||
lv_style_scr.img_recolor = OPA_TRANSP;
|
||||
lv_style_scr.line_width = 1 * LV_DOWNSCALE;
|
||||
|
||||
/*Plain style (by default near the same as the screen style)*/
|
||||
memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t));
|
||||
lv_style_plain.mcolor = COLOR_WHITE;
|
||||
lv_style_plain.gcolor = COLOR_WHITE;
|
||||
lv_style_plain.bcolor = COLOR_WHITE;
|
||||
|
||||
/*Plain color style*/
|
||||
memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_plain_color.ccolor = COLOR_MAKE(0xf0, 0xf0, 0xf0);
|
||||
lv_style_plain_color.mcolor = COLOR_MAKE(0x55, 0x96, 0xd8);
|
||||
lv_style_plain_color.gcolor = lv_style_plain_color.mcolor;
|
||||
|
||||
/*Pretty style */
|
||||
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_pretty.ccolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_pretty.mcolor = COLOR_WHITE;
|
||||
lv_style_pretty.gcolor = COLOR_SILVER;
|
||||
lv_style_pretty.bcolor = COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_style_pretty.radius = LV_DPI / 15;
|
||||
lv_style_pretty.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_pretty.bopa = OPA_50;
|
||||
|
||||
/*Pretty color style*/
|
||||
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
||||
lv_style_pretty_color.ccolor = COLOR_MAKE(0xe0, 0xe0, 0xe0);
|
||||
lv_style_pretty_color.mcolor = COLOR_MAKE(0x6b, 0x9a, 0xc7);
|
||||
lv_style_pretty_color.gcolor = COLOR_MAKE(0x2b, 0x59, 0x8b);
|
||||
lv_style_pretty_color.bcolor = COLOR_MAKE(0x15, 0x2c, 0x42);
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_style_transp, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_transp.empty = 1;
|
||||
lv_style_transp.bwidth = 0;
|
||||
lv_style_transp.glass = 1;
|
||||
|
||||
/*Transparent tight style*/
|
||||
memcpy(&lv_style_transp_tight, &lv_style_transp, sizeof(lv_style_t));
|
||||
lv_style_transp_tight.hpad = 0;
|
||||
lv_style_transp_tight.vpad = 0;
|
||||
|
||||
/*Button released style*/
|
||||
memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_btn_rel.mcolor = COLOR_MAKE(0x76, 0xa2, 0xd0);
|
||||
lv_style_btn_rel.gcolor = COLOR_MAKE(0x19, 0x3a, 0x5d);
|
||||
lv_style_btn_rel.bcolor = COLOR_MAKE(0x0b, 0x19, 0x28);
|
||||
lv_style_btn_rel.ccolor = COLOR_MAKE(0xff, 0xff, 0xff);
|
||||
lv_style_btn_rel.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_btn_rel.radius = LV_DPI / 15;
|
||||
lv_style_btn_rel.bopa = OPA_70;
|
||||
lv_style_btn_rel.scolor = COLOR_GRAY;
|
||||
lv_style_btn_rel.swidth = 0;
|
||||
lv_style_btn_rel.hpad = LV_DPI / 4;
|
||||
lv_style_btn_rel.vpad = LV_DPI / 6;
|
||||
lv_style_btn_rel.opad = LV_DPI / 10;
|
||||
lv_style_btn_rel.txt_align = LV_TXT_ALIGN_MID;
|
||||
|
||||
/*Button pressed style*/
|
||||
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_pr.mcolor = COLOR_MAKE(0x33, 0x62, 0x94);
|
||||
lv_style_btn_pr.gcolor = COLOR_MAKE(0x10, 0x26, 0x3c);
|
||||
lv_style_btn_pr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button toggle released style*/
|
||||
memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_trel.mcolor = COLOR_MAKE(0x0a, 0x11, 0x22);
|
||||
lv_style_btn_trel.gcolor = COLOR_MAKE(0x37, 0x62, 0x90);
|
||||
lv_style_btn_trel.bcolor = COLOR_MAKE(0x01, 0x07, 0x0d);
|
||||
lv_style_btn_trel.ccolor = COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
|
||||
/*Button toggle pressed style*/
|
||||
memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_tpr.mcolor = COLOR_MAKE(0x02, 0x14, 0x27);
|
||||
lv_style_btn_tpr.gcolor = COLOR_MAKE(0x2b, 0x4c, 0x70);
|
||||
lv_style_btn_tpr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button inactive style*/
|
||||
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_ina.mcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.gcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.bcolor = COLOR_MAKE(0x90, 0x90, 0x90);
|
||||
lv_style_btn_ina.ccolor = COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get style from its name
|
||||
* @param style_name an element of the 'lv_style_name_t' enum
|
||||
* @return pointer to the requested style (lv_style_def by default)
|
||||
*/
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy)
|
||||
{
|
||||
lv_style_t * style = &lv_style_plain;
|
||||
|
||||
switch(style_name) {
|
||||
case LV_STYLE_SCR:
|
||||
style = &lv_style_scr;
|
||||
break;
|
||||
case LV_STYLE_PLAIN:
|
||||
style = &lv_style_plain;
|
||||
break;
|
||||
case LV_STYLE_PLAIN_COLOR:
|
||||
style = &lv_style_plain_color;
|
||||
break;
|
||||
case LV_STYLE_PRETTY:
|
||||
style = &lv_style_pretty;
|
||||
break;
|
||||
case LV_STYLE_PRETTY_COLOR:
|
||||
style = &lv_style_pretty_color;
|
||||
break;
|
||||
case LV_STYLE_TRANSP:
|
||||
style = &lv_style_transp;
|
||||
break;
|
||||
case LV_STYLE_TRANSP_TIGHT:
|
||||
style = &lv_style_transp_tight;
|
||||
break;
|
||||
case LV_STYLE_BTN_REL:
|
||||
style = &lv_style_btn_rel;
|
||||
break;
|
||||
case LV_STYLE_BTN_PR:
|
||||
style = &lv_style_btn_pr;
|
||||
break;
|
||||
case LV_STYLE_BTN_TREL:
|
||||
style = &lv_style_btn_trel;
|
||||
break;
|
||||
case LV_STYLE_BTN_TPR:
|
||||
style = &lv_style_btn_tpr;
|
||||
break;
|
||||
case LV_STYLE_BTN_INA:
|
||||
style = &lv_style_btn_ina;
|
||||
break;
|
||||
default:
|
||||
style = &lv_style_plain;
|
||||
}
|
||||
|
||||
if(copy != NULL) memcpy(copy, style, sizeof(lv_style_t));
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
* @param dest pointer to the destination style
|
||||
* @param src pointer to the source style
|
||||
*/
|
||||
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(lv_style_t));
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file lv_style.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_STYLE_H
|
||||
#define LV_STYLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RADIUS_CIRCLE (CORD_MAX) /*A very big radius to always draw as circle*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_TXT_ALIGN_LEFT = 0,
|
||||
LV_TXT_ALIGN_MID,
|
||||
}lv_txt_align_t;
|
||||
|
||||
|
||||
/*Shadow types*/
|
||||
typedef enum
|
||||
{
|
||||
LV_STYPE_BOTTOM = 0,
|
||||
LV_STYPE_FULL,
|
||||
}lv_stype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Object level styles*/
|
||||
color_t ccolor; /*Content color (e.g. text or image re-color )*/
|
||||
opa_t opa; /*Opacity of the object*/
|
||||
uint8_t glass :1; /*1: Do not inherit this style*/
|
||||
uint8_t empty :1; /*Transparent background (border drawn)*/
|
||||
uint8_t stype :2; /*Shadow type from 'lv_shadow_type_t'*/
|
||||
uint8_t txt_align:2;
|
||||
color_t mcolor; /*Main color of background*/
|
||||
color_t gcolor; /*Gradient color of background*/
|
||||
color_t bcolor; /*Border color of background*/
|
||||
color_t scolor; /*Shadow color of background*/
|
||||
cord_t radius; /*Corner radius of background*/
|
||||
cord_t bwidth; /*Width of the background border*/
|
||||
cord_t swidth; /*Width of the background shadow effect*/
|
||||
cord_t vpad; /*Vertical padding*/
|
||||
cord_t hpad; /*Horizontal padding*/
|
||||
cord_t opad; /*Object padding on the background*/
|
||||
opa_t bopa; /*Opacity of background border*/
|
||||
const font_t * font;
|
||||
cord_t letter_space;
|
||||
cord_t line_space;
|
||||
opa_t img_recolor;
|
||||
cord_t line_width;
|
||||
}lv_style_t;
|
||||
|
||||
typedef enum {
|
||||
LV_STYLE_SCR,
|
||||
LV_STYLE_TRANSP,
|
||||
LV_STYLE_TRANSP_TIGHT,
|
||||
LV_STYLE_PLAIN,
|
||||
LV_STYLE_PLAIN_COLOR,
|
||||
LV_STYLE_PRETTY,
|
||||
LV_STYLE_PRETTY_COLOR,
|
||||
LV_STYLE_BTN_REL,
|
||||
LV_STYLE_BTN_PR,
|
||||
LV_STYLE_BTN_TREL,
|
||||
LV_STYLE_BTN_TPR,
|
||||
LV_STYLE_BTN_INA,
|
||||
}lv_style_name_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void);
|
||||
|
||||
/**
|
||||
* Get style from its name
|
||||
* @param style_name an element of the 'lv_style_name_t' enum
|
||||
* @return pointer to the requested style (lv_style_def by default)
|
||||
*/
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy);
|
||||
|
||||
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_STYLE_H*/
|
||||
114
lv_obj/lv_vdb.c
114
lv_obj/lv_vdb.c
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file lv_vdb.c
|
||||
*
|
||||
*/
|
||||
#include "lv_conf.h"
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "hal/disp/disp.h"
|
||||
#include <stddef.h>
|
||||
#include "lv_vdb.h"
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_vdb_t vdb;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the vdb variable
|
||||
* @return pointer to the vdb variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void)
|
||||
{
|
||||
return &vdb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the content of the vdb
|
||||
*/
|
||||
void lv_vdb_flush(void)
|
||||
{
|
||||
#if LV_ANTIALIAS == 0
|
||||
disp_map(vdb.area.x1, vdb.area.y1, vdb.area.x2, vdb.area.y2, vdb.buf);
|
||||
#else
|
||||
/* Get the average of 2x2 pixels and put the result back to the VDB
|
||||
* The reading goes much faster then the write back
|
||||
* so useful data won't be overwritten
|
||||
* Example:
|
||||
* -----------------------------
|
||||
* in1_buf |2,2|6,8| 3,7
|
||||
* in2_buf |4,4|7,7| 1,2
|
||||
* --------- ==>
|
||||
* in1_buf |1,1|1,3|
|
||||
* in2_buf |1,1|1,3|
|
||||
* */
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
cord_t w = area_get_width(&vdb.area);
|
||||
color_t * in1_buf = vdb.buf; /*Pointer to the first row*/
|
||||
color_t * in2_buf = vdb.buf + w; /*Pointer to the second row*/
|
||||
color_t * out_buf = vdb.buf; /*Store the result here*/
|
||||
for(y = vdb.area.y1; y < vdb.area.y2; y += 2) {
|
||||
for(x = vdb.area.x1; x < vdb.area.x2; x += 2) {
|
||||
|
||||
/*If the pixels are the same do not calculate the average */
|
||||
if(in1_buf->full == (in1_buf + 1)->full &&
|
||||
in1_buf->full == in2_buf->full &&
|
||||
in1_buf->full == (in2_buf + 1)->full) {
|
||||
out_buf->full = in1_buf->full;
|
||||
} else {
|
||||
/*Get the average of 2x2 red*/
|
||||
out_buf->red = (in1_buf->red + (in1_buf + 1)->red +
|
||||
in2_buf->red + (in2_buf+ 1)->red) >> 2;
|
||||
/*Get the average of 2x2 green*/
|
||||
out_buf->green = (in1_buf->green + (in1_buf + 1)->green +
|
||||
in2_buf->green + (in2_buf + 1)->green) >> 2;
|
||||
/*Get the average of 2x2 blue*/
|
||||
out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue +
|
||||
in2_buf->blue + (in2_buf + 1)->blue) >> 2;
|
||||
}
|
||||
|
||||
in1_buf += 2; /*Skip the next pixel because it is already used above*/
|
||||
in2_buf += 2;
|
||||
out_buf ++;
|
||||
}
|
||||
/*2 row is ready so go the next 2*/
|
||||
in1_buf += w; /*Skip the next row because it is processed from in2_buf*/
|
||||
in2_buf += w;
|
||||
}
|
||||
|
||||
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
|
||||
* Write out the filtered map to the display*/
|
||||
disp_map(vdb.area.x1 >> 1, vdb.area.y1 >> 1, vdb.area.x2 >> 1, vdb.area.y2 >> 1, vdb.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* @file lv_vdb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_VDB_H
|
||||
#define LV_VDB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
area_t area;
|
||||
color_t buf[LV_VDB_SIZE];
|
||||
}lv_vdb_t;
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the vdb variable
|
||||
* @return pointer to the vdb variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void);
|
||||
|
||||
/**
|
||||
* Flush the content of the vdb
|
||||
*/
|
||||
void lv_vdb_flush(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_VDB_SIZE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_VDB_H*/
|
||||
306
lv_objx/lv_bar.c
306
lv_objx/lv_bar.c
@@ -1,306 +0,0 @@
|
||||
|
||||
|
||||
/**
|
||||
* @file lv_bar.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BAR != 0
|
||||
|
||||
#include <lvgl/lv_objx/lv_bar.h>
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a bar objects
|
||||
* @param par pointer to an object, it will be the parent of the new bar
|
||||
* @param copy pointer to a bar object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created bar
|
||||
*/
|
||||
lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_bar = lv_obj_create(par, copy);
|
||||
dm_assert(new_bar);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_bar_ext_t * ext = lv_obj_alloc_ext(new_bar, sizeof(lv_bar_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->min_value = 0;
|
||||
ext->max_value = 100;
|
||||
ext->act_value = 0;
|
||||
ext->style_indic = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
|
||||
/* Save the ancient design function.
|
||||
* It will be used in the bar design function*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_bar);
|
||||
|
||||
lv_obj_set_signal_f(new_bar, lv_bar_signal);
|
||||
lv_obj_set_design_f(new_bar, lv_bar_design);
|
||||
|
||||
/*Init the new bar object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_bar, false);
|
||||
lv_obj_set_size(new_bar, LV_DPI * 2, LV_DPI / 3);
|
||||
lv_obj_set_style(new_bar, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_bar_set_value(new_bar, ext->act_value);
|
||||
} else {
|
||||
lv_bar_ext_t * ext_copy = lv_obj_get_ext(copy);
|
||||
ext->min_value = ext_copy->min_value;
|
||||
ext->max_value = ext_copy->max_value;
|
||||
ext->act_value = ext_copy->act_value;
|
||||
ext->style_indic = ext_copy->style_indic;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_bar);
|
||||
|
||||
lv_bar_set_value(new_bar, ext->act_value);
|
||||
}
|
||||
return new_bar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(bar, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style_indic = lv_bar_get_style_indic(bar);
|
||||
if(style_indic->swidth > bar->ext_size) bar->ext_size = style_indic->swidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a new value on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
ext->act_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->act_value = ext->act_value < ext->min_value ? ext->min_value : ext->act_value;
|
||||
lv_obj_inv(bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new value with animation on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim_time animation time in milliseconds
|
||||
*/
|
||||
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
|
||||
{
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
int16_t new_value;
|
||||
new_value = value > ext->max_value ? ext->max_value : value;
|
||||
new_value = new_value < ext->min_value ? ext->min_value : new_value;
|
||||
|
||||
anim_t a;
|
||||
a.var = bar;
|
||||
a.start = ext->act_value;
|
||||
a.end = new_value;
|
||||
a.fp = (anim_fp_t)lv_bar_set_value;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
|
||||
anim_create(&a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a bar
|
||||
* @param bar pointer to he bar object
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
*/
|
||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
ext->max_value = max;
|
||||
ext->max_value = max;
|
||||
if(ext->act_value > max) {
|
||||
ext->act_value = max;
|
||||
lv_bar_set_value(bar, ext->act_value);
|
||||
}
|
||||
lv_obj_inv(bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of bar indicator
|
||||
* @param bar pointer to a bar object
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_bar_set_style_indic(lv_obj_t * bar, lv_style_t * style)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
|
||||
ext->style_indic = style;
|
||||
|
||||
bar->signal_f(bar, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_inv(bar);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
return ext->act_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the minimum value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_min_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
return ext->min_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the maximum value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_max_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
return ext->max_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of bar indicator
|
||||
* @param bar pointer to a bar object
|
||||
* @return pointer to the bar indicator style
|
||||
*/
|
||||
lv_style_t * lv_bar_get_style_indic(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
|
||||
if(ext->style_indic == NULL) return lv_obj_get_style(bar);
|
||||
|
||||
return ext->style_indic;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the bars
|
||||
* @param bar pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(bar, mask, mode);;
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
|
||||
lv_style_t * style_indic = lv_bar_get_style_indic(bar);
|
||||
area_t indic_area;
|
||||
area_cpy(&indic_area, &bar->cords);
|
||||
indic_area.x1 += style_indic->hpad;
|
||||
indic_area.x2 -= style_indic->hpad;
|
||||
indic_area.y1 += style_indic->vpad;
|
||||
indic_area.y2 -= style_indic->vpad;
|
||||
|
||||
cord_t w = area_get_width(&indic_area);
|
||||
cord_t h = area_get_height(&indic_area);
|
||||
|
||||
if(w >= h) {
|
||||
indic_area.x2 = (int32_t) ((int32_t)w * ext->act_value) / (ext->max_value - ext->min_value);
|
||||
indic_area.x2 += indic_area.x1;
|
||||
} else {
|
||||
indic_area.y1 = (int32_t) ((int32_t)h * ext->act_value) / (ext->max_value - ext->min_value);
|
||||
indic_area.y1 = indic_area.y2 - indic_area.y1;
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&indic_area, mask, style_indic);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
131
lv_objx/lv_bar.h
131
lv_objx/lv_bar.h
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* @file lv_bar.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BAR_H
|
||||
#define LV_BAR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BAR != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of bar*/
|
||||
typedef struct
|
||||
{
|
||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
int16_t act_value; /*Current value of the bar*/
|
||||
int16_t min_value; /*Minimum value of the bar*/
|
||||
int16_t max_value; /*Maximum value of the bar*/
|
||||
lv_style_t * style_indic; /*Style of the indicator*/
|
||||
}lv_bar_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a bar objects
|
||||
* @param par pointer to an object, it will be the parent of the new bar
|
||||
* @param copy pointer to a bar object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created bar
|
||||
*/
|
||||
lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a new value on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value);
|
||||
|
||||
/**
|
||||
* Set a new value with animation on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim_time animation time in milliseconds
|
||||
*/
|
||||
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time);
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a bar
|
||||
* @param bar pointer to he bar object
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
*/
|
||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
|
||||
|
||||
/**
|
||||
* Set the style of bar indicator
|
||||
* @param bar pointer to a bar object
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_bar_set_style_indic(lv_obj_t * bar, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_value(lv_obj_t * bar);
|
||||
|
||||
/**
|
||||
* Get the minimum value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the minimum value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_min_value(lv_obj_t * bar);
|
||||
|
||||
/**
|
||||
* Get the maximum value of a bar
|
||||
* @param bar pointer to a bar object
|
||||
* @return the maximum value of the bar
|
||||
*/
|
||||
int16_t lv_bar_get_max_value(lv_obj_t * bar);
|
||||
|
||||
/**
|
||||
* Get the style of bar indicator
|
||||
* @param bar pointer to a bar object
|
||||
* @return pointer to the bar indicator style
|
||||
*/
|
||||
lv_style_t * lv_bar_get_style_indic(lv_obj_t * bar);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_BAR*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_BAR_H*/
|
||||
368
lv_objx/lv_btn.c
368
lv_objx/lv_btn.c
@@ -1,368 +0,0 @@
|
||||
/**
|
||||
* @file lv_btn.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
#include "lvgl/lv_obj/lv_obj.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "lv_btn.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0
|
||||
static bool lv_btn_design(lv_obj_t * btn, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a button objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
lv_obj_t * new_btn;
|
||||
|
||||
new_btn = lv_cont_create(par, copy);
|
||||
dm_assert(new_btn);
|
||||
/*Allocate the extended data*/
|
||||
lv_btn_ext_t * ext = lv_obj_alloc_ext(new_btn, sizeof(lv_btn_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->state = LV_BTN_STATE_REL;
|
||||
ext->pr_action = NULL;
|
||||
ext->rel_action = NULL;
|
||||
ext->lpr_action = NULL;
|
||||
ext->lpr_rep_action = NULL;
|
||||
ext->styles[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->styles[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->styles[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BTN_TREL, NULL);
|
||||
ext->styles[LV_BTN_STATE_TPR] = lv_style_get(LV_STYLE_BTN_TPR, NULL);
|
||||
ext->styles[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BTN_INA, NULL);
|
||||
ext->lpr_exec = 0;
|
||||
ext->tgl = 0;
|
||||
|
||||
lv_obj_set_signal_f(new_btn, lv_btn_signal);
|
||||
|
||||
/*If no copy do the basic initialization*/
|
||||
if(copy == NULL) {
|
||||
lv_cont_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
|
||||
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
|
||||
}
|
||||
/*Copy 'copy'*/
|
||||
else {
|
||||
lv_btn_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->state = copy_ext->state;
|
||||
ext->pr_action = copy_ext->pr_action;
|
||||
ext->rel_action = copy_ext->rel_action;
|
||||
ext->lpr_action = copy_ext->lpr_action;
|
||||
ext->lpr_rep_action = copy_ext->lpr_action;
|
||||
ext->styles[LV_BTN_STATE_REL] = copy_ext->styles[LV_BTN_STATE_REL];
|
||||
ext->styles[LV_BTN_STATE_PR] = copy_ext->styles[LV_BTN_STATE_PR];
|
||||
ext->styles[LV_BTN_STATE_TREL] = copy_ext->styles[LV_BTN_STATE_TREL];
|
||||
ext->styles[LV_BTN_STATE_TPR] = copy_ext->styles[LV_BTN_STATE_TPR];
|
||||
ext->styles[LV_BTN_STATE_INA] = copy_ext->styles[LV_BTN_STATE_INA];
|
||||
ext->tgl = copy_ext->tgl;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_btn);
|
||||
}
|
||||
|
||||
return new_btn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_cont_signal(btn, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_btn_state_t state = lv_btn_get_state(btn);
|
||||
bool tgl = lv_btn_get_tgl(btn);
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
/*Refresh the state*/
|
||||
if(ext->state == LV_BTN_STATE_REL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_PR);
|
||||
} else if(ext->state == LV_BTN_STATE_TREL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TPR);
|
||||
}
|
||||
|
||||
ext->lpr_exec = 0;
|
||||
/*Call the press action, 'param' is the caller dispi*/
|
||||
if(ext->pr_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->pr_action(btn, param);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
/*Refresh the state*/
|
||||
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(ext->state == LV_BTN_STATE_TPR) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
/*When the button begins to drag revert pressed states to released*/
|
||||
if(lv_dispi_is_dragging(param) != false) {
|
||||
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(ext->state == LV_BTN_STATE_TPR) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If not dragged and it was not long press action then
|
||||
*change state and run the action*/
|
||||
if(lv_dispi_is_dragging(param) == false && ext->lpr_exec == 0) {
|
||||
if(ext->state == LV_BTN_STATE_PR && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(ext->state == LV_BTN_STATE_TPR && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
} else if(ext->state == LV_BTN_STATE_PR && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
} else if(ext->state == LV_BTN_STATE_TPR && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
}
|
||||
|
||||
if(ext->rel_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn, param);
|
||||
}
|
||||
} else { /*If dragged change back the state*/
|
||||
if(ext->state == LV_BTN_STATE_PR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(ext->state == LV_BTN_STATE_TPR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
/*Call the long press action, 'param' is the caller dispi*/
|
||||
if(ext->lpr_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
ext->lpr_exec = 1;
|
||||
valid = ext->lpr_action(btn, param);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
/*Call the release action, 'param' is the caller dispi*/
|
||||
if(ext->lpr_rep_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->lpr_rep_action(btn, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Enable the toggled states
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->tgl = tgl != false ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param state the new state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
if(ext->state != state) {
|
||||
ext->state = state;
|
||||
lv_obj_set_style(btn, ext->styles[state]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_t pr_action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->pr_action = pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_t rel_action)
|
||||
{
|
||||
lv_btn_ext_t * btn_p = lv_obj_get_ext(btn);
|
||||
|
||||
btn_p->rel_action = rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_t lpr_action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->lpr_action = lpr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->lpr_rep_action = lpr_rep_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set styles of a button is each state
|
||||
* @param btn pointer to button object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_btn_set_styles(lv_obj_t * btn, lv_style_t * rel, lv_style_t * pr,
|
||||
lv_style_t * trel, lv_style_t * tpr,
|
||||
lv_style_t * ina)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
ext->styles[LV_BTN_STATE_REL] = rel;
|
||||
ext->styles[LV_BTN_STATE_PR] = pr;
|
||||
ext->styles[LV_BTN_STATE_TREL] = trel;
|
||||
ext->styles[LV_BTN_STATE_TPR] = tpr;
|
||||
ext->styles[LV_BTN_STATE_INA] = ina;
|
||||
|
||||
lv_obj_set_style(btn, ext->styles[ext->state]);
|
||||
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the current state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return the state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
return ext->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the toggle enable attribute of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return ture: toggle enabled, false: disabled
|
||||
*/
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
return ext->tgl != 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of a button in a given state
|
||||
* @param btn pointer to a button object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
if(ext->styles[state] == NULL) return lv_obj_get_style(btn->par);
|
||||
|
||||
return ext->styles[state];
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Handle the drawing related tasks of the buttons
|
||||
* @param btn pointer to a button object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_btn_design(lv_obj_t * btn, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
|
||||
/* Because of the radius it is not sure the area is covered*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN || mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
169
lv_objx/lv_btn.h
169
lv_objx/lv_btn.h
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* @file lv_btn.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BTN_H
|
||||
#define LV_BTN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_CONT == 0
|
||||
#error "lv_btn: lv_cont is required. Enable it in lv_conf.h (USE_LV_CONT 1) "
|
||||
#endif
|
||||
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "../lv_obj/lv_dispi.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Button states*/
|
||||
typedef enum
|
||||
{
|
||||
LV_BTN_STATE_REL,
|
||||
LV_BTN_STATE_PR,
|
||||
LV_BTN_STATE_TREL,
|
||||
LV_BTN_STATE_TPR,
|
||||
LV_BTN_STATE_INA,
|
||||
LV_BTN_STATE_NUM,
|
||||
}lv_btn_state_t;
|
||||
|
||||
/*Data of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t cont; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t pr_action; /*A function to call when the button is pressed (NULL if unused)*/
|
||||
lv_action_t rel_action; /*A function to call when the button is released (NULL if unused)*/
|
||||
lv_action_t lpr_action; /*A function to call when the button is long pressed (NULL if unused)*/
|
||||
lv_action_t lpr_rep_action; /*A function to call periodically after long press (NULL if unused)*/
|
||||
|
||||
lv_style_t * styles[LV_BTN_STATE_NUM]; /*Styles in each state*/
|
||||
|
||||
lv_btn_state_t state; /*Current state of the button from 'lv_btn_state_t' enum*/
|
||||
uint8_t tgl :1; /*1: Toggle enabled*/
|
||||
uint8_t lpr_exec :1; /*1: Long press action executed (Handled by the library)*/
|
||||
}lv_btn_ext_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a button objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Enable the toggled states
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl);
|
||||
|
||||
/**
|
||||
* Set the state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param state the new state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_t lpr_action);
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action);
|
||||
|
||||
/**
|
||||
* Set styles of a button is each state
|
||||
* @param btn pointer to button object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_btn_set_styles(lv_obj_t * btn, lv_style_t * rel, lv_style_t * pr, lv_style_t * trel, lv_style_t * tpr, lv_style_t * ina);
|
||||
|
||||
/**
|
||||
* Get the current state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return the state of the button (from lv_btn_state_t enum)
|
||||
*/
|
||||
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the toggle enable attribute of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return ture: toggle enabled, false: disabled
|
||||
*/
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the style of a button in a given state
|
||||
* @param btn pointer to a button object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_BTN*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_BTN_H*/
|
||||
@@ -1,514 +0,0 @@
|
||||
/**
|
||||
* @file lv_btnm.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTNM != 0
|
||||
|
||||
#include "lv_btnm.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_BTNM_PR_NONE 0xFFFF
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_t mode);
|
||||
static uint8_t lv_btnm_get_width_unit(const char * btn_str);
|
||||
static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p);
|
||||
static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const char * lv_btnm_def_map[] = {"Btn1","Btn2", "Btn3","\n",
|
||||
"\002Btn4","Btn5", ""};
|
||||
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a button matrix objects
|
||||
* @param par pointer to an object, it will be the parent of the new button matrix
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button matrix
|
||||
*/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_btnm = lv_cont_create(par, copy);
|
||||
dm_assert(new_btnm);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_btnm_ext_t * ext = lv_obj_alloc_ext(new_btnm, sizeof(lv_btnm_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->btn_cnt = 0;
|
||||
ext->btn_pr = LV_BTNM_PR_NONE;
|
||||
ext->btn_areas = NULL;
|
||||
ext->cb = NULL;
|
||||
ext->map_p = NULL;
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_btnm);
|
||||
|
||||
lv_obj_set_signal_f(new_btnm, lv_btnm_signal);
|
||||
lv_obj_set_design_f(new_btnm, lv_btnm_design);
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_set_style(new_btnm, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_btnm_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->style_btn_rel = copy_ext->style_btn_rel;
|
||||
ext->style_btn_pr = copy_ext->style_btn_pr;
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
|
||||
ext->cb = copy_ext->cb;
|
||||
}
|
||||
|
||||
return new_btnm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_cont_signal(btnm, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
area_t btnm_area;
|
||||
area_t btn_area;
|
||||
point_t p;
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->btn_areas);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
|
||||
lv_btnm_set_map(btnm, ext->map_p);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
uint16_t btn_pr;
|
||||
/*Search the pressed area*/
|
||||
lv_dispi_get_point(param, &p);
|
||||
btn_pr = lv_btnm_get_btn_from_point(btnm, &p);
|
||||
/*Invalidate to old and the new areas*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
if(btn_pr != ext->btn_pr) {
|
||||
lv_dispi_reset_lpr(param);
|
||||
if(ext->btn_pr != LV_BTNM_PR_NONE) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[ext->btn_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(btn_pr != LV_BTNM_PR_NONE) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[btn_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);
|
||||
}
|
||||
}
|
||||
|
||||
ext->btn_pr = btn_pr;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
if(ext->cb != NULL && ext->btn_pr != LV_BTNM_PR_NONE) {
|
||||
uint16_t txt_i = 0;
|
||||
uint16_t btn_i = 0;
|
||||
|
||||
/* Search the text of ext->btn_pr the buttons text in the map
|
||||
* Skip "\n"-s*/
|
||||
while(btn_i != ext->btn_pr) {
|
||||
btn_i ++;
|
||||
txt_i ++;
|
||||
if(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
|
||||
}
|
||||
|
||||
ext->cb(btnm, txt_i);
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_RELEASED && ext->btn_pr != LV_BTNM_PR_NONE) {
|
||||
/*Invalidate to old area*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
area_cpy(&btn_area, &ext->btn_areas[ext->btn_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);
|
||||
|
||||
ext->btn_pr = LV_BTNM_PR_NONE;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
ext->btn_pr = LV_BTNM_PR_NONE;
|
||||
lv_obj_inv(btnm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a new map. Buttons will be created/deleted according to the map.
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param map pointer a string array. The last string has to be: "".
|
||||
* Use "\n" to begin a new line.
|
||||
* Use octal numbers (e.g. "\003") to set the relative
|
||||
* width of a button. (max. 9 -> \011)
|
||||
* (e.g. const char * str[] = {"a", "b", "\n", "\004c", "d", ""}).
|
||||
* The button do not copy the array so it can not be a local variable.
|
||||
*/
|
||||
void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
{
|
||||
if(map == NULL) return;
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
ext->map_p = map;
|
||||
|
||||
/*Analyze the map and create the required number of buttons*/
|
||||
lv_btnm_create_btns(btnm, map);
|
||||
|
||||
/*Set size and positions of the buttons*/
|
||||
lv_style_t * btnms = lv_obj_get_style(btnm);
|
||||
cord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->hpad;
|
||||
cord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->vpad;
|
||||
cord_t act_y = btnms->vpad;
|
||||
|
||||
/*Count the lines to calculate button height*/
|
||||
uint8_t line_cnt = 1;
|
||||
uint8_t li;
|
||||
for(li = 0; strlen(map[li]) != 0; li++) {
|
||||
if(strcmp(map[li], "\n") == 0) line_cnt ++;
|
||||
}
|
||||
|
||||
cord_t btn_h = max_h - ((line_cnt - 1) * btnms->opad);
|
||||
btn_h = btn_h / line_cnt;
|
||||
|
||||
/* Count the units and the buttons in a line
|
||||
* (A button can be 1,2,3... unit wide)*/
|
||||
uint16_t unit_cnt; /*Number of units in a row*/
|
||||
uint16_t unit_act_cnt; /*Number of units currently put in a row*/
|
||||
uint16_t btn_cnt; /*Number of buttons in a row*/
|
||||
uint16_t i_tot = 0; /*Act. index in the str map*/
|
||||
uint16_t btn_i = 0; /*Act. index of button areas*/
|
||||
const char ** map_p_tmp = map;
|
||||
|
||||
/*Count the units and the buttons in a line*/
|
||||
while(1) {
|
||||
unit_cnt = 0;
|
||||
btn_cnt = 0;
|
||||
/*Count the buttons in a line*/
|
||||
while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 &&
|
||||
strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/
|
||||
unit_cnt += lv_btnm_get_width_unit(map_p_tmp[btn_cnt]);
|
||||
btn_cnt ++;
|
||||
}
|
||||
|
||||
/*Only deal with the non empty lines*/
|
||||
if(btn_cnt != 0) {
|
||||
/*Calculate the width of all units*/
|
||||
cord_t all_unit_w = max_w - ((btn_cnt-1) * btnms->opad);
|
||||
|
||||
/*Set the button size and positions and set the texts*/
|
||||
uint16_t i;
|
||||
cord_t act_x = btnms->hpad;
|
||||
cord_t act_unit_w;
|
||||
unit_act_cnt = 0;
|
||||
for(i = 0; i < btn_cnt; i++) {
|
||||
/* one_unit_w = all_unit_w / unit_cnt
|
||||
* act_unit_w = one_unit_w * button_width
|
||||
* do this two operation but the multiply first to divide a greater number */
|
||||
act_unit_w = (all_unit_w * lv_btnm_get_width_unit(map_p_tmp[i])) / unit_cnt;
|
||||
|
||||
/*Always recalculate act_x because of rounding errors */
|
||||
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * btnms->opad + btnms->hpad;
|
||||
|
||||
area_set(&ext->btn_areas[btn_i], act_x,
|
||||
act_y,
|
||||
act_x + act_unit_w,
|
||||
act_y + btn_h);
|
||||
|
||||
unit_act_cnt += lv_btnm_get_width_unit(map_p_tmp[i]);
|
||||
|
||||
i_tot ++;
|
||||
btn_i ++;
|
||||
}
|
||||
}
|
||||
act_y += btn_h + btnms->opad;
|
||||
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*/
|
||||
i_tot ++; /*Skip the '\n'*/
|
||||
}
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new callback function for the buttons (It will be called when a button is released)
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @param cb pointer to a callback function
|
||||
*/
|
||||
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the styles of the buttons of the button matrox
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @param style pointer to style
|
||||
*/
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
ext->style_btn_rel = rel;
|
||||
ext->style_btn_pr = pr;
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the current map of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @return the current map
|
||||
*/
|
||||
const char ** lv_btnm_get_map(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
return ext->map_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a the callback function of the buttons on a button matrix
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @return pointer to the callback function
|
||||
*/
|
||||
lv_btnm_callback_t lv_btnm_get_action(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
return ext->cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of buttons in button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @return pointer the button style in the given state
|
||||
*/
|
||||
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state)
|
||||
{
|
||||
lv_style_t * style;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
|
||||
switch(state) {
|
||||
case LV_BTN_STATE_PR:
|
||||
style = ext->style_btn_pr;
|
||||
break;
|
||||
case LV_BTN_STATE_REL:
|
||||
style = ext->style_btn_rel;
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
}
|
||||
|
||||
if(style == NULL) style = lv_obj_get_style(btnm);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the button matrixs
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design_f(btnm, mask, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
}
|
||||
/*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(btnm);
|
||||
lv_style_t * btn_style;
|
||||
|
||||
area_t area_btnm;
|
||||
area_t area_tmp;
|
||||
cord_t btn_w;
|
||||
cord_t btn_h;
|
||||
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i ++) {
|
||||
lv_obj_get_cords(btnm, &area_btnm);
|
||||
|
||||
area_cpy(&area_tmp, &ext->btn_areas[btn_i]);
|
||||
area_tmp.x1 += area_btnm.x1;
|
||||
area_tmp.y1 += area_btnm.y1;
|
||||
area_tmp.x2 += area_btnm.x1;
|
||||
area_tmp.y2 += area_btnm.y1;
|
||||
|
||||
btn_w = area_get_width(&area_tmp);
|
||||
btn_h = area_get_height(&area_tmp);
|
||||
|
||||
/*Load the style*/
|
||||
btn_style = lv_btnm_get_style_btn(btnm, ext->btn_pr == btn_i ? LV_BTN_STATE_PR : LV_BTN_STATE_REL);
|
||||
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
|
||||
/*Search the next valid text in the map*/
|
||||
while(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
|
||||
|
||||
/*Calculate the size of the text*/
|
||||
const font_t * font = btn_style->font;
|
||||
point_t txt_size;
|
||||
txt_get_size(&txt_size, ext->map_p[txt_i], font,
|
||||
btn_style->letter_space, btn_style->line_space,
|
||||
area_get_width(&area_btnm), TXT_FLAG_NONE);
|
||||
|
||||
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, ext->map_p[txt_i], TXT_FLAG_NONE, NULL);
|
||||
txt_i ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the required number of buttons according to a map
|
||||
* @param btnm pointer to button matrix object
|
||||
* @param map_p pointer to a string array
|
||||
*/
|
||||
static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map)
|
||||
{
|
||||
/*Count the buttons in the map*/
|
||||
uint16_t btn_cnt = 0;
|
||||
uint16_t i = 0;
|
||||
while(strlen(map[i]) != 0) {
|
||||
if(strcmp(map[i], "\n") != 0) { /*Do not count line breaks*/
|
||||
btn_cnt ++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
|
||||
if(ext->btn_areas != NULL) {
|
||||
dm_free(ext->btn_areas);
|
||||
ext->btn_areas = NULL;
|
||||
}
|
||||
|
||||
ext->btn_areas = dm_alloc(sizeof(area_t) * btn_cnt);
|
||||
ext->btn_cnt = btn_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a button in units. It comes from the first "letter".
|
||||
* @param btn_str The descriptor string of a button. E.g. "apple" or "\004banana"
|
||||
* @return the width of the button in units
|
||||
*/
|
||||
static uint8_t lv_btnm_get_width_unit(const char * btn_str)
|
||||
{
|
||||
if(btn_str[0] <= '\011') return btn_str[0];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p)
|
||||
{
|
||||
area_t btnm_cords;
|
||||
area_t btn_area;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
uint16_t i;
|
||||
lv_obj_get_cords(btnm, &btnm_cords);
|
||||
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[i]);
|
||||
btn_area.x1 += btnm_cords.x1;
|
||||
btn_area.y1 += btnm_cords.y1;
|
||||
btn_area.x2 += btnm_cords.x1;
|
||||
btn_area.y2 += btnm_cords.y1;
|
||||
if(area_is_point_on(&btn_area, p) != false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == ext->btn_cnt) i = LV_BTNM_PR_NONE;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* @file lv_btnm.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_BTNM_H
|
||||
#define LV_BTNM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTNM != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_btn.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Type of callback function which is called when a button is released on the button matrix
|
||||
* Parameters: button matrix, released button index in the map string
|
||||
* return LV_ACTION_RES_INV: the button matrix is deleted else LV_ACTION_RES_OK*/
|
||||
typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t);
|
||||
|
||||
/*Data of button matrix*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
const char ** map_p; /*Pointer to the current map*/
|
||||
area_t * btn_areas; /*Array of areas for the buttons (Handled by the library)*/
|
||||
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
|
||||
uint16_t btn_pr; /*Index of the currently pressed button or LV_BTNM_PR_NONE (Handled by the library)*/
|
||||
lv_btnm_callback_t cb; /*A function to call when a button is releases*/
|
||||
lv_style_t * style_btn_rel; /*Style of the released buttons*/
|
||||
lv_style_t * style_btn_pr; /*Style of the pressed buttons*/
|
||||
}lv_btnm_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a button matrix objects
|
||||
* @param par pointer to an object, it will be the parent of the new button matrix
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button matrix
|
||||
*/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a new map. Buttons will be created/deleted according to the map.
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param map pointer a string array. The last string has to be: "".
|
||||
* Use "\n" to begin a new line.
|
||||
* Use octal numbers (e.g. "\003") to set the relative
|
||||
* width of a button. (max. 9 -> \011)
|
||||
* (e.g. const char * str[] = {"a", "b", "\n", "\004c", "d", ""}).
|
||||
* The button do not copy the array so it can not be a local variable.
|
||||
*/
|
||||
void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
|
||||
|
||||
/**
|
||||
* Set a new callback function for the buttons (It will be called when a button is released)
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @param cb pointer to a callback function
|
||||
*/
|
||||
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb);
|
||||
|
||||
/**
|
||||
* Set the styles of the buttons of the button matrox
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @param style pointer to style
|
||||
*/
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr);
|
||||
|
||||
/**
|
||||
* Get the current map of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @return the current map
|
||||
*/
|
||||
const char ** lv_btnm_get_map(lv_obj_t * btnm);
|
||||
|
||||
/**
|
||||
* Get a the callback function of the buttons on a button matrix
|
||||
* @param btnm: pointer to button matrix object
|
||||
* @return pointer to the callback function
|
||||
*/
|
||||
lv_btnm_callback_t lv_btnm_get_action(lv_obj_t * btnm);
|
||||
|
||||
/**
|
||||
* Get the style of buttons in button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @return pointer the button style in the given state
|
||||
*/
|
||||
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_BTNM*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_BTNM_H*/
|
||||
206
lv_objx/lv_cb.c
206
lv_objx/lv_cb.c
@@ -1,206 +0,0 @@
|
||||
/**
|
||||
* @file lv_cb.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
#include "lv_cb.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_cb_design(lv_obj_t * cb, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a check box objects
|
||||
* @param par pointer to an object, it will be the parent of the new check box
|
||||
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created check box
|
||||
*/
|
||||
lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_cb = lv_btn_create(par, copy);
|
||||
dm_assert(new_cb);
|
||||
|
||||
lv_cb_ext_t * ext = lv_obj_alloc_ext(new_cb, sizeof(lv_cb_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->bullet = NULL;
|
||||
ext->label = NULL;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_cb);
|
||||
|
||||
lv_obj_set_signal_f(new_cb, lv_cb_signal);
|
||||
lv_obj_set_design_f(new_cb, lv_cb_design);
|
||||
|
||||
/*Init the new checkbox object*/
|
||||
if(copy == NULL) {
|
||||
ext->bullet = lv_btn_create(new_cb, NULL);
|
||||
lv_btn_set_styles(new_cb, lv_style_get(LV_STYLE_TRANSP, NULL), lv_style_get(LV_STYLE_TRANSP, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSP, NULL), lv_style_get(LV_STYLE_TRANSP, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_cont_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(new_cb, true, true);
|
||||
lv_btn_set_tgl(new_cb, true);
|
||||
|
||||
lv_obj_set_click(ext->bullet, false);
|
||||
lv_btn_set_styles(ext->bullet, lv_style_get(LV_STYLE_PRETTY, NULL), lv_style_get(LV_STYLE_PRETTY_COLOR, NULL),
|
||||
lv_style_get(LV_STYLE_BTN_TREL, NULL), lv_style_get(LV_STYLE_BTN_TPR, NULL),
|
||||
lv_style_get(LV_STYLE_BTN_INA, NULL));
|
||||
|
||||
ext->label = lv_label_create(new_cb, NULL);
|
||||
lv_obj_set_style(ext->label, NULL); /*Inherit the style of the parent*/
|
||||
lv_label_set_text(ext->label, "Check box");
|
||||
} else {
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
|
||||
ext->label = lv_label_create(new_cb, copy_ext->label);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_cb);
|
||||
}
|
||||
|
||||
return new_cb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the check box
|
||||
* @param cb pointer to a check box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_btn_signal(cb, sign, param);
|
||||
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_style_t * style = lv_obj_get_style(cb);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_obj_set_size(ext->bullet, font_get_height(style->font), font_get_height(style->font));
|
||||
}
|
||||
if(sign == LV_SIGNAL_PRESSED ||
|
||||
sign == LV_SIGNAL_RELEASED ||
|
||||
sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_btn_set_state(lv_cb_get_bullet(cb), lv_btn_get_state(cb));
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the text of a check box
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box
|
||||
*/
|
||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the text of a check box
|
||||
* @param cb pointer to check box object
|
||||
* @return pointer to the text of the check box
|
||||
*/
|
||||
const char * lv_cb_get_text(lv_obj_t * cb)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
return lv_label_get_text(ext->label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bullet (lv_btn) of a check box
|
||||
* @param cb pointer to check box object
|
||||
* @return pointer to the bullet of the check box (lv_btn)
|
||||
*/
|
||||
lv_obj_t * lv_cb_get_bullet(lv_obj_t * cb)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
return ext->bullet;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the check boxes
|
||||
* @param cb pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_cb_design(lv_obj_t * cb, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design_f(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(cb);
|
||||
lv_btn_ext_t * bullet_ext = lv_obj_get_ext(cb_ext->bullet);
|
||||
|
||||
/*Be sure he state of the bullet is the same as the parent button*/
|
||||
bullet_ext->state = cb_ext->bg_btn.state;
|
||||
|
||||
return ancestor_design_f(cb, mask, mode);
|
||||
|
||||
}
|
||||
|
||||
/*Draw the object*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
100
lv_objx/lv_cb.h
100
lv_objx/lv_cb.h
@@ -1,100 +0,0 @@
|
||||
/**
|
||||
* @file lv_cb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CB_H
|
||||
#define LV_CB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_BTN == 0
|
||||
#error "lv_cb: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_cb: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of check box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_btn_ext_t bg_btn; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * bullet; /*Pointer to button*/
|
||||
lv_obj_t * label; /*Pointer to label*/
|
||||
}lv_cb_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a check box objects
|
||||
* @param par pointer to an object, it will be the parent of the new check box
|
||||
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created check box
|
||||
*/
|
||||
lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the check box
|
||||
* @param cb pointer to a check box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the text of a check box
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box
|
||||
*/
|
||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
|
||||
|
||||
/**
|
||||
* Get the text of a check box
|
||||
* @param cb pointer to check box object
|
||||
* @return pointer to the text of the check box
|
||||
*/
|
||||
const char * lv_cb_get_text(lv_obj_t * cb);
|
||||
|
||||
/**
|
||||
* Get the bullet (lv_btn) of a check box
|
||||
* @param cb pointer to check box object
|
||||
* @return pointer to the bullet of the check box (lv_btn)
|
||||
*/
|
||||
lv_obj_t * lv_cb_get_bullet(lv_obj_t * cb);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_CB*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_CB_H*/
|
||||
@@ -1,614 +0,0 @@
|
||||
/**
|
||||
* @file lv_chart.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_CHART != 0
|
||||
|
||||
#include "lv_chart.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_CHART_YMIN_DEF 0
|
||||
#define LV_CHART_YMAX_DEF 100
|
||||
#define LV_CHART_HDIV_DEF 3
|
||||
#define LV_CHART_VDIV_DEF 5
|
||||
#define LV_CHART_PNUM_DEF 10
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_chart_design(lv_obj_t * chart, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask);
|
||||
static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask);
|
||||
static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask);
|
||||
static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a chart background objects
|
||||
* @param par pointer to an object, it will be the parent of the new chart background
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created chart background
|
||||
*/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_chart = lv_obj_create(par, copy);
|
||||
dm_assert(new_chart);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_chart_ext_t * ext = lv_obj_alloc_ext(new_chart, sizeof(lv_chart_ext_t));
|
||||
dm_assert(ext);
|
||||
ll_init(&ext->dl_ll, sizeof(lv_chart_dl_t));
|
||||
ext->dl_num = 0;
|
||||
ext->ymin = LV_CHART_YMIN_DEF;
|
||||
ext->ymax = LV_CHART_YMAX_DEF;
|
||||
ext->hdiv_num = LV_CHART_HDIV_DEF;
|
||||
ext->vdiv_num = LV_CHART_VDIV_DEF;
|
||||
ext->pnum = LV_CHART_PNUM_DEF;
|
||||
ext->type = LV_CHART_LINE;
|
||||
ext->dl_opa = OPA_COVER;
|
||||
ext->dl_dark = OPA_50;
|
||||
ext->dl_width = 2 * LV_DOWNSCALE;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_chart);
|
||||
|
||||
lv_obj_set_signal_f(new_chart, lv_chart_signal);
|
||||
lv_obj_set_design_f(new_chart, lv_chart_design);
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_chart, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
} else {
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext(copy);
|
||||
ext->type = ext_copy->type;
|
||||
ext->ymin = ext_copy->ymin;
|
||||
ext->ymax = ext_copy->ymax;
|
||||
ext->hdiv_num = ext_copy->hdiv_num;
|
||||
ext->vdiv_num = ext_copy->vdiv_num;
|
||||
ext->pnum = ext_copy->pnum;
|
||||
ext->dl_opa = ext_copy->dl_opa;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_chart);
|
||||
}
|
||||
|
||||
return new_chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the chart background
|
||||
* @param chart pointer to a chart background object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(chart, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
cord_t ** datal;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
LL_READ(ext->dl_ll, datal) {
|
||||
dm_free(*datal);
|
||||
}
|
||||
ll_clear(&ext->dl_ll);
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and add a data line to the chart
|
||||
* @param chart pointer to a chart object
|
||||
* @param color color of the data line
|
||||
* @return pointer to the allocated data line (
|
||||
*/
|
||||
lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_dl_t * dl = ll_ins_head(&ext->dl_ll);
|
||||
cord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
|
||||
if(dl == NULL) return NULL;
|
||||
|
||||
dl->color = color;
|
||||
|
||||
dl->points = dm_alloc(sizeof(cord_t) * ext->pnum);
|
||||
|
||||
uint16_t i;
|
||||
cord_t * p_tmp = dl->points;
|
||||
for(i = 0; i < ext->pnum; i++) {
|
||||
*p_tmp = def;
|
||||
p_tmp++;
|
||||
}
|
||||
|
||||
ext->dl_num++;
|
||||
|
||||
return dl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh a chart if its data line has changed
|
||||
* @param chart pointer to chart object
|
||||
*/
|
||||
void lv_chart_refr(lv_obj_t * chart)
|
||||
{
|
||||
lv_obj_inv(chart);
|
||||
}
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the number of horizontal and vertical division lines
|
||||
* @param chart pointer to a graph background object
|
||||
* @param hdiv number of horizontal division lines
|
||||
* @param vdiv number of vertical division lines
|
||||
*/
|
||||
void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
ext->hdiv_num = hdiv;
|
||||
ext->vdiv_num = vdiv;
|
||||
|
||||
lv_obj_inv(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimal and maximal x and y values
|
||||
* @param chart pointer to a graph background object
|
||||
* @param xmin x minimum value
|
||||
* @param xmax x maximum value
|
||||
* @param ymin y minimum value
|
||||
* @param ymax y maximum value
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
ext->ymin = ymin;
|
||||
ext->ymax = ymax;
|
||||
|
||||
lv_chart_refr(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new type for a chart
|
||||
* @param chart pointer to a chart object
|
||||
* @param type new type of the chart (from 'lv_chart_type_t' enum)
|
||||
*/
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
ext->type = type;
|
||||
|
||||
lv_chart_refr(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of points on a data line on a chart
|
||||
* @param chart pointer r to chart object
|
||||
* @param pnum new number of points on the data lines
|
||||
*/
|
||||
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_dl_t * dl;
|
||||
|
||||
if(pnum < 1) pnum = 1;
|
||||
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
dl->points = dm_realloc(dl->points, sizeof(cord_t) * pnum);
|
||||
}
|
||||
|
||||
ext->pnum = pnum;
|
||||
lv_chart_refr(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @param opa opacity of the data lines
|
||||
*/
|
||||
void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
ext->dl_opa = opa;
|
||||
lv_obj_inv(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the line width or point radius of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @param width the new width
|
||||
*/
|
||||
void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
ext->dl_width = width;
|
||||
lv_obj_inv(chart);
|
||||
}
|
||||
/**
|
||||
* Set the dark effect on the bottom of the points or columns
|
||||
* @param chart pointer to chart object
|
||||
* @param dark_eff dark effect level (OPA_TRANSP to turn off)
|
||||
*/
|
||||
void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
ext->dl_dark = dark_eff;
|
||||
}
|
||||
/**
|
||||
* Shift all data right and set the most right data on a data line
|
||||
* @param chart pointer to chart object
|
||||
* @param dl pointer to a data line on 'chart'
|
||||
* @param y the new value of the most right data
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->pnum - 1; i++) {
|
||||
dl->points[i] = dl->points[i + 1];
|
||||
}
|
||||
|
||||
dl->points[ext->pnum - 1] = y;
|
||||
lv_chart_refr(chart);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
* @param chart pointer to chart object
|
||||
* @return type of the chart (from 'lv_chart_t' enum)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data point number per data line on chart
|
||||
* @param chart pointer to chart object
|
||||
* @return point number on each data line
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
return ext->pnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the opacity of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @return the opacity of the data lines
|
||||
*/
|
||||
opa_t lv_chart_get_dl_opa(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
return ext->dl_opa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data line width
|
||||
* @param chart pointer to chart object
|
||||
* @return the width the data lines (lines or points)
|
||||
*/
|
||||
cord_t lv_chart_get_dl_width(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
return ext->dl_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dark effect level on the bottom of the points or columns
|
||||
* @param chart pointer to chart object
|
||||
* @return dark effect level (OPA_TRANSP to turn off)
|
||||
*/
|
||||
opa_t lv_chart_get_dl_dark(lv_obj_t * chart, opa_t dark_eff)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
return ext->dl_dark;
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the chart backgrounds
|
||||
* @param chart pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_chart_design(lv_obj_t * chart, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design_f(chart, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the background*/
|
||||
lv_draw_rect(&chart->cords, mask, lv_obj_get_style(chart));
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
lv_chart_draw_div(chart, mask);
|
||||
|
||||
if(ext->type & LV_CHART_LINE) lv_chart_draw_lines(chart, mask);
|
||||
if(ext->type & LV_CHART_COL) lv_chart_draw_cols(chart, mask);
|
||||
if(ext->type & LV_CHART_POINT) lv_chart_draw_points(chart, mask);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the division lines on chart background
|
||||
* @param chart pointer to chart object
|
||||
* @param mask mask, inherited from the design function
|
||||
*/
|
||||
static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t div_i;
|
||||
uint8_t div_i_end;
|
||||
uint8_t div_i_start;
|
||||
point_t p1;
|
||||
point_t p2;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
|
||||
if(ext->hdiv_num != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->bwidth != 0) {
|
||||
div_i_start = 1;
|
||||
div_i_end = ext->hdiv_num;
|
||||
} else {
|
||||
div_i_start = 0;
|
||||
div_i_end = ext->hdiv_num + 1;
|
||||
}
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
p2.x = w + x_ofs;
|
||||
for(div_i = div_i_start; div_i <= div_i_end; div_i++) {
|
||||
p1.y = (int32_t)((int32_t)h * div_i) / (ext->hdiv_num + 1);
|
||||
p1.y += y_ofs;
|
||||
if(div_i == div_i_start) p1.y += (style->line_width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end) p1.y -= (style->line_width >> 1) + 1; /*The last line might not be visible*/
|
||||
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
|
||||
if(ext->vdiv_num != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->bwidth != 0) {
|
||||
div_i_start = 1;
|
||||
div_i_end = ext->vdiv_num;
|
||||
} else {
|
||||
div_i_start = 0;
|
||||
div_i_end = ext->vdiv_num + 1;
|
||||
}
|
||||
|
||||
p1.y = 0 + y_ofs;
|
||||
p2.y = h + y_ofs;
|
||||
for(div_i = div_i_start; div_i <= div_i_end; div_i ++) {
|
||||
p1.x = (int32_t)((int32_t)w * div_i) / (ext->vdiv_num + 1);
|
||||
p1.x += x_ofs;
|
||||
if(div_i == div_i_start) p1.x += (style->line_width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end) p1.x -= (style->line_width >> 1) + 1; /*The last line might not be visible*/
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the data lines as lines on a chart
|
||||
* @param obj pointer to chart object
|
||||
*/
|
||||
static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
point_t p1;
|
||||
point_t p2;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
lv_style_t lines;
|
||||
lv_style_get(LV_STYLE_PLAIN, &lines);
|
||||
lines.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8;
|
||||
lines.line_width = ext->dl_width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
lines.ccolor = dl->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
p2.x = 0 + x_ofs;
|
||||
y_tmp = (int32_t)((int32_t) dl->points[0] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
for(i = 1; i < ext->pnum; i ++) {
|
||||
p1.x = p2.x;
|
||||
p1.y = p2.y;
|
||||
|
||||
p2.x = ((w * i) / (ext->pnum - 1)) + x_ofs;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) dl->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the data lines as points on a chart
|
||||
* @param chart pointer to chart object
|
||||
* @param mask mask, inherited from the design function
|
||||
*/
|
||||
static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
area_t cir_a;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
uint8_t dl_cnt = 0;
|
||||
lv_style_t style_point;
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_point);
|
||||
|
||||
style_point.bwidth = 0;
|
||||
style_point.empty = 0;
|
||||
style_point.radius = LV_RADIUS_CIRCLE;
|
||||
style_point.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8;
|
||||
style_point.radius = ext->dl_width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
style_point.mcolor = dl->color;
|
||||
style_point.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dl_dark);
|
||||
|
||||
for(i = 0; i < ext->pnum; i ++) {
|
||||
cir_a.x1 = ((w * i) / (ext->pnum - 1)) + x_ofs;
|
||||
cir_a.x2 = cir_a.x1 + style_point.radius;
|
||||
cir_a.x1 -= style_point.radius;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) dl->points[i] - 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.radius;
|
||||
cir_a.y1 -= style_point.radius;
|
||||
|
||||
lv_draw_rect(&cir_a, mask, &style_point);
|
||||
}
|
||||
dl_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the data lines as columns on a chart
|
||||
* @param chart pointer to chart object
|
||||
* @param mask mask, inherited from the design function
|
||||
*/
|
||||
static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
area_t col_a;
|
||||
area_t col_mask;
|
||||
bool mask_ret;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
lv_style_t rects;
|
||||
cord_t col_w = w / ((ext->dl_num + 1) * ext->pnum); /* Suppose + 1 dl as separator*/
|
||||
cord_t x_ofs = col_w / 2; /*Shift with a half col.*/
|
||||
|
||||
lv_style_get(LV_STYLE_PLAIN, &rects);
|
||||
rects.bwidth = 0;
|
||||
rects.empty = 0;
|
||||
rects.radius = 0;
|
||||
rects.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8;
|
||||
|
||||
col_a.y2 = chart->cords.y2;
|
||||
|
||||
cord_t x_act;
|
||||
|
||||
/*Go through all points*/
|
||||
for(i = 0; i < ext->pnum; i ++) {
|
||||
x_act = (int32_t)((int32_t) w * i) / ext->pnum;
|
||||
x_act += chart->cords.x1 + x_ofs;
|
||||
|
||||
/*Draw the current point of all data line*/
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
rects.mcolor = dl->color;
|
||||
rects.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dl_dark);
|
||||
col_a.x1 = x_act;
|
||||
col_a.x2 = col_a.x1 + col_w;
|
||||
x_act += col_w;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) dl->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
col_a.y1 = h - y_tmp + chart->cords.y1;
|
||||
|
||||
mask_ret = area_union(&col_mask, mask, &col_a);
|
||||
if(mask_ret != false) {
|
||||
lv_draw_rect(&chart->cords, &col_mask, &rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,203 +0,0 @@
|
||||
/**
|
||||
* @file lv_chart.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CHART_H
|
||||
#define LV_CHART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_CHART != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_line.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
cord_t * points;
|
||||
color_t color;
|
||||
}lv_chart_dl_t;
|
||||
|
||||
/*Data of chart */
|
||||
typedef struct
|
||||
{
|
||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
|
||||
cord_t ymin; /*y min value (used to scale the data)*/
|
||||
cord_t ymax; /*y max value (used to scale the data)*/
|
||||
uint8_t hdiv_num; /*Number of horizontal division lines*/
|
||||
uint8_t vdiv_num; /*Number of vertical division lines*/
|
||||
uint16_t pnum; /*Point number in a data line*/
|
||||
cord_t dl_width; /*Line width or point radius*/
|
||||
uint8_t dl_num; /*Number of data lines in dl_ll*/
|
||||
opa_t dl_opa; /*Opacity of data lines*/
|
||||
opa_t dl_dark; /*Dark level of the point/column bottoms*/
|
||||
uint8_t type :3; /*Line, column or point chart (from 'lv_chart_type_t')*/
|
||||
}lv_chart_ext_t;
|
||||
|
||||
/*Chart types*/
|
||||
typedef enum
|
||||
{
|
||||
LV_CHART_NONE = 0,
|
||||
LV_CHART_LINE = 0x01,
|
||||
LV_CHART_COL = 0x02,
|
||||
LV_CHART_POINT = 0x04,
|
||||
}lv_chart_type_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a chart background objects
|
||||
* @param par pointer to an object, it will be the parent of the new chart background
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created chart background
|
||||
*/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the chart background
|
||||
* @param chart pointer to a chart background object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Allocate and add a data line to the chart
|
||||
* @param chart pointer to a chart object
|
||||
* @param color color of the data line
|
||||
* @return pointer to the allocated data line (
|
||||
*/
|
||||
lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color);
|
||||
|
||||
/**
|
||||
* Refresh a chart if its data line has changed
|
||||
* @param chart pointer to chart object
|
||||
*/
|
||||
void lv_chart_refr(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Set the number of horizontal and vertical division lines
|
||||
* @param chart pointer to a graph background object
|
||||
* @param hdiv number of horizontal division lines
|
||||
* @param vdiv number of vertical division lines
|
||||
*/
|
||||
void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
|
||||
|
||||
/**
|
||||
* Set the minimal and maximal x and y values
|
||||
* @param chart pointer to a graph background object
|
||||
* @param xmin x minimum value
|
||||
* @param xmax x maximum value
|
||||
* @param ymin y minimum value
|
||||
* @param ymax y maximum value
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax);
|
||||
|
||||
/**
|
||||
* Set a new type for a chart
|
||||
* @param chart pointer to a chart object
|
||||
* @param type new type of the chart (from 'lv_chart_type_t' enum)
|
||||
*/
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
|
||||
|
||||
/**
|
||||
* Set the number of points on a data line on a chart
|
||||
* @param chart pointer r to chart object
|
||||
* @param pnum new number of points on the data lines
|
||||
*/
|
||||
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum);
|
||||
|
||||
/**
|
||||
* Set the opacity of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @param opa opacity of the data lines
|
||||
*/
|
||||
void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa);
|
||||
|
||||
/**
|
||||
* Set the line width or point radius of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @param width the new width
|
||||
*/
|
||||
void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width);
|
||||
|
||||
/**
|
||||
* Set the dark effect on the bottom of the points or columns
|
||||
* @param chart pointer to chart object
|
||||
* @param dark_eff dark effect level (OPA_TRANSP to turn off)
|
||||
*/
|
||||
void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff);
|
||||
|
||||
/**
|
||||
* Shift all data right and set the most right data on a data line
|
||||
* @param chart pointer to chart object
|
||||
* @param dl pointer to a data line on 'chart'
|
||||
* @param y the new value of the most right data
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y);
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
* @param chart pointer to chart object
|
||||
* @return type of the chart (from 'lv_chart_t' enum)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Get the data point number per data line on chart
|
||||
* @param chart pointer to chart object
|
||||
* @return point number on each data line
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Get the opacity of the data lines
|
||||
* @param chart pointer to chart object
|
||||
* @return the opacity of the data lines
|
||||
*/
|
||||
opa_t lv_chart_get_dl_opa(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Get the data line width
|
||||
* @param chart pointer to chart object
|
||||
* @return the width the data lines (lines or points)
|
||||
*/
|
||||
cord_t lv_chart_get_dl_width(lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* Get the dark effect level on the bottom of the points or columns
|
||||
* @param chart pointer to chart object
|
||||
* @return dark effect level (OPA_TRANSP to turn off)
|
||||
*/
|
||||
opa_t lv_chart_get_dl_dark(lv_obj_t * chart, opa_t dark_eff);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_CHART*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_CHART_H*/
|
||||
@@ -1,622 +0,0 @@
|
||||
/**
|
||||
* @file lv_rect.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lv_cont.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_draw/lv_draw_vbasic.h"
|
||||
#include "misc/gfx/area.h"
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0
|
||||
static bool lv_cont_design(lv_obj_t * cont, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
|
||||
static void lv_cont_refr_layout(lv_obj_t * cont);
|
||||
static void lv_cont_layout_col(lv_obj_t * cont);
|
||||
static void lv_cont_layout_row(lv_obj_t * cont);
|
||||
static void lv_cont_layout_center(lv_obj_t * cont);
|
||||
static void lv_cont_layout_pretty(lv_obj_t * cont);
|
||||
static void lv_cont_layout_grid(lv_obj_t * cont);
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a container objects
|
||||
* @param par pointer to an object, it will be the parent of the new container
|
||||
* @param copy pointer to a container object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created container
|
||||
*/
|
||||
lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create a basic object*/
|
||||
lv_obj_t * new_rect = lv_obj_create(par, copy);
|
||||
dm_assert(new_rect);
|
||||
lv_obj_alloc_ext(new_rect, sizeof(lv_cont_ext_t));
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(new_rect);
|
||||
dm_assert(ext);
|
||||
ext->hfit_en = 0;
|
||||
ext->vfit_en = 0;
|
||||
ext->layout = LV_CONT_LAYOUT_OFF;
|
||||
|
||||
lv_obj_set_signal_f(new_rect, lv_cont_signal);
|
||||
|
||||
/*Init the new container*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_rect, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->hfit_en = copy_ext->hfit_en;
|
||||
ext->vfit_en = copy_ext->vfit_en;
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_rect);
|
||||
|
||||
}
|
||||
|
||||
return new_rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the container
|
||||
* @param cont pointer to a container object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(cont, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_STYLE_CHG: /*Recalculate the padding if the style changed*/
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
break;
|
||||
case LV_SIGNAL_CHILD_CHG:
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
break;
|
||||
case LV_SIGNAL_CORD_CHG:
|
||||
if(lv_obj_get_width(cont) != area_get_width(param) ||
|
||||
lv_obj_get_height(cont) != area_get_height(param)) {
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the layout on a container
|
||||
* @param cont pointer to a container object
|
||||
* @param layout a layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
ext->layout = layout;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* @param cont pointer to a container object
|
||||
* @param hor_en true: enable the horizontal padding
|
||||
* @param ver_en true: enable the vertical padding
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
{
|
||||
lv_obj_inv(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
ext->hfit_en = hor_en == false ? 0 : 1;
|
||||
ext->vfit_en = ver_en == false ? 0 : 1;
|
||||
|
||||
/*Send a signal to set a new size*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, cont);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the layout of a container
|
||||
* @param cont pointer to container object
|
||||
* @return the layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_hfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->hfit_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: vertical padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_vfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
return ext->vfit_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
#if 0
|
||||
/**
|
||||
* Handle the drawing related tasks of the containers
|
||||
* @param cont pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_cont_design(lv_obj_t * cont, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
|
||||
return false;
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the layout of a container
|
||||
* @param cont pointer to an object which layout should be refreshed
|
||||
*/
|
||||
static void lv_cont_refr_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
|
||||
/*'rect' has to be at least 1 child*/
|
||||
if(lv_obj_get_child(cont, NULL) == NULL) return;
|
||||
|
||||
if(type == LV_CONT_LAYOUT_OFF) return;
|
||||
|
||||
if(type == LV_CONT_LAYOUT_CENTER) {
|
||||
lv_cont_layout_center(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_COL_L || type == LV_CONT_LAYOUT_COL_M || type == LV_CONT_LAYOUT_COL_R) {
|
||||
lv_cont_layout_col(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_ROW_T || type == LV_CONT_LAYOUT_ROW_M || type == LV_CONT_LAYOUT_ROW_B) {
|
||||
lv_cont_layout_row(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_PRETTY) {
|
||||
lv_cont_layout_pretty(cont);
|
||||
} else if(type == LV_CONT_LAYOUT_GRID) {
|
||||
lv_cont_layout_grid(cont);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle column type layouts
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t hpad_corr;
|
||||
|
||||
switch(type) {
|
||||
case LV_CONT_LAYOUT_COL_L:
|
||||
hpad_corr = style->hpad;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_CONT_LAYOUT_COL_M:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_MID;
|
||||
break;
|
||||
case LV_CONT_LAYOUT_COL_R:
|
||||
hpad_corr = -style->hpad;
|
||||
align = LV_ALIGN_IN_TOP_RIGHT;
|
||||
break;
|
||||
default:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
/* Align the children */
|
||||
cord_t last_cord = style->vpad;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, align, hpad_corr , last_cord);
|
||||
last_cord += lv_obj_get_height(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle row type layouts
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t vpad_corr = style->vpad;
|
||||
|
||||
switch(type) {
|
||||
case LV_CONT_LAYOUT_ROW_T:
|
||||
vpad_corr = style->vpad;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_CONT_LAYOUT_ROW_M:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_LEFT_MID;
|
||||
break;
|
||||
case LV_CONT_LAYOUT_ROW_B:
|
||||
vpad_corr = -style->vpad;
|
||||
align = LV_ALIGN_IN_BOTTOM_LEFT;
|
||||
break;
|
||||
default:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t last_cord = style->hpad;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, align, last_cord, vpad_corr);
|
||||
last_cord += lv_obj_get_width(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the center layout
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
uint32_t obj_num = 0;
|
||||
cord_t h_tot = 0;
|
||||
|
||||
LL_READ(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
h_tot += lv_obj_get_height(child) + style->opad;
|
||||
obj_num ++;
|
||||
}
|
||||
|
||||
if(obj_num == 0) return;
|
||||
|
||||
h_tot -= style->opad;
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t last_cord = - (h_tot / 2);
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
last_cord += lv_obj_get_height(child) + style->opad;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the pretty layout. Put as many object as possible in row
|
||||
* then begin a new row
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child_rs; /* Row starter child */
|
||||
lv_obj_t * child_rc; /* Row closer child */
|
||||
lv_obj_t * child_tmp; /* Temporary child */
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t w_obj = lv_obj_get_width(cont);
|
||||
cord_t act_y = style->vpad;
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
|
||||
child_rs = ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
if(child_rs == NULL) return; /*Return if no child*/
|
||||
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||
while(child_rs != NULL) {
|
||||
cord_t h_row = 0;
|
||||
cord_t w_row = style->hpad * 2; /*The width is at least the left+right hpad*/
|
||||
uint32_t obj_num = 0;
|
||||
|
||||
/*Find the row closer object and collect some data*/
|
||||
do {
|
||||
if(lv_obj_get_hidden(child_rc) == false &&
|
||||
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
|
||||
/*If this object is already not fit then break*/
|
||||
if(w_row + lv_obj_get_width(child_rc) > w_obj) {
|
||||
/*Step back one child because the last already not fit, so the previous is the closer*/
|
||||
if(child_rc != NULL && obj_num != 0 ) {
|
||||
child_rc = ll_get_next(&cont->child_ll, child_rc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
w_row += lv_obj_get_width(child_rc) + style->opad; /*Add the object width + opad*/
|
||||
h_row = MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/
|
||||
|
||||
}
|
||||
child_rc = ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
|
||||
}while(child_rc != NULL);
|
||||
|
||||
/*If the object is too long then align it to the middle*/
|
||||
if(obj_num == 0) {
|
||||
if(child_rc != NULL) {
|
||||
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
|
||||
}
|
||||
}
|
||||
/*If here is only one object in the row then align it to the middle*/
|
||||
else if (obj_num == 1) {
|
||||
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
w_row -= style->opad * obj_num;
|
||||
cord_t new_opad = (w_obj - w_row) / (obj_num - 1);
|
||||
cord_t act_x = style->hpad; /*x init*/
|
||||
child_tmp = child_rs;
|
||||
while(child_tmp != NULL) {
|
||||
if(lv_obj_get_hidden(child_tmp) == false &&
|
||||
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y);
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
if(child_tmp == child_rc) break;
|
||||
child_tmp = ll_get_prev(&cont->child_ll, child_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(child_rc == NULL) break;
|
||||
act_y += style->opad + h_row; /*y increment*/
|
||||
child_rs = ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the grid layout. Align same-sized objects in a grid
|
||||
* @param cont pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
cord_t w_tot = lv_obj_get_width(cont);
|
||||
cord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
||||
cord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
||||
uint16_t obj_row = (w_tot - (2 * style->hpad)) / (w_obj + style->opad); /*Obj. num. in a row*/
|
||||
cord_t x_ofs;
|
||||
if(obj_row > 1) {
|
||||
x_ofs = w_obj + (w_tot - (2 * style->hpad) - (obj_row * w_obj)) / (obj_row - 1);
|
||||
} else {
|
||||
x_ofs = w_tot / 2 - w_obj / 2;
|
||||
}
|
||||
cord_t y_ofs = h_obj + style->opad;
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
cord_t act_x = style->hpad;
|
||||
cord_t act_y = style->vpad;
|
||||
uint16_t obj_cnt = 0;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
if(obj_row > 1) {
|
||||
lv_obj_set_pos(child, act_x, act_y);
|
||||
act_x += x_ofs;
|
||||
} else {
|
||||
lv_obj_set_pos(child, x_ofs, act_y);
|
||||
}
|
||||
obj_cnt ++;
|
||||
|
||||
if(obj_cnt >= obj_row) {
|
||||
obj_cnt = 0;
|
||||
act_x = style->hpad;
|
||||
act_y += y_ofs;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle auto fit. Set the size of the object to involve all children.
|
||||
* @param cont pointer to an object which size will be modified
|
||||
*/
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
|
||||
if(ext->hfit_en == 0 &&
|
||||
ext->vfit_en == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
area_t new_cords;
|
||||
area_t ori;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_obj_t * i;
|
||||
cord_t hpad = style->hpad;
|
||||
cord_t vpad = style->vpad;
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_cords(cont, &ori);
|
||||
lv_obj_get_cords(cont, &new_cords);
|
||||
|
||||
new_cords.x1 = CORD_MAX;
|
||||
new_cords.y1 = CORD_MAX;
|
||||
new_cords.x2 = CORD_MIN;
|
||||
new_cords.y2 = CORD_MIN;
|
||||
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->cords.y1);
|
||||
new_cords.x2 = MATH_MAX(new_cords.x2, i->cords.x2);
|
||||
new_cords.y2 = MATH_MAX(new_cords.y2, i->cords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
if(new_cords.x1 != CORD_MAX) {
|
||||
if(ext->hfit_en != 0) {
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = cont->cords.x1;
|
||||
new_cords.x2 = cont->cords.x2;
|
||||
}
|
||||
if(ext->vfit_en != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = cont->cords.y1;
|
||||
new_cords.y2 = cont->cords.y2;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->cords.x1 != new_cords.x1 ||
|
||||
cont->cords.y1 != new_cords.y1 ||
|
||||
cont->cords.x2 != new_cords.x2 ||
|
||||
cont->cords.y2 != new_cords.y2) {
|
||||
|
||||
lv_obj_inv(cont);
|
||||
area_cpy(&cont->cords, &new_cords);
|
||||
lv_obj_inv(cont);
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* @file lv_cont.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CONT_H
|
||||
#define LV_CONT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Layout options*/
|
||||
typedef enum
|
||||
{
|
||||
LV_CONT_LAYOUT_OFF = 0,
|
||||
LV_CONT_LAYOUT_CENTER,
|
||||
LV_CONT_LAYOUT_COL_L, /*Column left align*/
|
||||
LV_CONT_LAYOUT_COL_M, /*Column middle align*/
|
||||
LV_CONT_LAYOUT_COL_R, /*Column right align*/
|
||||
LV_CONT_LAYOUT_ROW_T, /*Row top align*/
|
||||
LV_CONT_LAYOUT_ROW_M, /*Row middle align*/
|
||||
LV_CONT_LAYOUT_ROW_B, /*Row bottom align*/
|
||||
LV_CONT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
|
||||
LV_CONT_LAYOUT_GRID, /*Align same-sized object into a grid*/
|
||||
}lv_cont_layout_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :5; /*A layout from 'lv_cont_layout_t' enum*/
|
||||
uint8_t hfit_en :1; /*Enable horizontal padding to involve all children*/
|
||||
uint8_t vfit_en :1; /*Enable horizontal padding to involve all children*/
|
||||
}lv_cont_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a container objects
|
||||
* @param par pointer to an object, it will be the parent of the new container
|
||||
* @param copy pointer to a container object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created container
|
||||
*/
|
||||
lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the container
|
||||
* @param cont pointer to a container object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the layout on a container
|
||||
* @param cont pointer to a container object
|
||||
* @param layout a layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout);
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* @param cont pointer to a container object
|
||||
* @param hor_en true: enable the horizontal padding
|
||||
* @param ver_en true: enable the vertical padding
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en);
|
||||
|
||||
/**
|
||||
* Get the layout of a container
|
||||
* @param cont pointer to container object
|
||||
* @return the layout from 'lv_cont_layout_t'
|
||||
*/
|
||||
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_hfit(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: vertical padding is enabled
|
||||
*/
|
||||
bool lv_cont_get_vfit(lv_obj_t * cont);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_CONT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_CONT_H*/
|
||||
@@ -1,482 +0,0 @@
|
||||
/**
|
||||
* @file lv_ddlist.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_DDLIST != 0
|
||||
|
||||
#include "lv_ddlist.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_DDLIST_DEF_ANIM_TIME 200 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_mode_t mode);
|
||||
static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time);
|
||||
static void lv_ddlist_pos_act_option(lv_obj_t * ddlist);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static const char * def_options[] = {"Option 1", "Option 2", "Option 3", ""};
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a drop down list objects
|
||||
* @param par pointer to an object, it will be the parent of the new drop down list
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created drop down list
|
||||
*/
|
||||
lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor drop down list*/
|
||||
lv_obj_t * new_ddlist = lv_page_create(par, copy);
|
||||
dm_assert(new_ddlist);
|
||||
|
||||
/*Allocate the drop down list type specific extended data*/
|
||||
lv_ddlist_ext_t * ext = lv_obj_alloc_ext(new_ddlist, sizeof(lv_ddlist_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->opt_label = NULL;
|
||||
ext->cb = NULL;
|
||||
ext->opened = 0;
|
||||
ext->auto_size = 0;
|
||||
ext->sel_opt = 0;
|
||||
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
|
||||
ext->style_sel = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_ddlist);
|
||||
|
||||
lv_obj_set_signal_f(new_ddlist, lv_ddlist_signal);
|
||||
lv_obj_set_design_f(new_ddlist, lv_ddlist_design);
|
||||
|
||||
/*Init the new drop down list drop down list*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
|
||||
lv_obj_set_drag(scrl, false);
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
|
||||
ext->opt_label = lv_label_create(new_ddlist, NULL);
|
||||
lv_cont_set_fit(new_ddlist, true, false);
|
||||
lv_page_set_rel_action(new_ddlist, lv_ddlist_rel_action);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
|
||||
lv_obj_set_style(new_ddlist, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_ddlist_set_options(new_ddlist, def_options);
|
||||
}
|
||||
/*Copy an existing drop down list*/
|
||||
else {
|
||||
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->opt_label = lv_label_create(new_ddlist, copy_ext->opt_label);
|
||||
lv_label_set_text(ext->opt_label, lv_label_get_text(copy_ext->opt_label));
|
||||
ext->sel_opt = copy_ext->sel_opt;
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
ext->cb = copy_ext->cb;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_ddlist);
|
||||
}
|
||||
|
||||
return new_ddlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the drop down list
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_page_signal(ddlist, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist));
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the options in a drop down list from an array
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @param options an array of strings with the text of the options.
|
||||
* The lest element has to be "" (empty string)
|
||||
* E.g. const char * opts[] = {"apple", "banana", "orange", ""};
|
||||
*/
|
||||
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
|
||||
lv_label_set_text(ext->opt_label, "");
|
||||
uint16_t i = 0;
|
||||
while(options[i][0] != '\0') {
|
||||
lv_label_append_text(ext->opt_label, options[i]);
|
||||
if(options[i + 1][0] != '\0') lv_label_append_text(ext->opt_label, "\n");
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the options in a drop down list from a string
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
|
||||
*/
|
||||
void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_label_set_text(ext->opt_label, options);
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the selected option
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @param sel_opt id of the selected option (0 ... number of option - 1);
|
||||
*/
|
||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
|
||||
ext->sel_opt = sel_opt;
|
||||
|
||||
/*Move the list to show the current option*/
|
||||
if(ext->opened == 0) {
|
||||
lv_ddlist_pos_act_option(ddlist);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when a new option is chosen
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param cb pointer to a call back function
|
||||
*/
|
||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
|
||||
* In this case the drop down list can be scrolled.
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param auto_size true: enable auto size, false: disable
|
||||
*/
|
||||
void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
ext->auto_size = auto_size == false ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the open/close animation time.
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param anim_time: open/close animation time [ms]
|
||||
*/
|
||||
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
ext->anim_time = anim_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of the rectangle on the selected option
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param style pointer the new style of the select rectangle
|
||||
*/
|
||||
void lv_dlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
ext->style_sel = style;
|
||||
|
||||
}
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the options of a drop down list
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
|
||||
*/
|
||||
const char * lv_ddlist_get_options(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
return lv_label_get_text(ext->opt_label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected option
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return id of the selected option (0 ... number of option - 1);
|
||||
*/
|
||||
uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
|
||||
return ext->sel_opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
* @param buf pointer to an array to store the string
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
|
||||
uint16_t i;
|
||||
uint16_t line = 0;
|
||||
const char * opt_txt = lv_label_get_text(ext->opt_label);
|
||||
uint16_t txt_len = strlen(opt_txt);
|
||||
|
||||
|
||||
for(i = 0; i < txt_len && line != ext->sel_opt; i++) {
|
||||
if(opt_txt[i] == '\n') line ++;
|
||||
}
|
||||
|
||||
uint16_t c;
|
||||
for(c = 0; opt_txt[i] != '\n' && i < txt_len; c++, i++) buf[c] = opt_txt[i];
|
||||
|
||||
buf[c] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auto size attribute.
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return true: the auto_size is enabled, false: disabled
|
||||
*/
|
||||
bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of the rectangle on the selected option
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return pointer the style of the select rectangle
|
||||
*/
|
||||
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
if(ext->style_sel == NULL) return lv_obj_get_style(ddlist);
|
||||
|
||||
return ext->style_sel;
|
||||
}
|
||||
/**
|
||||
* Get the open/close animation time.
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @return open/close animation time [ms]
|
||||
*/
|
||||
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
return ext->anim_time;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the drop down lists
|
||||
* @param ddlist pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design_f(ddlist, mask, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(ddlist, mask, mode);
|
||||
|
||||
/*If the list is opened draw a rectangle below the selected item*/
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
if(ext->opened != 0) {
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
const font_t * font = style->font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
area_t rect_area;
|
||||
lv_style_t * style_page_scrl = lv_obj_get_style(lv_page_get_scrl(ddlist));
|
||||
rect_area.y1 = ext->opt_label->cords.y1;
|
||||
rect_area.y1 += ext->sel_opt * (font_h + style->line_space);
|
||||
rect_area.y1 -= style->line_space / 2;
|
||||
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->line_space;
|
||||
rect_area.x1 = ext->opt_label->cords.x1 - style_page_scrl->hpad;
|
||||
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(ddlist));
|
||||
|
||||
lv_draw_rect(&rect_area, mask, ext->style_sel);
|
||||
}
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design_f(ddlist, mask, mode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a drop down list is released to open it or set new option
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param dispi pointer to the called display input
|
||||
* @return LV_ACTION_RES_INV if the ddlist it deleted in the user callback else LV_ACTION_RES_OK
|
||||
*/
|
||||
static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
|
||||
if(ext->opened == 0) { /*Open the list*/
|
||||
ext->opened = 1;
|
||||
lv_obj_set_drag(lv_page_get_scrl(ddlist), true);
|
||||
} else {
|
||||
ext->opened = 0;
|
||||
lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
|
||||
|
||||
/*Search the clicked option*/
|
||||
point_t p;
|
||||
lv_dispi_get_point(dispi, &p);
|
||||
p.x -= ext->opt_label->cords.x1;
|
||||
p.y -= ext->opt_label->cords.y1;
|
||||
uint16_t letter_i;
|
||||
letter_i = lv_label_get_letter_on(ext->opt_label, &p);
|
||||
|
||||
uint16_t new_opt = 0;
|
||||
const char * txt = lv_label_get_text(ext->opt_label);
|
||||
uint16_t i;
|
||||
for(i = 0; i < letter_i; i++) {
|
||||
if(txt[i] == '\n') new_opt ++;
|
||||
}
|
||||
|
||||
ext->sel_opt = new_opt;
|
||||
|
||||
if(ext->cb != NULL) {
|
||||
ext->cb(ddlist, dispi);
|
||||
}
|
||||
}
|
||||
lv_ddlist_refr_size(ddlist, ext->anim_time);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the size of drop down list according its start (open or closed)
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param anim_time animations time for open/close [ms]
|
||||
*/
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
cord_t new_height;
|
||||
if(ext->opened != 0) { /*Open the list*/
|
||||
new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->vpad;
|
||||
lv_obj_t * parent = lv_obj_get_parent(ddlist);
|
||||
/*Reduce the height if enabled and required*/
|
||||
if(ext->auto_size != 0 && new_height + ddlist->cords.y1 > parent->cords.y2) {
|
||||
new_height = parent->cords.y2 - ddlist->cords.y1;
|
||||
}
|
||||
} else { /*Close the list*/
|
||||
const font_t * font = style->font;
|
||||
lv_style_t * label_style = lv_obj_get_style(ext->opt_label);
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
new_height = font_h + 2 * label_style->line_space;
|
||||
}
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_height(ddlist, new_height);
|
||||
lv_ddlist_pos_act_option(ddlist);
|
||||
} else {
|
||||
anim_t a;
|
||||
a.var = ddlist;
|
||||
a.start = lv_obj_get_height(ddlist);
|
||||
a.end = new_height;
|
||||
a.fp = (anim_fp_t)lv_obj_set_height;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = (anim_cb_t)lv_ddlist_pos_act_option;
|
||||
a.act_time = 0;
|
||||
a.time = ext->anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
|
||||
anim_create(&a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of list when it is closed to show the selected item
|
||||
* @param ddlist pointer to a drop down list
|
||||
*/
|
||||
static void lv_ddlist_pos_act_option(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
const font_t * font = style->font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
lv_style_t * label_style = lv_obj_get_style(ext->opt_label);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
lv_obj_set_y(scrl, -(ext->sel_opt * (font_h + label_style->line_space) - label_style->line_space) - style_scrl->hpad);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,160 +0,0 @@
|
||||
/**
|
||||
* @file lv_ddlist.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DDLIST_H
|
||||
#define LV_DDLIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_DDLIST != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_PAGE == 0
|
||||
#error "lv_ddlist: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_ddlist: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_objx/lv_page.h"
|
||||
#include "../lv_objx/lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of drop down list*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * opt_label; /*Label for the options*/
|
||||
lv_style_t * style_sel; /*Style of the selected option*/
|
||||
lv_action_t cb; /*Pointer to function to call when an option is slected*/
|
||||
uint16_t sel_opt; /*Index of the current option*/
|
||||
uint16_t anim_time; /*Open/Close animation time [ms]*/
|
||||
uint8_t opened :1; /*1: The list is opened*/
|
||||
uint8_t auto_size :1; /*1: Set height to show all options. 0: Set height maximum to the parent bottom*/
|
||||
}lv_ddlist_ext_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a drop down list objects
|
||||
* @param par pointer to an object, it will be the parent of the new drop down list
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created drop down list
|
||||
*/
|
||||
lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the drop down list
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the options in a drop down list
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @param options an array of strings wit the text of the options.
|
||||
* The lest element has to be "" (empty string)
|
||||
* E.g. const char * opts[] = {"apple", "banana", "orange", ""};
|
||||
*/
|
||||
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options);
|
||||
|
||||
void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options);
|
||||
/**
|
||||
* Set the selected option
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @param sel_opt id of the selected option (0 ... number of option - 1);
|
||||
*/
|
||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
||||
|
||||
|
||||
/**
|
||||
* Set a function to call when a new option is chosen
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param cb pointer to a call back function
|
||||
*/
|
||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb);
|
||||
|
||||
/**
|
||||
* Set the auto size attribute. If enabled the height will reduced to be visible on the parent.
|
||||
* In this case the drop down list can be scrolled.
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param auto_size true: enable auto size, false: disable
|
||||
*/
|
||||
void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size);
|
||||
|
||||
/**
|
||||
* Set the style of the rectangle on the selected option
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param style pointer the new style of the select rectangle
|
||||
*/
|
||||
void lv_dlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the options of a drop down list
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
|
||||
*/
|
||||
const char * lv_ddlist_get_options(lv_obj_t * ddlist);
|
||||
|
||||
/**
|
||||
* Get the selected option
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return id of the selected option (0 ... number of option - 1);
|
||||
*/
|
||||
uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist);
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
* @param buf pointer to an array to store the string
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf);
|
||||
|
||||
/**
|
||||
* Get the auto size attribute.
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return true: the auto_size is enabled, false: disabled
|
||||
*/
|
||||
bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size);
|
||||
|
||||
/**
|
||||
* Get the style of the rectangle on the selected option
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return pointer the style of the select rectangle
|
||||
*/
|
||||
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_DDLIST*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DDLIST_H*/
|
||||
@@ -1,461 +0,0 @@
|
||||
/**
|
||||
* @file lv_gauge.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
#include "lv_gauge.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/math/trigo.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_GAUGE_MAX_NEEDLE
|
||||
#define LV_GAUGE_MAX_NEEDLE 4 /*Max number of needles. Used in the style.*/
|
||||
#endif
|
||||
|
||||
#define LV_GAUGE_DEF_NEEDLE_COLOR COLOR_RED
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_t * style);
|
||||
static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style_t * style);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f = NULL;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a gauge objects
|
||||
* @param par pointer to an object, it will be the parent of the new gauge
|
||||
* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created gauge
|
||||
*/
|
||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor gauge*/
|
||||
lv_obj_t * new_gauge = lv_lmeter_create(par, copy);
|
||||
dm_assert(new_gauge);
|
||||
|
||||
/*Allocate the gauge type specific extended data*/
|
||||
lv_gauge_ext_t * ext = lv_obj_alloc_ext(new_gauge, sizeof(lv_gauge_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->needle_num = 0;
|
||||
ext->values = NULL;
|
||||
ext->needle_colors = NULL;
|
||||
ext->low_critical = 0;
|
||||
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_gauge);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_f(new_gauge, lv_gauge_design);
|
||||
|
||||
/*Init the new gauge gauge*/
|
||||
if(copy == NULL) {
|
||||
lv_lmeter_set_scale(new_gauge, 220, 6);
|
||||
lv_gauge_set_needle_num(new_gauge, 1, NULL);
|
||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||
lv_obj_set_style(new_gauge, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
}
|
||||
/*Copy an existing gauge*/
|
||||
else {
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->low_critical = copy_ext->low_critical;
|
||||
lv_gauge_set_style_critical(new_gauge, lv_gauge_get_style_critical(copy));
|
||||
lv_gauge_set_needle_num(new_gauge, copy_ext->needle_num, copy_ext->needle_colors);
|
||||
|
||||
uint8_t i;
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
ext->values[i] = copy_ext->values[i];
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_gauge);
|
||||
}
|
||||
|
||||
return new_gauge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_lmeter_signal(gauge, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style_crit = lv_gauge_get_style_critical(gauge);
|
||||
if(style_crit->swidth > gauge->ext_size) gauge->ext_size = style_crit->swidth;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the number of needles
|
||||
* @param gauge pointer to gauge object
|
||||
* @param num number of needles
|
||||
* @param colors an array of colors for needles (with 'num' elements)
|
||||
*/
|
||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
if(ext->values != NULL) {
|
||||
dm_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
|
||||
ext->values = dm_realloc(ext->values, num * sizeof(int16_t));
|
||||
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
uint8_t n;
|
||||
for(n = ext->needle_num; n < num; n++) {
|
||||
ext->values[n] = min;
|
||||
}
|
||||
|
||||
ext->needle_num = num;
|
||||
ext->needle_colors = colors;
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the value of a needle
|
||||
* @param gauge pointer to gauge
|
||||
* @param needle the id of the needle
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return;
|
||||
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
int16_t max = lv_bar_get_max_value(gauge);
|
||||
|
||||
if(value > max) value = max;
|
||||
else if(value < min) value = min;
|
||||
|
||||
ext->values[needle] = value;
|
||||
|
||||
/*To be consistent with bar set the first needle's value for the bar*/
|
||||
if(needle == 0) lv_bar_set_value(gauge, value);
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
ext->low_critical = low == false ? 0 : 1;
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the critical style of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param style pointer to the new critical style
|
||||
*/
|
||||
void lv_gauge_set_style_critical(lv_obj_t * gauge, lv_style_t * style)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
ext->style_critical = style;
|
||||
gauge->signal_f(gauge, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
lv_obj_inv(gauge);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the number of needles on a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return number of needles
|
||||
*/
|
||||
uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
return ext->needle_num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a needle
|
||||
* @param gauge pointer to gauge object
|
||||
* @param needle the id of the needle
|
||||
* @return the value of the needle [min,max]
|
||||
*/
|
||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return min;
|
||||
|
||||
return ext->values[needle];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
return ext->low_critical == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the critical style of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @return pointer to the critical style
|
||||
*/
|
||||
lv_style_t * lv_gauge_get_style_critical(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
if(ext->style_critical == NULL) return lv_obj_get_style(gauge);
|
||||
|
||||
return ext->style_critical;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the gauges
|
||||
* @param gauge pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style_base = lv_obj_get_style(gauge);
|
||||
lv_style_t * style_critical = lv_gauge_get_style_critical(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
/* Draw the background
|
||||
* Re-color the gauge according to the critical value*/
|
||||
lv_style_t style_bg;
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
int16_t max = lv_bar_get_max_value(gauge);
|
||||
|
||||
/*To be consistent with bar use the bar value as the first needle*/
|
||||
if(ext->needle_num != 0) {
|
||||
ext->values[0] = lv_bar_get_value(gauge);
|
||||
}
|
||||
|
||||
int16_t critical_val = ext->low_critical == 0 ? min : max;
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
critical_val = ext->low_critical == 0 ? MATH_MAX(critical_val, ext->values[i]) : MATH_MIN(critical_val, ext->values[i]);
|
||||
}
|
||||
|
||||
opa_t ratio = ((critical_val - min) * OPA_COVER) / (max - min);
|
||||
|
||||
if(ext->low_critical != 0) ratio = OPA_COVER - ratio;
|
||||
|
||||
/*Mix the normal and the critical style*/
|
||||
memcpy(&style_bg, style_base, sizeof(lv_style_t));
|
||||
style_bg.ccolor = color_mix(style_critical->ccolor, style_base->ccolor, ratio);
|
||||
style_bg.mcolor= color_mix(style_critical->mcolor, style_base->mcolor, ratio);
|
||||
style_bg.gcolor = color_mix(style_critical->gcolor, style_base->gcolor, ratio);
|
||||
style_bg.bcolor = color_mix(style_critical->bcolor, style_base->bcolor, ratio);
|
||||
style_bg.scolor = color_mix(style_critical->scolor, style_base->scolor, ratio);
|
||||
style_bg.swidth = (cord_t)(((cord_t)style_critical->swidth * ratio) + ((cord_t)style_base->swidth * (OPA_COVER - ratio))) >> 8;
|
||||
style_bg.opa = (cord_t)(((uint16_t)style_critical->opa * ratio) + ((uint16_t)style_base->opa * (OPA_COVER - ratio))) >> 8;
|
||||
|
||||
lv_draw_rect(&gauge->cords, mask, &style_bg);
|
||||
|
||||
lv_gauge_draw_scale(gauge, mask, &style_bg);
|
||||
|
||||
lv_gauge_draw_needle(gauge, mask, &style_bg);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design_f(gauge, mask, mode);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the scale on a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param mask mask of drawing
|
||||
*/
|
||||
static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_t * style)
|
||||
{
|
||||
char scale_txt[16];
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->hpad;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
|
||||
uint16_t scale_num = lv_lmeter_get_scale_num(gauge);
|
||||
int16_t angle_ofs = 90 + (360 - scale_angle) / 2;
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
int16_t max = lv_bar_get_max_value(gauge);
|
||||
|
||||
uint8_t i;
|
||||
for(i = 0; i < scale_num; i++) {
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * scale_angle) / (scale_num - 1) + angle_ofs;
|
||||
|
||||
cord_t y = (int32_t)((int32_t)trigo_sin(angle) * r) / TRIGO_SIN_MAX;
|
||||
y += y_ofs;
|
||||
|
||||
cord_t x = (int32_t)((int32_t)trigo_sin(angle + 90) * r) / TRIGO_SIN_MAX;
|
||||
x += x_ofs;
|
||||
|
||||
int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (scale_num - 1);
|
||||
scale_act += min;
|
||||
sprintf(scale_txt, "%d", scale_act);
|
||||
|
||||
area_t label_cord;
|
||||
point_t label_size;
|
||||
txt_get_size(&label_size, scale_txt, style->font,
|
||||
style->letter_space, style->line_space,
|
||||
CORD_MAX, TXT_FLAG_NONE);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
label_cord.y1 = y - label_size.y / 2;
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, style, scale_txt, TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Draw the needles of a gauge
|
||||
* @param gauge pointer to gauge object
|
||||
* @param mask mask of drawing
|
||||
*/
|
||||
static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style_t * style)
|
||||
{
|
||||
lv_style_t style_needle;
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->opad;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
uint16_t angle = lv_lmeter_get_scale_angle(gauge);
|
||||
int16_t angle_ofs = 90 + (360 - angle) / 2;
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
int16_t max = lv_bar_get_max_value(gauge);
|
||||
point_t p_mid;
|
||||
point_t p_end;
|
||||
uint8_t i;
|
||||
|
||||
memcpy(&style_needle, style, sizeof(lv_style_t));
|
||||
|
||||
p_mid.x = x_ofs;
|
||||
p_mid.y = y_ofs;
|
||||
for(i = 0; i < ext->needle_num; i++) {
|
||||
/*Calculate the end point of a needle*/
|
||||
int16_t needle_angle = (ext->values[i] - min) * angle / (max - min) + angle_ofs;
|
||||
p_end.y = (trigo_sin(needle_angle) * r) / TRIGO_SIN_MAX + y_ofs;
|
||||
p_end.x = (trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs;
|
||||
|
||||
/*Draw the needle with the corresponding color*/
|
||||
if(ext->needle_colors == NULL) style_needle.ccolor = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||
else style_needle.ccolor = ext->needle_colors[i];
|
||||
|
||||
lv_draw_line(&p_mid, &p_end, mask, &style_needle);
|
||||
}
|
||||
|
||||
/*Draw the needle middle area*/
|
||||
lv_style_t style_neddle_mid;
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_neddle_mid);
|
||||
style_neddle_mid.mcolor = style->bcolor;
|
||||
style_neddle_mid.gcolor = style->bcolor;
|
||||
style_neddle_mid.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
area_t nm_cord;
|
||||
nm_cord.x1 = x_ofs - style->opad;
|
||||
nm_cord.y1 = y_ofs - style->opad;
|
||||
nm_cord.x2 = x_ofs + style->opad;
|
||||
nm_cord.y2 = y_ofs + style->opad;
|
||||
|
||||
lv_draw_rect(&nm_cord, mask, &style_neddle_mid);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
/**
|
||||
* @file lv_gauge.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GAUGE_H
|
||||
#define LV_GAUGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_LMETER == 0
|
||||
#error "lv_gauge: lv_lmeter is required. Enable it in lv_conf.h (USE_LV_LMETER 1) "
|
||||
#endif
|
||||
|
||||
#if USE_TRIGO == 0
|
||||
#error "lv_gauge: trigo is required. Enable it in misc_conf.h (USE_TRIGO 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_lmeter.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_line.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of gauge*/
|
||||
typedef struct
|
||||
{
|
||||
lv_lmeter_ext_t lmeter; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
int16_t * values; /*Array of the set values (for needles) */
|
||||
lv_style_t * style_critical; /*Fade to this style nearer to the critical value*/
|
||||
color_t * needle_colors; /*Color of the needles (color_t my_colors[needle_num])*/
|
||||
uint8_t needle_num; /*Number of needles*/
|
||||
uint8_t low_critical:1; /*0: the higher value is more critical, 1: the lower value is more critical*/
|
||||
}lv_gauge_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a gauge objects
|
||||
* @param par pointer to an object, it will be the parent of the new gauge
|
||||
* @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created gauge
|
||||
*/
|
||||
lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the number of needles
|
||||
* @param gauge pointer to gauge object
|
||||
* @param num number of needles
|
||||
* @param colors an array of colors for needles (with 'num' elements)
|
||||
*/
|
||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors);
|
||||
|
||||
/**
|
||||
* Set the value of a needle
|
||||
* @param gauge pointer to gauge
|
||||
* @param needle the id of the needle
|
||||
* @param value the new value
|
||||
*/
|
||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value);
|
||||
|
||||
/**
|
||||
* Set which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low);
|
||||
|
||||
/**
|
||||
* Set the critical style of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param style pointer to the new critical style
|
||||
*/
|
||||
void lv_gauge_set_style_critical(lv_obj_t * gauge, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the number of needles on a gauge
|
||||
* @param gauge pointer to gauge
|
||||
* @return number of needles
|
||||
*/
|
||||
uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge);
|
||||
|
||||
/**
|
||||
* Get the value of a needle
|
||||
* @param gauge pointer to gauge object
|
||||
* @param needle the id of the needle
|
||||
* @return the value of the needle [min,max]
|
||||
*/
|
||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle);
|
||||
|
||||
/**
|
||||
* Get which value is more critical (lower or higher)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param low false: higher / true: lower value is more critical
|
||||
*/
|
||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge);
|
||||
|
||||
/**
|
||||
* Get the critical style of the gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @return pointer to the critical style
|
||||
*/
|
||||
lv_style_t * lv_gauge_get_style_critical(lv_obj_t * gauge);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_GAUGE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_GAUGE_H*/
|
||||
365
lv_objx/lv_img.c
365
lv_objx/lv_img.c
@@ -1,365 +0,0 @@
|
||||
/**
|
||||
* @file lv_img.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
|
||||
#include "lv_img.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
#include "misc/fs/ufs/ufs.h"
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#include "misc/gfx/text.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
static bool lv_img_is_symbol(const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an image objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created image
|
||||
*/
|
||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
lv_obj_t * new_img = NULL;
|
||||
|
||||
/*Create a basic object*/
|
||||
new_img = lv_obj_create(par, copy);
|
||||
dm_assert(new_img);
|
||||
|
||||
/*Extend the basic object to image object*/
|
||||
lv_img_ext_t * ext = lv_obj_alloc_ext(new_img, sizeof(lv_img_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->fn = NULL;
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
ext->h = lv_obj_get_height(new_img);
|
||||
ext->transp = 0;
|
||||
ext->upscale = 0;
|
||||
ext->auto_size = 1;
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_f(new_img, lv_img_signal);
|
||||
lv_obj_set_design_f(new_img, lv_img_design);
|
||||
|
||||
if(copy == NULL) {
|
||||
/* Enable auto size for non screens
|
||||
* because image screens are wallpapers
|
||||
* and must be screen sized*/
|
||||
if(par != NULL) ext->auto_size = 1;
|
||||
else ext->auto_size = 0;
|
||||
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
|
||||
else lv_obj_set_style(new_img, lv_style_get(LV_STYLE_PLAIN, NULL)); /*Set style for screens*/
|
||||
} else {
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
ext->upscale = copy_ext->upscale;
|
||||
lv_img_set_file(new_img, copy_ext->fn);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_img);
|
||||
}
|
||||
|
||||
return new_img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the image
|
||||
* @param img pointer to animage object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(img, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->fn);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh the file name to refresh the symbol text size*/
|
||||
if(lv_img_is_symbol(ext->fn) != false) {
|
||||
lv_img_set_file(img, ext->fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data)
|
||||
{
|
||||
const lv_img_raw_header_t * raw_p = (lv_img_raw_header_t *) data;
|
||||
fs_res_t res;
|
||||
res = ufs_create_const(fn, data, raw_p->w * raw_p->h * sizeof(color_t) + sizeof(lv_img_raw_header_t));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a file to the image
|
||||
* @param img pointer to an image object
|
||||
* @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1").
|
||||
*/
|
||||
void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
/*Handle normal images*/
|
||||
if(lv_img_is_symbol(fn) == false) {
|
||||
|
||||
fs_file_t file;
|
||||
fs_res_t res;
|
||||
lv_img_raw_header_t header;
|
||||
uint32_t rn;
|
||||
res = fs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
res = fs_read(&file, &header, sizeof(header), &rn);
|
||||
}
|
||||
|
||||
/*Create a dummy header on fs error*/
|
||||
if(res != FS_RES_OK || rn != sizeof(header)) {
|
||||
header.w = lv_obj_get_width(img);
|
||||
header.h = lv_obj_get_height(img);
|
||||
header.transp = 0;
|
||||
header.cd = 0;
|
||||
}
|
||||
|
||||
fs_close(&file);
|
||||
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
ext->transp = header.transp;
|
||||
|
||||
#if LV_ANTIALIAS != 0
|
||||
if(ext->upscale != 0) {
|
||||
ext->w *= 2;
|
||||
ext->h *= 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*Handle symbol texts*/
|
||||
else {
|
||||
#if LV_IMG_ENABLE_SYMBOLS
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
point_t size;
|
||||
txt_get_size(&size, fn, style->font, style->letter_space, style->line_space, CORD_MAX, TXT_FLAG_NONE);
|
||||
ext->w = size.x;
|
||||
ext->h = size.y;
|
||||
ext->transp = 1; /*Symbols always have transparent parts*/
|
||||
#else
|
||||
/*Never goes here, just to be sure handle this */
|
||||
ext->w = lv_obj_get_width(img);
|
||||
ext->h = lv_obj_get_height(img);
|
||||
ext->transp = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
if(fn != NULL) {
|
||||
ext->fn = dm_realloc(ext->fn, strlen(fn) + 1);
|
||||
strcpy(ext->fn, fn);
|
||||
} else {
|
||||
ext->fn = NULL;
|
||||
}
|
||||
|
||||
|
||||
if(lv_img_get_auto_size(img) != false) {
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
lv_obj_inv(img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the auto size feature.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param en true: auto size enable, false: auto size disable
|
||||
*/
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
ext->auto_size = (en == false ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable the upscaling with LV_DOWNSCALE.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param en true: upscale enable, false: upscale disable
|
||||
*/
|
||||
void lv_img_set_upscale(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
/*Upscale works only if antialiassing is enabled*/
|
||||
#if LV_ANTIALIAS == 0
|
||||
en = false;
|
||||
#endif
|
||||
ext->upscale = (en == false ? 0 : 1);
|
||||
|
||||
/*Refresh the image with the new size*/
|
||||
lv_img_set_file(img, ext->fn);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the auto size enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
bool lv_img_get_auto_size(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upscale enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: upscale is enabled, false: upscale is disabled
|
||||
*/
|
||||
bool lv_img_get_upscale(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
return ext->upscale == 0 ? false : true;
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the images
|
||||
* @param img pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
bool cover = false;
|
||||
if(ext->transp == 0) cover = area_is_in(mask, &img->cords);
|
||||
return cover;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
area_t cords;
|
||||
/*Create a default style for symbol texts*/
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
bool sym = lv_img_is_symbol(ext->fn);
|
||||
#endif
|
||||
|
||||
lv_obj_get_cords(img, &cords);
|
||||
|
||||
area_t cords_tmp;
|
||||
cords_tmp.y1 = cords.y1;
|
||||
cords_tmp.y2 = cords.y1 + ext->h - 1;
|
||||
|
||||
for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
|
||||
cords_tmp.x1 = cords.x1;
|
||||
cords_tmp.x2 = cords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS == 0
|
||||
lv_draw_img(&cords_tmp, mask, style, ext->fn);
|
||||
#else
|
||||
if(sym == false) lv_draw_img(&cords_tmp, mask, style, ext->fn);
|
||||
else lv_draw_label(&cords_tmp, mask, style, ext->fn, TXT_FLAG_NONE, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* From the settings in lv_conf.h and the file name
|
||||
* tells it a filename or a symbol text.
|
||||
* @param txt a file name (e.g. "U:/file1") or a symbol (e.g. SYMBOL_OK)
|
||||
* @return true: 'txt' is a symbol text, false: 'txt' is a file name
|
||||
*/
|
||||
static bool lv_img_is_symbol(const char * txt)
|
||||
{
|
||||
/*If the symbols are not enabled always tell false*/
|
||||
#if LV_IMG_ENABLE_SYMBOLS == 0
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if(txt == NULL) return false;
|
||||
|
||||
/* if txt begins with an upper case letter then it refers to a driver
|
||||
* so it is a file name*/
|
||||
if(txt[0] >= 'A' && txt[0] <= 'Z') return false;
|
||||
|
||||
/*If not returned during the above tests then it is symbol text*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
149
lv_objx/lv_img.h
149
lv_objx/lv_img.h
@@ -1,149 +0,0 @@
|
||||
/**
|
||||
* @file lv_img.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMG_H
|
||||
#define LV_IMG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0 && USE_UFS != 0
|
||||
|
||||
#if USE_FSINT == 0
|
||||
#error "lv_img: fsint is required. Enable it in misc_conf.h (USE_FSINT 1) "
|
||||
#endif
|
||||
|
||||
#if USE_UFS == 0
|
||||
#error "lv_img: ufs is required. Enable it in misc_conf.h (USE_UFS 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
|
||||
#ifndef LV_IMG_ENABLE_SYMBOLS
|
||||
#define LV_IMG_ENABLE_SYMBOLS 0
|
||||
#endif
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#include "lv_label.h"
|
||||
#include "misc/gfx/fonts/symbol_def.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of image*/
|
||||
typedef struct
|
||||
{
|
||||
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char* fn; /*Image file name. E.g. "U:/my_image"*/
|
||||
cord_t w; /*Width of the image (doubled when upscaled) (Handled by the library)*/
|
||||
cord_t h; /*Height of the image (doubled when upscaled) (Handled by the library)*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t upscale :1; /*1: upscale to double size with antialaissing*/
|
||||
uint8_t transp :1; /*Transp. bit in the image header (Handled by the library)*/
|
||||
}lv_img_ext_t;
|
||||
|
||||
/* Image header it is compatible with
|
||||
* the result image converter utility*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t w:12; /*Width of the image map*/
|
||||
uint32_t h:12; /*Height of the image map*/
|
||||
uint32_t transp:1; /*1: The image contains transparent pixels with LV_COLOR_TRANSP color*/
|
||||
uint32_t cd:3; /*Color depth (0: reserved, 1: 8 bit, 2: 16 bit or 3: 24 bit, 4-7: reserved)*/
|
||||
uint32_t res :4; /*Reserved*/
|
||||
}lv_img_raw_header_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an image objects
|
||||
* @param par pointer to an object, it will be the parent of the new button
|
||||
* @param copy pointer to a image object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created image
|
||||
*/
|
||||
lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the image
|
||||
* @param img pointer to animage object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data);
|
||||
|
||||
/**
|
||||
* Set a file to the image
|
||||
* @param img pointer to an image object
|
||||
* @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1").
|
||||
*/
|
||||
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 en true: auto size enable, false: auto size disable
|
||||
*/
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool en);
|
||||
|
||||
/**
|
||||
* Enable the upscaling with LV_DOWNSCALE.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
* @param img pointer to an image
|
||||
* @param en true: upscale enable, false: upscale disable
|
||||
*/
|
||||
void lv_img_set_upscale(lv_obj_t * img, bool en);
|
||||
|
||||
/**
|
||||
* Get the auto size enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
bool lv_img_get_auto_size(lv_obj_t * img);
|
||||
|
||||
/**
|
||||
* Get the upscale enable attribute
|
||||
* @param img pointer to an image
|
||||
* @return true: upscale is enabled, false: upscale is disabled
|
||||
*/
|
||||
bool lv_img_get_upscale(lv_obj_t * img);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*Use this macro to declare an image in a c file*/
|
||||
#define LV_IMG_DECLARE(var_name) extern const color_int_t var_name[];
|
||||
|
||||
#endif /*USE_LV_IMG*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_IMG_H*/
|
||||
@@ -1,693 +0,0 @@
|
||||
/**
|
||||
* @file lv_rect.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lv_label.h"
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_LABEL_SCROLL_SPEED
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_SPEED_VER
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_PLAYBACK_PAUSE
|
||||
#define LV_LABEL_SCROLL_PLAYBACK_PAUSE 500 /*Wait before the scroll turns back in ms*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_REPEAT_PAUSE
|
||||
#define LV_LABEL_SCROLL_REPEAT_PAUSE 500 /*Wait before the scroll begins again in ms*/
|
||||
#endif
|
||||
|
||||
#define LV_LABEL_DOT_NUM 3
|
||||
#define LV_LABEL_DOT_END_INV 0xFFFF
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_label_refr_text(lv_obj_t * label);
|
||||
static void lv_label_set_offset_x(lv_obj_t * label, cord_t x);
|
||||
static void lv_label_set_offset_y(lv_obj_t * label, cord_t y);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a label objects
|
||||
* @param par pointer to an object, it will be the parent of the new label
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create a basic object*/
|
||||
lv_obj_t * new_label = lv_obj_create(par, copy);
|
||||
dm_assert(new_label);
|
||||
|
||||
/*Extend the basic object to a label object*/
|
||||
lv_obj_alloc_ext(new_label, sizeof(lv_label_ext_t));
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(new_label);
|
||||
dm_assert(ext);
|
||||
ext->txt = NULL;
|
||||
ext->static_txt = 0;
|
||||
ext->recolor = 0;
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
ext->long_mode = LV_LABEL_LONG_EXPAND;
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
lv_obj_set_design_f(new_label, lv_label_design);
|
||||
lv_obj_set_signal_f(new_label, lv_label_signal);
|
||||
|
||||
/*Init the new label*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_label, false);
|
||||
lv_obj_set_style(new_label, NULL);
|
||||
lv_label_set_long_mode(new_label, LV_LABEL_LONG_EXPAND);
|
||||
lv_label_set_text(new_label, "Text");
|
||||
}
|
||||
/*Copy 'copy' if not NULL*/
|
||||
else {
|
||||
lv_label_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_label_set_long_mode(new_label, lv_label_get_long_mode(copy));
|
||||
lv_label_set_recolor(new_label, lv_label_get_recolor(copy));
|
||||
if(copy_ext->static_txt == 0) lv_label_set_text(new_label, lv_label_get_text(copy));
|
||||
else lv_label_set_text_static(new_label, lv_label_get_text(copy));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_label);
|
||||
}
|
||||
return new_label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the label
|
||||
* @param label pointer to a label object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(label, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
/*No signal handling*/
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
if(ext->static_txt == 0) {
|
||||
dm_free(ext->txt);
|
||||
ext->txt = NULL;
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
lv_label_set_text(label, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
lv_obj_inv(label);
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
/*If trying to set its own text or the text is NULL then refresh */
|
||||
if(text == ext->txt || text == NULL) {
|
||||
lv_label_refr_text(label);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Allocate space for the new text*/
|
||||
uint32_t len = strlen(text) + 1;
|
||||
if(ext->txt != NULL && ext->static_txt == 0) {
|
||||
dm_free(ext->txt);
|
||||
ext->txt = NULL;
|
||||
}
|
||||
ext->txt = dm_alloc(len);
|
||||
strcpy(ext->txt, text);
|
||||
ext->static_txt = 0; /*Now the text is dynamically allocated*/
|
||||
|
||||
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.
|
||||
* @param label pointer to a label object
|
||||
* @param array array of characters or NULL to refresh the label
|
||||
* @param size the size of 'array' in bytes
|
||||
*/
|
||||
void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size)
|
||||
{
|
||||
lv_obj_inv(label);
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
/*If trying to set its own text or the array is NULL then refresh */
|
||||
if(array == ext->txt || array == NULL) {
|
||||
lv_label_refr_text(label);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Allocate space for the new text*/
|
||||
if(ext->txt != NULL && ext->static_txt == 0) {
|
||||
dm_free(ext->txt);
|
||||
ext->txt = NULL;
|
||||
}
|
||||
ext->txt = dm_alloc(size + 1);
|
||||
memcpy(ext->txt, array, size);
|
||||
ext->txt[size] = '\0';
|
||||
ext->static_txt = 0; /*Now the text is dynamically allocated*/
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a static text. It will not be saved by the label so the 'text' variable
|
||||
* has to be 'alive' while the label exist.
|
||||
* @param label pointer to a label object
|
||||
* @param text pointer to a text. NULL to refresh with the current text.
|
||||
*/
|
||||
void lv_label_set_text_static(lv_obj_t * label, const char * text)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
if(ext->static_txt == 0 && ext->txt != NULL) {
|
||||
dm_free(ext->txt);
|
||||
ext->txt = NULL;
|
||||
}
|
||||
|
||||
if(text != NULL) {
|
||||
ext->static_txt = 1;
|
||||
ext->txt = (char *) text;
|
||||
}
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a text to the label. The label current label text can not be static.
|
||||
* @param label pointer to label object
|
||||
* @param text pointe rto the new text
|
||||
*/
|
||||
void lv_label_append_text(lv_obj_t * label, const char * text)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
/*Can not append to static text*/
|
||||
if(ext->static_txt != 0) return;
|
||||
|
||||
lv_obj_inv(label);
|
||||
|
||||
/*Allocate space for the new text*/
|
||||
uint32_t old_len = strlen(ext->txt);
|
||||
uint32_t app_len = strlen(text);
|
||||
uint32_t new_len = app_len + old_len;
|
||||
ext->txt = dm_realloc(ext->txt, new_len + 1);
|
||||
memcpy(ext->txt + old_len, text, app_len);
|
||||
ext->txt[new_len] = '\0';
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
* @param long_mode the new mode from 'lv_label_long_mode' enum.
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
/*When changing from dot mode reload the characters replaced by dots*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_DOTS &&
|
||||
ext->dot_end != LV_LABEL_DOT_END_INV) {
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM + 1; i++) {
|
||||
ext->txt[ext->dot_end - LV_LABEL_DOT_NUM + i] = ext->dot_tmp[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*Delete the old animation (if exists)*/
|
||||
anim_del(label, (anim_fp_t) lv_obj_set_x);
|
||||
anim_del(label, (anim_fp_t) lv_obj_set_y);
|
||||
anim_del(label, (anim_fp_t) lv_label_set_offset_x);
|
||||
anim_del(label, (anim_fp_t) lv_label_set_offset_y);
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
|
||||
if(long_mode == LV_LABEL_LONG_ROLL) ext->expand = 1;
|
||||
else ext->expand = 0;
|
||||
|
||||
ext->long_mode = long_mode;
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the recoloring by in-line commands
|
||||
* @param label pointer to a label object
|
||||
* @param recolor true: enable recoloring, false: disable
|
||||
*/
|
||||
void lv_label_set_recolor(lv_obj_t * label, bool recolor)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
ext->recolor = recolor == false ? 0 : 1;
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the text of a label
|
||||
* @param label pointer to a label object
|
||||
* @return the text of the label
|
||||
*/
|
||||
char * lv_label_get_text(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
return ext->txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the long mode of a label
|
||||
* @param label pointer to a label object
|
||||
* @return the long mode
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
return ext->long_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the recoloring attribute
|
||||
* @param label pointer to a label object
|
||||
* @return true: recoloring is enabled, false: disable
|
||||
*/
|
||||
bool lv_label_get_recolor(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
return ext->recolor == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the relative x and y coordinates of a letter
|
||||
* @param label pointer to a label object
|
||||
* @param index index of the letter (0 ... text length)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
const font_t * font = style->font;
|
||||
uint8_t letter_height = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
cord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
|
||||
/*If the width will be expanded the set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
max_w = CORD_MAX;
|
||||
}
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[new_line_start] != '\0') {
|
||||
new_line_start += txt_get_next_line(&txt[line_start], font, style->letter_space, max_w, flag);
|
||||
if(index < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/
|
||||
|
||||
y += letter_height + style->line_space;
|
||||
line_start = new_line_start;
|
||||
}
|
||||
|
||||
if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') {
|
||||
y += letter_height + style->line_space;
|
||||
line_start = index;
|
||||
}
|
||||
|
||||
/*Calculate the x coordinate*/
|
||||
cord_t x = 0;
|
||||
uint32_t i;
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
for(i = line_start; i < index; i++) {
|
||||
/*Handle the recolor command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
x += (font_get_width(font, txt[i]) >> FONT_ANTIALIAS) + style->letter_space;
|
||||
|
||||
}
|
||||
|
||||
if(style->txt_align == LV_TXT_ALIGN_MID) {
|
||||
cord_t line_w;
|
||||
line_w = txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
|
||||
pos->x = x;
|
||||
pos->y = y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of letter on a relative point of a label
|
||||
* @param label pointer to label object
|
||||
* @param pos pointer to point with coordinates on a the label
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
const font_t * font = style->font;
|
||||
uint8_t letter_height = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
cord_t y = 0;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
|
||||
/*If the width will be expanded set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
max_w = CORD_MAX;
|
||||
}
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[line_start] != '\0') {
|
||||
new_line_start += txt_get_next_line(&txt[line_start], font, style->letter_space, max_w, flag);
|
||||
if(pos->y <= y + letter_height + style->line_space) break; /*The line is found ('line_start')*/
|
||||
y += letter_height + style->line_space;
|
||||
line_start = new_line_start;
|
||||
}
|
||||
|
||||
/*Calculate the x coordinate*/
|
||||
cord_t x = 0;
|
||||
if(style->txt_align == LV_TXT_ALIGN_MID) {
|
||||
cord_t line_w;
|
||||
line_w = txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
|
||||
txt_cmd_state_t cmd_state = TXT_CMD_STATE_WAIT;
|
||||
uint16_t i;
|
||||
for(i = line_start; i < new_line_start - 1; i++) {
|
||||
/*Handle the recolor command*/
|
||||
if((flag & TXT_FLAG_RECOLOR) != 0) {
|
||||
if(txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
|
||||
x += (font_get_width(font, txt[i]) >> FONT_ANTIALIAS) + style->letter_space;
|
||||
|
||||
if(pos->x < x) break;
|
||||
}
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the labels
|
||||
* @param label pointer to a label object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*TEST: draw a background for the label*/
|
||||
//lv_vfill(&label->cords, mask, COLOR_LIME, OPA_COVER);
|
||||
|
||||
area_t cords;
|
||||
lv_obj_get_cords(label, &cords);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
|
||||
if(strcmp("Folder1", ext->txt) == 0) {
|
||||
uint8_t i;
|
||||
i = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_draw_label(&cords, mask, lv_obj_get_style(label), ext->txt, flag, &ext->offset);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the label with its text stored in its extended data
|
||||
* @param label pointer to a label object
|
||||
*/
|
||||
static void lv_label_refr_text(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
|
||||
if(ext->txt == NULL) return;
|
||||
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
const font_t * font = style->font;
|
||||
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV; /*Initialize the dot end index*/
|
||||
|
||||
/*If the width will be expanded set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND ||
|
||||
ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
max_w = CORD_MAX;
|
||||
}
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
point_t size;
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
txt_get_size(&size, ext->txt, font, style->letter_space, style->line_space, max_w, flag);
|
||||
|
||||
/*Refresh the full size in expand mode*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
lv_obj_set_size(label, size.x, size.y);
|
||||
|
||||
/*Start scrolling if the label is greater then its parent*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
lv_obj_t * parent = lv_obj_get_parent(label);
|
||||
|
||||
/*Delete the potential previous scroller animations*/
|
||||
anim_del(label, (anim_fp_t) lv_obj_set_x);
|
||||
anim_del(label, (anim_fp_t) lv_obj_set_y);
|
||||
|
||||
anim_t anim;
|
||||
anim.var = label;
|
||||
anim.repeat = 1;
|
||||
anim.playback = 1;
|
||||
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
|
||||
anim.act_time = 0;
|
||||
anim.end_cb = NULL;
|
||||
anim.path = anim_get_path(ANIM_PATH_LIN);
|
||||
anim.time = 3000;
|
||||
anim.playback_pause = LV_LABEL_SCROLL_PLAYBACK_PAUSE;
|
||||
anim.repeat_pause = LV_LABEL_SCROLL_REPEAT_PAUSE;
|
||||
|
||||
bool hor_anim = false;
|
||||
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
|
||||
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) -
|
||||
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t) lv_obj_set_x;
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
|
||||
anim_create(&anim);
|
||||
hor_anim = true;
|
||||
}
|
||||
|
||||
if(lv_obj_get_height(label) > lv_obj_get_height(parent)) {
|
||||
anim.end = lv_obj_get_height(parent) - lv_obj_get_height(label) -
|
||||
(font_get_height(font) - FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t)lv_obj_set_y;
|
||||
|
||||
/*Different animation speed if horizontal animation is created too*/
|
||||
if(hor_anim == false) {
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
|
||||
} else {
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED_VER, anim.start, anim.end);
|
||||
}
|
||||
anim_create(&anim);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*In roll mode keep the size but start offset animations*/
|
||||
else if(ext->long_mode == LV_LABEL_LONG_ROLL) {
|
||||
anim_t anim;
|
||||
anim.var = label;
|
||||
anim.repeat = 1;
|
||||
anim.playback = 1;
|
||||
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
|
||||
anim.act_time = 0;
|
||||
anim.end_cb = NULL;
|
||||
anim.path = anim_get_path(ANIM_PATH_LIN);
|
||||
anim.playback_pause = LV_LABEL_SCROLL_PLAYBACK_PAUSE;
|
||||
anim.repeat_pause = LV_LABEL_SCROLL_REPEAT_PAUSE;
|
||||
|
||||
bool hor_anim = false;
|
||||
if(size.x > lv_obj_get_width(label)) {
|
||||
anim.end = lv_obj_get_width(label) - size.x -
|
||||
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t) lv_label_set_offset_x;
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
|
||||
anim_create(&anim);
|
||||
hor_anim = true;
|
||||
}
|
||||
|
||||
if(size.y > lv_obj_get_height(label)) {
|
||||
anim.end = lv_obj_get_height(label) - size.y -
|
||||
(font_get_height(font) - FONT_ANTIALIAS);
|
||||
anim.fp = (anim_fp_t)lv_label_set_offset_y;
|
||||
|
||||
/*Different animation speed if horizontal animation is created too*/
|
||||
if(hor_anim == false) {
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
|
||||
} else {
|
||||
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED_VER, anim.start, anim.end);
|
||||
}
|
||||
anim_create(&anim);
|
||||
}
|
||||
}
|
||||
/*In break mode only the height can change*/
|
||||
else if (ext->long_mode == LV_LABEL_LONG_BREAK) {
|
||||
lv_obj_set_height(label, size.y);
|
||||
}
|
||||
/*Replace the last 'LV_LABEL_DOT_NUM' characters with dots
|
||||
* and save these characters*/
|
||||
else if(ext->long_mode == LV_LABEL_LONG_DOTS) {
|
||||
point_t point;
|
||||
point.x = lv_obj_get_width(label) - 1;
|
||||
point.y = lv_obj_get_height(label) - 1;
|
||||
uint16_t index = lv_label_get_letter_on(label, &point);
|
||||
|
||||
if(index < strlen(ext->txt) - 1) {
|
||||
|
||||
/* Change the last 'LV_LABEL_DOT_NUM' to dots
|
||||
* (if there are at least 'LV_LABEL_DOT_NUM' characters*/
|
||||
if(index > LV_LABEL_DOT_NUM) {
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->dot_tmp[i] = ext->txt[index - LV_LABEL_DOT_NUM + i];
|
||||
ext->txt[index - LV_LABEL_DOT_NUM + i] = '.';
|
||||
}
|
||||
/*The last character is '\0'. Save this character from the text too.*/
|
||||
ext->dot_tmp[i] = ext->txt[index];
|
||||
ext->txt[index] = '\0';
|
||||
}
|
||||
/*Else with short text change all characters to dots*/
|
||||
else {
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->txt[i] = '.';
|
||||
}
|
||||
ext->txt[i] = '\0';
|
||||
}
|
||||
/*Save the dot end index*/
|
||||
ext->dot_end = index;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_inv(label);
|
||||
}
|
||||
|
||||
|
||||
static void lv_label_set_offset_x(lv_obj_t * label, cord_t x)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
ext->offset.x = x;
|
||||
lv_obj_inv(label);
|
||||
}
|
||||
|
||||
static void lv_label_set_offset_y(lv_obj_t * label, cord_t y)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
ext->offset.y = y;
|
||||
lv_obj_inv(label);
|
||||
}
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
/**
|
||||
* @file lv_rect.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LABEL_H
|
||||
#define LV_LABEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/text.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LABEL_DOT_NUM 3
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Long mode behaviors. Used in 'lv_label_ext_t' */
|
||||
typedef enum
|
||||
{
|
||||
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
|
||||
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object height*/
|
||||
LV_LABEL_LONG_DOTS, /*Keep the object size, break the text and write dots in the last line*/
|
||||
LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/
|
||||
LV_LABEL_LONG_ROLL, /*Keep the size and roll the text infinitely*/
|
||||
}lv_label_long_mode_t;
|
||||
|
||||
/*Data of label*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
char * txt; /*Text of the label*/
|
||||
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
|
||||
char dot_tmp[LV_LABEL_DOT_NUM + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
|
||||
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
|
||||
point_t offset;
|
||||
uint8_t static_txt :1; /*Flag to indicate the text is static*/
|
||||
uint8_t recolor :1; /*Enable in-line letter re-coloring*/
|
||||
uint8_t expand :1; /*Force expand size when solving line length (used by the library with LV_LABEL_LONG_ROLL)*/
|
||||
}lv_label_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a label objects
|
||||
* @param par pointer to an object, it will be the parent of the new label
|
||||
* @param copy pointer to a button object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created button
|
||||
*/
|
||||
lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the label
|
||||
* @param label pointer to a label object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param label pointer to a label object
|
||||
* @param array array of characters or NULL to refresh the label
|
||||
* @param size the size of 'array' in bytes
|
||||
*/
|
||||
void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size);
|
||||
|
||||
/**
|
||||
* Set a static text. It will not be saved by the label so the 'text' variable
|
||||
* has to be 'alive' while the label exist.
|
||||
* @param label pointer to a label object
|
||||
* @param text pointer to a text. NULL to refresh with the current text.
|
||||
*/
|
||||
void lv_label_set_text_static(lv_obj_t * label, const char * text);
|
||||
|
||||
/**
|
||||
* Append a text to the label. The label current label text can not be static.
|
||||
* @param label pointer to label object
|
||||
* @param text pointe rto the new text
|
||||
*/
|
||||
void lv_label_append_text(lv_obj_t * label, const char * text);
|
||||
|
||||
/**
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
* @param long_mode the new mode from 'lv_label_long_mode' enum.
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
|
||||
|
||||
/**
|
||||
* Enable the recoloring by in-line commands
|
||||
* @param label pointer to a label object
|
||||
* @param recolor true: enable recoloring, false: disable
|
||||
*/
|
||||
void lv_label_set_recolor(lv_obj_t * label, bool recolor);
|
||||
|
||||
/**
|
||||
* Enable the password mode
|
||||
* @param label pointer to a label object
|
||||
* @param pwd true: enable password mode, false: disable
|
||||
*/
|
||||
void lv_label_set_pwd_mode(lv_obj_t * label, bool pwd);
|
||||
|
||||
/**
|
||||
* Get the text of a label
|
||||
* @param label pointer to a label object
|
||||
* @return the text of the label
|
||||
*/
|
||||
char * lv_label_get_text(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the long mode of a label
|
||||
* @param label pointer to a label object
|
||||
* @return the long mode
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the recoloring attribute
|
||||
* @param label pointer to a label object
|
||||
* @return true: recoloring is enabled, false: disable
|
||||
*/
|
||||
bool lv_label_get_recolor(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the password mode
|
||||
* @param label pointer to a label object
|
||||
* @return true: password mode is enabled, false: disable
|
||||
*/
|
||||
bool lv_label_get_pwd_mode(lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* Get the relative x and y coordinates of a letter
|
||||
* @param label pointer to a label object
|
||||
* @param index index of the letter (0 ... text length)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos);
|
||||
|
||||
/**
|
||||
* Get the index of letter on a relative point of a label
|
||||
* @param label pointer to label object
|
||||
* @param pos pointer to point with coordinates on a the label
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_LABEL*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LABEL_H*/
|
||||
219
lv_objx/lv_led.c
219
lv_objx/lv_led.c
@@ -1,219 +0,0 @@
|
||||
/**
|
||||
* @file lv_led.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LED != 0
|
||||
|
||||
#include "lv_led.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
|
||||
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
|
||||
#define LV_LED_BRIGHT_OFF 100
|
||||
#define LV_LED_BRIGHT_ON 255
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a led objects
|
||||
* @param par pointer to an object, it will be the parent of the new led
|
||||
* @param copy pointer to a led object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created led
|
||||
*/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_led = lv_obj_create(par, copy);
|
||||
dm_assert(new_led);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_led_ext_t * ext = lv_obj_alloc_ext(new_led, sizeof(lv_led_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->bright = LV_LED_BRIGHT_ON;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_led);
|
||||
|
||||
lv_obj_set_signal_f(new_led, lv_led_signal);
|
||||
lv_obj_set_design_f(new_led, lv_led_design);
|
||||
|
||||
/*Init the new led object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_led, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_led_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->bright = copy_ext->bright;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_led);
|
||||
}
|
||||
|
||||
return new_led;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the led
|
||||
* @param led pointer to a led object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(led, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the brightness of a LED object
|
||||
* @param led pointer to a LED object
|
||||
* @param bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||
{
|
||||
/*Set the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
ext->bright = bright;
|
||||
|
||||
/*Invalidate the object there fore it will be redrawn*/
|
||||
lv_obj_inv(led);
|
||||
}
|
||||
|
||||
/**
|
||||
* Light on a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Light off a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the state of a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_tgl(lv_obj_t * led)
|
||||
{
|
||||
uint8_t bright = lv_led_get_bright(led);
|
||||
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1) lv_led_off(led);
|
||||
else lv_led_on(led);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the brightness of a LEd object
|
||||
* @param led pointer to LED object
|
||||
* @return bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
uint8_t lv_led_get_bright(lv_obj_t * led)
|
||||
{
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
return ext->bright;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the leds
|
||||
* @param led pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(led, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
lv_style_t * style = lv_obj_get_style(led);
|
||||
|
||||
/*Create a temporal style*/
|
||||
lv_style_t leds_tmp;
|
||||
memcpy(&leds_tmp, style, sizeof(leds_tmp));
|
||||
|
||||
/*Mix. the color with black proportionally with brightness*/
|
||||
leds_tmp.mcolor = color_mix(leds_tmp.mcolor, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.gcolor = color_mix(leds_tmp.gcolor, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.bcolor = color_mix(leds_tmp.bcolor, COLOR_BLACK, ext->bright);
|
||||
|
||||
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
|
||||
uint16_t bright_tmp = ext->bright;
|
||||
leds_tmp.swidth = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->swidth) / (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF);
|
||||
|
||||
led->style_p = &leds_tmp;
|
||||
ancestor_design_f(led, mask, mode);
|
||||
led->style_p = style;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,293 +0,0 @@
|
||||
/**
|
||||
* @file lv_line.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if USE_LV_LINE != 0
|
||||
#include "lv_line.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_line_design(lv_obj_t * line, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a line objects
|
||||
* @param par pointer to an object, it will be the parent of the new line
|
||||
* @return pointer to the created line
|
||||
*/
|
||||
lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create a basic object*/
|
||||
lv_obj_t * new_line = lv_obj_create(par, copy);
|
||||
dm_assert(new_line);
|
||||
|
||||
/*Extend the basic object to line object*/
|
||||
lv_line_ext_t * ext = lv_obj_alloc_ext(new_line, sizeof(lv_line_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->point_num = 0;
|
||||
ext->point_array = NULL;
|
||||
ext->auto_size = 1;
|
||||
ext->y_inv = 0;
|
||||
ext->upscale = 0;
|
||||
|
||||
lv_obj_set_design_f(new_line, lv_line_design);
|
||||
lv_obj_set_signal_f(new_line, lv_line_signal);
|
||||
|
||||
/*Init the new line*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_line, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_line_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_y_inv(new_line,lv_line_get_y_inv(copy));
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_upscale(new_line,lv_line_get_upscale(copy));
|
||||
lv_line_set_points(new_line, copy_ext->point_array, copy_ext->point_num);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_line);
|
||||
}
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the line
|
||||
* @param line pointer to a line object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(line, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
switch(sign) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set an array of points. The line object will connect these points.
|
||||
* @param line pointer to a line object
|
||||
* @param point_a an array of points. Only the address is saved,
|
||||
* so the array can NOT be a local variable which will be destroyed
|
||||
* @param point_num number of points in 'point_a'
|
||||
*/
|
||||
void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point_num)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
ext->point_array = point_a;
|
||||
ext->point_num = point_num;
|
||||
|
||||
uint8_t us = 1;
|
||||
if(ext->upscale != 0) {
|
||||
us = LV_DOWNSCALE;
|
||||
}
|
||||
|
||||
if(point_num > 0 && ext->auto_size != 0) {
|
||||
uint16_t i;
|
||||
cord_t xmax = CORD_MIN;
|
||||
cord_t ymax = CORD_MIN;
|
||||
for(i = 0; i < point_num; i++) {
|
||||
xmax = MATH_MAX(point_a[i].x * us, xmax);
|
||||
ymax = MATH_MAX(point_a[i].y * us, ymax);
|
||||
}
|
||||
|
||||
lv_style_t * lines = lv_obj_get_style(line);
|
||||
lv_obj_set_size(line, xmax + lines->line_width, ymax + lines->line_width);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
void lv_line_set_auto_size(lv_obj_t * line, bool autosize)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
ext->auto_size = autosize == false ? 0 : 1;
|
||||
|
||||
/*Refresh the object*/
|
||||
if(autosize != false) {
|
||||
lv_line_set_points(line, ext->point_array, ext->point_num);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 true: enable the y inversion, false:disable the y inversion
|
||||
*/
|
||||
void lv_line_set_y_inv(lv_obj_t * line, bool yinv)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
ext->y_inv = yinv == false ? 0 : 1;
|
||||
|
||||
lv_obj_inv(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable (or disable) the point coordinate upscaling (compensate LV_DOWNSCALE).
|
||||
* @param line pointer to a line object
|
||||
* @param unscale true: enable the point coordinate upscaling
|
||||
*/
|
||||
void lv_line_set_upscale(lv_obj_t * line, bool unscale)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
ext->upscale = unscale == false ? 0 : 1;
|
||||
|
||||
/*Refresh to point to handle auto size*/
|
||||
lv_line_set_points(line, ext->point_array, ext->point_num);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the auto size attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: auto size is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_auto_size(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y inversion attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: y inversion is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_y_inv(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
return ext->y_inv == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the point upscale enable attribute
|
||||
* @param obj pointer to a line object
|
||||
* @return true: point coordinate upscale is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_upscale(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
return ext->upscale == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the lines
|
||||
* @param line pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_line_design(lv_obj_t * line, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*A line never covers an area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
|
||||
if(ext->point_num == 0 || ext->point_array == NULL) return false;
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(line);
|
||||
area_t area;
|
||||
lv_obj_get_cords(line, &area);
|
||||
cord_t x_ofs = area.x1;
|
||||
cord_t y_ofs = area.y1;
|
||||
point_t p1;
|
||||
point_t p2;
|
||||
cord_t h = lv_obj_get_height(line);
|
||||
uint16_t i;
|
||||
uint8_t us = 1;
|
||||
if(ext->upscale != 0) {
|
||||
us = LV_DOWNSCALE;
|
||||
}
|
||||
|
||||
/*Read all pints and draw the lines*/
|
||||
for (i = 0; i < ext->point_num - 1; i++) {
|
||||
|
||||
p1.x = ext->point_array[i].x * us + x_ofs;
|
||||
p2.x = ext->point_array[i + 1].x * us + x_ofs;
|
||||
|
||||
if(ext->y_inv == 0) {
|
||||
p1.y = ext->point_array[i].y * us + y_ofs;
|
||||
p2.y = ext->point_array[i + 1].y * us + y_ofs;
|
||||
} else {
|
||||
p1.y = h - ext->point_array[i].y * us + y_ofs;
|
||||
p2.y = h - ext->point_array[i + 1].y * us + y_ofs;
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,123 +0,0 @@
|
||||
/**
|
||||
* @file lv_line.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LINE_H
|
||||
#define LV_LINE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
#include "lvgl/lv_obj/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of line*/
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
|
||||
const point_t * point_array; /*Pointer to an array with the points of the line*/
|
||||
uint16_t point_num; /*Number of points in 'point_array' */
|
||||
uint8_t auto_size :1; /*1: set obj. width to x max and obj. height to y max */
|
||||
uint8_t y_inv :1; /*1: y == 0 will be on the bottom*/
|
||||
uint8_t upscale :1; /*1: upscale coordinates with LV_DOWNSCALE*/
|
||||
}lv_line_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a line objects
|
||||
* @param par pointer to an object, it will be the parent of the new line
|
||||
* @return pointer to the created line
|
||||
*/
|
||||
lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the line
|
||||
* @param line pointer to a line object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set an array of points. The line object will connect these points.
|
||||
* @param line pointer to a line object
|
||||
* @param point_a an array of points. Only the address is saved,
|
||||
* so the array can NOT be a local variable which will be destroyed
|
||||
* @param point_num number of points in 'point_a'
|
||||
*/
|
||||
void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point_num);
|
||||
|
||||
/**
|
||||
* 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 true: auto size is enabled, false: auto size is disabled
|
||||
*/
|
||||
void lv_line_set_auto_size(lv_obj_t * line, bool autosize);
|
||||
|
||||
/**
|
||||
* 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 true: enable the y inversion, false:disable the y inversion
|
||||
*/
|
||||
void lv_line_set_y_inv(lv_obj_t * line, bool yinv);
|
||||
|
||||
/**
|
||||
* Enable (or disable) the point coordinate upscaling (compensate LV_DOWNSCALE).
|
||||
* @param line pointer to a line object
|
||||
* @param unscale true: enable the point coordinate upscaling
|
||||
*/
|
||||
void lv_line_set_upscale(lv_obj_t * line, bool unscale);
|
||||
|
||||
/**
|
||||
* Get the auto size attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: auto size is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_auto_size(lv_obj_t * line);
|
||||
|
||||
/**
|
||||
* Get the y inversion attribute
|
||||
* @param line pointer to a line object
|
||||
* @return true: y inversion is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_y_inv(lv_obj_t * line);
|
||||
|
||||
/**
|
||||
* Get the point upscale enable attribute
|
||||
* @param obj pointer to a line object
|
||||
* @return true: point coordinate upscale is enabled, false: disabled
|
||||
*/
|
||||
bool lv_line_get_upscale(lv_obj_t * line);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_LINE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LINE_H*/
|
||||
@@ -1,391 +0,0 @@
|
||||
/**
|
||||
* @file lv_list.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
#include "lv_list.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LIST_LAYOUT_DEF LV_CONT_LAYOUT_COL_M
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0
|
||||
static bool lv_list_design(lv_obj_t * list, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a list objects
|
||||
* @param par pointer to an object, it will be the parent of the new list
|
||||
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created list
|
||||
*/
|
||||
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_list = lv_page_create(par, copy);
|
||||
dm_assert(new_list);
|
||||
lv_list_ext_t * ext = lv_obj_alloc_ext(new_list, sizeof(lv_list_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
ext->sb_out = 0;
|
||||
ext->style_img = NULL;
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BTN_TREL, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BTN_TPR, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BTN_INA, NULL);
|
||||
|
||||
lv_obj_set_signal_f(new_list, lv_list_signal);
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_cont_set_layout(ext->page.scrl, LV_LIST_LAYOUT_DEF);
|
||||
lv_obj_set_style(new_list, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_style(lv_page_get_scrl(new_list), lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_AUTO);
|
||||
} else {
|
||||
lv_list_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
|
||||
lv_list_set_styles_btn(new_list, copy_ext->styles_btn[LV_BTN_STATE_REL],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_PR],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TREL],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
lv_list_set_style_img(new_list, copy_ext->style_img);
|
||||
|
||||
lv_list_set_sb_out(new_list, copy_ext->sb_out);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_list);
|
||||
}
|
||||
|
||||
return new_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the list
|
||||
* @param list pointer to a list object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_page_signal(list, sign, param);
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a list element to the list
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
/*Create a list element with the image an the text*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_btn_create(list, NULL);
|
||||
lv_btn_set_styles(liste, ext->styles_btn[LV_BTN_STATE_REL], ext->styles_btn[LV_BTN_STATE_PR],
|
||||
ext->styles_btn[LV_BTN_STATE_TREL], ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
|
||||
lv_btn_set_rel_action(liste, rel_action);
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_cont_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(liste, false, true);
|
||||
|
||||
/*Make the size adjustment*/
|
||||
cord_t w = lv_obj_get_width(list);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
|
||||
cord_t hpad_tot = style->hpad + style_scrl->hpad;
|
||||
w -= hpad_tot * 2;
|
||||
|
||||
/*Make place for the scrollbar if hpad_tot is too small*/
|
||||
if(ext->sb_out != 0) {
|
||||
if(hpad_tot < ext->page.sb_width) w -= ext->page.sb_width - hpad_tot;
|
||||
}
|
||||
lv_obj_set_width(liste, w);
|
||||
|
||||
if(img_fn != NULL && img_fn[0] != '\0') {
|
||||
lv_obj_t * img = lv_img_create(liste, NULL);
|
||||
lv_img_set_file(img, img_fn);
|
||||
lv_obj_set_style(img, ext->style_img);
|
||||
lv_obj_set_click(img, false);
|
||||
}
|
||||
|
||||
if(txt != NULL) {
|
||||
lv_obj_t * label = lv_label_create(liste, NULL);
|
||||
lv_label_set_text(label, txt);
|
||||
lv_obj_set_style(label, ext->styles_btn[LV_BTN_STATE_REL]);
|
||||
lv_obj_set_click(label, false);
|
||||
lv_obj_set_width(label, liste->cords.x2 - label->cords.x1);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
|
||||
}
|
||||
|
||||
return liste;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the list elements up by one
|
||||
* @param list pointer a to list object
|
||||
*/
|
||||
void lv_list_up(lv_obj_t * list)
|
||||
{
|
||||
/*Search the first list element which 'y' coordinate is below the parent
|
||||
* and position the list to show this element on the bottom*/
|
||||
lv_obj_t * h = lv_obj_get_parent(list);
|
||||
lv_obj_t * e;
|
||||
lv_obj_t * e_prev = NULL;
|
||||
e = lv_obj_get_child(list, NULL);
|
||||
while(e != NULL) {
|
||||
if(e->cords.y2 <= h->cords.y2) {
|
||||
if(e_prev != NULL)
|
||||
lv_obj_set_y(list, lv_obj_get_height(h) -
|
||||
(lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev)));
|
||||
break;
|
||||
}
|
||||
e_prev = e;
|
||||
e = lv_obj_get_child(list, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the list elements down by one
|
||||
* @param list pointer to a list object
|
||||
*/
|
||||
void lv_list_down(lv_obj_t * list)
|
||||
{
|
||||
/*Search the first list element which 'y' coordinate is above the parent
|
||||
* and position the list to show this element on the top*/
|
||||
lv_obj_t * h = lv_obj_get_parent(list);
|
||||
lv_obj_t * e;
|
||||
e = lv_obj_get_child(list, NULL);
|
||||
while(e != NULL) {
|
||||
if(e->cords.y1 < h->cords.y1) {
|
||||
lv_obj_set_y(list, -lv_obj_get_y(e));
|
||||
break;
|
||||
}
|
||||
e = lv_obj_get_child(list, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Enable/Disable to scrollbar outside attribute
|
||||
* @param list pointer to list object
|
||||
* @param out true: reduce the buttons width therefore scroll bar will be out of the buttons,
|
||||
* false: keep button size and place scroll bar on the buttons
|
||||
*/
|
||||
void lv_list_set_sb_out(lv_obj_t * list, bool out)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
ext->sb_out = out == false ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the text rolling on a list element
|
||||
* @param liste pinter to list element
|
||||
* @param en true: enable text scrolling, false: disable text scrolling
|
||||
*/
|
||||
void lv_list_set_element_text_roll(lv_obj_t * liste, bool en)
|
||||
{
|
||||
/*The last child is the label*/
|
||||
lv_obj_t * label = lv_obj_get_child(liste, NULL);
|
||||
if(en == false) {
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_DOTS);
|
||||
} else {
|
||||
lv_obj_set_width(label, liste->cords.x2 - label->cords.x1);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set styles of the list elements of a list in each state
|
||||
* @param list pointer to list object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
|
||||
lv_style_t * trel, lv_style_t * tpr,
|
||||
lv_style_t * ina)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = rel;
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = pr;
|
||||
ext->styles_btn[LV_BTN_STATE_TREL] = trel;
|
||||
ext->styles_btn[LV_BTN_STATE_TPR] = tpr;
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = ina;
|
||||
|
||||
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||
lv_obj_t * liste = lv_obj_get_child(scrl, NULL);
|
||||
while(liste != NULL)
|
||||
{
|
||||
lv_btn_set_styles(liste, rel, pr, trel, tpr, ina);
|
||||
liste = lv_obj_get_child(scrl, liste);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the styles of the list element image (typically to set symbol font)
|
||||
* @param list pointer to list object
|
||||
* @param style pointer to the new style of the button images
|
||||
*/
|
||||
void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
ext->style_img = style;
|
||||
|
||||
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||
lv_obj_t * liste = lv_obj_get_child(scrl, NULL);
|
||||
lv_obj_t * img;
|
||||
while(liste != NULL)
|
||||
{
|
||||
img = lv_obj_get_child(liste, NULL); /*Now img = the label*/
|
||||
img = lv_obj_get_child(liste, img); /*Now img = the image (if ULL then no image) */
|
||||
if(img != NULL) lv_obj_set_style(img, style);
|
||||
|
||||
liste = lv_obj_get_child(scrl, liste);
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the text of a list element
|
||||
* @param liste pointer to list element
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_list_get_element_text(lv_obj_t * liste)
|
||||
{
|
||||
/*The last child is the label*/
|
||||
lv_obj_t * label = lv_obj_get_child(liste, NULL);
|
||||
return lv_label_get_text(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scroll bar outside attribute
|
||||
* @param list pointer to list object
|
||||
* @param en true: scroll bar outside the buttons, false: scroll bar inside
|
||||
*/
|
||||
bool lv_list_get_sb_out(lv_obj_t * list, bool en)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
return ext->sb_out == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style of the list elements in a given state
|
||||
* @param list pointer to a list object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_liste(lv_obj_t * list, lv_btn_state_t state)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
if(ext->styles_btn[state] == NULL) return lv_obj_get_style(list);
|
||||
|
||||
return ext->styles_btn[state];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the style of the list elements images
|
||||
* @param list pointer to a list object
|
||||
* @return pointer to the image style
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_img(lv_obj_t * list, lv_btn_state_t state)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
|
||||
if(ext->style_img == NULL) return lv_list_get_style_liste(list, LV_BTN_STATE_REL);
|
||||
|
||||
return ext->style_img;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if 0 /*A new design function is not necessary*/
|
||||
/**
|
||||
* Handle the drawing related tasks of the lists
|
||||
* @param list pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_list_design(lv_obj_t * list, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Draw the object*/
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,176 +0,0 @@
|
||||
/**
|
||||
* @file lv_list.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LIST_H
|
||||
#define LV_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_PAGE == 0
|
||||
#error "lv_list: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_BTN == 0
|
||||
#error "lv_list: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_list: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_IMG == 0
|
||||
#error "lv_list: lv_img is required. Enable it in lv_conf.h (USE_LV_IMG 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_page.h"
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_img.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of list*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/
|
||||
lv_style_t * style_img; /*Style of the list element images on buttons*/
|
||||
uint8_t sb_out :1; /*1: Keep space for the scrollbar*/
|
||||
}lv_list_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a list objects
|
||||
* @param par pointer to an object, it will be the parent of the new list
|
||||
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created list
|
||||
*/
|
||||
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the list
|
||||
* @param list pointer to a list object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Add a list element to the list
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @param rel_action pointer to release action function (like with lv_btn)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Move the list elements up by one
|
||||
* @param list pointer a to list object
|
||||
*/
|
||||
void lv_list_up(lv_obj_t * list);
|
||||
|
||||
/**
|
||||
* Move the list elements down by one
|
||||
* @param list pointer to a list object
|
||||
*/
|
||||
void lv_list_down(lv_obj_t * list);
|
||||
|
||||
/**
|
||||
* Enable/Disable to scrollbar outside attribute
|
||||
* @param list pointer to list object
|
||||
* @param out true: reduce the buttons width therefore scroll bar will be out of the buttons,
|
||||
* false: keep button size and place scroll bar on the buttons
|
||||
*/
|
||||
void lv_list_set_sb_out(lv_obj_t * list, bool out);
|
||||
|
||||
/**
|
||||
* Enable or disable the text rolling on a list element
|
||||
* @param liste pinter to list element
|
||||
* @param en true: enable text scrolling, false: disable text scrolling
|
||||
*/
|
||||
void lv_list_set_element_text_roll(lv_obj_t * liste, bool en);
|
||||
|
||||
/**
|
||||
* Set styles of the list elements of a list in each state
|
||||
* @param list pointer to list object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
|
||||
lv_style_t * trel, lv_style_t * tpr,
|
||||
lv_style_t * ina);
|
||||
|
||||
/**
|
||||
* Set the styles of the list element image (typically to set symbol font)
|
||||
* @param list pointer to list object
|
||||
* @param style pointer to the new style of the button images
|
||||
*/
|
||||
void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the text of a list element
|
||||
* @param liste pointer to list element
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_list_get_element_text(lv_obj_t * liste);
|
||||
|
||||
/**
|
||||
* Get the scroll bar outside attribute
|
||||
* @param list pointer to list object
|
||||
* @param en true: scroll bar outside the buttons, false: scroll bar inside
|
||||
*/
|
||||
bool lv_list_get_sb_out(lv_obj_t * list, bool en);
|
||||
|
||||
/**
|
||||
* Get the style of the list elements in a given state
|
||||
* @param list pointer to a list object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_liste(lv_obj_t * list, lv_btn_state_t state);
|
||||
|
||||
/**
|
||||
* Get the style of the list elements images
|
||||
* @param list pointer to a list object
|
||||
* @return pointer to the image style
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_img(lv_obj_t * list, lv_btn_state_t state);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_LIST*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LIST_H*/
|
||||
@@ -1,236 +0,0 @@
|
||||
/**
|
||||
* @file lv_lmeter.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_LMETER != 0
|
||||
|
||||
#include "lv_lmeter.h"
|
||||
#include "misc/math/trigo.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a line meter objects
|
||||
* @param par pointer to an object, it will be the parent of the new line meter
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created line meter
|
||||
*/
|
||||
lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor of line meter*/
|
||||
lv_obj_t * new_lmeter = lv_bar_create(par, copy);
|
||||
dm_assert(new_lmeter);
|
||||
|
||||
/*Allocate the line meter type specific extended data*/
|
||||
lv_lmeter_ext_t * ext = lv_obj_alloc_ext(new_lmeter, sizeof(lv_lmeter_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->scale_num = 31; /*Odd scale number looks better*/
|
||||
ext->scale_angle = 240; /*(scale_num - 1) * N looks better */
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_lmeter, lv_lmeter_signal);
|
||||
lv_obj_set_design_f(new_lmeter, lv_lmeter_design);
|
||||
|
||||
/*Init the new line meter line meter*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_lmeter, 1 * LV_DPI, 1 * LV_DPI);
|
||||
lv_obj_set_style(new_lmeter, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||
}
|
||||
/*Copy an existing line meter*/
|
||||
else {
|
||||
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->scale_angle = copy_ext->scale_angle;
|
||||
ext->scale_num = copy_ext->scale_num;
|
||||
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_lmeter);
|
||||
}
|
||||
|
||||
return new_lmeter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_bar_signal(lmeter, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the scale settings of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param num number of scale units
|
||||
*/
|
||||
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
ext->scale_angle = angle;
|
||||
ext->scale_num = num;
|
||||
|
||||
lv_obj_inv(lmeter);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the scale number of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @return number of the scale units
|
||||
*/
|
||||
uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
return ext->scale_num ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scale angle of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @return angle of the scale
|
||||
*/
|
||||
uint16_t lv_lmeter_get_scale_angle(lv_obj_t * lmeter)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
return ext->scale_angle;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the line meters
|
||||
* @param lmeter pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
lv_style_t * style = lv_obj_get_style(lmeter);
|
||||
|
||||
lv_style_t style_tmp;
|
||||
memcpy(&style_tmp, style, sizeof(lv_style_t));
|
||||
|
||||
cord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||
cord_t r_in =r_out - style->hpad;
|
||||
cord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->cords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t min = lv_bar_get_min_value(lmeter);
|
||||
int16_t max = lv_bar_get_max_value(lmeter);
|
||||
int16_t level = (int32_t)((int32_t)(lv_bar_get_value(lmeter) - min) * ext->scale_num) / (max - min);
|
||||
uint8_t i;
|
||||
|
||||
style_tmp.ccolor = style->mcolor;
|
||||
|
||||
for(i = 0; i < ext->scale_num; i++) {
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * ext->scale_angle) / (ext->scale_num - 1) + angle_ofs;
|
||||
|
||||
cord_t y_out = (int32_t)((int32_t)trigo_sin(angle) * r_out) / TRIGO_SIN_MAX;
|
||||
cord_t x_out = (int32_t)((int32_t)trigo_sin(angle + 90) * r_out) / TRIGO_SIN_MAX;
|
||||
cord_t y_in = (int32_t)((int32_t)trigo_sin(angle) * r_in) / TRIGO_SIN_MAX;
|
||||
cord_t x_in = (int32_t)((int32_t)trigo_sin(angle + 90) * r_in) / TRIGO_SIN_MAX;
|
||||
|
||||
point_t p1;
|
||||
point_t p2;
|
||||
|
||||
p2.x = x_in + x_ofs;
|
||||
p2.y = y_in + y_ofs;
|
||||
|
||||
p1.x = x_out+ x_ofs;
|
||||
p1.y = y_out + y_ofs;
|
||||
|
||||
if(i > level) style_tmp.ccolor = style->ccolor;
|
||||
else {
|
||||
style_tmp.ccolor=color_mix(style->gcolor, style->mcolor, (255 * i) / ext->scale_num);
|
||||
}
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &style_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* @file lv_lmeter.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LMETER_H
|
||||
#define LV_LMETER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "misc_conf.h"
|
||||
#if USE_LV_LMETER != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_BAR == 0
|
||||
#error "lv_lmeter: lv_bar is required. Enable it in lv_conf.h (USE_LV_BAR 1) "
|
||||
#endif
|
||||
|
||||
#if USE_TRIGO == 0
|
||||
#error "lv_lmeter: trigo is required. Enable it in misc_conf.h (USE_TRIGO 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_bar.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of line meter*/
|
||||
typedef struct
|
||||
{
|
||||
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
|
||||
uint8_t scale_num; /*Number of scale units */
|
||||
}lv_lmeter_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a line meter objects
|
||||
* @param par pointer to an object, it will be the parent of the new line meter
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created line meter
|
||||
*/
|
||||
lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set the scale settings of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param num number of scale units
|
||||
*/
|
||||
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num);
|
||||
|
||||
/**
|
||||
* Get the scale number of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @return number of the scale units
|
||||
*/
|
||||
uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter);
|
||||
|
||||
/**
|
||||
* Get the scale angle of a line meter
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @return angle of the scale
|
||||
*/
|
||||
uint16_t lv_lmeter_get_scale_angle(lv_obj_t * lmeter);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_LMETER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LMETER_H*/
|
||||
@@ -1,412 +0,0 @@
|
||||
/**
|
||||
* @file lv_mbox.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_MBOX != 0
|
||||
|
||||
#include "lv_mbox.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MBOX_CLOSE_ANIM_TIME 200 /*Default close anim. time [ms]*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0 /*Unused*/
|
||||
static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
static void lv_mbox_realign(lv_obj_t * mbox);
|
||||
static void lv_mbox_disable_fit(lv_obj_t * mbox);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a message box objects
|
||||
* @param par pointer to an object, it will be the parent of the new message box
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor message box*/
|
||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||
dm_assert(new_mbox);
|
||||
|
||||
/*Allocate the message box type specific extended data*/
|
||||
lv_mbox_ext_t * ext = lv_obj_alloc_ext(new_mbox, sizeof(lv_mbox_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->txt = NULL;
|
||||
ext->btnh = NULL;
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->anim_close_time = LV_MBOX_CLOSE_ANIM_TIME;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_mbox, lv_mbox_signal);
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
lv_cont_set_layout(new_mbox, LV_CONT_LAYOUT_COL_L);
|
||||
lv_cont_set_fit(new_mbox, true, true);
|
||||
|
||||
ext->txt = lv_label_create(new_mbox, NULL);
|
||||
lv_label_set_text(ext->txt, "Text of the message box");
|
||||
|
||||
lv_obj_set_style(new_mbox, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
}
|
||||
/*Copy an existing message box*/
|
||||
else {
|
||||
lv_mbox_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
|
||||
ext->txt = lv_label_create(new_mbox, copy_ext->txt);
|
||||
|
||||
/*Copy the buttons and the label on them*/
|
||||
if(copy_ext->btnh != NULL) {
|
||||
lv_obj_t * btn_copy;
|
||||
const char * btn_txt_copy;
|
||||
lv_btn_ext_t * btn_ext_copy;
|
||||
LL_READ_BACK(copy_ext->btnh->child_ll, btn_copy) {
|
||||
btn_txt_copy = lv_label_get_text(lv_obj_get_child(btn_copy, NULL));
|
||||
btn_ext_copy = lv_obj_get_ext(btn_copy);
|
||||
lv_mbox_add_btn(new_mbox, btn_txt_copy, btn_ext_copy->rel_action);
|
||||
}
|
||||
}
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_mbox);
|
||||
}
|
||||
|
||||
lv_mbox_realign(new_mbox);
|
||||
|
||||
return new_mbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_cont_signal(mbox, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*If the size is changed refresh the message box*/
|
||||
if(area_get_width(param) != lv_obj_get_width(mbox) ||
|
||||
area_get_height(param) != lv_obj_get_height(mbox)) {
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
lv_mbox_start_auto_close(mbox, 0);
|
||||
lv_dispi_wait_release(param);
|
||||
valid = false;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh all the buttons*/
|
||||
if(ext->btnh != NULL) {
|
||||
lv_obj_t * btn;
|
||||
btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(btn != NULL) {
|
||||
/*Refresh the next button's style*/
|
||||
lv_btn_set_styles(btn, ext->style_btn_rel, ext->style_btn_pr, NULL, NULL, NULL);
|
||||
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always lv_action_res_t because the button is deleted with the mesage box
|
||||
*/
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
|
||||
lv_obj_del(mbox);
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
* @param btn_txt the text of the button
|
||||
* @param rel_action a function which will be called when the button is released
|
||||
* @return pointer to the created button (lv_btn)
|
||||
*/
|
||||
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
/*Create a button if it is not existed yet*/
|
||||
if(ext->btnh == NULL) {
|
||||
ext->btnh = lv_cont_create(mbox, NULL);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_obj_set_click(ext->btnh, false);
|
||||
lv_cont_set_fit(ext->btnh, false, true);
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_PRETTY);
|
||||
}
|
||||
|
||||
lv_obj_t * btn;
|
||||
btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
lv_btn_set_styles(btn, ext->style_btn_rel, ext->style_btn_pr, NULL, NULL, NULL);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(label, btn_txt);
|
||||
|
||||
lv_mbox_realign(mbox);
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
lv_mbox_realign(mbox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set styles of the buttons of a message box in each state
|
||||
* @param mbox pointer to a message box object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
ext->style_btn_rel = rel;
|
||||
ext->style_btn_pr = pr;
|
||||
|
||||
if(ext->btnh != NULL) {
|
||||
lv_obj_t * btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
|
||||
while(btn != NULL) {
|
||||
lv_btn_set_styles(btn, rel, pr, NULL, NULL, NULL);
|
||||
btn = lv_obj_get_child(mbox, btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set close animation duration
|
||||
* @param mbox pointer to a message box object
|
||||
* @param time animation length in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_mbox_set_anim_close_time(lv_obj_t * mbox, uint16_t time)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
ext->anim_close_time = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically delete the message box after a given time
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
if(ext->anim_close_time != 0) {
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_H| ANIM_OUT, ext->anim_close_time, tout, NULL);
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_V| ANIM_OUT, ext->anim_close_time, tout, lv_obj_del);
|
||||
|
||||
/*When the animations start disable fit to let shrinking work*/
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
} else {
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, ext->anim_close_time, tout, lv_obj_del);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the auto. closing of message box
|
||||
* @param mbox pointer to a message box object
|
||||
*/
|
||||
void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
||||
{
|
||||
anim_del(mbox, NULL);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the text of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @return pointer to the text of the message box
|
||||
*/
|
||||
const char * lv_mbox_get_txt(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
return lv_label_get_text(ext->txt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message box object from one of its button.
|
||||
* It is useful in the button release actions where only the button is known
|
||||
* @param btn pointer to a button of a message box
|
||||
* @return pointer to the button's message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn)
|
||||
{
|
||||
lv_obj_t * btnh = lv_obj_get_parent(btn);
|
||||
lv_obj_t * mbox = lv_obj_get_parent(btnh);
|
||||
|
||||
return mbox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the close animation duration
|
||||
* @param mbox pointer to a message box object
|
||||
* @return animation length in milliseconds (0: no animation)
|
||||
*/
|
||||
uint16_t lv_mbox_get_anim_close_time(lv_obj_t * mbox )
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
return ext->anim_close_time;
|
||||
}
|
||||
/**
|
||||
* Get the style of the buttons on a message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
if(ext->styles[state] == NULL) return lv_obj_get_style(mbox);
|
||||
|
||||
return ext->styles[state];
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if 0 /*Not used*/
|
||||
/**
|
||||
* Handle the drawing related tasks of the message boxs
|
||||
* @param mbox pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*Draw the object*/
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Realign the elements of the message box
|
||||
* @param mbox pointer to message box object
|
||||
*/
|
||||
static void lv_mbox_realign(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
|
||||
if(ext->txt == NULL) return;
|
||||
|
||||
/*Set the button holder width to the width of the text and title*/
|
||||
if(ext->btnh != NULL) {
|
||||
cord_t txt_w = lv_obj_get_width(ext->txt);
|
||||
cord_t btn_w = 0;
|
||||
lv_obj_t * btn;
|
||||
btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(btn != NULL) {
|
||||
btn_w = MATH_MAX(lv_obj_get_width(btn), btn_w);
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
cord_t w = MATH_MAX(txt_w, btn_w);
|
||||
lv_obj_set_width(ext->btnh, w );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the close animations starts to disable the recargle's fit
|
||||
* @param mbox ppointer to message box object
|
||||
*/
|
||||
static void lv_mbox_disable_fit(lv_obj_t * mbox)
|
||||
{
|
||||
lv_cont_set_fit(mbox, false, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,174 +0,0 @@
|
||||
/**
|
||||
* @file lv_mbox.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MBOX_H
|
||||
#define LV_MBOX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_MBOX != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_CONT == 0
|
||||
#error "lv_mbox: lv_cont is required. Enable it in lv_conf.h (USE_LV_CONT 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_BTN == 0
|
||||
#error "lv_mbox: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_mbox: lv_rlabel is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of message box*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * txt; /*Text of the message box*/
|
||||
lv_obj_t * btnh; /*Holder of the buttons*/
|
||||
lv_style_t * style_btn_rel; /*Style of the released buttons*/
|
||||
lv_style_t * style_btn_pr; /*Style of the pressed buttons*/
|
||||
uint16_t anim_close_time; /*Duration of close animation [ms] (0: no animation)*/
|
||||
}lv_mbox_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a message box objects
|
||||
* @param par pointer to an object, it will be the parent of the new message box
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a message box button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always lv_action_res_t because the button is deleted with the mesage box
|
||||
*/
|
||||
lv_action_res_t lv_mbox_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Add a button to the message box
|
||||
* @param mbox pointer to message box object
|
||||
* @param btn_txt the text of the button
|
||||
* @param rel_action a function which will be called when the button is released
|
||||
* @return pointer to the created button (lv_btn)
|
||||
*/
|
||||
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set the text of the message box
|
||||
* @param mbox pointer to a message box
|
||||
* @param txt a '\0' terminated character string which will be the message box text
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
|
||||
|
||||
/**
|
||||
* Set styles of the buttons of a message box in each state
|
||||
* @param mbox pointer to a message box object
|
||||
* @param rel pointer to a style for releases state
|
||||
* @param pr pointer to a style for pressed state
|
||||
* @param trel pointer to a style for toggled releases state
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr);
|
||||
|
||||
/**
|
||||
* Set close animation duration
|
||||
* @param mbox pointer to a message box object
|
||||
* @param time animation length in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_mbox_set_anim_close_time(lv_obj_t * mbox, uint16_t time);
|
||||
|
||||
/**
|
||||
* Automatically delete the message box after a given time
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout);
|
||||
|
||||
/**
|
||||
* Stop the auto. closing of message box
|
||||
* @param mbox pointer to a message box object
|
||||
*/
|
||||
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
|
||||
|
||||
/**
|
||||
* Get the text of the message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @return pointer to the text of the message box
|
||||
*/
|
||||
const char * lv_mbox_get_txt(lv_obj_t * mbox);
|
||||
|
||||
/**
|
||||
* Get the message box object from one of its button.
|
||||
* It is useful in the button release actions where only the button is known
|
||||
* @param btn pointer to a button of a message box
|
||||
* @return pointer to the button's message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the close animation duration
|
||||
* @param mbox pointer to a message box object
|
||||
* @return animation length in milliseconds (0: no animation)
|
||||
*/
|
||||
uint16_t lv_mbox_get_anim_close_time(lv_obj_t * mbox );
|
||||
|
||||
/**
|
||||
* Get the style of the buttons on a message box
|
||||
* @param mbox pointer to a message box object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_MBOX*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_MBOX_H*/
|
||||
@@ -1,166 +0,0 @@
|
||||
/**
|
||||
* @file lv_templ.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
|
||||
* templ -> object short name with lower case(e.g. btn, label etc)
|
||||
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_TEMPL != 0
|
||||
|
||||
#include "lv_templ.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a template objects
|
||||
* @param par pointer to an object, it will be the parent of the new template
|
||||
* @param copy pointer to a template object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created template
|
||||
*/
|
||||
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor of template*/
|
||||
/*TODO modify it to the ancestor create function */
|
||||
lv_obj_t * new_templ = lv_ANCESTOR_create(par, copy);
|
||||
dm_assert(new_templ);
|
||||
|
||||
/*Allocate the template type specific extended data*/
|
||||
lv_templ_ext_t * ext = lv_obj_alloc_ext(new_templ, sizeof(lv_templ_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->xyz = 0;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_templ, lv_templ_signal);
|
||||
lv_obj_set_design_f(new_templ, lv_templ_design);
|
||||
|
||||
/*Init the new template template*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_templ, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
}
|
||||
/*Copy an existing template*/
|
||||
else {
|
||||
lv_templ_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_templ);
|
||||
}
|
||||
|
||||
return new_templ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the template
|
||||
* @param templ pointer to a template object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
/* TODO update it to the ancestor's signal function*/
|
||||
valid = lv_ANCESTOR_signal(templ, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*
|
||||
* New object specific "set" function comes here
|
||||
*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/*
|
||||
* New object specific "get" function comes here
|
||||
*/
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the templates
|
||||
* @param templ pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @file lv_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
|
||||
* templ -> object short name with lower case(e.g. btn, label etc)
|
||||
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEMPL_H
|
||||
#define LV_TEMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_TEMPL != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of template*/
|
||||
typedef struct
|
||||
{
|
||||
/*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
}lv_templ_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a template objects
|
||||
* @param par pointer to an object, it will be the parent of the new template
|
||||
* @param copy pointer to a template object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created template
|
||||
*/
|
||||
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the template
|
||||
* @param templ pointer to a template object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_TEMPL*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEMPL_H*/
|
||||
@@ -1,675 +0,0 @@
|
||||
/**
|
||||
* @file lv_page.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_PAGE != 0
|
||||
|
||||
#include "misc/math/math_base.h"
|
||||
#include "../lv_objx/lv_page.h"
|
||||
#include "../lv_objx/lv_cont.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_page_sb_refresh(lv_obj_t * main);
|
||||
static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_t mode);
|
||||
static bool lv_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void* param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a page objects
|
||||
* @param par pointer to an object, it will be the parent of the new page
|
||||
* @param copy pointer to a page object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created page
|
||||
*/
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_page = lv_cont_create(par, copy);
|
||||
dm_assert(new_page);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_page_ext_t * ext = lv_obj_alloc_ext(new_page, sizeof(lv_page_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->scrl = NULL;
|
||||
ext->pr_action = NULL;
|
||||
ext->rel_action = NULL;
|
||||
ext->sbh_draw = 0;
|
||||
ext->sbv_draw = 0;
|
||||
ext->style_sb = lv_style_get(LV_STYLE_PRETTY, NULL);
|
||||
ext->sb_width = LV_DPI / 8; /*Will be modified later*/
|
||||
ext->sb_mode = LV_PAGE_SB_MODE_ON;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_page);
|
||||
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
lv_style_t * style = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT);
|
||||
lv_cont_set_fit(ext->scrl, true, true);
|
||||
lv_obj_set_style(ext->scrl, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
|
||||
lv_page_set_sb_width(new_page, style->hpad);
|
||||
lv_page_set_sb_mode(new_page, ext->sb_mode);
|
||||
lv_page_set_style_sb(new_page, ext->style_sb);
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_f(new_page, lv_page_signal);
|
||||
lv_obj_set_design_f(new_page, lv_page_design);
|
||||
lv_obj_set_style(new_page, style);
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_scrl_signal);
|
||||
|
||||
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
||||
lv_page_set_rel_action(new_page, copy_ext->rel_action);
|
||||
lv_page_set_sb_mode(new_page, copy_ext->sb_mode);
|
||||
lv_page_set_sb_width(new_page, copy_ext->sb_width);
|
||||
lv_page_set_style_sb(new_page, copy_ext->style_sb);
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_f(new_page, lv_page_signal);
|
||||
lv_obj_set_design_f(new_page, lv_page_design);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_page);
|
||||
}
|
||||
|
||||
lv_page_sb_refresh(new_page);
|
||||
|
||||
return new_page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the page
|
||||
* @param page pointer to a page object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool obj_valid = true;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
obj_valid = lv_cont_signal(page, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(obj_valid != false) {
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_obj_t * child;
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CHILD_CHG: /*Move children to the scrollable object*/
|
||||
child = lv_obj_get_child(page, NULL);
|
||||
while(child != NULL) {
|
||||
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
||||
lv_obj_t * tmp = child;
|
||||
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
|
||||
lv_obj_set_parent(tmp, ext->scrl);
|
||||
} else {
|
||||
child = lv_obj_get_child(page, child);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_ON) {
|
||||
ext->sbh_draw = 1;
|
||||
ext->sbv_draw = 1;
|
||||
} else {
|
||||
ext->sbh_draw = 0;
|
||||
ext->sbv_draw = 0;
|
||||
}
|
||||
|
||||
lv_page_sb_refresh(page);
|
||||
break;
|
||||
|
||||
case LV_SIGNAL_CORD_CHG:
|
||||
/*Refresh the scrollbar and notify the scrl if the size is changed*/
|
||||
if(ext->scrl != NULL &&
|
||||
(lv_obj_get_width(page) != area_get_width(param) ||
|
||||
lv_obj_get_height(page) != area_get_height(param))) {
|
||||
ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords);
|
||||
|
||||
/*The scrolbars are important olny if they are visible now*/
|
||||
if(ext->sbh_draw != 0 || ext->sbv_draw != 0)
|
||||
lv_page_sb_refresh(page);
|
||||
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_PRESSED:
|
||||
if(ext->pr_action != NULL) {
|
||||
ext->pr_action(page, param);
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_RELEASED:
|
||||
if(lv_dispi_is_dragging(param) == false) {
|
||||
if(ext->rel_action != NULL) {
|
||||
ext->rel_action(page, param);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return obj_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the scrollable part of a page
|
||||
* @param scrl pointer to the scrollable object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
static bool lv_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void* param)
|
||||
{
|
||||
bool obj_valid = true;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
obj_valid = lv_cont_signal(scrl, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(obj_valid != false) {
|
||||
|
||||
cord_t new_x;
|
||||
cord_t new_y;
|
||||
bool refr_x = false;
|
||||
bool refr_y = false;
|
||||
area_t page_cords;
|
||||
area_t obj_cords;
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
lv_style_t * page_style = lv_obj_get_style(page);
|
||||
lv_page_ext_t * page_ext = lv_obj_get_ext(page);
|
||||
cord_t hpad = page_style->hpad;
|
||||
cord_t vpad = page_style->vpad;
|
||||
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CORD_CHG:
|
||||
new_x = lv_obj_get_x(scrl);
|
||||
new_y = lv_obj_get_y(scrl);
|
||||
lv_obj_get_cords(scrl, &obj_cords);
|
||||
lv_obj_get_cords(page, &page_cords);
|
||||
|
||||
/*scrollable width smaller then page width? -> align to left*/
|
||||
if(area_get_width(&obj_cords) + 2 * hpad < area_get_width(&page_cords)) {
|
||||
if(obj_cords.x1 != page_cords.x1 + hpad) {
|
||||
new_x = hpad;
|
||||
refr_x = true;
|
||||
}
|
||||
} else {
|
||||
/*The edges of the scrollable can not be in the page (minus hpad) */
|
||||
if(obj_cords.x2 < page_cords.x2 - hpad) {
|
||||
new_x = area_get_width(&page_cords) - area_get_width(&obj_cords) - hpad; /* Right align */
|
||||
refr_x = true;
|
||||
}
|
||||
if (obj_cords.x1 > page_cords.x1 + hpad) {
|
||||
new_x = hpad; /*Left align*/
|
||||
refr_x = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*scrollable height smaller then page height? -> align to left*/
|
||||
if(area_get_height(&obj_cords) + 2 * vpad < area_get_height(&page_cords)) {
|
||||
if(obj_cords.y1 != page_cords.y1 + vpad) {
|
||||
new_y = vpad;
|
||||
refr_y = true;
|
||||
}
|
||||
} else {
|
||||
/*The edges of the scrollable can not be in the page (minus vpad) */
|
||||
if(obj_cords.y2 < page_cords.y2 - vpad) {
|
||||
new_y = area_get_height(&page_cords) - area_get_height(&obj_cords) - vpad; /* Bottom align */
|
||||
refr_y = true;
|
||||
}
|
||||
if (obj_cords.y1 > page_cords.y1 + vpad) {
|
||||
new_y = vpad; /*Top align*/
|
||||
refr_y = true;
|
||||
}
|
||||
}
|
||||
if(refr_x != false || refr_y != false) {
|
||||
lv_obj_set_pos(scrl, new_x, new_y);
|
||||
}
|
||||
|
||||
lv_page_sb_refresh(page);
|
||||
break;
|
||||
|
||||
case LV_SIGNAL_DRAG_BEGIN:
|
||||
if(page_ext->sb_mode == LV_PAGE_SB_MODE_DRAG ) {
|
||||
cord_t sbh_pad = MATH_MAX(page_ext->sb_width, page_style->hpad);
|
||||
cord_t sbv_pad = MATH_MAX(page_ext->sb_width, page_style->vpad);
|
||||
if(area_get_height(&page_ext->sbv) < lv_obj_get_height(scrl) - 2 * sbv_pad) {
|
||||
page_ext->sbv_draw = 1;
|
||||
}
|
||||
if(area_get_width(&page_ext->sbh) < lv_obj_get_width(scrl) - 2 * sbh_pad) {
|
||||
page_ext->sbh_draw = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LV_SIGNAL_DRAG_END:
|
||||
if(page_ext->sb_mode == LV_PAGE_SB_MODE_DRAG) {
|
||||
area_t sb_area_tmp;
|
||||
if(page_ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &page_ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
page_ext->sbh_draw = 0;
|
||||
}
|
||||
if(page_ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &page_ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
page_ext->sbv_draw = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_PRESSED:
|
||||
if(page_ext->pr_action != NULL) {
|
||||
page_ext->pr_action(page, param);
|
||||
}
|
||||
break;
|
||||
case LV_SIGNAL_RELEASED:
|
||||
if(lv_dispi_is_dragging(param) == false) {
|
||||
if(page_ext->rel_action != NULL) {
|
||||
page_ext->rel_action(page, param);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return obj_valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a release action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param rel_action a function to call when the page is released
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
ext->rel_action = rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a press action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param pr_action a function to call when the page is pressed
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
ext->pr_action = pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar width on a page
|
||||
* @param page pointer to a page object
|
||||
* @param sb_width the new scroll bar width in pixels
|
||||
*/
|
||||
void lv_page_set_sb_width(lv_obj_t * page, cord_t sb_width)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
ext->sb_width = sb_width;
|
||||
area_set_height(&ext->sbh, ext->sb_width);
|
||||
area_set_width(&ext->sbv, ext->sb_width);
|
||||
lv_page_sb_refresh(page);
|
||||
lv_obj_inv(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
|
||||
*/
|
||||
void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
ext->sb_mode = sb_mode;
|
||||
page->signal_f(page, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_inv(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new style for the scroll bars object on the page
|
||||
* @param page pointer to a page object
|
||||
* @param style pointer to a style for the scroll bars
|
||||
*/
|
||||
void lv_page_set_style_sb(lv_obj_t * page, lv_style_t * style)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
ext->style_sb = style;
|
||||
lv_obj_inv(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
|
||||
* @param obj pointer to an object on a page
|
||||
* @param glue true: enable glue, false: disable glue
|
||||
*/
|
||||
void lv_page_glue_obj(lv_obj_t * obj, bool glue)
|
||||
{
|
||||
lv_obj_set_drag_parent(obj, glue);
|
||||
lv_obj_set_drag(obj, glue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus on an object. It ensures that the object will be visible on the page.
|
||||
* @param page pointer to a page object
|
||||
* @param obj pointer to an object to focus (must be on the page)
|
||||
* @param anim_time scroll animation time in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
cord_t obj_y = obj->cords.y1 - ext->scrl->cords.y1;
|
||||
cord_t obj_h = lv_obj_get_height(obj);
|
||||
cord_t scrlable_y = lv_obj_get_y(ext->scrl);
|
||||
cord_t page_h = lv_obj_get_height(page);
|
||||
|
||||
cord_t top_err = -(scrlable_y + obj_y);
|
||||
cord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
||||
|
||||
/*If obj is higher then the page focus where the "error" is smaller*/
|
||||
/*Out of the page on the top*/
|
||||
if((obj_h <= page_h && top_err > 0) ||
|
||||
(obj_h > page_h && top_err < bot_err)) {
|
||||
/*Calculate a new position and to let scrable_rects.vpad space above*/
|
||||
scrlable_y = -(obj_y - style_scrl->vpad - style->vpad);
|
||||
scrlable_y += style_scrl->vpad;
|
||||
}
|
||||
/*Out of the page on the bottom*/
|
||||
else if((obj_h <= page_h && bot_err > 0) ||
|
||||
(obj_h > page_h && top_err >= bot_err)) {
|
||||
/*Calculate a new position and to let scrable_rects.vpad space below*/
|
||||
scrlable_y = -obj_y;
|
||||
scrlable_y += page_h - obj_h;
|
||||
scrlable_y -= style_scrl->vpad;
|
||||
} else {
|
||||
/*Alraedy in focus*/
|
||||
return;
|
||||
}
|
||||
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_y(ext->scrl, scrlable_y);
|
||||
}
|
||||
else {
|
||||
anim_t a;
|
||||
a.act_time = 0;
|
||||
a.start = lv_obj_get_y(ext->scrl);
|
||||
a.end = scrlable_y;
|
||||
a.time = anim_time;
|
||||
a.end_cb = NULL;
|
||||
a.playback = 0;
|
||||
a.repeat = 0;
|
||||
a.var = ext->scrl;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.fp = (anim_fp_t) lv_obj_set_y;
|
||||
anim_create(&a);
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the scrollable object of a page-
|
||||
* @param page pointer to page object
|
||||
* @return pointer to a container which is the scrollable part of the page
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
|
||||
return ext->scrl;
|
||||
}
|
||||
/**
|
||||
* Get the scroll bar width on a page
|
||||
* @param page pointer to a page object
|
||||
* @return the scroll bar width in pixels
|
||||
*/
|
||||
cord_t lv_page_get_sb_width(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
return ext->sb_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
* @return the mode from 'lv_page_sb_mode_t' enum
|
||||
*/
|
||||
lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
return ext->sb_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new style for the scroll bars object on the page
|
||||
* @param page pointer to a page object
|
||||
* @return pointer to a style for the scroll bars
|
||||
*/
|
||||
lv_style_t * lv_page_get_style_sb(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
if(ext->style_sb == NULL) return lv_obj_get_style(page);
|
||||
|
||||
else return ext->style_sb;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the pages
|
||||
* @param page pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design_f(page, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(page, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
||||
ancestor_design_f(page, mask, mode);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
|
||||
/*Draw the scrollbars*/
|
||||
area_t sb_area;
|
||||
if(ext->sbh_draw != 0) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
area_cpy(&sb_area, &ext->sbh);
|
||||
sb_area.x1 += page->cords.x1;
|
||||
sb_area.y1 += page->cords.y1;
|
||||
sb_area.x2 += page->cords.x1;
|
||||
sb_area.y2 += page->cords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->style_sb);
|
||||
}
|
||||
|
||||
if(ext->sbv_draw != 0) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
area_cpy(&sb_area, &ext->sbv);
|
||||
sb_area.x1 += page->cords.x1;
|
||||
sb_area.y1 += page->cords.y1;
|
||||
sb_area.x2 += page->cords.x1;
|
||||
sb_area.y2 += page->cords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->style_sb);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the position and size of the scroll bars.
|
||||
* @param page pointer to a page object
|
||||
*/
|
||||
static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
{
|
||||
/*Always let sb_width padding above,under, left and right to the scrollbars
|
||||
* else:
|
||||
* - horizontal and vertical scrollbars can overlap on the corners
|
||||
* - if the page has radius the scrollbar can be out of the radius */
|
||||
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = ext->scrl;
|
||||
cord_t size_tmp;
|
||||
cord_t scrl_w = lv_obj_get_width(scrl);
|
||||
cord_t scrl_h = lv_obj_get_height(scrl);
|
||||
cord_t hpad = style->hpad;
|
||||
cord_t vpad = style->vpad;
|
||||
cord_t obj_w = lv_obj_get_width(page);
|
||||
cord_t obj_h = lv_obj_get_height(page);
|
||||
cord_t sbh_pad = MATH_MAX(ext->sb_width, style->hpad);
|
||||
cord_t sbv_pad = MATH_MAX(ext->sb_width, style->vpad);
|
||||
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_OFF) return;
|
||||
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_ON) {
|
||||
ext->sbh_draw = 1;
|
||||
ext->sbv_draw = 1;
|
||||
}
|
||||
|
||||
/*Invalidate the current (old) scrollbar areas*/
|
||||
area_t sb_area_tmp;
|
||||
if(ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
if(ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
|
||||
/*Horizontal scrollbar*/
|
||||
if(scrl_w <= obj_w - 2 * hpad) { /*Full sized scroll bar*/
|
||||
area_set_width(&ext->sbh, obj_w - 2 * sbh_pad);
|
||||
area_set_pos(&ext->sbh, sbh_pad, obj_h - ext->sb_width);
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_AUTO) ext->sbh_draw = 0;
|
||||
} else {
|
||||
size_tmp = (obj_w * (obj_w - (2 * sbh_pad))) / (scrl_w + 2 * hpad);
|
||||
area_set_width(&ext->sbh, size_tmp);
|
||||
|
||||
area_set_pos(&ext->sbh, sbh_pad +
|
||||
(-(lv_obj_get_x(scrl) - hpad) * (obj_w - size_tmp - 2 * sbh_pad)) /
|
||||
(scrl_w + 2 * hpad - obj_w ), obj_h - ext->sb_width);
|
||||
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_AUTO) ext->sbh_draw = 1;
|
||||
}
|
||||
|
||||
/*Vertical scrollbar*/
|
||||
if(scrl_h <= obj_h - 2 * vpad) { /*Full sized scroll bar*/
|
||||
area_set_height(&ext->sbv, obj_h - 2 * sbv_pad);
|
||||
area_set_pos(&ext->sbv, obj_w - ext->sb_width, sbv_pad);
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_AUTO) ext->sbv_draw = 0;
|
||||
} else {
|
||||
size_tmp = (obj_h * (obj_h - (2 * sbv_pad))) / (scrl_h + 2 * vpad);
|
||||
area_set_height(&ext->sbv, size_tmp);
|
||||
|
||||
area_set_pos(&ext->sbv, obj_w - ext->sb_width,
|
||||
sbv_pad +
|
||||
(-(lv_obj_get_y(scrl) - vpad) * (obj_h - size_tmp - 2 * sbv_pad)) /
|
||||
(scrl_h + 2 * vpad - obj_h ));
|
||||
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_AUTO) ext->sbv_draw = 1;
|
||||
}
|
||||
|
||||
/*Invalidate the new scrollbar areas*/
|
||||
if(ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
if(ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,171 +0,0 @@
|
||||
/**
|
||||
* @file lv_page.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PAGE_H
|
||||
#define LV_PAGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_PAGE != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_CONT == 0
|
||||
#error "lv_page: lv_cont is required. Enable it in lv_conf.h (USE_LV_CONT 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lvgl/lv_objx/lv_cont.h"
|
||||
#include "../lv_obj/lv_dispi.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Scrollbar modes: shows when should the scrollbars be visible*/
|
||||
typedef enum
|
||||
{
|
||||
LV_PAGE_SB_MODE_OFF, /*Never show scrollbars*/
|
||||
LV_PAGE_SB_MODE_ON, /*Always show scrollbars*/
|
||||
LV_PAGE_SB_MODE_DRAG, /*Show scrollbars when page is being dragged*/
|
||||
LV_PAGE_SB_MODE_AUTO, /*Show scrollbars when the scrollable container is large enough to be scrolled*/
|
||||
}lv_page_sb_mode_t;
|
||||
|
||||
/*Data of page*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t bg; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * scrl; /*The scrollable object on the background*/
|
||||
lv_action_t rel_action; /*Function to call when the page is released*/
|
||||
lv_action_t pr_action; /*Function to call when the page is pressed*/
|
||||
lv_style_t * style_sb; /*Style of scrollbars*/
|
||||
cord_t sb_width; /*Width of the scrollbars*/
|
||||
lv_page_sb_mode_t sb_mode; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/
|
||||
area_t sbh; /*Horizontal scrollbar area relative to the page. (Handled by the library) */
|
||||
area_t sbv; /*Vertical scrollbar area relative to the page (Handled by the library)*/
|
||||
uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now (Handled by the library)*/
|
||||
uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now (Handled by the library)*/
|
||||
}lv_page_ext_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a page objects
|
||||
* @param par pointer to an object, it will be the parent of the new page
|
||||
* @param copy pointer to a page object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created page
|
||||
*/
|
||||
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the page
|
||||
* @param page pointer to a page object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
*/
|
||||
bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a release action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param rel_action a function to call when the page is released
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a press action for the page
|
||||
* @param page pointer to a page object
|
||||
* @param pr_action a function to call when the page is pressed
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Set the scroll bar width on a page
|
||||
* @param page pointer to a page object
|
||||
* @param sb_width the new scroll bar width in pixels
|
||||
*/
|
||||
void lv_page_set_sb_width(lv_obj_t * page, cord_t sb_width);
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
|
||||
*/
|
||||
void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode);
|
||||
|
||||
/**
|
||||
* Set a new style for the scroll bars object on the page
|
||||
* @param page pointer to a page object
|
||||
* @param style pointer to a style for the scroll bars
|
||||
*/
|
||||
void lv_page_set_style_sb(lv_obj_t * page, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
|
||||
* @param obj pointer to an object on a page
|
||||
* @param glue true: enable glue, false: disable glue
|
||||
*/
|
||||
void lv_page_glue_obj(lv_obj_t * obj, bool glue);
|
||||
|
||||
/**
|
||||
* Focus on an object. It ensures that the object will be visible on the page.
|
||||
* @param page pointer to a page object
|
||||
* @param obj pointer to an object to focus (must be on the page)
|
||||
* @param anim_time scroll animation time in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time);
|
||||
|
||||
/**
|
||||
* Get the scrollable object of a page-
|
||||
* @param page pointer to page object
|
||||
* @return pointer to a container which is the scrollable part of the page
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Get the scroll bar width on a page
|
||||
* @param page pointer to a page object
|
||||
* @return the scroll bar width in pixels
|
||||
*/
|
||||
cord_t lv_page_get_sb_width(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode on a page
|
||||
* @param page pointer to a page object
|
||||
* @return the mode from 'lv_page_sb_mode_t' enum
|
||||
*/
|
||||
lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Set a new style for the scroll bars object on the page
|
||||
* @param page pointer to a page object
|
||||
* @return pointer to a style for the scroll bars
|
||||
*/
|
||||
lv_style_t * lv_page_get_style_sb(lv_obj_t * page);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_PAGE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_PAGE_H*/
|
||||
@@ -1,303 +0,0 @@
|
||||
/**
|
||||
* @file lv_slider.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_SLIDER != 0
|
||||
|
||||
#include "lv_slider.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a slider objects
|
||||
* @param par pointer to an object, it will be the parent of the new slider
|
||||
* @param copy pointer to a slider object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created slider
|
||||
*/
|
||||
lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor slider*/
|
||||
/*TODO modify it to the ancestor create function */
|
||||
lv_obj_t * new_slider = lv_bar_create(par, copy);
|
||||
dm_assert(new_slider);
|
||||
|
||||
/*Allocate the slider type specific extended data*/
|
||||
lv_slider_ext_t * ext = lv_obj_alloc_ext(new_slider, sizeof(lv_slider_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->cb = NULL;
|
||||
ext->tmp_value = ext->bar.min_value;
|
||||
ext->style_knob = lv_style_get(LV_STYLE_PRETTY, NULL);
|
||||
|
||||
/* Save the bar design function.
|
||||
* It will be used in the sllider design function*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_slider);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_slider, lv_slider_signal);
|
||||
lv_obj_set_design_f(new_slider, lv_slider_design);
|
||||
|
||||
/*Init the new slider slider*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_slider, true);
|
||||
lv_slider_set_style_knob(new_slider, ext->style_knob);
|
||||
}
|
||||
/*Copy an existing slider*/
|
||||
else {
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
ext->cb = copy_ext->cb;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_slider);
|
||||
}
|
||||
|
||||
return new_slider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the slider
|
||||
* @param slider pointer to a slider object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
/* TODO update it to the ancestor's signal function*/
|
||||
valid = lv_bar_signal(slider, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
point_t p;
|
||||
cord_t w = lv_obj_get_width(slider);
|
||||
cord_t h = lv_obj_get_height(slider);
|
||||
int16_t tmp;
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
ext->tmp_value = lv_bar_get_value(slider);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_dispi_get_point(param, &p);
|
||||
if(w > h) {
|
||||
p.x -= slider->cords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - h);
|
||||
} else {
|
||||
p.y -= slider->cords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - w);
|
||||
tmp = ext->bar.max_value - tmp; /*Invert he value: small value means higher y*/
|
||||
}
|
||||
|
||||
lv_bar_set_value(slider, tmp);
|
||||
}
|
||||
else if (sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_bar_set_value(slider, ext->tmp_value);
|
||||
}
|
||||
else if (sign == LV_SIGNAL_RELEASED) {
|
||||
ext->tmp_value = lv_bar_get_value(slider);
|
||||
lv_bar_set_value(slider, ext->tmp_value);
|
||||
if(ext->cb != NULL) ext->cb(slider, param);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
|
||||
if(lv_obj_get_width(slider) != area_get_width(param) ||
|
||||
lv_obj_get_height(slider) != area_get_height(param)) {
|
||||
slider->signal_f(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
cord_t x = MATH_MIN(w, h);
|
||||
if(slider->ext_size < x) slider->ext_size = x;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a function which will be called when a new value is set on the slider
|
||||
* @param slider pointer to slider object
|
||||
* @param cb a callback function
|
||||
*/
|
||||
void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of knob on a slider
|
||||
* @param slider pointer to slider object
|
||||
* @param style pointer the new knob style
|
||||
*/
|
||||
void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
ext->style_knob = style;
|
||||
|
||||
slider->signal_f(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_inv(slider);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the slider callback function
|
||||
* @param slider pointer to slider object
|
||||
* @return the callback function
|
||||
*/
|
||||
lv_action_t lv_slider_get_action(lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
return ext->cb;
|
||||
}
|
||||
/**
|
||||
* Get the style of knob on a slider
|
||||
* @param slider pointer to slider object
|
||||
* @return pointer the new knob style
|
||||
*/
|
||||
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
return ext->style_knob;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the sliders
|
||||
* @param slider pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style_slider = lv_obj_get_style(slider);
|
||||
lv_style_t * style_knob = lv_slider_get_style_knob(slider);
|
||||
lv_style_t * style_indic = lv_bar_get_style_indic(slider);
|
||||
|
||||
area_t area_bar;
|
||||
|
||||
area_cpy(&area_bar, &slider->cords);
|
||||
area_bar.x1 += style_knob->hpad;
|
||||
area_bar.x2 -= style_knob->hpad;
|
||||
area_bar.y1 += style_knob->vpad;
|
||||
area_bar.y2 -= style_knob->vpad;
|
||||
lv_draw_rect(&area_bar, mask, style_slider);
|
||||
|
||||
area_t area_indic;
|
||||
area_cpy(&area_indic, &area_bar);
|
||||
area_indic.x1 += style_indic->hpad;
|
||||
area_indic.x2 -= style_indic->hpad;
|
||||
area_indic.y1 += style_indic->vpad;
|
||||
area_indic.y2 -= style_indic->vpad;
|
||||
|
||||
cord_t slider_w = area_get_width(&slider->cords);
|
||||
cord_t slider_h = area_get_height(&slider->cords);
|
||||
cord_t act_value = lv_bar_get_value(slider);
|
||||
cord_t min_value = lv_bar_get_min_value(slider);
|
||||
cord_t max_value = lv_bar_get_max_value(slider);
|
||||
|
||||
if(slider_w >= slider_h) {
|
||||
area_indic.x2 = (int32_t) ((int32_t)area_get_width(&area_indic) * act_value) / (max_value - min_value);
|
||||
area_indic.x2 += area_indic.x1;
|
||||
} else {
|
||||
area_indic.y1 = (int32_t) ((int32_t)area_get_height(&area_indic) * act_value) / (max_value - min_value);
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1;
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&area_indic, mask, style_indic);
|
||||
|
||||
area_t knob_area;
|
||||
area_cpy(&knob_area, &slider->cords);
|
||||
|
||||
if(slider_w >= slider_h) {
|
||||
knob_area.x1 = area_indic.x2 - slider_h / 2;
|
||||
knob_area.x2 = knob_area.x1 + slider_h;
|
||||
|
||||
knob_area.y1 = slider->cords.y1;
|
||||
knob_area.y2 = slider->cords.y2;
|
||||
} else {
|
||||
knob_area.y1 = area_indic.y1 - slider_w / 2;
|
||||
knob_area.y2 = knob_area.y1 + slider_w;
|
||||
|
||||
knob_area.x1 = slider->cords.x1;
|
||||
knob_area.x2 = slider->cords.x2;
|
||||
|
||||
}
|
||||
|
||||
lv_draw_rect(&knob_area, mask, style_knob);
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* @file lv_slider.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SLIDER_H
|
||||
#define LV_SLIDER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_SLIDER != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_bar.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of slider*/
|
||||
typedef struct
|
||||
{
|
||||
lv_bar_ext_t bar; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t cb; /*Function to call when a new value is set*/
|
||||
lv_style_t * style_knob; /*Style of the knob*/
|
||||
int16_t tmp_value; /*Store a temporal value during press until release (Handled by the library)*/
|
||||
}lv_slider_ext_t;
|
||||
|
||||
/*Built-in styles of slider*/
|
||||
typedef enum
|
||||
{
|
||||
LV_SLIDERS_DEF,
|
||||
}lv_sliders_builtin_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a slider objects
|
||||
* @param par pointer to an object, it will be the parent of the new slider
|
||||
* @param copy pointer to a slider object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created slider
|
||||
*/
|
||||
lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the slider
|
||||
* @param slider pointer to a slider object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Set a function which will be called when a new value is set on the slider
|
||||
* @param slider pointer to slider object
|
||||
* @param cb a callback function
|
||||
*/
|
||||
void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb);
|
||||
|
||||
/**
|
||||
* Set the style of knob on a slider
|
||||
* @param slider pointer to slider object
|
||||
* @param style pointer the new knob style
|
||||
*/
|
||||
void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the slider callback function
|
||||
* @param slider pointer to slider object
|
||||
* @return the callback function
|
||||
*/
|
||||
lv_action_t lv_slider_get_action(lv_obj_t * slider);
|
||||
|
||||
/**
|
||||
* Get the style of knob on a slider
|
||||
* @param slider pointer to slider object
|
||||
* @return pointer the new knob style
|
||||
*/
|
||||
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_SLIDER*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_SLIDER_H*/
|
||||
741
lv_objx/lv_ta.c
741
lv_objx/lv_ta.c
@@ -1,741 +0,0 @@
|
||||
/**
|
||||
* @file lv_ta.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_TA != 0
|
||||
|
||||
#include "lv_ta.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configuration*/
|
||||
#ifndef LV_TA_MAX_LENGTH
|
||||
#define LV_TA_MAX_LENGTH 256
|
||||
#endif
|
||||
|
||||
#ifndef LV_TA_CUR_BLINK_TIME
|
||||
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_TA_PWD_SHOW_TIME
|
||||
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
#define LV_TA_DEF_WIDTH (2 * LV_DPI)
|
||||
#define LV_TA_DEF_HEIGHT (1 * LV_DPI)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_ta_design(lv_obj_t * ta, const area_t * mask, lv_design_mode_t mode);
|
||||
static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_design_mode_t mode);
|
||||
static void cursor_blink_anim(lv_obj_t * ta, uint8_t hide);
|
||||
static void pwd_char_hider_anim(lv_obj_t * ta, uint8_t x);
|
||||
static void pwd_char_hider(lv_obj_t * ta);
|
||||
static void lv_ta_save_valid_cursor_x(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_design_f_t ancestor_design_f;
|
||||
lv_design_f_t scrl_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a text area objects
|
||||
* @param par pointer to an object, it will be the parent of the new text area
|
||||
* @param copy pointer to a text area object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created text area
|
||||
*/
|
||||
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_ta = lv_page_create(par, copy);
|
||||
dm_assert(new_ta);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_ta_ext_t * ext = lv_obj_alloc_ext(new_ta, sizeof(lv_ta_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->cursor_show = 1;
|
||||
ext->cursor_state = 0;
|
||||
ext->pwd_mode = 0;
|
||||
ext->pwd_tmp = NULL;
|
||||
ext->cursor_pos = 0;
|
||||
ext->cursor_valid_x = 0;
|
||||
ext->label = NULL;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_ta);
|
||||
if(scrl_design_f == NULL) scrl_design_f = lv_obj_get_design_f(ext->page.scrl);
|
||||
|
||||
lv_obj_set_signal_f(new_ta, lv_ta_signal);
|
||||
lv_obj_set_design_f(new_ta, lv_ta_design);
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
|
||||
lv_obj_set_design_f(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_page_glue_obj(ext->label, true);
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_style(new_ta, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_page_set_sb_mode(new_ta, LV_PAGE_SB_MODE_AUTO);
|
||||
lv_obj_set_style(lv_page_get_scrl(new_ta), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_obj_set_design_f(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
ext->label = lv_label_create(new_ta, copy_ext->label);
|
||||
ext->cursor_show = copy_ext->cursor_show;
|
||||
lv_page_glue_obj(ext->label, true);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_ta);
|
||||
}
|
||||
|
||||
/*Create a cursor blinker animation*/
|
||||
anim_t a;
|
||||
a.var = new_ta;
|
||||
a.fp = (anim_fp_t)cursor_blink_anim;
|
||||
a.time = LV_TA_CUR_BLINK_TIME;
|
||||
a.act_time = 0;
|
||||
a.end_cb = NULL;
|
||||
a.start = 0;
|
||||
a.end= 1;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
a.playback_pause = 0;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
|
||||
return new_ta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the text area
|
||||
* @param ta pointer to a text area object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_page_signal(ta, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_style_t * style = lv_obj_get_style(ta);
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
/* Nothing to clean up.
|
||||
* (The created label will be deleted automatically) */
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
if(ext->label) {
|
||||
lv_obj_set_style(ext->label, lv_obj_get_style(ext->page.scrl));
|
||||
lv_obj_set_width(ext->label, lv_obj_get_width(ta) - 2 *
|
||||
(style->hpad + style->hpad));
|
||||
lv_label_set_text(ext->label, NULL);
|
||||
}
|
||||
break;
|
||||
/*Set the label width according to the text area width*/
|
||||
case LV_SIGNAL_CORD_CHG:
|
||||
if(ext->label != NULL) {
|
||||
lv_obj_set_width(ext->label, lv_obj_get_width(ta) - 2 *
|
||||
(style->hpad + style->hpad));
|
||||
lv_label_set_text(ext->label, NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Insert a character to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param c a character
|
||||
*/
|
||||
void lv_ta_add_char(lv_obj_t * ta, char c)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
|
||||
const char * label_txt = lv_label_get_text(ext->label);
|
||||
|
||||
/*Test the new length: txt length + 1 (closing'\0') + 1 (c character)*/
|
||||
if((strlen(label_txt) + 2) > LV_TA_MAX_LENGTH) return;
|
||||
|
||||
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
|
||||
|
||||
char buf[LV_TA_MAX_LENGTH];
|
||||
|
||||
/*Insert the character*/
|
||||
memcpy(buf, label_txt, ext->cursor_pos);
|
||||
buf[ext->cursor_pos] = c;
|
||||
memcpy(buf+ext->cursor_pos+1, label_txt+ext->cursor_pos, strlen(label_txt) - ext->cursor_pos + 1);
|
||||
|
||||
/*Refresh the label*/
|
||||
lv_label_set_text(ext->label, buf);
|
||||
|
||||
/*Move the cursor after the new character*/
|
||||
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + 1);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
anim_t a;
|
||||
a.var = ta;
|
||||
a.fp = (anim_fp_t)pwd_char_hider_anim;
|
||||
a.time = LV_TA_PWD_SHOW_TIME;
|
||||
a.act_time = 0;
|
||||
a.end_cb = (anim_cb_t)pwd_char_hider;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a text to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param txt a '\0' terminated string to insert
|
||||
*/
|
||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
|
||||
const char * label_txt = lv_label_get_text(ext->label);
|
||||
uint16_t label_len = strlen(label_txt);
|
||||
uint16_t txt_len = strlen(txt);
|
||||
|
||||
/*Test the new length (+ 1 for the closing '\0')*/
|
||||
if((label_len + txt_len + 1) > LV_TA_MAX_LENGTH) return;
|
||||
|
||||
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
|
||||
|
||||
/*Insert the text*/
|
||||
char buf[LV_TA_MAX_LENGTH];
|
||||
|
||||
memcpy(buf, label_txt, ext->cursor_pos);
|
||||
memcpy(buf + ext->cursor_pos, txt, txt_len);
|
||||
memcpy(buf + ext->cursor_pos + txt_len, label_txt+ext->cursor_pos, label_len - ext->cursor_pos + 1);
|
||||
|
||||
/*Refresh the label*/
|
||||
lv_label_set_text(ext->label, buf);
|
||||
|
||||
/*Move the cursor after the new text*/
|
||||
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + txt_len);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
anim_t a;
|
||||
a.var = ta;
|
||||
a.fp = (anim_fp_t)pwd_char_hider_anim;
|
||||
a.time = LV_TA_PWD_SHOW_TIME;
|
||||
a.act_time = 0;
|
||||
a.end_cb = (anim_cb_t)pwd_char_hider;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text of a text area
|
||||
* @param ta pointer to a text area
|
||||
* @param txt pointer to the text
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_ta_set_cursor_pos(ta, LV_TA_CUR_LAST);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
anim_t a;
|
||||
a.var = ta;
|
||||
a.fp = (anim_fp_t)pwd_char_hider_anim;
|
||||
a.time = LV_TA_PWD_SHOW_TIME;
|
||||
a.act_time = 0;
|
||||
a.end_cb = (anim_cb_t)pwd_char_hider;
|
||||
a.start = 0;
|
||||
a.end = 1;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a the left character from the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_del(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
uint16_t cur_pos = ext->cursor_pos;
|
||||
|
||||
if(cur_pos == 0) return;
|
||||
|
||||
/*Delete a character*/
|
||||
char buf[LV_TA_MAX_LENGTH];
|
||||
const char * label_txt = lv_label_get_text(ext->label);
|
||||
uint16_t label_len = strlen(label_txt);
|
||||
memcpy(buf, label_txt, cur_pos - 1);
|
||||
memcpy(buf+cur_pos - 1, label_txt + cur_pos, label_len - cur_pos + 1);
|
||||
|
||||
/*Refresh the label*/
|
||||
lv_label_set_text(ext->label, buf);
|
||||
|
||||
/*Move the cursor to the place of the deleted character*/
|
||||
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) - 1);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the cursor position
|
||||
* @param obj pointer to a text area object
|
||||
* @param pos the new cursor position in character index
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TA_CUR_LAST: go after the last character
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ta);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
uint16_t txt_len = strlen(lv_label_get_text(ext->label));
|
||||
|
||||
if(pos < 0) pos = txt_len + pos;
|
||||
|
||||
if(pos > txt_len || pos == LV_TA_CUR_LAST) pos = txt_len;
|
||||
|
||||
ext->cursor_pos = pos;
|
||||
|
||||
/*Position the label to make the cursor visible*/
|
||||
lv_obj_t * label_par = lv_obj_get_parent(ext->label);
|
||||
point_t cur_pos;
|
||||
lv_style_t * style = lv_obj_get_style(ta);
|
||||
const font_t * font_p = style->font;
|
||||
area_t label_cords;
|
||||
area_t ta_cords;
|
||||
lv_label_get_letter_pos(ext->label, pos, &cur_pos);
|
||||
lv_obj_get_cords(ta, &ta_cords);
|
||||
lv_obj_get_cords(ext->label, &label_cords);
|
||||
|
||||
/*Check the top*/
|
||||
if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
|
||||
lv_obj_set_y(label_par, - cur_pos.y);
|
||||
}
|
||||
|
||||
/*Check the bottom*/
|
||||
cord_t font_h = font_get_height(font_p) >> FONT_ANTIALIAS;
|
||||
if(label_cords.y1 + cur_pos.y + font_h + style_scrl->vpad > ta_cords.y2) {
|
||||
lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) +
|
||||
font_h + 2 * style_scrl->vpad));
|
||||
}
|
||||
|
||||
lv_obj_inv(ta);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move the cursor one character right
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_right(lv_obj_t * ta)
|
||||
{
|
||||
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
||||
cp++;
|
||||
lv_ta_set_cursor_pos(ta, cp);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor one character left
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_left(lv_obj_t * ta)
|
||||
{
|
||||
uint16_t cp = lv_ta_get_cursor_pos(ta);
|
||||
if(cp > 0) {
|
||||
cp--;
|
||||
lv_ta_set_cursor_pos(ta, cp);
|
||||
|
||||
/*It is a valid x step so save it*/
|
||||
lv_ta_save_valid_cursor_x(ta);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor one line down
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_down(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
point_t pos;
|
||||
|
||||
/*Get the position of the current letter*/
|
||||
lv_label_get_letter_pos(ext->label, lv_ta_get_cursor_pos(ta), &pos);
|
||||
|
||||
/*Increment the y with one line and keep the valid x*/
|
||||
lv_style_t * label_style = lv_obj_get_style(ext->label);
|
||||
const font_t * font_p = label_style->font;
|
||||
cord_t font_h = font_get_height(font_p) >> FONT_ANTIALIAS;
|
||||
pos.y += font_h + label_style->line_space + 1;
|
||||
pos.x = ext->cursor_valid_x;
|
||||
|
||||
/*Do not go below he last line*/
|
||||
if(pos.y < lv_obj_get_height(ext->label)) {
|
||||
/*Get the letter index on the new cursor position and set it*/
|
||||
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
lv_ta_set_cursor_pos(ta, new_cur_pos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the cursor one line up
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_up(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
point_t pos;
|
||||
|
||||
/*Get the position of the current letter*/
|
||||
lv_label_get_letter_pos(ext->label, lv_ta_get_cursor_pos(ta), &pos);
|
||||
|
||||
/*Decrement the y with one line and keep the valid x*/
|
||||
lv_style_t * label_style = lv_obj_get_style(ext->label);
|
||||
const font_t * font = label_style->font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
pos.y -= font_h + label_style->line_space - 1;
|
||||
pos.x = ext->cursor_valid_x;
|
||||
|
||||
/*Get the letter index on the new cursor position and set it*/
|
||||
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
lv_ta_set_cursor_pos(ta, new_cur_pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cursor visibility.
|
||||
* @param ta pointer to a text area object
|
||||
* @return show true: show the cursor and blink it, false: hide cursor
|
||||
*/
|
||||
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
ext->cursor_show = show == false ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable password mode
|
||||
* @param ta ointer to a text area object
|
||||
* @param en true: enable, false: disable
|
||||
*/
|
||||
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
|
||||
/*Pwd mode is now enabled*/
|
||||
if(ext->pwd_mode == 0 && en != false) {
|
||||
char * txt = lv_label_get_text(ext->label);
|
||||
uint16_t txt_len = strlen(txt);
|
||||
ext->pwd_tmp = dm_alloc(txt_len + 1);
|
||||
strcpy(ext->pwd_tmp, txt);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < txt_len; i++) {
|
||||
txt[i] = '*'; /*All char to '*'*/
|
||||
}
|
||||
|
||||
lv_label_set_text(ext->label, NULL);
|
||||
}
|
||||
/*Pwd mode is now disabled*/
|
||||
else if(ext->pwd_mode == 1 && en == false) {
|
||||
lv_label_set_text(ext->label, ext->pwd_tmp);
|
||||
dm_free(ext->pwd_tmp);
|
||||
ext->pwd_tmp = NULL;
|
||||
}
|
||||
|
||||
ext->pwd_mode = en == false ? 0 : 1;
|
||||
}
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the text of a text area
|
||||
* @param ta pointer to a text area object
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_ta_get_txt(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
|
||||
const char * txt;
|
||||
if(ext->pwd_mode == 0) {
|
||||
txt = lv_label_get_text(ext->label);
|
||||
} else {
|
||||
txt = ext->pwd_tmp;
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the label of a text area
|
||||
* @param ta pointer to a text area object
|
||||
* @return pointer to the label object
|
||||
*/
|
||||
lv_obj_t * lv_ta_get_label(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
return ext->label;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current cursor position in character index
|
||||
* @param ta pointer to a text area object
|
||||
* @return the cursor position
|
||||
*/
|
||||
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
return ext->cursor_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current cursor visibility.
|
||||
* @param ta pointer to a text area object
|
||||
* @return true: the cursor is drawn, false: the cursor is hidden
|
||||
*/
|
||||
bool lv_ta_get_cursor_show(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
return ext->cursor_show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password mode
|
||||
* @param ta pointer to a text area object
|
||||
* @return true: password mode is enabled, false: disabled
|
||||
*/
|
||||
bool lv_ta_get_pwd_mode(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
return ext->pwd_mode;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the text areas
|
||||
* @param ta pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW_MAIN: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_ta_design(lv_obj_t * ta, const area_t * masp, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design_f(ta, masp, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
ancestor_design_f(ta, masp, mode);
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design_f(ta, masp, mode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* An extended scrolling design of the page. Calls the normal design function and it draws a cursor.
|
||||
* @param label pointer to a text area object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW_MAIN: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @return return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return scrl_design_f(scrling, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
scrl_design_f(scrling, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
scrl_design_f(scrling, mask, mode);
|
||||
|
||||
/*Draw the cursor too*/
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrling);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext(ta);
|
||||
lv_style_t * scrl_style = lv_obj_get_style(lv_page_get_scrl(ta));
|
||||
|
||||
if(ta_ext->cursor_show != 0 && ta_ext->cursor_state == 0) {
|
||||
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
|
||||
point_t letter_pos;
|
||||
lv_label_get_letter_pos(ta_ext->label, cur_pos, &letter_pos);
|
||||
|
||||
area_t cur_area;
|
||||
lv_style_t * labels_p = lv_obj_get_style(ta_ext->label);
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + scrl_style->line_width ;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + (font_get_height(labels_p->font) >> FONT_ANTIALIAS);
|
||||
|
||||
lv_style_t cur_rects;
|
||||
lv_style_get(LV_STYLE_PLAIN, &cur_rects);
|
||||
cur_rects.radius = 0;
|
||||
cur_rects.bwidth = 0;
|
||||
cur_rects.mcolor = scrl_style->ccolor;
|
||||
cur_rects.gcolor = scrl_style->ccolor;
|
||||
lv_draw_rect(&cur_area, mask, &cur_rects);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called to blink the cursor
|
||||
* @param ta pointer to a text area
|
||||
* @param hide 1: hide the cursor, 0: show it
|
||||
*/
|
||||
static void cursor_blink_anim(lv_obj_t * ta, uint8_t hide)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
if(hide != ext->cursor_state) {
|
||||
ext->cursor_state = hide == 0 ? 0 : 1;
|
||||
if(ext->cursor_show != 0) lv_obj_inv(ta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dummy function to animate char hiding in pwd mode.
|
||||
* Does nothing, nut a function is required in car hiding anim.
|
||||
* (pwd_char_hider callback do the real job)
|
||||
* @param ta unused
|
||||
* @param x unused
|
||||
*/
|
||||
static void pwd_char_hider_anim(lv_obj_t * ta, uint8_t x)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide all characters (convert them to '*')
|
||||
* @param ta: pointer to text area object
|
||||
*/
|
||||
static void pwd_char_hider(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
if(ext->pwd_mode != 0) {
|
||||
char * txt = lv_label_get_text(ext->label);
|
||||
int16_t txt_len = strlen(txt);
|
||||
bool refr = false;
|
||||
uint16_t i;
|
||||
for(i = 0; i < txt_len; i++) {
|
||||
if(txt[i] != '*') {
|
||||
txt[i] = '*';
|
||||
refr = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(refr != false) lv_label_set_text(ext->label, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the cursor x position as valid. It is important when jumping up/down to a shorter line
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
static void lv_ta_save_valid_cursor_x(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
point_t cur_pos;
|
||||
lv_label_get_letter_pos(ext->label, ext->cursor_pos, &cur_pos);
|
||||
ext->cursor_valid_x = cur_pos.x;
|
||||
}
|
||||
|
||||
#endif
|
||||
195
lv_objx/lv_ta.h
195
lv_objx/lv_ta.h
@@ -1,195 +0,0 @@
|
||||
/**
|
||||
* @file lv_ta.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TA_H
|
||||
#define LV_TA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_TA != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_PAGE == 0
|
||||
#error "lv_ta: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_ta: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "lv_page.h"
|
||||
#include "lv_label.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_TA_CUR_LAST (0x7FFF) /*Put the cursor after the last character*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of text area*/
|
||||
typedef struct
|
||||
{
|
||||
lv_page_ext_t page; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * label; /*Label of the text area*/
|
||||
char * pwd_tmp; /*Used to store the original text in password mode*/
|
||||
cord_t cursor_valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
|
||||
uint16_t cursor_pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
|
||||
uint8_t cursor_show :1; /*Show or hide cursor */
|
||||
uint8_t pwd_mode :1; /*Replace characters with '*' */
|
||||
uint8_t cursor_state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
|
||||
}lv_ta_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a text area objects
|
||||
* @param par pointer to an object, it will be the parent of the new text area
|
||||
* @param copy pointer to a text area object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created text area
|
||||
*/
|
||||
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the text area
|
||||
* @param ta pointer to a text area object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Insert a character to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param c a character
|
||||
*/
|
||||
void lv_ta_add_char(lv_obj_t * ta, char c);
|
||||
|
||||
/**
|
||||
* Insert a text to the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
* @param txt a '\0' terminated string to insert
|
||||
*/
|
||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt);
|
||||
|
||||
/**
|
||||
* Set the text of a text area
|
||||
* @param ta pointer to a text area
|
||||
* @param txt pointer to the text
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt);
|
||||
|
||||
/**
|
||||
* Delete a the left character from the current cursor position
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_del(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Set the cursor position
|
||||
* @param obj pointer to a text area object
|
||||
* @param pos the new cursor position in character index
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TA_CUR_LAST: go after the last character
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
|
||||
|
||||
/**
|
||||
* Move the cursor one character right
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_right(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one character left
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_left(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one line down
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_down(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Move the cursor one line up
|
||||
* @param ta pointer to a text area object
|
||||
*/
|
||||
void lv_ta_cursor_up(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the current cursor visibility.
|
||||
* @param ta pointer to a text area object
|
||||
* @return show true: show the cursor and blink it, false: hide cursor
|
||||
*/
|
||||
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
|
||||
|
||||
/**
|
||||
* Enable/Disable password mode
|
||||
* @param ta ointer to a text area object
|
||||
* @param en true: enable, false: disable
|
||||
*/
|
||||
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en);
|
||||
|
||||
/**
|
||||
* Get the text of the i the text area
|
||||
* @param ta obj pointer to a text area object
|
||||
* @return pointer to the text
|
||||
*/
|
||||
const char * lv_ta_get_txt(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the label of a text area
|
||||
* @param ta pointer to a text area object
|
||||
* @return pointer to the label object
|
||||
*/
|
||||
lv_obj_t * lv_ta_get_label(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the current cursor position in character index
|
||||
* @param ta pointer to a text area object
|
||||
* @return the cursor position
|
||||
*/
|
||||
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the current cursor visibility.
|
||||
* @param ta pointer to a text area object
|
||||
* @return true: the cursor is drawn, false: the cursor is hidden
|
||||
*/
|
||||
bool lv_ta_get_cursor_show(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the password mode
|
||||
* @param ta pointer to a text area object
|
||||
* @return true: password mode is enabled, false: disabled
|
||||
*/
|
||||
bool lv_ta_get_pwd_mode(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_TA_H*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_TA_H*/
|
||||
440
lv_objx/lv_win.c
440
lv_objx/lv_win.c
@@ -1,440 +0,0 @@
|
||||
/**
|
||||
* @file lv_win.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
#include "lv_win.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if 0 /*Not used*/
|
||||
static bool lv_win_design(lv_obj_t * win, const area_t * mask, lv_design_mode_t mode);
|
||||
#endif
|
||||
static void lv_win_realign(lv_obj_t * win);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*-----------------
|
||||
* Create function
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Create a window objects
|
||||
* @param par pointer to an object, it will be the parent of the new window
|
||||
* @param copy pointer to a window object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created window
|
||||
*/
|
||||
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t * new_win = lv_obj_create(par, copy);
|
||||
dm_assert(new_win);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_win_ext_t * ext = lv_obj_alloc_ext(new_win, sizeof(lv_win_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->page = NULL;
|
||||
ext->btnh = NULL;
|
||||
ext->header = NULL;
|
||||
ext->title = NULL;
|
||||
ext->style_header = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
ext->style_cbtn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->style_cbtn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->cbtn_size = ( LV_DPI) / 2;
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_pos(new_win, 0, 0);
|
||||
lv_obj_set_style(new_win, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
|
||||
ext->page = lv_page_create(new_win, NULL);
|
||||
lv_obj_set_protect(ext->page, LV_PROTECT_PARENT);
|
||||
lv_obj_set_style(ext->page, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_page_set_sb_mode(ext->page, LV_PAGE_SB_MODE_AUTO);
|
||||
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_cont_set_fit(scrl, false, true);
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
|
||||
/*Create a holder for the header*/
|
||||
ext->header = lv_cont_create(new_win, NULL);
|
||||
lv_cont_set_fit(ext->header, false, true);
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
lv_obj_set_style(ext->header, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
|
||||
|
||||
/*Create a title on the header*/
|
||||
ext->title = lv_label_create(ext->header, NULL);
|
||||
lv_label_set_text(ext->title,"My title");
|
||||
|
||||
/*Create a holder for the control buttons*/
|
||||
ext->btnh = lv_cont_create(ext->header, NULL);
|
||||
lv_cont_set_fit(ext->btnh, true, false);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_set_signal_f(new_win, lv_win_signal);
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
/*Create the objects*/
|
||||
ext->header = lv_cont_create(new_win, copy_ext->header);
|
||||
ext->title = lv_label_create(ext->header, copy_ext->title);
|
||||
ext->btnh = lv_cont_create(ext->header, copy_ext->btnh);
|
||||
|
||||
/*Copy the control buttons*/
|
||||
lv_obj_t * child;
|
||||
lv_obj_t * cbtn;
|
||||
child = lv_obj_get_child(copy_ext->btnh, NULL);
|
||||
while(child != NULL) {
|
||||
cbtn = lv_btn_create(ext->btnh, child);
|
||||
lv_img_create(cbtn, lv_obj_get_child(child, NULL));
|
||||
child = lv_obj_get_child(copy_ext->btnh, child);
|
||||
}
|
||||
|
||||
lv_obj_set_signal_f(new_win, lv_win_signal);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_win);
|
||||
}
|
||||
|
||||
lv_win_realign(new_win);
|
||||
|
||||
return new_win;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal function of the window
|
||||
* @param win pointer to a window object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_obj_signal(win, sign, param);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
|
||||
if(sign == LV_SIGNAL_CHILD_CHG) { /*Move children to the page*/
|
||||
lv_obj_t * page = lv_win_get_page(win);
|
||||
if(page != NULL) {
|
||||
lv_obj_t * child;
|
||||
child = lv_obj_get_child(win, NULL);
|
||||
while(child != NULL) {
|
||||
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
||||
lv_obj_t * tmp = child;
|
||||
child = lv_obj_get_child(win, child); /*Get the next child before move this*/
|
||||
lv_obj_set_parent(tmp, page);
|
||||
} else {
|
||||
child = lv_obj_get_child(win, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh the style of all control buttons*/
|
||||
// lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
// lv_style_t * style = lv_obj_get_style(win);
|
||||
// lv_obj_t * child;
|
||||
// child = lv_obj_get_child(ext->ctrl_holder, NULL);
|
||||
// while(child != NULL) {
|
||||
// lv_obj_set_style(child, &style->ctrl_btn);
|
||||
//
|
||||
// /*Refresh the image style too*/
|
||||
// lv_obj_set_style(lv_obj_get_child(child, NULL), &style->ctrl_img);
|
||||
// child = lv_obj_get_child(ext->ctrl_holder, child);
|
||||
// }
|
||||
|
||||
lv_win_realign(win);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*If the size is changed refresh the window*/
|
||||
if(area_get_width(param) != lv_obj_get_width(win) ||
|
||||
area_get_height(param) != lv_obj_get_height(win)) {
|
||||
lv_win_realign(win);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_path path of an image on the control button
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_styles(btn, ext->style_cbtn_rel, ext->style_cbtn_pr,
|
||||
NULL, NULL, NULL);
|
||||
lv_obj_set_size(btn, ext->cbtn_size, ext->cbtn_size);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
|
||||
lv_obj_t * img = lv_img_create(btn, NULL);
|
||||
lv_obj_set_click(img, false);
|
||||
lv_img_set_file(img, img_path);
|
||||
|
||||
lv_win_realign(win);
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a window control button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always LV_ACTION_RES_INV because the button is deleted with the window
|
||||
*/
|
||||
lv_action_res_t lv_win_close_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_t * win = lv_win_get_from_cbtn(btn);
|
||||
|
||||
lv_obj_del(win);
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @param title string of the new title
|
||||
*/
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
lv_win_realign(win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
ext->cbtn_size = size;
|
||||
|
||||
lv_win_realign(win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the styles of the window control buttons in a given state
|
||||
* @param win pointer to a window object
|
||||
* @param rel pointer to the style in released state
|
||||
* @param pr pointer to the style in pressed state
|
||||
*/
|
||||
void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
ext->style_cbtn_rel = rel;
|
||||
ext->style_cbtn_pr = pr;
|
||||
lv_obj_t * cbtn;
|
||||
cbtn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(cbtn != NULL) {
|
||||
lv_btn_set_styles(cbtn, ext->style_cbtn_rel, ext->style_cbtn_pr, NULL, NULL, NULL);
|
||||
cbtn = lv_obj_get_child(ext->btnh, cbtn);
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @return title string of the window
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return lv_label_get_text(ext->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page of a window
|
||||
* @param win pointer to a window object
|
||||
* @return page pointer to the page object of the window
|
||||
*/
|
||||
lv_obj_t * lv_win_get_page(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return ext->page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the s window header
|
||||
* @param win pointer to a window object
|
||||
* @return pointer to the window header object (lv_rect)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_header(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return ext->header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
cord_t lv_win_get_cbtn_size(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return ext->cbtn_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width of the content area (page scrollable) of the window
|
||||
* @param win pointer to a window object
|
||||
* @return the width of the content area
|
||||
*/
|
||||
cord_t lv_win_get_width(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
return lv_obj_get_width(scrl) - 2 * style_scrl->hpad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
* @param ctrl_btn pointer to a control button of a window
|
||||
* @return pointer to the window of 'ctrl_btn'
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_cbtn(lv_obj_t * ctrl_btn)
|
||||
{
|
||||
lv_obj_t * ctrl_holder = lv_obj_get_parent(ctrl_btn);
|
||||
lv_obj_t * header = lv_obj_get_parent(ctrl_holder);
|
||||
lv_obj_t * win = lv_obj_get_parent(header);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if 0 /*Not used*/
|
||||
/**
|
||||
* Handle the drawing related tasks of the windows
|
||||
* @param win pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* @param return true/false, depends on 'mode'
|
||||
*/
|
||||
static bool lv_win_design(lv_obj_t * win, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return false;
|
||||
} else if (mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
|
||||
} else if (mode == LV_DESIGN_DRAW_POST) {
|
||||
/*Draw after all children is drawn*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Realign the building elements of a window
|
||||
* @param win pointer to window objectker
|
||||
*/
|
||||
static void lv_win_realign(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
|
||||
if(ext->page == NULL || ext->btnh == NULL || ext->header == NULL || ext->title == NULL) return;
|
||||
|
||||
lv_obj_t * cbtn;
|
||||
/*Refresh the size of all control buttons*/
|
||||
cbtn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(cbtn != NULL) {
|
||||
lv_obj_set_size(cbtn, ext->cbtn_size, ext->cbtn_size);
|
||||
cbtn = lv_obj_get_child(ext->btnh, cbtn);
|
||||
}
|
||||
|
||||
lv_style_t * btnh_style = lv_obj_get_style(ext->btnh);
|
||||
lv_obj_set_height(ext->btnh, ext->cbtn_size + 2 * btnh_style->vpad * 2);
|
||||
lv_obj_set_width(ext->header, lv_obj_get_width(win));
|
||||
|
||||
/*Align the higher object first to make the correct header size first*/
|
||||
if(lv_obj_get_height(ext->title) > lv_obj_get_height(ext->btnh)) {
|
||||
lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->hpad, 0);
|
||||
lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->hpad, 0);
|
||||
} else {
|
||||
lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->hpad, 0);
|
||||
lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->hpad, 0);
|
||||
}
|
||||
|
||||
lv_obj_set_pos_us(ext->header, 0, 0);
|
||||
|
||||
lv_obj_t * page = lv_win_get_page(win);
|
||||
lv_obj_set_size(page, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header));
|
||||
lv_obj_align(page, ext->header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
lv_style_t * style_page = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||
|
||||
lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * style_page->hpad);
|
||||
|
||||
}
|
||||
#endif
|
||||
180
lv_objx/lv_win.h
180
lv_objx/lv_win.h
@@ -1,180 +0,0 @@
|
||||
/**
|
||||
* @file lv_win.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_WIN_H
|
||||
#define LV_WIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_BTN == 0
|
||||
#error "lv_win: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL == 0
|
||||
#error "lv_win: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_IMG == 0
|
||||
#error "lv_win: lv_img is required. Enable it in lv_conf.h (USE_LV_IMG 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_LV_PAGE == 0
|
||||
#error "lv_win: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lv_btn.h"
|
||||
#include "lv_label.h"
|
||||
#include "lv_img.h"
|
||||
#include "lv_page.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Data of window*/
|
||||
typedef struct
|
||||
{
|
||||
/*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * page; /*Pointer to a page which holds the content*/
|
||||
lv_obj_t * header; /*Pointer to the header container of the window*/
|
||||
lv_obj_t * title; /*Pointer to the title label of the window*/
|
||||
lv_obj_t * btnh; /*Pointer to the control button holder container of the window*/
|
||||
lv_style_t * style_header; /*Style of the header container*/
|
||||
lv_style_t * style_cbtn_rel; /*Control button releases style*/
|
||||
lv_style_t * style_cbtn_pr; /*Control button pressed style*/
|
||||
cord_t cbtn_size; /*Size of the control buttons (square)*/
|
||||
}lv_win_ext_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a window objects
|
||||
* @param par pointer to an object, it will be the parent of the new window
|
||||
* @param copy pointer to a window object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created window
|
||||
*/
|
||||
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Signal function of the window
|
||||
* @param win pointer to a window object
|
||||
* @param sign a signal type from lv_signal_t enum
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return true: the object is still valid (not deleted), false: the object become invalid
|
||||
*/
|
||||
bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Add control button to the header of the window
|
||||
* @param win pointer to a window object
|
||||
* @param img_path path of an image on the control button
|
||||
* @param rel_action a function pointer to call when the button is released
|
||||
* @return pointer to the created button object
|
||||
*/
|
||||
lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* A release action which can be assigned to a window control button to close it
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return always LV_ACTION_RES_INV because the button is deleted with the window
|
||||
*/
|
||||
lv_action_res_t lv_win_close_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**
|
||||
* Set the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @param title string of the new title
|
||||
*/
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title);
|
||||
|
||||
/**
|
||||
* Set the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size);
|
||||
|
||||
/**
|
||||
* Set the styles of the window control buttons in a given state
|
||||
* @param win pointer to a window object
|
||||
* @param rel pointer to the style in released state
|
||||
* @param pr pointer to the style in pressed state
|
||||
*/
|
||||
void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr);
|
||||
|
||||
/**
|
||||
* Get the title of a window
|
||||
* @param win pointer to a window object
|
||||
* @return title string of the window
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the page of a window
|
||||
* @param win pointer to a window object
|
||||
* @return page pointer to the page object of the window
|
||||
*/
|
||||
lv_obj_t * lv_win_get_page(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the s window header
|
||||
* @param win pointer to a window object
|
||||
* @return pointer to the window header object (lv_rect)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_header(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
cord_t lv_win_get_cbtn_size(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get width of the content area (page scrollable) of the window
|
||||
* @param win pointer to a window object
|
||||
* @return the width of the content area
|
||||
*/
|
||||
cord_t lv_win_get_width(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
* @param ctrl_btn pointer to a control button of a window
|
||||
* @return pointer to the window of 'ctrl_btn'
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_cbtn(lv_obj_t * ctrl_btn);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_WIN*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_WIN_H*/
|
||||
91
lvgl.h
91
lvgl.h
@@ -14,54 +14,63 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*Test misc. module version*/
|
||||
#include "misc/misc.h"
|
||||
#define LV_MISC_REQ_MAJOR 4
|
||||
#define LV_MISC_REQ_MINOR 1
|
||||
#define LV_MISC_REQ_PATCH 0
|
||||
#include "src/lv_version.h"
|
||||
|
||||
#if MISC_VERSION_MAJOR != LV_MISC_REQ_MAJOR /*The version major has to match*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
#include "src/lv_misc/lv_log.h"
|
||||
#include "src/lv_misc/lv_task.h"
|
||||
#include "src/lv_misc/lv_math.h"
|
||||
|
||||
#if MISC_VERSION_MINOR < LV_MISC_REQ_MINOR /*The version minor has to be the same or greater*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
#include "src/lv_hal/lv_hal.h"
|
||||
|
||||
#if MISC_VERSION_PATCH < LV_MISC_REQ_PATCH /*The version patch has to be the same or greater*/
|
||||
#error "LV: incompatible misc. module version! See lvgl.h"
|
||||
#endif
|
||||
#include "src/lv_core/lv_obj.h"
|
||||
#include "src/lv_core/lv_group.h"
|
||||
|
||||
#include "lv_obj/lv_obj.h"
|
||||
#include "lv_objx/lv_btn.h"
|
||||
#include "lv_objx/lv_img.h"
|
||||
#include "lv_objx/lv_label.h"
|
||||
#include "lv_objx/lv_line.h"
|
||||
#include "lv_objx/lv_page.h"
|
||||
#include "lv_objx/lv_cont.h"
|
||||
#include "lv_objx/lv_list.h"
|
||||
#include "lv_objx/lv_chart.h"
|
||||
#include "lv_objx/lv_cb.h"
|
||||
#include "lv_objx/lv_bar.h"
|
||||
#include "lv_objx/lv_slider.h"
|
||||
#include "lv_objx/lv_led.h"
|
||||
#include "lv_objx/lv_btnm.h"
|
||||
#include "lv_objx/lv_ddlist.h"
|
||||
#include "lv_objx/lv_ta.h"
|
||||
#include "lv_objx/lv_win.h"
|
||||
#include "lv_objx/lv_mbox.h"
|
||||
#include "lv_objx/lv_gauge.h"
|
||||
#include "lv_objx/lv_lmeter.h"
|
||||
#include "src/lv_core/lv_refr.h"
|
||||
#include "src/lv_core/lv_disp.h"
|
||||
|
||||
#include "lv_app/lv_app.h"
|
||||
#include "src/lv_themes/lv_theme.h"
|
||||
|
||||
#include "src/lv_font/lv_font.h"
|
||||
#include "src/lv_font/lv_font_fmt_txt.h"
|
||||
|
||||
#include "src/lv_objx/lv_btn.h"
|
||||
#include "src/lv_objx/lv_imgbtn.h"
|
||||
#include "src/lv_objx/lv_img.h"
|
||||
#include "src/lv_objx/lv_label.h"
|
||||
#include "src/lv_objx/lv_line.h"
|
||||
#include "src/lv_objx/lv_page.h"
|
||||
#include "src/lv_objx/lv_cont.h"
|
||||
#include "src/lv_objx/lv_list.h"
|
||||
#include "src/lv_objx/lv_chart.h"
|
||||
#include "src/lv_objx/lv_table.h"
|
||||
#include "src/lv_objx/lv_cb.h"
|
||||
#include "src/lv_objx/lv_bar.h"
|
||||
#include "src/lv_objx/lv_slider.h"
|
||||
#include "src/lv_objx/lv_led.h"
|
||||
#include "src/lv_objx/lv_btnm.h"
|
||||
#include "src/lv_objx/lv_kb.h"
|
||||
#include "src/lv_objx/lv_ddlist.h"
|
||||
#include "src/lv_objx/lv_roller.h"
|
||||
#include "src/lv_objx/lv_ta.h"
|
||||
#include "src/lv_objx/lv_canvas.h"
|
||||
#include "src/lv_objx/lv_win.h"
|
||||
#include "src/lv_objx/lv_tabview.h"
|
||||
#include "src/lv_objx/lv_tileview.h"
|
||||
#include "src/lv_objx/lv_mbox.h"
|
||||
#include "src/lv_objx/lv_gauge.h"
|
||||
#include "src/lv_objx/lv_lmeter.h"
|
||||
#include "src/lv_objx/lv_sw.h"
|
||||
#include "src/lv_objx/lv_kb.h"
|
||||
#include "src/lv_objx/lv_arc.h"
|
||||
#include "src/lv_objx/lv_preload.h"
|
||||
#include "src/lv_objx/lv_calendar.h"
|
||||
#include "src/lv_objx/lv_spinbox.h"
|
||||
|
||||
#include "src/lv_draw/lv_img_cache.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LVGL_VERSION_MAJOR 4
|
||||
#define LVGL_VERSION_MINOR 1
|
||||
#define LVGL_VERSION_PATH 0
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -75,4 +84,8 @@ extern "C" {
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*LVGL_H*/
|
||||
|
||||
8
lvgl.mk
Normal file
8
lvgl.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
include $(LVGL_DIR)/lvgl/src/lv_core/lv_core.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_hal/lv_hal.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_objx/lv_objx.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_font/lv_font.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_misc/lv_misc.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_themes/lv_themes.mk
|
||||
include $(LVGL_DIR)/lvgl/src/lv_draw/lv_draw.mk
|
||||
|
||||
202
porting/lv_port_disp_template.c
Normal file
202
porting/lv_port_disp_template.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* @file lv_port_disp_templ.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_port_disp_templ.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void disp_init(void);
|
||||
|
||||
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
#if LV_USE_GPU
|
||||
static void gpu_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
static void gpu_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
/*-------------------------
|
||||
* Initialize your display
|
||||
* -----------------------*/
|
||||
disp_init();
|
||||
|
||||
/*-----------------------------
|
||||
* Create a buffer for drawing
|
||||
*----------------------------*/
|
||||
|
||||
/* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row
|
||||
*
|
||||
* There are three buffering configurations:
|
||||
* 1. Create ONE buffer with some rows:
|
||||
* LittlevGL will draw the display's content here and writes it to your display
|
||||
*
|
||||
* 2. Create TWO buffer with some rows:
|
||||
* LittlevGL will draw the display's content to a buffer and writes it your display.
|
||||
* You should use DMA to write the buffer's content to the display.
|
||||
* It will enable LittlevGL to draw the next part of the screen to the other buffer while
|
||||
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
|
||||
*
|
||||
* 3. Create TWO screen-sized buffer:
|
||||
* Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the
|
||||
* whole frame to display. This way you only need to change the frame buffer's address instead of
|
||||
* copying the pixels.
|
||||
* */
|
||||
|
||||
/* Example for 1) */
|
||||
static lv_disp_buf_t disp_buf_1;
|
||||
static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
|
||||
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 2) */
|
||||
static lv_disp_buf_t disp_buf_2;
|
||||
static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
|
||||
static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/
|
||||
lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 3) */
|
||||
static lv_disp_buf_t disp_buf_3;
|
||||
static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/
|
||||
static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/
|
||||
lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/
|
||||
|
||||
|
||||
/*-----------------------------------
|
||||
* Register the display in LittlevGL
|
||||
*----------------------------------*/
|
||||
|
||||
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set up the functions to access to your display*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = 480;
|
||||
disp_drv.ver_res = 320;
|
||||
|
||||
/*Used to copy the buffer's content to the display*/
|
||||
disp_drv.flush_cb = disp_flush;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.buffer = &disp_buf_2;
|
||||
|
||||
#if LV_USE_GPU
|
||||
/*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/
|
||||
|
||||
/*Blend two color array using opacity*/
|
||||
disp_drv.gpu_blend = gpu_blend;
|
||||
|
||||
/*Fill a memory array with a color*/
|
||||
disp_drv.gpu_fill = gpu_fill;
|
||||
#endif
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/* Initialize your display and the required peripherals. */
|
||||
static void disp_init(void)
|
||||
{
|
||||
/*You code here*/
|
||||
}
|
||||
|
||||
/* Flush the content of the internal buffer the specific area on the display
|
||||
* You can use DMA or any hardware acceleration to do this operation in the background but
|
||||
* 'lv_disp_flush_ready()' has to be called when finished. */
|
||||
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
for(y = area->y1; y <= area->y2; y++) {
|
||||
for(x = area->x1; x <= area->x2; x++) {
|
||||
/* Put a pixel to the display. For example: */
|
||||
/* put_px(x, y, *color_p)*/
|
||||
color_p++;
|
||||
}
|
||||
}
|
||||
|
||||
/* IMPORTANT!!!
|
||||
* Inform the graphics library that you are ready with the flushing*/
|
||||
lv_disp_flush_ready(disp);
|
||||
}
|
||||
|
||||
|
||||
/*OPTIONAL: GPU INTERFACE*/
|
||||
#if LV_USE_GPU
|
||||
|
||||
/* If your MCU has hardware accelerator (GPU) then you can use it to blend to memories using opacity
|
||||
* It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
|
||||
static void gpu_blend(lv_disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
|
||||
{
|
||||
/*It's an example code which should be done by your GPU*/
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < length; i++) {
|
||||
dest[i] = lv_color_mix(dest[i], src[i], opa);
|
||||
}
|
||||
}
|
||||
|
||||
/* If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color
|
||||
* It can be used only in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
|
||||
static void gpu_fill_cb(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
|
||||
const lv_area_t * fill_area, lv_color_t color);
|
||||
{
|
||||
/*It's an example code which should be done by your GPU*/
|
||||
uint32_t x, y;
|
||||
dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
|
||||
|
||||
for(y = fill_area->y1; y < fill_area->y2; y++) {
|
||||
for(x = fill_area->x1; x < fill_area->x2; x++) {
|
||||
dest_buf[x] = color;
|
||||
}
|
||||
dest_buf+=dest_width; /*Go to the next line*/
|
||||
}
|
||||
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < length; i++) {
|
||||
dest[i] = color;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_USE_GPU*/
|
||||
|
||||
#else /* Enable this file at the top */
|
||||
|
||||
/* This dummy typedef exists purely to silence -Wpedantic. */
|
||||
typedef int keep_pedantic_happy;
|
||||
#endif
|
||||
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
* @file lv_app_gsm.h
|
||||
* @file lv_port_disp_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_GSM_H
|
||||
#define LV_APP_GSM_H
|
||||
/*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
#ifndef LV_PORT_DISP_TEMPL_H
|
||||
#define LV_PORT_DISP_TEMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -13,9 +16,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_GSM != 0
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -24,24 +25,20 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_gsm_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_gsm_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
#endif /*LV_PORT_DISP_TEMPL_H*/
|
||||
|
||||
#endif /*Disable/Enable content*/
|
||||
365
porting/lv_port_fs_template.c
Normal file
365
porting/lv_port_fs_template.c
Normal file
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
* @file lv_port_fs_templ.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*Copy this file as "lv_port_fs.c" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_port_fs_templ.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Create a type to store the required data about your file.
|
||||
* If you are using a File System library
|
||||
* it already should have a File type.
|
||||
* For example FatFS has `FIL`. In this case use `typedef FIL file_t`*/
|
||||
typedef struct {
|
||||
/*Add the data you need to store about a file*/
|
||||
uint32_t dummy1;
|
||||
uint32_t dummy2;
|
||||
}file_t;
|
||||
|
||||
/*Similarly to `file_t` create a type for directory reading too */
|
||||
typedef struct {
|
||||
/*Add the data you need to store about directory reading*/
|
||||
uint32_t dummy1;
|
||||
uint32_t dummy2;
|
||||
}dir_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void fs_init(void);
|
||||
|
||||
static lv_fs_res_t fs_open (void * file_p, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close (void * file_p);
|
||||
static lv_fs_res_t fs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek (void * file_p, uint32_t pos);
|
||||
static lv_fs_res_t fs_size (void * file_p, uint32_t * size_p);
|
||||
static lv_fs_res_t fs_tell (void * file_p, uint32_t * pos_p);
|
||||
static lv_fs_res_t fs_remove (const char *path);
|
||||
static lv_fs_res_t fs_trunc (void * file_p);
|
||||
static lv_fs_res_t fs_rename (const char * oldname, const char * newname);
|
||||
static lv_fs_res_t fs_free (uint32_t * total_p, uint32_t * free_p);
|
||||
static lv_fs_res_t fs_dir_open (void * rddir_p, const char *path);
|
||||
static lv_fs_res_t fs_dir_read (void * rddir_p, char *fn);
|
||||
static lv_fs_res_t fs_dir_close (void * rddir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_port_fs_init(void)
|
||||
{
|
||||
/*----------------------------------------------------
|
||||
* Initialize your storage device and File System
|
||||
* -------------------------------------------------*/
|
||||
fs_init();
|
||||
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/* Add a simple drive to open images */
|
||||
lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
memset(&fs_drv, 0, sizeof(lv_fs_drv_t)); /*Initialization*/
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.file_size = sizeof(file_t);
|
||||
fs_drv.letter = 'P';
|
||||
fs_drv.open = fs_open;
|
||||
fs_drv.close = fs_close;
|
||||
fs_drv.read = fs_read;
|
||||
fs_drv.write = fs_write;
|
||||
fs_drv.seek = fs_seek;
|
||||
fs_drv.tell = fs_tell;
|
||||
fs_drv.free = fs_free;
|
||||
fs_drv.size = fs_size;
|
||||
fs_drv.remove = fs_remove;
|
||||
fs_drv.rename = fs_rename;
|
||||
fs_drv.trunc = fs_trunc;
|
||||
|
||||
fs_drv.rddir_size = sizeof(dir_t);
|
||||
fs_drv.dir_close = fs_dir_close;
|
||||
fs_drv.dir_open = fs_dir_open;
|
||||
fs_drv.dir_read = fs_dir_read;
|
||||
|
||||
lv_fs_add_drv(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/* Initialize your Storage device and File system. */
|
||||
static void fs_init(void)
|
||||
{
|
||||
/*E.g. for FatFS initalize the SD card and FatFS itself*/
|
||||
|
||||
/*You code here*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_open (void * file_p, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
if(mode == LV_FS_MODE_WR)
|
||||
{
|
||||
/*Open a file for write*/
|
||||
|
||||
/* Add your code here*/
|
||||
}
|
||||
else if(mode == LV_FS_MODE_RD)
|
||||
{
|
||||
/*Open a file for read*/
|
||||
|
||||
/* Add your code here*/
|
||||
}
|
||||
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD))
|
||||
{
|
||||
/*Open a file for read and write*/
|
||||
|
||||
/* Add your code here*/
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param file_p pointer to a file_t variable. (opened with lv_ufs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close (void * file_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to a file_t variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param file_p pointer to a file_t variable. (opened with lv_ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek (void * file_p, uint32_t pos)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a file bytes
|
||||
* @param file_p pointer to a file_t variable
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_size (void * file_p, uint32_t * size_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a file_t variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell (void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
* @param path path of the file to delete
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_remove (const char *path)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with lv_fs_open )
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_trunc (void * file_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a file
|
||||
* @param oldname path to the file
|
||||
* @param newname path with the new name
|
||||
* @return LV_FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
static lv_fs_res_t fs_rename (const char * oldname, const char * newname)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the free and total size of a driver in kB
|
||||
* @param letter the driver letter
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_open (void * rddir_p, const char *path)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read (void * rddir_p, char *fn)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close (void * rddir_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
/* Add your code here*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#else /* Enable this file at the top */
|
||||
|
||||
/* This dummy typedef exists purely to silence -Wpedantic. */
|
||||
typedef int keep_pedantic_happy;
|
||||
#endif
|
||||
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
* @file lv_app_example.h
|
||||
* @file lv_port_fs_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_WIFI_H
|
||||
#define LV_APP_WIFI_H
|
||||
/*Copy this file as "lv_port_fs.h" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
#ifndef LV_PORT_FS_TEMPL_H
|
||||
#define LV_PORT_FS_TEMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -13,9 +16,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_WIFI != 0
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -24,24 +25,20 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_wifi_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_wifi_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
#endif /*LV_PORT_FS_TEMPL_H*/
|
||||
|
||||
#endif /*Disable/Enable content*/
|
||||
428
porting/lv_port_indev_template.c
Normal file
428
porting/lv_port_indev_template.c
Normal file
@@ -0,0 +1,428 @@
|
||||
/**
|
||||
* @file lv_port_indev_templ.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_port_indev_templ.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static void touchpad_init(void);
|
||||
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static bool touchpad_is_pressed(void);
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void mouse_init(void);
|
||||
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static bool mouse_is_pressed(void);
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void keypad_init(void);
|
||||
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static uint32_t keypad_get_key(void);
|
||||
|
||||
static void encoder_init(void);
|
||||
static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static void encoder_handler(void);
|
||||
|
||||
static void button_init(void);
|
||||
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
static int8_t button_get_pressed_id(void);
|
||||
static bool button_is_pressed(uint8_t id);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_indev_t * indev_touchpad;
|
||||
lv_indev_t * indev_mouse;
|
||||
lv_indev_t * indev_keypad;
|
||||
lv_indev_t * indev_encoder;
|
||||
lv_indev_t * indev_button;
|
||||
|
||||
static int32_t encoder_diff;
|
||||
static lv_indev_state_t encoder_state;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
/* Here you will find example implementation of input devices supported by LittelvGL:
|
||||
* - Touchpad
|
||||
* - Mouse (with cursor support)
|
||||
* - Keypad (supports GUI usage only with key)
|
||||
* - Encoder (supports GUI usage only with: left, right, push)
|
||||
* - Button (external buttons to press points on the screen)
|
||||
*
|
||||
* The `..._read()` function are only examples.
|
||||
* You should shape them according to your hardware
|
||||
*/
|
||||
|
||||
|
||||
lv_indev_drv_t indev_drv;
|
||||
|
||||
/*------------------
|
||||
* Touchpad
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your touchpad if you have*/
|
||||
touchpad_init();
|
||||
|
||||
/*Register a touchpad input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = touchpad_read;
|
||||
indev_touchpad = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*------------------
|
||||
* Mouse
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your touchpad if you have*/
|
||||
mouse_init();
|
||||
|
||||
/*Register a mouse input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = mouse_read;
|
||||
indev_mouse = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*Set cursor. For simplicity set a HOME symbol now.*/
|
||||
lv_obj_t * mouse_cursor = lv_img_create(lv_disp_get_scr_act(NULL), NULL);
|
||||
lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME);
|
||||
lv_indev_set_cursor(indev_mouse, mouse_cursor);
|
||||
|
||||
/*------------------
|
||||
* Keypad
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your keypad or keyboard if you have*/
|
||||
keypad_init();
|
||||
|
||||
/*Register a keypad input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_drv.read_cb = keypad_read;
|
||||
indev_keypad = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/* Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
|
||||
* add objects to the group with `lv_group_add_obj(group, obj)`
|
||||
* and assign this input device to group to navigate in it:
|
||||
* `lv_indev_set_group(indev_keypad, group);` */
|
||||
|
||||
/*------------------
|
||||
* Encoder
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your encoder if you have*/
|
||||
encoder_init();
|
||||
|
||||
/*Register a encoder input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_drv.read_cb = encoder_read;
|
||||
indev_encoder = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/* Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
|
||||
* add objects to the group with `lv_group_add_obj(group, obj)`
|
||||
* and assign this input device to group to navigate in it:
|
||||
* `lv_indev_set_group(indev_keypad, group);` */
|
||||
|
||||
/*------------------
|
||||
* Button
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your button if you have*/
|
||||
button_init();
|
||||
|
||||
/*Register a button input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_BUTTON;
|
||||
indev_drv.read_cb = button_read;
|
||||
indev_button = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*Assign buttons to points on the screen*/
|
||||
static const lv_point_t btn_points[2] = {
|
||||
{10, 10}, /*Button 0 -> x:10; y:10*/
|
||||
{40, 100}, /*Button 1 -> x:40; y:100*/
|
||||
};
|
||||
lv_indev_set_button_points(indev_button, btn_points);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
|
||||
/*------------------
|
||||
* Touchpad
|
||||
* -----------------*/
|
||||
|
||||
/*Initialize your touchpad*/
|
||||
static void touchpad_init(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the touchpad */
|
||||
static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
|
||||
/*Save the pressed coordinates and the state*/
|
||||
if(touchpad_is_pressed()) {
|
||||
touchpad_get_xy(&last_x, &last_y);
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/*Set the last pressed coordinates*/
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Return true is the touchpad is pressed*/
|
||||
static bool touchpad_is_pressed(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get the x and y coordinates if the touchpad is pressed*/
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
(*x) = 0;
|
||||
(*y) = 0;
|
||||
}
|
||||
|
||||
|
||||
/*------------------
|
||||
* Mouse
|
||||
* -----------------*/
|
||||
|
||||
/* Initialize your mouse */
|
||||
static void mouse_init(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the mouse */
|
||||
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
/*Get the current x and y coordinates*/
|
||||
mouse_get_xy(&data->point.x, &data->point.y);
|
||||
|
||||
/*Get whether the mouse button is pressed or released*/
|
||||
if(mouse_is_pressed()) {
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Return true is the mouse button is pressed*/
|
||||
static bool mouse_is_pressed(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get the x and y coordinates if the mouse is pressed*/
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
(*x) = 0;
|
||||
(*y) = 0;
|
||||
}
|
||||
|
||||
/*------------------
|
||||
* Keypad
|
||||
* -----------------*/
|
||||
|
||||
/* Initialize your keypad */
|
||||
static void keypad_init(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the mouse */
|
||||
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static uint32_t last_key = 0;
|
||||
|
||||
/*Get the current x and y coordinates*/
|
||||
mouse_get_xy(&data->point.x, &data->point.y);
|
||||
|
||||
/*Get whether the a key is pressed and save the pressed key*/
|
||||
uint32_t act_key = keypad_get_key();
|
||||
if(act_key != 0) {
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
|
||||
/*Translate the keys to LittlevGL control characters according to your key definitions*/
|
||||
switch(act_key) {
|
||||
case 1:
|
||||
act_key = LV_KEY_NEXT;
|
||||
break;
|
||||
case 2:
|
||||
act_key = LV_KEY_PREV;
|
||||
break;
|
||||
case 3:
|
||||
act_key = LV_KEY_LEFT;
|
||||
break;
|
||||
case 4:
|
||||
act_key = LV_KEY_RIGHT;
|
||||
break;
|
||||
case 5:
|
||||
act_key = LV_KEY_ENTER;
|
||||
break;
|
||||
}
|
||||
|
||||
last_key = act_key;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
data->key = last_key;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get the currently being pressed key. 0 if no key is pressed*/
|
||||
static uint32_t keypad_get_key(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*------------------
|
||||
* Encoder
|
||||
* -----------------*/
|
||||
|
||||
/* Initialize your keypad */
|
||||
static void encoder_init(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the encoder */
|
||||
static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
data->enc_diff = encoder_diff;
|
||||
data->state = encoder_state;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Call this function in an interrupt to process encoder events (turn, press)*/
|
||||
static void encoder_handler(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
encoder_diff += 0;
|
||||
encoder_state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
|
||||
/*------------------
|
||||
* Button
|
||||
* -----------------*/
|
||||
|
||||
/* Initialize your buttons */
|
||||
static void button_init(void)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the button */
|
||||
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
static uint8_t last_btn = 0;
|
||||
|
||||
/*Get the pressed button's ID*/
|
||||
int8_t btn_act = button_get_pressed_id();
|
||||
|
||||
if(btn_act >= 0) {
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
last_btn = btn_act;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/*Save the last pressed button's ID*/
|
||||
data->btn_id = last_btn;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/*Get ID (0, 1, 2 ..) of the pressed button*/
|
||||
static int8_t button_get_pressed_id(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
/*Check to buttons see which is being pressed (assume there are 2 buttons)*/
|
||||
for(i = 0; i < 2; i++) {
|
||||
/*Return the pressed button's ID*/
|
||||
if(button_is_pressed(i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/*No button pressed*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*Test if `id` button is pressed or not*/
|
||||
static bool button_is_pressed(uint8_t id)
|
||||
{
|
||||
|
||||
/*Your code comes here*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#else /* Enable this file at the top */
|
||||
|
||||
/* This dummy typedef exists purely to silence -Wpedantic. */
|
||||
typedef int keep_pedantic_happy;
|
||||
#endif
|
||||
@@ -1,10 +1,14 @@
|
||||
|
||||
/**
|
||||
* @file lv_app_files.h
|
||||
* @file lv_port_indev_templ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_FILES_H
|
||||
#define LV_APP_FILES_H
|
||||
/*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/
|
||||
#if 0
|
||||
|
||||
#ifndef LV_PORT_INDEV_TEMPL_H
|
||||
#define LV_PORT_INDEV_TEMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -13,9 +17,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -24,24 +26,20 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_files_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_files_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
#endif /*LV_PORT_INDEV_TEMPL_H*/
|
||||
|
||||
#endif /*Disable/Enable content*/
|
||||
2455
scripts/Doxyfile
Normal file
2455
scripts/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
BIN
scripts/built_in_font/FontAwesome.ttf
Normal file
BIN
scripts/built_in_font/FontAwesome.ttf
Normal file
Binary file not shown.
BIN
scripts/built_in_font/Roboto-Regular.woff
Normal file
BIN
scripts/built_in_font/Roboto-Regular.woff
Normal file
Binary file not shown.
47
scripts/built_in_font/built_in_font_gen.py
Normal file
47
scripts/built_in_font/built_in_font_gen.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import argparse
|
||||
from argparse import RawTextHelpFormatter
|
||||
import os
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(description="""Create fonts for LittelvGL including the built-in symbols. lv_font_conv needs to be installed. See https://github.com/littlevgl/lv_font_conv
|
||||
Example: python built_in_font_gen.py --size 16 -o lv_font_roboto_16.c --bpp 4 -r 0x20-0x7F""", formatter_class=RawTextHelpFormatter)
|
||||
parser.add_argument('-s', '--size',
|
||||
type=int,
|
||||
metavar = 'px',
|
||||
nargs='?',
|
||||
help='Size of the font in px')
|
||||
parser.add_argument('--bpp',
|
||||
type=int,
|
||||
metavar = '1,2,4',
|
||||
nargs='?',
|
||||
help='Bit per pixel')
|
||||
parser.add_argument('-r', '--range',
|
||||
nargs='+',
|
||||
metavar = 'start-end',
|
||||
default='0x20-0x7F',
|
||||
help='Ranges and/or characters to include. Default is 0x20-7F (ASCII). E.g. -r 0x20-0x7F, 0x200, 324')
|
||||
parser.add_argument('--font',
|
||||
metavar = 'file',
|
||||
nargs='?',
|
||||
default='Roboto-Regular.woff',
|
||||
help='A TTF or WOFF file')
|
||||
parser.add_argument('-o', '--output',
|
||||
nargs='?',
|
||||
metavar='file',
|
||||
help='Output file name. E.g. my_font_20.c')
|
||||
parser.add_argument('--compressed', action='store_true',
|
||||
help='Compress the bitmaps')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.compressed == False:
|
||||
compr = "--no-compress --no-prefilter"
|
||||
else:
|
||||
compr = ""
|
||||
|
||||
#Built in symbols
|
||||
syms = "61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099"
|
||||
|
||||
#Run the command
|
||||
cmd = "lv_font_conv {} --bpp {} --size {} --font ./Roboto-Regular.woff -r {} --font FontAwesome.ttf -r {} --format lvgl -o {} --force-fast-kern-format".format(compr, args.bpp, args.size, args.range[0], syms, args.output)
|
||||
os.system(cmd)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user